babylon.gui.js 746 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/perfCounter");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /** @hidden */
  516. _this._numLayoutCalls = 0;
  517. /** @hidden */
  518. _this._numRenderCalls = 0;
  519. /**
  520. * Define type to string to ensure compatibility across browsers
  521. * Safari doesn't support DataTransfer constructor
  522. */
  523. _this._clipboardData = "";
  524. /**
  525. * Observable event triggered each time an clipboard event is received from the rendering canvas
  526. */
  527. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered each time a pointer down is intercepted by a control
  530. */
  531. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered before layout is evaluated
  534. */
  535. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered after the layout was evaluated
  538. */
  539. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered before the texture is rendered
  542. */
  543. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Observable event triggered after the texture was rendered
  546. */
  547. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  548. /**
  549. * Gets or sets a boolean defining if alpha is stored as premultiplied
  550. */
  551. _this.premulAlpha = false;
  552. _this._useInvalidateRectOptimization = true;
  553. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  554. _this._invalidatedRectangle = null;
  555. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  556. /** @hidden */
  557. _this.onClipboardCopy = function (rawEvt) {
  558. var evt = rawEvt;
  559. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  560. _this.onClipboardObservable.notifyObservers(ev);
  561. evt.preventDefault();
  562. };
  563. /** @hidden */
  564. _this.onClipboardCut = function (rawEvt) {
  565. var evt = rawEvt;
  566. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  567. _this.onClipboardObservable.notifyObservers(ev);
  568. evt.preventDefault();
  569. };
  570. /** @hidden */
  571. _this.onClipboardPaste = function (rawEvt) {
  572. var evt = rawEvt;
  573. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  574. _this.onClipboardObservable.notifyObservers(ev);
  575. evt.preventDefault();
  576. };
  577. scene = _this.getScene();
  578. if (!scene || !_this._texture) {
  579. return _this;
  580. }
  581. _this._rootElement = scene.getEngine().getInputElement();
  582. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  583. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  584. if (!_this._focusedControl) {
  585. return;
  586. }
  587. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  588. _this._focusedControl.processKeyboard(info.event);
  589. }
  590. info.skipOnPointerObservable = true;
  591. });
  592. _this._rootContainer._link(_this);
  593. _this.hasAlpha = true;
  594. if (!width || !height) {
  595. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  596. _this._onResize();
  597. }
  598. _this._texture.isReady = true;
  599. return _this;
  600. }
  601. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  602. /** Gets the number of layout calls made the last time the ADT has been rendered */
  603. get: function () {
  604. return this._numLayoutCalls;
  605. },
  606. enumerable: true,
  607. configurable: true
  608. });
  609. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  610. /** Gets the number of render calls made the last time the ADT has been rendered */
  611. get: function () {
  612. return this._numRenderCalls;
  613. },
  614. enumerable: true,
  615. configurable: true
  616. });
  617. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  618. /**
  619. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  620. * Useful when you want more antialiasing
  621. */
  622. get: function () {
  623. return this._renderScale;
  624. },
  625. set: function (value) {
  626. if (value === this._renderScale) {
  627. return;
  628. }
  629. this._renderScale = value;
  630. this._onResize();
  631. },
  632. enumerable: true,
  633. configurable: true
  634. });
  635. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  636. /** Gets or sets the background color */
  637. get: function () {
  638. return this._background;
  639. },
  640. set: function (value) {
  641. if (this._background === value) {
  642. return;
  643. }
  644. this._background = value;
  645. this.markAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  651. /**
  652. * Gets or sets the ideal width used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealWidth;
  658. },
  659. set: function (value) {
  660. if (this._idealWidth === value) {
  661. return;
  662. }
  663. this._idealWidth = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  671. /**
  672. * Gets or sets the ideal height used to design controls.
  673. * The GUI will then rescale everything accordingly
  674. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  675. */
  676. get: function () {
  677. return this._idealHeight;
  678. },
  679. set: function (value) {
  680. if (this._idealHeight === value) {
  681. return;
  682. }
  683. this._idealHeight = value;
  684. this.markAsDirty();
  685. this._rootContainer._markAllAsDirty();
  686. },
  687. enumerable: true,
  688. configurable: true
  689. });
  690. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  691. /**
  692. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  693. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  694. */
  695. get: function () {
  696. return this._useSmallestIdeal;
  697. },
  698. set: function (value) {
  699. if (this._useSmallestIdeal === value) {
  700. return;
  701. }
  702. this._useSmallestIdeal = value;
  703. this.markAsDirty();
  704. this._rootContainer._markAllAsDirty();
  705. },
  706. enumerable: true,
  707. configurable: true
  708. });
  709. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  710. /**
  711. * Gets or sets a boolean indicating if adaptive scaling must be used
  712. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  713. */
  714. get: function () {
  715. return this._renderAtIdealSize;
  716. },
  717. set: function (value) {
  718. if (this._renderAtIdealSize === value) {
  719. return;
  720. }
  721. this._renderAtIdealSize = value;
  722. this._onResize();
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  728. /**
  729. * Gets the ratio used when in "ideal mode"
  730. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  731. * */
  732. get: function () {
  733. var rwidth = 0;
  734. var rheight = 0;
  735. if (this._idealWidth) {
  736. rwidth = (this.getSize().width) / this._idealWidth;
  737. }
  738. if (this._idealHeight) {
  739. rheight = (this.getSize().height) / this._idealHeight;
  740. }
  741. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  742. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  743. }
  744. if (this._idealWidth) { // horizontal
  745. return rwidth;
  746. }
  747. if (this._idealHeight) { // vertical
  748. return rheight;
  749. }
  750. return 1;
  751. },
  752. enumerable: true,
  753. configurable: true
  754. });
  755. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  756. /**
  757. * Gets the underlying layer used to render the texture when in fullscreen mode
  758. */
  759. get: function () {
  760. return this._layerToDispose;
  761. },
  762. enumerable: true,
  763. configurable: true
  764. });
  765. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  766. /**
  767. * Gets the root container control
  768. */
  769. get: function () {
  770. return this._rootContainer;
  771. },
  772. enumerable: true,
  773. configurable: true
  774. });
  775. /**
  776. * Returns an array containing the root container.
  777. * This is mostly used to let the Inspector introspects the ADT
  778. * @returns an array containing the rootContainer
  779. */
  780. AdvancedDynamicTexture.prototype.getChildren = function () {
  781. return [this._rootContainer];
  782. };
  783. /**
  784. * Will return all controls that are inside this texture
  785. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  786. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  787. * @return all child controls
  788. */
  789. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  790. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  791. };
  792. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  793. /**
  794. * Gets or sets the current focused control
  795. */
  796. get: function () {
  797. return this._focusedControl;
  798. },
  799. set: function (control) {
  800. if (this._focusedControl == control) {
  801. return;
  802. }
  803. if (this._focusedControl) {
  804. this._focusedControl.onBlur();
  805. }
  806. if (control) {
  807. control.onFocus();
  808. }
  809. this._focusedControl = control;
  810. },
  811. enumerable: true,
  812. configurable: true
  813. });
  814. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  815. /**
  816. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  817. */
  818. get: function () {
  819. if (!this.layer) {
  820. return true;
  821. }
  822. return (!this.layer.isBackground);
  823. },
  824. set: function (value) {
  825. if (!this.layer) {
  826. return;
  827. }
  828. if (this.layer.isBackground === !value) {
  829. return;
  830. }
  831. this.layer.isBackground = !value;
  832. },
  833. enumerable: true,
  834. configurable: true
  835. });
  836. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  837. /**
  838. * Gets or set information about clipboardData
  839. */
  840. get: function () {
  841. return this._clipboardData;
  842. },
  843. set: function (value) {
  844. this._clipboardData = value;
  845. },
  846. enumerable: true,
  847. configurable: true
  848. });
  849. /**
  850. * Get the current class name of the texture useful for serialization or dynamic coding.
  851. * @returns "AdvancedDynamicTexture"
  852. */
  853. AdvancedDynamicTexture.prototype.getClassName = function () {
  854. return "AdvancedDynamicTexture";
  855. };
  856. /**
  857. * Function used to execute a function on all controls
  858. * @param func defines the function to execute
  859. * @param container defines the container where controls belong. If null the root container will be used
  860. */
  861. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  862. if (!container) {
  863. container = this._rootContainer;
  864. }
  865. func(container);
  866. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  867. var child = _a[_i];
  868. if (child.children) {
  869. this.executeOnAllControls(func, child);
  870. continue;
  871. }
  872. func(child);
  873. }
  874. };
  875. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  876. /**
  877. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  878. */
  879. get: function () {
  880. return this._useInvalidateRectOptimization;
  881. },
  882. set: function (value) {
  883. this._useInvalidateRectOptimization = value;
  884. },
  885. enumerable: true,
  886. configurable: true
  887. });
  888. /**
  889. * Invalidates a rectangle area on the gui texture
  890. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  891. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  892. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  893. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  894. */
  895. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  896. if (!this._useInvalidateRectOptimization) {
  897. return;
  898. }
  899. if (!this._invalidatedRectangle) {
  900. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  901. }
  902. else {
  903. // Compute intersection
  904. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  905. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  906. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  907. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  908. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  909. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  910. }
  911. };
  912. /**
  913. * Marks the texture as dirty forcing a complete update
  914. */
  915. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  916. this._isDirty = true;
  917. };
  918. /**
  919. * Helper function used to create a new style
  920. * @returns a new style
  921. * @see http://doc.babylonjs.com/how_to/gui#styles
  922. */
  923. AdvancedDynamicTexture.prototype.createStyle = function () {
  924. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  925. };
  926. /**
  927. * Adds a new control to the root container
  928. * @param control defines the control to add
  929. * @returns the current texture
  930. */
  931. AdvancedDynamicTexture.prototype.addControl = function (control) {
  932. this._rootContainer.addControl(control);
  933. return this;
  934. };
  935. /**
  936. * Removes a control from the root container
  937. * @param control defines the control to remove
  938. * @returns the current texture
  939. */
  940. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  941. this._rootContainer.removeControl(control);
  942. return this;
  943. };
  944. /**
  945. * Release all resources
  946. */
  947. AdvancedDynamicTexture.prototype.dispose = function () {
  948. var scene = this.getScene();
  949. if (!scene) {
  950. return;
  951. }
  952. this._rootElement = null;
  953. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  954. if (this._resizeObserver) {
  955. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  956. }
  957. if (this._pointerMoveObserver) {
  958. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  959. }
  960. if (this._pointerObserver) {
  961. scene.onPointerObservable.remove(this._pointerObserver);
  962. }
  963. if (this._preKeyboardObserver) {
  964. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  965. }
  966. if (this._canvasPointerOutObserver) {
  967. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  968. }
  969. if (this._layerToDispose) {
  970. this._layerToDispose.texture = null;
  971. this._layerToDispose.dispose();
  972. this._layerToDispose = null;
  973. }
  974. this._rootContainer.dispose();
  975. this.onClipboardObservable.clear();
  976. this.onControlPickedObservable.clear();
  977. this.onBeginRenderObservable.clear();
  978. this.onEndRenderObservable.clear();
  979. this.onBeginLayoutObservable.clear();
  980. this.onEndLayoutObservable.clear();
  981. _super.prototype.dispose.call(this);
  982. };
  983. AdvancedDynamicTexture.prototype._onResize = function () {
  984. var scene = this.getScene();
  985. if (!scene) {
  986. return;
  987. }
  988. // Check size
  989. var engine = scene.getEngine();
  990. var textureSize = this.getSize();
  991. var renderWidth = engine.getRenderWidth() * this._renderScale;
  992. var renderHeight = engine.getRenderHeight() * this._renderScale;
  993. if (this._renderAtIdealSize) {
  994. if (this._idealWidth) {
  995. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  996. renderWidth = this._idealWidth;
  997. }
  998. else if (this._idealHeight) {
  999. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1000. renderHeight = this._idealHeight;
  1001. }
  1002. }
  1003. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1004. this.scaleTo(renderWidth, renderHeight);
  1005. this.markAsDirty();
  1006. if (this._idealWidth || this._idealHeight) {
  1007. this._rootContainer._markAllAsDirty();
  1008. }
  1009. }
  1010. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1011. };
  1012. /** @hidden */
  1013. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1014. var engine = scene.getEngine();
  1015. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1016. };
  1017. /**
  1018. * Get screen coordinates for a vector3
  1019. * @param position defines the position to project
  1020. * @param worldMatrix defines the world matrix to use
  1021. * @returns the projected position
  1022. */
  1023. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1024. var scene = this.getScene();
  1025. if (!scene) {
  1026. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1027. }
  1028. var globalViewport = this._getGlobalViewport(scene);
  1029. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1030. projectedPosition.scaleInPlace(this.renderScale);
  1031. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1032. };
  1033. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1034. if (this._layerToDispose) {
  1035. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1036. return;
  1037. }
  1038. }
  1039. if (this._isFullscreen && this._linkedControls.length) {
  1040. var scene = this.getScene();
  1041. if (!scene) {
  1042. return;
  1043. }
  1044. var globalViewport = this._getGlobalViewport(scene);
  1045. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1046. var control = _a[_i];
  1047. if (!control.isVisible) {
  1048. continue;
  1049. }
  1050. var mesh = control._linkedMesh;
  1051. if (!mesh || mesh.isDisposed()) {
  1052. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1053. control.linkWithMesh(null);
  1054. });
  1055. continue;
  1056. }
  1057. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1058. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1059. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1060. control.notRenderable = true;
  1061. continue;
  1062. }
  1063. control.notRenderable = false;
  1064. // Account for RenderScale.
  1065. projectedPosition.scaleInPlace(this.renderScale);
  1066. control._moveToProjectedPosition(projectedPosition);
  1067. }
  1068. }
  1069. if (!this._isDirty && !this._rootContainer.isDirty) {
  1070. return;
  1071. }
  1072. this._isDirty = false;
  1073. this._render();
  1074. this.update(true, this.premulAlpha);
  1075. };
  1076. AdvancedDynamicTexture.prototype._render = function () {
  1077. var textureSize = this.getSize();
  1078. var renderWidth = textureSize.width;
  1079. var renderHeight = textureSize.height;
  1080. var context = this.getContext();
  1081. context.font = "18px Arial";
  1082. context.strokeStyle = "white";
  1083. // Layout
  1084. this.onBeginLayoutObservable.notifyObservers(this);
  1085. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1086. this._numLayoutCalls = 0;
  1087. this._rootContainer._layout(measure, context);
  1088. this.onEndLayoutObservable.notifyObservers(this);
  1089. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1090. // Clear
  1091. if (this._invalidatedRectangle) {
  1092. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1093. }
  1094. else {
  1095. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1096. }
  1097. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1098. if (this._background) {
  1099. context.save();
  1100. context.fillStyle = this._background;
  1101. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1102. context.restore();
  1103. }
  1104. // Render
  1105. this.onBeginRenderObservable.notifyObservers(this);
  1106. this._numRenderCalls = 0;
  1107. this._rootContainer._render(context, this._invalidatedRectangle);
  1108. this.onEndRenderObservable.notifyObservers(this);
  1109. this._invalidatedRectangle = null;
  1110. };
  1111. /** @hidden */
  1112. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1113. if (this._rootElement) {
  1114. this._rootElement.style.cursor = cursor;
  1115. this._cursorChanged = true;
  1116. }
  1117. };
  1118. /** @hidden */
  1119. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1120. this._lastControlDown[pointerId] = control;
  1121. this.onControlPickedObservable.notifyObservers(control);
  1122. };
  1123. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1124. var scene = this.getScene();
  1125. if (!scene) {
  1126. return;
  1127. }
  1128. var engine = scene.getEngine();
  1129. var textureSize = this.getSize();
  1130. if (this._isFullscreen) {
  1131. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1132. var viewport = camera.viewport;
  1133. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1134. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1135. }
  1136. if (this._capturingControl[pointerId]) {
  1137. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1138. return;
  1139. }
  1140. this._cursorChanged = false;
  1141. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1142. this._changeCursor("");
  1143. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1144. if (this._lastControlOver[pointerId]) {
  1145. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1146. delete this._lastControlOver[pointerId];
  1147. }
  1148. }
  1149. }
  1150. if (!this._cursorChanged) {
  1151. this._changeCursor("");
  1152. }
  1153. this._manageFocus();
  1154. };
  1155. /** @hidden */
  1156. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1157. for (var pointerId in list) {
  1158. if (!list.hasOwnProperty(pointerId)) {
  1159. continue;
  1160. }
  1161. var lastControlOver = list[pointerId];
  1162. if (lastControlOver === control) {
  1163. delete list[pointerId];
  1164. }
  1165. }
  1166. };
  1167. /** @hidden */
  1168. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1169. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1170. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1171. };
  1172. /** Attach to all scene events required to support pointer events */
  1173. AdvancedDynamicTexture.prototype.attach = function () {
  1174. var _this = this;
  1175. var scene = this.getScene();
  1176. if (!scene) {
  1177. return;
  1178. }
  1179. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1180. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1181. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1182. return;
  1183. }
  1184. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1185. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1186. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1187. return;
  1188. }
  1189. if (!scene) {
  1190. return;
  1191. }
  1192. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1193. var engine = scene.getEngine();
  1194. if (!camera) {
  1195. tempViewport.x = 0;
  1196. tempViewport.y = 0;
  1197. tempViewport.width = engine.getRenderWidth();
  1198. tempViewport.height = engine.getRenderHeight();
  1199. }
  1200. else {
  1201. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1202. }
  1203. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1204. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1205. _this._shouldBlockPointer = false;
  1206. // Do picking modifies _shouldBlockPointer
  1207. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1208. // Avoid overwriting a true skipOnPointerObservable to false
  1209. if (_this._shouldBlockPointer) {
  1210. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1211. }
  1212. });
  1213. this._attachToOnPointerOut(scene);
  1214. };
  1215. /**
  1216. * Register the clipboard Events onto the canvas
  1217. */
  1218. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1219. self.addEventListener("copy", this.onClipboardCopy, false);
  1220. self.addEventListener("cut", this.onClipboardCut, false);
  1221. self.addEventListener("paste", this.onClipboardPaste, false);
  1222. };
  1223. /**
  1224. * Unregister the clipboard Events from the canvas
  1225. */
  1226. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1227. self.removeEventListener("copy", this.onClipboardCopy);
  1228. self.removeEventListener("cut", this.onClipboardCut);
  1229. self.removeEventListener("paste", this.onClipboardPaste);
  1230. };
  1231. /**
  1232. * Connect the texture to a hosting mesh to enable interactions
  1233. * @param mesh defines the mesh to attach to
  1234. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1235. */
  1236. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1237. var _this = this;
  1238. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1239. var scene = this.getScene();
  1240. if (!scene) {
  1241. return;
  1242. }
  1243. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1244. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1245. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1246. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1247. return;
  1248. }
  1249. var pointerId = pi.event.pointerId || 0;
  1250. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1251. var uv = pi.pickInfo.getTextureCoordinates();
  1252. if (uv) {
  1253. var size = _this.getSize();
  1254. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1255. }
  1256. }
  1257. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1258. if (_this._lastControlDown[pointerId]) {
  1259. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1260. }
  1261. delete _this._lastControlDown[pointerId];
  1262. if (_this.focusedControl) {
  1263. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1264. var canMoveFocus = true;
  1265. if (friendlyControls) {
  1266. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1267. var control = friendlyControls_1[_i];
  1268. // Same host, no need to keep the focus
  1269. if (_this === control._host) {
  1270. continue;
  1271. }
  1272. // Different hosts
  1273. var otherHost = control._host;
  1274. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1275. canMoveFocus = false;
  1276. break;
  1277. }
  1278. }
  1279. }
  1280. if (canMoveFocus) {
  1281. _this.focusedControl = null;
  1282. }
  1283. }
  1284. }
  1285. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1286. if (_this._lastControlOver[pointerId]) {
  1287. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1288. }
  1289. delete _this._lastControlOver[pointerId];
  1290. }
  1291. });
  1292. mesh.enablePointerMoveEvents = supportPointerMove;
  1293. this._attachToOnPointerOut(scene);
  1294. };
  1295. /**
  1296. * Move the focus to a specific control
  1297. * @param control defines the control which will receive the focus
  1298. */
  1299. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1300. this.focusedControl = control;
  1301. this._lastPickedControl = control;
  1302. this._blockNextFocusCheck = true;
  1303. };
  1304. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1305. if (this._blockNextFocusCheck) {
  1306. this._blockNextFocusCheck = false;
  1307. this._lastPickedControl = this._focusedControl;
  1308. return;
  1309. }
  1310. // Focus management
  1311. if (this._focusedControl) {
  1312. if (this._focusedControl !== this._lastPickedControl) {
  1313. if (this._lastPickedControl.isFocusInvisible) {
  1314. return;
  1315. }
  1316. this.focusedControl = null;
  1317. }
  1318. }
  1319. };
  1320. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1321. var _this = this;
  1322. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1323. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1324. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1325. }
  1326. delete _this._lastControlOver[pointerEvent.pointerId];
  1327. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1328. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1329. delete _this._lastControlDown[pointerEvent.pointerId];
  1330. }
  1331. });
  1332. };
  1333. // Statics
  1334. /**
  1335. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1336. * @param mesh defines the mesh which will receive the texture
  1337. * @param width defines the texture width (1024 by default)
  1338. * @param height defines the texture height (1024 by default)
  1339. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1340. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1341. * @returns a new AdvancedDynamicTexture
  1342. */
  1343. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1344. if (width === void 0) { width = 1024; }
  1345. if (height === void 0) { height = 1024; }
  1346. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1347. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1348. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1349. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1350. material.backFaceCulling = false;
  1351. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1352. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1353. if (onlyAlphaTesting) {
  1354. material.diffuseTexture = result;
  1355. material.emissiveTexture = result;
  1356. result.hasAlpha = true;
  1357. }
  1358. else {
  1359. material.emissiveTexture = result;
  1360. material.opacityTexture = result;
  1361. }
  1362. mesh.material = material;
  1363. result.attachToMesh(mesh, supportPointerMove);
  1364. return result;
  1365. };
  1366. /**
  1367. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1368. * In this mode the texture will rely on a layer for its rendering.
  1369. * This allows it to be treated like any other layer.
  1370. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1371. * LayerMask is set through advancedTexture.layer.layerMask
  1372. * @param name defines name for the texture
  1373. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1374. * @param scene defines the hsoting scene
  1375. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1376. * @returns a new AdvancedDynamicTexture
  1377. */
  1378. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1379. if (foreground === void 0) { foreground = true; }
  1380. if (scene === void 0) { scene = null; }
  1381. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1382. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1383. // Display
  1384. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1385. layer.texture = result;
  1386. result._layerToDispose = layer;
  1387. result._isFullscreen = true;
  1388. // Attach
  1389. result.attach();
  1390. return result;
  1391. };
  1392. return AdvancedDynamicTexture;
  1393. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1394. /***/ }),
  1395. /***/ "./2D/controls/button.ts":
  1396. /*!*******************************!*\
  1397. !*** ./2D/controls/button.ts ***!
  1398. \*******************************/
  1399. /*! exports provided: Button */
  1400. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1401. "use strict";
  1402. __webpack_require__.r(__webpack_exports__);
  1403. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1404. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1405. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1406. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1407. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1408. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1409. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  1410. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1411. /**
  1412. * Class used to create 2D buttons
  1413. */
  1414. var Button = /** @class */ (function (_super) {
  1415. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1416. /**
  1417. * Creates a new Button
  1418. * @param name defines the name of the button
  1419. */
  1420. function Button(name) {
  1421. var _this = _super.call(this, name) || this;
  1422. _this.name = name;
  1423. /**
  1424. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1425. */
  1426. _this.delegatePickingToChildren = false;
  1427. _this.thickness = 1;
  1428. _this.isPointerBlocker = true;
  1429. var alphaStore = null;
  1430. _this.pointerEnterAnimation = function () {
  1431. alphaStore = _this.alpha;
  1432. _this.alpha -= 0.1;
  1433. };
  1434. _this.pointerOutAnimation = function () {
  1435. if (alphaStore !== null) {
  1436. _this.alpha = alphaStore;
  1437. }
  1438. };
  1439. _this.pointerDownAnimation = function () {
  1440. _this.scaleX -= 0.05;
  1441. _this.scaleY -= 0.05;
  1442. };
  1443. _this.pointerUpAnimation = function () {
  1444. _this.scaleX += 0.05;
  1445. _this.scaleY += 0.05;
  1446. };
  1447. return _this;
  1448. }
  1449. Object.defineProperty(Button.prototype, "image", {
  1450. /**
  1451. * Returns the image part of the button (if any)
  1452. */
  1453. get: function () {
  1454. return this._image;
  1455. },
  1456. enumerable: true,
  1457. configurable: true
  1458. });
  1459. Object.defineProperty(Button.prototype, "textBlock", {
  1460. /**
  1461. * Returns the image part of the button (if any)
  1462. */
  1463. get: function () {
  1464. return this._textBlock;
  1465. },
  1466. enumerable: true,
  1467. configurable: true
  1468. });
  1469. Button.prototype._getTypeName = function () {
  1470. return "Button";
  1471. };
  1472. // While being a container, the button behaves like a control.
  1473. /** @hidden */
  1474. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1475. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1476. return false;
  1477. }
  1478. if (!_super.prototype.contains.call(this, x, y)) {
  1479. return false;
  1480. }
  1481. if (this.delegatePickingToChildren) {
  1482. var contains = false;
  1483. for (var index = this._children.length - 1; index >= 0; index--) {
  1484. var child = this._children[index];
  1485. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1486. contains = true;
  1487. break;
  1488. }
  1489. }
  1490. if (!contains) {
  1491. return false;
  1492. }
  1493. }
  1494. this._processObservables(type, x, y, pointerId, buttonIndex);
  1495. return true;
  1496. };
  1497. /** @hidden */
  1498. Button.prototype._onPointerEnter = function (target) {
  1499. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1500. return false;
  1501. }
  1502. if (this.pointerEnterAnimation) {
  1503. this.pointerEnterAnimation();
  1504. }
  1505. return true;
  1506. };
  1507. /** @hidden */
  1508. Button.prototype._onPointerOut = function (target, force) {
  1509. if (force === void 0) { force = false; }
  1510. if (this.pointerOutAnimation) {
  1511. this.pointerOutAnimation();
  1512. }
  1513. _super.prototype._onPointerOut.call(this, target, force);
  1514. };
  1515. /** @hidden */
  1516. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1517. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1518. return false;
  1519. }
  1520. if (this.pointerDownAnimation) {
  1521. this.pointerDownAnimation();
  1522. }
  1523. return true;
  1524. };
  1525. /** @hidden */
  1526. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1527. if (this.pointerUpAnimation) {
  1528. this.pointerUpAnimation();
  1529. }
  1530. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1531. };
  1532. // Statics
  1533. /**
  1534. * Creates a new button made with an image and a text
  1535. * @param name defines the name of the button
  1536. * @param text defines the text of the button
  1537. * @param imageUrl defines the url of the image
  1538. * @returns a new Button
  1539. */
  1540. Button.CreateImageButton = function (name, text, imageUrl) {
  1541. var result = new Button(name);
  1542. // Adding text
  1543. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1544. textBlock.textWrapping = true;
  1545. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1546. textBlock.paddingLeft = "20%";
  1547. result.addControl(textBlock);
  1548. // Adding image
  1549. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1550. iconImage.width = "20%";
  1551. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1552. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1553. result.addControl(iconImage);
  1554. // Store
  1555. result._image = iconImage;
  1556. result._textBlock = textBlock;
  1557. return result;
  1558. };
  1559. /**
  1560. * Creates a new button made with an image
  1561. * @param name defines the name of the button
  1562. * @param imageUrl defines the url of the image
  1563. * @returns a new Button
  1564. */
  1565. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1566. var result = new Button(name);
  1567. // Adding image
  1568. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1569. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1570. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1571. result.addControl(iconImage);
  1572. // Store
  1573. result._image = iconImage;
  1574. return result;
  1575. };
  1576. /**
  1577. * Creates a new button made with a text
  1578. * @param name defines the name of the button
  1579. * @param text defines the text of the button
  1580. * @returns a new Button
  1581. */
  1582. Button.CreateSimpleButton = function (name, text) {
  1583. var result = new Button(name);
  1584. // Adding text
  1585. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1586. textBlock.textWrapping = true;
  1587. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1588. result.addControl(textBlock);
  1589. // Store
  1590. result._textBlock = textBlock;
  1591. return result;
  1592. };
  1593. /**
  1594. * Creates a new button made with an image and a centered text
  1595. * @param name defines the name of the button
  1596. * @param text defines the text of the button
  1597. * @param imageUrl defines the url of the image
  1598. * @returns a new Button
  1599. */
  1600. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1601. var result = new Button(name);
  1602. // Adding image
  1603. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1604. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1605. result.addControl(iconImage);
  1606. // Adding text
  1607. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1608. textBlock.textWrapping = true;
  1609. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1610. result.addControl(textBlock);
  1611. // Store
  1612. result._image = iconImage;
  1613. result._textBlock = textBlock;
  1614. return result;
  1615. };
  1616. return Button;
  1617. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1618. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1619. /***/ }),
  1620. /***/ "./2D/controls/checkbox.ts":
  1621. /*!*********************************!*\
  1622. !*** ./2D/controls/checkbox.ts ***!
  1623. \*********************************/
  1624. /*! exports provided: Checkbox */
  1625. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1626. "use strict";
  1627. __webpack_require__.r(__webpack_exports__);
  1628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1629. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1630. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1631. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1632. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1633. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1634. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1635. /**
  1636. * Class used to represent a 2D checkbox
  1637. */
  1638. var Checkbox = /** @class */ (function (_super) {
  1639. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1640. /**
  1641. * Creates a new CheckBox
  1642. * @param name defines the control name
  1643. */
  1644. function Checkbox(name) {
  1645. var _this = _super.call(this, name) || this;
  1646. _this.name = name;
  1647. _this._isChecked = false;
  1648. _this._background = "black";
  1649. _this._checkSizeRatio = 0.8;
  1650. _this._thickness = 1;
  1651. /**
  1652. * Observable raised when isChecked property changes
  1653. */
  1654. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1655. _this.isPointerBlocker = true;
  1656. return _this;
  1657. }
  1658. Object.defineProperty(Checkbox.prototype, "thickness", {
  1659. /** Gets or sets border thickness */
  1660. get: function () {
  1661. return this._thickness;
  1662. },
  1663. set: function (value) {
  1664. if (this._thickness === value) {
  1665. return;
  1666. }
  1667. this._thickness = value;
  1668. this._markAsDirty();
  1669. },
  1670. enumerable: true,
  1671. configurable: true
  1672. });
  1673. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1674. /** Gets or sets a value indicating the ratio between overall size and check size */
  1675. get: function () {
  1676. return this._checkSizeRatio;
  1677. },
  1678. set: function (value) {
  1679. value = Math.max(Math.min(1, value), 0);
  1680. if (this._checkSizeRatio === value) {
  1681. return;
  1682. }
  1683. this._checkSizeRatio = value;
  1684. this._markAsDirty();
  1685. },
  1686. enumerable: true,
  1687. configurable: true
  1688. });
  1689. Object.defineProperty(Checkbox.prototype, "background", {
  1690. /** Gets or sets background color */
  1691. get: function () {
  1692. return this._background;
  1693. },
  1694. set: function (value) {
  1695. if (this._background === value) {
  1696. return;
  1697. }
  1698. this._background = value;
  1699. this._markAsDirty();
  1700. },
  1701. enumerable: true,
  1702. configurable: true
  1703. });
  1704. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1705. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1706. get: function () {
  1707. return this._isChecked;
  1708. },
  1709. set: function (value) {
  1710. if (this._isChecked === value) {
  1711. return;
  1712. }
  1713. this._isChecked = value;
  1714. this._markAsDirty();
  1715. this.onIsCheckedChangedObservable.notifyObservers(value);
  1716. },
  1717. enumerable: true,
  1718. configurable: true
  1719. });
  1720. Checkbox.prototype._getTypeName = function () {
  1721. return "Checkbox";
  1722. };
  1723. /** @hidden */
  1724. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1725. context.save();
  1726. this._applyStates(context);
  1727. var actualWidth = this._currentMeasure.width - this._thickness;
  1728. var actualHeight = this._currentMeasure.height - this._thickness;
  1729. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1730. context.shadowColor = this.shadowColor;
  1731. context.shadowBlur = this.shadowBlur;
  1732. context.shadowOffsetX = this.shadowOffsetX;
  1733. context.shadowOffsetY = this.shadowOffsetY;
  1734. }
  1735. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1736. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1737. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1738. context.shadowBlur = 0;
  1739. context.shadowOffsetX = 0;
  1740. context.shadowOffsetY = 0;
  1741. }
  1742. if (this._isChecked) {
  1743. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1744. var offsetWidth = actualWidth * this._checkSizeRatio;
  1745. var offseHeight = actualHeight * this._checkSizeRatio;
  1746. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1747. }
  1748. context.strokeStyle = this.color;
  1749. context.lineWidth = this._thickness;
  1750. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1751. context.restore();
  1752. };
  1753. // Events
  1754. /** @hidden */
  1755. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1756. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1757. return false;
  1758. }
  1759. this.isChecked = !this.isChecked;
  1760. return true;
  1761. };
  1762. /**
  1763. * Utility function to easily create a checkbox with a header
  1764. * @param title defines the label to use for the header
  1765. * @param onValueChanged defines the callback to call when value changes
  1766. * @returns a StackPanel containing the checkbox and a textBlock
  1767. */
  1768. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1769. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1770. panel.isVertical = false;
  1771. panel.height = "30px";
  1772. var checkbox = new Checkbox();
  1773. checkbox.width = "20px";
  1774. checkbox.height = "20px";
  1775. checkbox.isChecked = true;
  1776. checkbox.color = "green";
  1777. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1778. panel.addControl(checkbox);
  1779. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1780. header.text = title;
  1781. header.width = "180px";
  1782. header.paddingLeft = "5px";
  1783. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1784. header.color = "white";
  1785. panel.addControl(header);
  1786. return panel;
  1787. };
  1788. return Checkbox;
  1789. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1790. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1791. /***/ }),
  1792. /***/ "./2D/controls/colorpicker.ts":
  1793. /*!************************************!*\
  1794. !*** ./2D/controls/colorpicker.ts ***!
  1795. \************************************/
  1796. /*! exports provided: ColorPicker */
  1797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1798. "use strict";
  1799. __webpack_require__.r(__webpack_exports__);
  1800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1801. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1802. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  1803. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1804. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1805. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1806. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1807. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1808. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1809. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1810. /** Class used to create color pickers */
  1811. var ColorPicker = /** @class */ (function (_super) {
  1812. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1813. /**
  1814. * Creates a new ColorPicker
  1815. * @param name defines the control name
  1816. */
  1817. function ColorPicker(name) {
  1818. var _this = _super.call(this, name) || this;
  1819. _this.name = name;
  1820. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1821. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1822. _this._pointerStartedOnSquare = false;
  1823. _this._pointerStartedOnWheel = false;
  1824. _this._squareLeft = 0;
  1825. _this._squareTop = 0;
  1826. _this._squareSize = 0;
  1827. _this._h = 360;
  1828. _this._s = 1;
  1829. _this._v = 1;
  1830. _this._lastPointerDownID = -1;
  1831. /**
  1832. * Observable raised when the value changes
  1833. */
  1834. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1835. // Events
  1836. _this._pointerIsDown = false;
  1837. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1838. _this.size = "200px";
  1839. _this.isPointerBlocker = true;
  1840. return _this;
  1841. }
  1842. Object.defineProperty(ColorPicker.prototype, "value", {
  1843. /** Gets or sets the color of the color picker */
  1844. get: function () {
  1845. return this._value;
  1846. },
  1847. set: function (value) {
  1848. if (this._value.equals(value)) {
  1849. return;
  1850. }
  1851. this._value.copyFrom(value);
  1852. this._value.toHSVToRef(this._tmpColor);
  1853. this._h = this._tmpColor.r;
  1854. this._s = Math.max(this._tmpColor.g, 0.00001);
  1855. this._v = Math.max(this._tmpColor.b, 0.00001);
  1856. this._markAsDirty();
  1857. if (this._value.r <= ColorPicker._Epsilon) {
  1858. this._value.r = 0;
  1859. }
  1860. if (this._value.g <= ColorPicker._Epsilon) {
  1861. this._value.g = 0;
  1862. }
  1863. if (this._value.b <= ColorPicker._Epsilon) {
  1864. this._value.b = 0;
  1865. }
  1866. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1867. this._value.r = 1.0;
  1868. }
  1869. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1870. this._value.g = 1.0;
  1871. }
  1872. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1873. this._value.b = 1.0;
  1874. }
  1875. this.onValueChangedObservable.notifyObservers(this._value);
  1876. },
  1877. enumerable: true,
  1878. configurable: true
  1879. });
  1880. Object.defineProperty(ColorPicker.prototype, "width", {
  1881. /**
  1882. * Gets or sets control width
  1883. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1884. */
  1885. get: function () {
  1886. return this._width.toString(this._host);
  1887. },
  1888. set: function (value) {
  1889. if (this._width.toString(this._host) === value) {
  1890. return;
  1891. }
  1892. if (this._width.fromString(value)) {
  1893. this._height.fromString(value);
  1894. this._markAsDirty();
  1895. }
  1896. },
  1897. enumerable: true,
  1898. configurable: true
  1899. });
  1900. Object.defineProperty(ColorPicker.prototype, "height", {
  1901. /**
  1902. * Gets or sets control height
  1903. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1904. */
  1905. get: function () {
  1906. return this._height.toString(this._host);
  1907. },
  1908. /** Gets or sets control height */
  1909. set: function (value) {
  1910. if (this._height.toString(this._host) === value) {
  1911. return;
  1912. }
  1913. if (this._height.fromString(value)) {
  1914. this._width.fromString(value);
  1915. this._markAsDirty();
  1916. }
  1917. },
  1918. enumerable: true,
  1919. configurable: true
  1920. });
  1921. Object.defineProperty(ColorPicker.prototype, "size", {
  1922. /** Gets or sets control size */
  1923. get: function () {
  1924. return this.width;
  1925. },
  1926. set: function (value) {
  1927. this.width = value;
  1928. },
  1929. enumerable: true,
  1930. configurable: true
  1931. });
  1932. ColorPicker.prototype._getTypeName = function () {
  1933. return "ColorPicker";
  1934. };
  1935. /** @hidden */
  1936. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1937. if (parentMeasure.width < parentMeasure.height) {
  1938. this._currentMeasure.height = parentMeasure.width;
  1939. }
  1940. else {
  1941. this._currentMeasure.width = parentMeasure.height;
  1942. }
  1943. };
  1944. ColorPicker.prototype._updateSquareProps = function () {
  1945. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1946. var wheelThickness = radius * .2;
  1947. var innerDiameter = (radius - wheelThickness) * 2;
  1948. var squareSize = innerDiameter / (Math.sqrt(2));
  1949. var offset = radius - squareSize * .5;
  1950. this._squareLeft = this._currentMeasure.left + offset;
  1951. this._squareTop = this._currentMeasure.top + offset;
  1952. this._squareSize = squareSize;
  1953. };
  1954. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1955. var lgh = context.createLinearGradient(left, top, width + left, top);
  1956. lgh.addColorStop(0, '#fff');
  1957. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1958. context.fillStyle = lgh;
  1959. context.fillRect(left, top, width, height);
  1960. var lgv = context.createLinearGradient(left, top, left, height + top);
  1961. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1962. lgv.addColorStop(1, '#000');
  1963. context.fillStyle = lgv;
  1964. context.fillRect(left, top, width, height);
  1965. };
  1966. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1967. context.beginPath();
  1968. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1969. context.lineWidth = 3;
  1970. context.strokeStyle = '#333333';
  1971. context.stroke();
  1972. context.beginPath();
  1973. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1974. context.lineWidth = 3;
  1975. context.strokeStyle = '#ffffff';
  1976. context.stroke();
  1977. };
  1978. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1979. var canvas = document.createElement("canvas");
  1980. canvas.width = radius * 2;
  1981. canvas.height = radius * 2;
  1982. var context = canvas.getContext("2d");
  1983. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1984. var data = image.data;
  1985. var color = this._tmpColor;
  1986. var maxDistSq = radius * radius;
  1987. var innerRadius = radius - thickness;
  1988. var minDistSq = innerRadius * innerRadius;
  1989. for (var x = -radius; x < radius; x++) {
  1990. for (var y = -radius; y < radius; y++) {
  1991. var distSq = x * x + y * y;
  1992. if (distSq > maxDistSq || distSq < minDistSq) {
  1993. continue;
  1994. }
  1995. var dist = Math.sqrt(distSq);
  1996. var ang = Math.atan2(y, x);
  1997. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1998. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1999. data[index] = color.r * 255;
  2000. data[index + 1] = color.g * 255;
  2001. data[index + 2] = color.b * 255;
  2002. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2003. //apply less alpha to bigger color pickers
  2004. var alphaAmount = .2;
  2005. var maxAlpha = .2;
  2006. var minAlpha = .04;
  2007. var lowerRadius = 50;
  2008. var upperRadius = 150;
  2009. if (radius < lowerRadius) {
  2010. alphaAmount = maxAlpha;
  2011. }
  2012. else if (radius > upperRadius) {
  2013. alphaAmount = minAlpha;
  2014. }
  2015. else {
  2016. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2017. }
  2018. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2019. if (alphaRatio < alphaAmount) {
  2020. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2021. }
  2022. else if (alphaRatio > 1 - alphaAmount) {
  2023. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2024. }
  2025. else {
  2026. data[index + 3] = 255;
  2027. }
  2028. }
  2029. }
  2030. context.putImageData(image, 0, 0);
  2031. return canvas;
  2032. };
  2033. /** @hidden */
  2034. ColorPicker.prototype._draw = function (context) {
  2035. context.save();
  2036. this._applyStates(context);
  2037. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2038. var wheelThickness = radius * .2;
  2039. var left = this._currentMeasure.left;
  2040. var top = this._currentMeasure.top;
  2041. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2042. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2043. }
  2044. this._updateSquareProps();
  2045. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2046. context.shadowColor = this.shadowColor;
  2047. context.shadowBlur = this.shadowBlur;
  2048. context.shadowOffsetX = this.shadowOffsetX;
  2049. context.shadowOffsetY = this.shadowOffsetY;
  2050. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2051. }
  2052. context.drawImage(this._colorWheelCanvas, left, top);
  2053. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2054. context.shadowBlur = 0;
  2055. context.shadowOffsetX = 0;
  2056. context.shadowOffsetY = 0;
  2057. }
  2058. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2059. var cx = this._squareLeft + this._squareSize * this._s;
  2060. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2061. this._drawCircle(cx, cy, radius * .04, context);
  2062. var dist = radius - wheelThickness * .5;
  2063. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2064. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2065. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2066. context.restore();
  2067. };
  2068. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2069. if (this._pointerStartedOnWheel) {
  2070. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2071. var centerX = radius + this._currentMeasure.left;
  2072. var centerY = radius + this._currentMeasure.top;
  2073. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2074. }
  2075. else if (this._pointerStartedOnSquare) {
  2076. this._updateSquareProps();
  2077. this._s = (x - this._squareLeft) / this._squareSize;
  2078. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2079. this._s = Math.min(this._s, 1);
  2080. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2081. this._v = Math.min(this._v, 1);
  2082. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2083. }
  2084. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2085. this.value = this._tmpColor;
  2086. };
  2087. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2088. this._updateSquareProps();
  2089. var left = this._squareLeft;
  2090. var top = this._squareTop;
  2091. var size = this._squareSize;
  2092. if (x >= left && x <= left + size &&
  2093. y >= top && y <= top + size) {
  2094. return true;
  2095. }
  2096. return false;
  2097. };
  2098. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2099. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2100. var centerX = radius + this._currentMeasure.left;
  2101. var centerY = radius + this._currentMeasure.top;
  2102. var wheelThickness = radius * .2;
  2103. var innerRadius = radius - wheelThickness;
  2104. var radiusSq = radius * radius;
  2105. var innerRadiusSq = innerRadius * innerRadius;
  2106. var dx = x - centerX;
  2107. var dy = y - centerY;
  2108. var distSq = dx * dx + dy * dy;
  2109. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2110. return true;
  2111. }
  2112. return false;
  2113. };
  2114. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2115. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2116. return false;
  2117. }
  2118. this._pointerIsDown = true;
  2119. this._pointerStartedOnSquare = false;
  2120. this._pointerStartedOnWheel = false;
  2121. // Invert transform
  2122. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2123. var x = this._transformedPosition.x;
  2124. var y = this._transformedPosition.y;
  2125. if (this._isPointOnSquare(x, y)) {
  2126. this._pointerStartedOnSquare = true;
  2127. }
  2128. else if (this._isPointOnWheel(x, y)) {
  2129. this._pointerStartedOnWheel = true;
  2130. }
  2131. this._updateValueFromPointer(x, y);
  2132. this._host._capturingControl[pointerId] = this;
  2133. this._lastPointerDownID = pointerId;
  2134. return true;
  2135. };
  2136. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2137. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2138. if (pointerId != this._lastPointerDownID) {
  2139. return;
  2140. }
  2141. // Invert transform
  2142. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2143. var x = this._transformedPosition.x;
  2144. var y = this._transformedPosition.y;
  2145. if (this._pointerIsDown) {
  2146. this._updateValueFromPointer(x, y);
  2147. }
  2148. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2149. };
  2150. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2151. this._pointerIsDown = false;
  2152. delete this._host._capturingControl[pointerId];
  2153. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2154. };
  2155. /**
  2156. * This function expands the color picker by creating a color picker dialog with manual
  2157. * color value input and the ability to save colors into an array to be used later in
  2158. * subsequent launches of the dialogue.
  2159. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2160. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  2161. * @returns picked color as a hex string and the saved colors array as hex strings.
  2162. */
  2163. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2164. return new Promise(function (resolve, reject) {
  2165. // Default options
  2166. options.pickerWidth = options.pickerWidth || "640px";
  2167. options.pickerHeight = options.pickerHeight || "400px";
  2168. options.headerHeight = options.headerHeight || "35px";
  2169. options.lastColor = options.lastColor || "#000000";
  2170. options.swatchLimit = options.swatchLimit || 20;
  2171. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2172. // Window size settings
  2173. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2174. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2175. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2176. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2177. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2178. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2179. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2180. // Button Colors
  2181. var buttonColor = "#c0c0c0";
  2182. var buttonBackgroundColor = "#535353";
  2183. var buttonBackgroundHoverColor = "#414141";
  2184. var buttonBackgroundClickColor = "515151";
  2185. var buttonDisabledColor = "#555555";
  2186. var buttonDisabledBackgroundColor = "#454545";
  2187. var currentSwatchesOutlineColor = "#404040";
  2188. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2189. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2190. var iconColorDark = "#aaaaaa";
  2191. var iconColorLight = "#ffffff";
  2192. var closeIconColor;
  2193. // Button settings
  2194. var buttonFontSize;
  2195. var butEdit;
  2196. var buttonWidth;
  2197. var buttonHeight;
  2198. // Input Text Colors
  2199. var inputFieldLabels = ["R", "G", "B"];
  2200. var inputTextBackgroundColor = "#454545";
  2201. var inputTextColor = "#f0f0f0";
  2202. // This is the current color as set by either the picker or by entering a value
  2203. var currentColor;
  2204. // This int is used for naming swatches and serves as the index for calling them from the list
  2205. var swatchNumber;
  2206. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2207. var swatchDrawer;
  2208. var editSwatchMode = false;
  2209. // Color InputText fields that will be updated upon value change
  2210. var picker;
  2211. var rValInt;
  2212. var gValInt;
  2213. var bValInt;
  2214. var rValDec;
  2215. var gValDec;
  2216. var bValDec;
  2217. var hexVal;
  2218. var newSwatch;
  2219. var lastVal;
  2220. var activeField;
  2221. /**
  2222. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2223. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2224. * are will receive no update. This is to prevent the input from the user being overwritten.
  2225. */
  2226. function updateValues(value, inputField) {
  2227. activeField = inputField;
  2228. var pickedColor = value.toHexString();
  2229. newSwatch.background = pickedColor;
  2230. if (rValInt.name != activeField) {
  2231. rValInt.text = Math.floor(value.r * 255).toString();
  2232. }
  2233. if (gValInt.name != activeField) {
  2234. gValInt.text = Math.floor(value.g * 255).toString();
  2235. }
  2236. if (bValInt.name != activeField) {
  2237. bValInt.text = Math.floor(value.b * 255).toString();
  2238. }
  2239. if (rValDec.name != activeField) {
  2240. rValDec.text = value.r.toString();
  2241. }
  2242. if (gValDec.name != activeField) {
  2243. gValDec.text = value.g.toString();
  2244. }
  2245. if (bValDec.name != activeField) {
  2246. bValDec.text = value.b.toString();
  2247. }
  2248. if (hexVal.name != activeField) {
  2249. var minusPound = pickedColor.split("#");
  2250. hexVal.text = minusPound[1];
  2251. }
  2252. if (picker.name != activeField) {
  2253. picker.value = value;
  2254. }
  2255. }
  2256. // When the user enters an integer for R, G, or B we check to make sure it is a valid number and replace if not.
  2257. function updateInt(field, channel) {
  2258. var newValue = field.text;
  2259. var checkVal = /[^0-9]/g.test(newValue);
  2260. if (checkVal) {
  2261. field.text = lastVal;
  2262. return;
  2263. }
  2264. else {
  2265. if (newValue != "") {
  2266. if (Math.floor(parseInt(newValue)) < 0) {
  2267. newValue = "0";
  2268. }
  2269. else if (Math.floor(parseInt(newValue)) > 255) {
  2270. newValue = "255";
  2271. }
  2272. else if (isNaN(parseInt(newValue))) {
  2273. newValue = "0";
  2274. }
  2275. }
  2276. if (activeField == field.name) {
  2277. lastVal = newValue;
  2278. }
  2279. }
  2280. if (newValue != "") {
  2281. newValue = parseInt(newValue).toString();
  2282. field.text = newValue;
  2283. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2284. if (activeField == field.name) {
  2285. if (channel == "r") {
  2286. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2287. }
  2288. else if (channel == "g") {
  2289. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2290. }
  2291. else {
  2292. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2293. }
  2294. }
  2295. }
  2296. }
  2297. // When the user enters a float for R, G, or B we check to make sure it is a valid number and replace if not.
  2298. function updateFloat(field, channel) {
  2299. var newValue = field.text;
  2300. var checkVal = /[^0-9\.]/g.test(newValue);
  2301. if (checkVal) {
  2302. field.text = lastVal;
  2303. return;
  2304. }
  2305. else {
  2306. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2307. if (parseFloat(newValue) < 0.0) {
  2308. newValue = "0.0";
  2309. }
  2310. else if (parseFloat(newValue) > 1.0) {
  2311. newValue = "1.0";
  2312. }
  2313. else if (isNaN(parseFloat(newValue))) {
  2314. newValue = "0.0";
  2315. }
  2316. }
  2317. if (activeField == field.name) {
  2318. lastVal = newValue;
  2319. }
  2320. }
  2321. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2322. newValue = parseFloat(newValue).toString();
  2323. field.text = newValue;
  2324. }
  2325. else {
  2326. newValue = "0.0";
  2327. }
  2328. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2329. if (activeField == field.name) {
  2330. if (channel == "r") {
  2331. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2332. }
  2333. else if (channel == "g") {
  2334. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2335. }
  2336. else {
  2337. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2338. }
  2339. }
  2340. }
  2341. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2342. function deleteSwatch(index) {
  2343. if (options.savedColors) {
  2344. options.savedColors.splice(index, 1);
  2345. }
  2346. if (options.savedColors && options.savedColors.length == 0) {
  2347. setEditButtonVisibility(false);
  2348. editSwatchMode = false;
  2349. }
  2350. }
  2351. // Creates and styles an individual swatch when updateSwatches is called.
  2352. function createSwatch() {
  2353. if (options.savedColors && options.savedColors[swatchNumber]) {
  2354. if (editSwatchMode) {
  2355. var icon = "b";
  2356. }
  2357. else {
  2358. var icon = "";
  2359. }
  2360. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2361. swatch.fontFamily = "BabylonJSglyphs";
  2362. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2363. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2364. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2365. if (swatchLuminence > luminanceLimit) {
  2366. swatch.color = iconColorDark;
  2367. }
  2368. else {
  2369. swatch.color = iconColorLight;
  2370. }
  2371. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2372. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2373. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2374. swatch.background = options.savedColors[swatchNumber];
  2375. swatch.thickness = 2;
  2376. var metadata_1 = swatchNumber;
  2377. swatch.pointerDownAnimation = function () {
  2378. swatch.thickness = 4;
  2379. };
  2380. swatch.pointerUpAnimation = function () {
  2381. swatch.thickness = 3;
  2382. };
  2383. swatch.pointerEnterAnimation = function () {
  2384. swatch.thickness = 3;
  2385. };
  2386. swatch.pointerOutAnimation = function () {
  2387. swatch.thickness = 2;
  2388. };
  2389. swatch.onPointerClickObservable.add(function () {
  2390. if (!editSwatchMode) {
  2391. if (options.savedColors) {
  2392. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2393. }
  2394. }
  2395. else {
  2396. deleteSwatch(metadata_1);
  2397. updateSwatches("", butSave);
  2398. }
  2399. });
  2400. return swatch;
  2401. }
  2402. else {
  2403. return null;
  2404. }
  2405. }
  2406. // Mode switch to render button text and close symbols on swatch controls
  2407. function editSwatches(mode) {
  2408. if (mode !== undefined) {
  2409. editSwatchMode = mode;
  2410. }
  2411. if (editSwatchMode) {
  2412. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2413. var thisButton = swatchDrawer.children[i];
  2414. thisButton.textBlock.text = "b";
  2415. }
  2416. if (butEdit !== undefined) {
  2417. butEdit.textBlock.text = "Done";
  2418. }
  2419. }
  2420. else {
  2421. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2422. var thisButton = swatchDrawer.children[i];
  2423. thisButton.textBlock.text = "";
  2424. }
  2425. if (butEdit !== undefined) {
  2426. butEdit.textBlock.text = "Edit";
  2427. }
  2428. }
  2429. }
  2430. /**
  2431. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2432. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2433. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2434. * saved colors there are and how many can be stored per row.
  2435. */
  2436. function updateSwatches(color, button) {
  2437. if (options.savedColors) {
  2438. if (color != "") {
  2439. options.savedColors.push(color);
  2440. }
  2441. swatchNumber = 0;
  2442. swatchDrawer.clearControls();
  2443. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2444. if (rowCount == 0) {
  2445. var gutterCount = 0;
  2446. }
  2447. else {
  2448. var gutterCount = rowCount + 1;
  2449. }
  2450. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2451. var currentRows = swatchDrawer.rowCount;
  2452. for (var i = 0; i < currentRows; i++) {
  2453. swatchDrawer.removeRowDefinition(0);
  2454. }
  2455. for (var i = 0; i < rowCount + gutterCount; i++) {
  2456. if (i % 2) {
  2457. swatchDrawer.addRowDefinition(swatchSize, true);
  2458. }
  2459. else {
  2460. swatchDrawer.addRowDefinition(gutterSize, true);
  2461. }
  2462. }
  2463. }
  2464. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2465. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2466. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2467. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2468. var totalButtonsThisRow = options.numSwatchesPerLine;
  2469. }
  2470. else {
  2471. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2472. }
  2473. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2474. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2475. if (x > options.numSwatchesPerLine) {
  2476. continue;
  2477. }
  2478. var swatch = createSwatch();
  2479. if (swatch != null) {
  2480. swatchDrawer.addControl(swatch, y, w);
  2481. w += 2;
  2482. swatchNumber++;
  2483. }
  2484. else {
  2485. continue;
  2486. }
  2487. }
  2488. }
  2489. if (options.savedColors.length >= options.swatchLimit) {
  2490. disableButton(button, true);
  2491. }
  2492. else {
  2493. disableButton(button, false);
  2494. }
  2495. }
  2496. }
  2497. // Shows or hides edit swatches button depending on if there are saved swatches
  2498. function setEditButtonVisibility(enableButton) {
  2499. if (enableButton) {
  2500. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2501. butEdit.width = buttonWidth;
  2502. butEdit.height = buttonHeight;
  2503. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2504. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2505. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2506. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2507. butEdit.thickness = 2;
  2508. butEdit.color = buttonColor;
  2509. butEdit.fontSize = buttonFontSize;
  2510. butEdit.background = buttonBackgroundColor;
  2511. butEdit.onPointerEnterObservable.add(function () {
  2512. butEdit.background = buttonBackgroundHoverColor;
  2513. });
  2514. butEdit.onPointerOutObservable.add(function () {
  2515. butEdit.background = buttonBackgroundColor;
  2516. });
  2517. butEdit.pointerDownAnimation = function () {
  2518. butEdit.background = buttonBackgroundClickColor;
  2519. };
  2520. butEdit.pointerUpAnimation = function () {
  2521. butEdit.background = buttonBackgroundHoverColor;
  2522. };
  2523. butEdit.onPointerClickObservable.add(function () {
  2524. if (editSwatchMode) {
  2525. editSwatchMode = false;
  2526. }
  2527. else {
  2528. editSwatchMode = true;
  2529. }
  2530. editSwatches();
  2531. });
  2532. pickerGrid.addControl(butEdit, 1, 0);
  2533. }
  2534. else {
  2535. pickerGrid.removeControl(butEdit);
  2536. }
  2537. }
  2538. // Called when the user hits the limit of saved colors in the drawer.
  2539. function disableButton(button, disabled) {
  2540. if (disabled) {
  2541. button.color = buttonDisabledColor;
  2542. button.background = buttonDisabledBackgroundColor;
  2543. }
  2544. else {
  2545. button.color = buttonColor;
  2546. button.background = buttonBackgroundColor;
  2547. }
  2548. }
  2549. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2550. function closePicker(color) {
  2551. if (options.savedColors && options.savedColors.length > 0) {
  2552. resolve({
  2553. savedColors: options.savedColors,
  2554. pickedColor: color
  2555. });
  2556. }
  2557. else {
  2558. resolve({
  2559. pickedColor: color
  2560. });
  2561. }
  2562. advancedTexture.removeControl(dialogContainer);
  2563. }
  2564. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2565. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2566. dialogContainer.name = "Dialog Container";
  2567. dialogContainer.width = options.pickerWidth;
  2568. if (options.savedColors) {
  2569. dialogContainer.height = containerSize;
  2570. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2571. dialogContainer.addRowDefinition(topRow, false);
  2572. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2573. }
  2574. else {
  2575. dialogContainer.height = options.pickerHeight;
  2576. dialogContainer.addRowDefinition(1.0, false);
  2577. }
  2578. advancedTexture.addControl(dialogContainer);
  2579. // Swatch drawer which contains all saved color buttons
  2580. if (options.savedColors) {
  2581. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2582. swatchDrawer.name = "Swatch Drawer";
  2583. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2584. swatchDrawer.background = buttonBackgroundColor;
  2585. swatchDrawer.width = options.pickerWidth;
  2586. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2587. if (initialRows == 0) {
  2588. var gutterCount = 0;
  2589. }
  2590. else {
  2591. var gutterCount = initialRows + 1;
  2592. }
  2593. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2594. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2595. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2596. if (i % 2 != 0) {
  2597. swatchDrawer.addRowDefinition(swatchSize, true);
  2598. }
  2599. else {
  2600. swatchDrawer.addRowDefinition(gutterSize, true);
  2601. }
  2602. }
  2603. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2604. if (i % 2 != 0) {
  2605. swatchDrawer.addColumnDefinition(swatchSize, true);
  2606. }
  2607. else {
  2608. swatchDrawer.addColumnDefinition(gutterSize, true);
  2609. }
  2610. }
  2611. dialogContainer.addControl(swatchDrawer, 1, 0);
  2612. }
  2613. // Picker container
  2614. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2615. pickerPanel.name = "Picker Panel";
  2616. pickerPanel.height = options.pickerHeight;
  2617. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2618. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2619. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2620. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2621. dialogContainer.addControl(pickerPanel, 0, 0);
  2622. // Picker container header
  2623. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2624. header.name = "Dialogue Header Bar";
  2625. header.background = "#cccccc";
  2626. header.thickness = 0;
  2627. pickerPanel.addControl(header, 0, 0);
  2628. // Header close button
  2629. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2630. closeButton.fontFamily = "BabylonJSglyphs";
  2631. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2632. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2633. closeButton.color = closeIconColor.toHexString();
  2634. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2635. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2636. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2637. closeButton.height = closeButton.width = options.headerHeight;
  2638. closeButton.background = header.background;
  2639. closeButton.thickness = 0;
  2640. closeButton.pointerDownAnimation = function () {
  2641. };
  2642. closeButton.pointerUpAnimation = function () {
  2643. closeButton.background = header.background;
  2644. };
  2645. closeButton.pointerEnterAnimation = function () {
  2646. closeButton.color = header.background;
  2647. closeButton.background = "red";
  2648. };
  2649. closeButton.pointerOutAnimation = function () {
  2650. closeButton.color = closeIconColor.toHexString();
  2651. closeButton.background = header.background;
  2652. };
  2653. closeButton.onPointerClickObservable.add(function () {
  2654. closePicker(currentSwatch.background);
  2655. });
  2656. pickerPanel.addControl(closeButton, 0, 0);
  2657. // Dialog container body
  2658. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2659. dialogBody.name = "Dialogue Body";
  2660. dialogBody.background = buttonBackgroundColor;
  2661. var dialogBodyCols = [0.4375, 0.5625];
  2662. dialogBody.addRowDefinition(1.0, false);
  2663. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2664. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2665. pickerPanel.addControl(dialogBody, 1, 0);
  2666. // Picker grid
  2667. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2668. pickerGrid.name = "Picker Grid";
  2669. pickerGrid.addRowDefinition(0.85, false);
  2670. pickerGrid.addRowDefinition(0.15, false);
  2671. dialogBody.addControl(pickerGrid, 0, 0);
  2672. // Picker control
  2673. picker = new ColorPicker();
  2674. picker.name = "GUI Color Picker";
  2675. if (options.pickerHeight < options.pickerWidth) {
  2676. picker.width = 0.89;
  2677. }
  2678. else {
  2679. picker.height = 0.89;
  2680. }
  2681. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2682. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2683. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2684. picker.onPointerDownObservable.add(function () {
  2685. activeField = picker.name;
  2686. lastVal = "";
  2687. editSwatches(false);
  2688. });
  2689. picker.onValueChangedObservable.add(function (value) {
  2690. if (activeField == picker.name) {
  2691. updateValues(value, picker.name);
  2692. }
  2693. });
  2694. pickerGrid.addControl(picker, 0, 0);
  2695. // Picker body right quarant
  2696. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2697. pickerBodyRight.name = "Dialogue Right Half";
  2698. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2699. var pickerBodyRightRows = [0.514, 0.486];
  2700. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2701. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2702. dialogBody.addControl(pickerBodyRight, 1, 1);
  2703. // Picker container swatches and buttons
  2704. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2705. pickerSwatchesButtons.name = "Swatches and Buttons";
  2706. var pickerButtonsCol = [0.417, 0.583];
  2707. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2708. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2709. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2710. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2711. // Picker Swatches quadrant
  2712. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2713. pickerSwatches.name = "New and Current Swatches";
  2714. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2715. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2716. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2717. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2718. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2719. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2720. // Active swatches
  2721. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2722. activeSwatches.name = "Active Swatches";
  2723. activeSwatches.width = 0.67;
  2724. activeSwatches.addRowDefinition(0.5, false);
  2725. activeSwatches.addRowDefinition(0.5, false);
  2726. pickerSwatches.addControl(activeSwatches, 2, 0);
  2727. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2728. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2729. if (options.pickerWidth > options.pickerHeight) {
  2730. var labelTextSize = labelHeight;
  2731. }
  2732. else {
  2733. var labelTextSize = labelWidth;
  2734. }
  2735. // New color swatch and previous color button
  2736. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2737. newText.text = "new";
  2738. newText.name = "New Color Label";
  2739. newText.color = buttonColor;
  2740. newText.fontSize = labelTextSize;
  2741. pickerSwatches.addControl(newText, 1, 0);
  2742. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2743. newSwatch.name = "New Color Swatch";
  2744. newSwatch.background = options.lastColor;
  2745. newSwatch.thickness = 0;
  2746. activeSwatches.addControl(newSwatch, 0, 0);
  2747. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2748. currentSwatch.background = options.lastColor;
  2749. currentSwatch.thickness = 0;
  2750. currentSwatch.onPointerClickObservable.add(function () {
  2751. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2752. updateValues(revertColor, currentSwatch.name);
  2753. editSwatches(false);
  2754. });
  2755. currentSwatch.pointerDownAnimation = function () { };
  2756. currentSwatch.pointerUpAnimation = function () { };
  2757. currentSwatch.pointerEnterAnimation = function () { };
  2758. currentSwatch.pointerOutAnimation = function () { };
  2759. activeSwatches.addControl(currentSwatch, 1, 0);
  2760. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2761. swatchOutline.name = "Swatch Outline";
  2762. swatchOutline.width = 0.67;
  2763. swatchOutline.thickness = 2;
  2764. swatchOutline.color = currentSwatchesOutlineColor;
  2765. swatchOutline.isHitTestVisible = false;
  2766. pickerSwatches.addControl(swatchOutline, 2, 0);
  2767. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2768. currentText.name = "Current Color Label";
  2769. currentText.text = "current";
  2770. currentText.color = buttonColor;
  2771. currentText.fontSize = labelTextSize;
  2772. pickerSwatches.addControl(currentText, 3, 0);
  2773. // Buttons grid
  2774. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2775. buttonGrid.name = "Button Grid";
  2776. buttonGrid.height = 0.8;
  2777. var buttonGridRows = 1 / 3;
  2778. buttonGrid.addRowDefinition(buttonGridRows, false);
  2779. buttonGrid.addRowDefinition(buttonGridRows, false);
  2780. buttonGrid.addRowDefinition(buttonGridRows, false);
  2781. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2782. // Determine pixel width and height for all buttons from overall panel dimensions
  2783. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2784. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2785. // Determine button type size
  2786. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2787. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2788. }
  2789. else {
  2790. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2791. }
  2792. // Panel Buttons
  2793. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2794. butOK.width = buttonWidth;
  2795. butOK.height = buttonHeight;
  2796. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2797. butOK.thickness = 2;
  2798. butOK.color = buttonColor;
  2799. butOK.fontSize = buttonFontSize;
  2800. butOK.background = buttonBackgroundColor;
  2801. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2802. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2803. butOK.pointerDownAnimation = function () {
  2804. butOK.background = buttonBackgroundClickColor;
  2805. };
  2806. butOK.pointerUpAnimation = function () {
  2807. butOK.background = buttonBackgroundHoverColor;
  2808. };
  2809. butOK.onPointerClickObservable.add(function () {
  2810. editSwatches(false);
  2811. closePicker(newSwatch.background);
  2812. });
  2813. buttonGrid.addControl(butOK, 0, 0);
  2814. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2815. butCancel.width = buttonWidth;
  2816. butCancel.height = buttonHeight;
  2817. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2818. butCancel.thickness = 2;
  2819. butCancel.color = buttonColor;
  2820. butCancel.fontSize = buttonFontSize;
  2821. butCancel.background = buttonBackgroundColor;
  2822. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2823. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2824. butCancel.pointerDownAnimation = function () {
  2825. butCancel.background = buttonBackgroundClickColor;
  2826. };
  2827. butCancel.pointerUpAnimation = function () {
  2828. butCancel.background = buttonBackgroundHoverColor;
  2829. };
  2830. butCancel.onPointerClickObservable.add(function () {
  2831. editSwatches(false);
  2832. closePicker(currentSwatch.background);
  2833. });
  2834. buttonGrid.addControl(butCancel, 1, 0);
  2835. if (options.savedColors) {
  2836. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2837. butSave.width = buttonWidth;
  2838. butSave.height = buttonHeight;
  2839. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2840. butSave.thickness = 2;
  2841. butSave.fontSize = buttonFontSize;
  2842. if (options.savedColors.length < options.swatchLimit) {
  2843. butSave.color = buttonColor;
  2844. butSave.background = buttonBackgroundColor;
  2845. }
  2846. else {
  2847. disableButton(butSave, true);
  2848. }
  2849. butSave.onPointerEnterObservable.add(function () {
  2850. if (options.savedColors) {
  2851. if (options.savedColors.length < options.swatchLimit) {
  2852. butSave.background = buttonBackgroundHoverColor;
  2853. }
  2854. }
  2855. });
  2856. butSave.onPointerOutObservable.add(function () {
  2857. if (options.savedColors) {
  2858. if (options.savedColors.length < options.swatchLimit) {
  2859. butSave.background = buttonBackgroundColor;
  2860. }
  2861. }
  2862. });
  2863. butSave.pointerDownAnimation = function () {
  2864. if (options.savedColors) {
  2865. if (options.savedColors.length < options.swatchLimit) {
  2866. butSave.background = buttonBackgroundClickColor;
  2867. }
  2868. }
  2869. };
  2870. butSave.pointerUpAnimation = function () {
  2871. if (options.savedColors) {
  2872. if (options.savedColors.length < options.swatchLimit) {
  2873. butSave.background = buttonBackgroundHoverColor;
  2874. }
  2875. }
  2876. };
  2877. butSave.onPointerClickObservable.add(function () {
  2878. if (options.savedColors) {
  2879. if (options.savedColors.length == 0) {
  2880. setEditButtonVisibility(true);
  2881. }
  2882. if (options.savedColors.length < options.swatchLimit) {
  2883. updateSwatches(newSwatch.background, butSave);
  2884. }
  2885. editSwatches(false);
  2886. }
  2887. });
  2888. if (options.savedColors.length > 0) {
  2889. setEditButtonVisibility(true);
  2890. }
  2891. buttonGrid.addControl(butSave, 2, 0);
  2892. }
  2893. // Picker color values input
  2894. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2895. pickerColorValues.name = "Dialog Lower Right";
  2896. pickerColorValues.addRowDefinition(0.02, false);
  2897. pickerColorValues.addRowDefinition(0.63, false);
  2898. pickerColorValues.addRowDefinition(0.21, false);
  2899. pickerColorValues.addRowDefinition(0.14, false);
  2900. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2901. // RGB values text boxes
  2902. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2903. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2904. rgbValuesQuadrant.name = "RGB Values";
  2905. rgbValuesQuadrant.width = 0.82;
  2906. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2907. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2908. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2909. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2910. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2911. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2912. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2913. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2914. for (var i = 0; i < inputFieldLabels.length; i++) {
  2915. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2916. labelText.text = inputFieldLabels[i];
  2917. labelText.color = buttonColor;
  2918. labelText.fontSize = buttonFontSize;
  2919. rgbValuesQuadrant.addControl(labelText, i, 0);
  2920. }
  2921. // Input fields for RGB values
  2922. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2923. rValInt.width = 0.83;
  2924. rValInt.height = 0.72;
  2925. rValInt.name = "rIntField";
  2926. rValInt.fontSize = buttonFontSize;
  2927. rValInt.text = (currentColor.r * 255).toString();
  2928. rValInt.color = inputTextColor;
  2929. rValInt.background = inputTextBackgroundColor;
  2930. rValInt.onFocusObservable.add(function () {
  2931. activeField = rValInt.name;
  2932. lastVal = rValInt.text;
  2933. editSwatches(false);
  2934. });
  2935. rValInt.onBlurObservable.add(function () {
  2936. if (rValInt.text == "") {
  2937. rValInt.text = "0";
  2938. }
  2939. updateInt(rValInt, "r");
  2940. if (activeField == rValInt.name) {
  2941. activeField = "";
  2942. }
  2943. });
  2944. rValInt.onTextChangedObservable.add(function () {
  2945. if (activeField == rValInt.name) {
  2946. updateInt(rValInt, "r");
  2947. }
  2948. });
  2949. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2950. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2951. gValInt.width = 0.83;
  2952. gValInt.height = 0.72;
  2953. gValInt.name = "gIntField";
  2954. gValInt.fontSize = buttonFontSize;
  2955. gValInt.text = (currentColor.g * 255).toString();
  2956. gValInt.color = inputTextColor;
  2957. gValInt.background = inputTextBackgroundColor;
  2958. gValInt.onFocusObservable.add(function () {
  2959. activeField = gValInt.name;
  2960. lastVal = gValInt.text;
  2961. editSwatches(false);
  2962. });
  2963. gValInt.onBlurObservable.add(function () {
  2964. if (gValInt.text == "") {
  2965. gValInt.text = "0";
  2966. }
  2967. updateInt(gValInt, "g");
  2968. if (activeField == gValInt.name) {
  2969. activeField = "";
  2970. }
  2971. });
  2972. gValInt.onTextChangedObservable.add(function () {
  2973. if (activeField == gValInt.name) {
  2974. updateInt(gValInt, "g");
  2975. }
  2976. });
  2977. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2978. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2979. bValInt.width = 0.83;
  2980. bValInt.height = 0.72;
  2981. bValInt.name = "bIntField";
  2982. bValInt.fontSize = buttonFontSize;
  2983. bValInt.text = (currentColor.b * 255).toString();
  2984. bValInt.color = inputTextColor;
  2985. bValInt.background = inputTextBackgroundColor;
  2986. bValInt.onFocusObservable.add(function () {
  2987. activeField = bValInt.name;
  2988. lastVal = bValInt.text;
  2989. editSwatches(false);
  2990. });
  2991. bValInt.onBlurObservable.add(function () {
  2992. if (bValInt.text == "") {
  2993. bValInt.text = "0";
  2994. }
  2995. updateInt(bValInt, "b");
  2996. if (activeField == bValInt.name) {
  2997. activeField = "";
  2998. }
  2999. });
  3000. bValInt.onTextChangedObservable.add(function () {
  3001. if (activeField == bValInt.name) {
  3002. updateInt(bValInt, "b");
  3003. }
  3004. });
  3005. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3006. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3007. rValDec.width = 0.95;
  3008. rValDec.height = 0.72;
  3009. rValDec.name = "rDecField";
  3010. rValDec.fontSize = buttonFontSize;
  3011. rValDec.text = currentColor.r.toString();
  3012. rValDec.color = inputTextColor;
  3013. rValDec.background = inputTextBackgroundColor;
  3014. rValDec.onFocusObservable.add(function () {
  3015. activeField = rValDec.name;
  3016. lastVal = rValDec.text;
  3017. editSwatches(false);
  3018. });
  3019. rValDec.onBlurObservable.add(function () {
  3020. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3021. rValDec.text = "0";
  3022. updateFloat(rValDec, "r");
  3023. }
  3024. if (activeField == rValDec.name) {
  3025. activeField = "";
  3026. }
  3027. });
  3028. rValDec.onTextChangedObservable.add(function () {
  3029. if (activeField == rValDec.name) {
  3030. updateFloat(rValDec, "r");
  3031. }
  3032. });
  3033. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3034. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3035. gValDec.width = 0.95;
  3036. gValDec.height = 0.72;
  3037. gValDec.name = "gDecField";
  3038. gValDec.fontSize = buttonFontSize;
  3039. gValDec.text = currentColor.g.toString();
  3040. gValDec.color = inputTextColor;
  3041. gValDec.background = inputTextBackgroundColor;
  3042. gValDec.onFocusObservable.add(function () {
  3043. activeField = gValDec.name;
  3044. lastVal = gValDec.text;
  3045. editSwatches(false);
  3046. });
  3047. gValDec.onBlurObservable.add(function () {
  3048. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3049. gValDec.text = "0";
  3050. updateFloat(gValDec, "g");
  3051. }
  3052. if (activeField == gValDec.name) {
  3053. activeField = "";
  3054. }
  3055. });
  3056. gValDec.onTextChangedObservable.add(function () {
  3057. if (activeField == gValDec.name) {
  3058. updateFloat(gValDec, "g");
  3059. }
  3060. });
  3061. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3062. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3063. bValDec.width = 0.95;
  3064. bValDec.height = 0.72;
  3065. bValDec.name = "bDecField";
  3066. bValDec.fontSize = buttonFontSize;
  3067. bValDec.text = currentColor.b.toString();
  3068. bValDec.color = inputTextColor;
  3069. bValDec.background = inputTextBackgroundColor;
  3070. bValDec.onFocusObservable.add(function () {
  3071. activeField = bValDec.name;
  3072. lastVal = bValDec.text;
  3073. editSwatches(false);
  3074. });
  3075. bValDec.onBlurObservable.add(function () {
  3076. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3077. bValDec.text = "0";
  3078. updateFloat(bValDec, "b");
  3079. }
  3080. if (activeField == bValDec.name) {
  3081. activeField = "";
  3082. }
  3083. });
  3084. bValDec.onTextChangedObservable.add(function () {
  3085. if (activeField == bValDec.name) {
  3086. updateFloat(bValDec, "b");
  3087. }
  3088. });
  3089. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3090. // Hex value input
  3091. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3092. hexValueQuadrant.name = "Hex Value";
  3093. hexValueQuadrant.width = 0.82;
  3094. hexValueQuadrant.addRowDefinition(1.0, false);
  3095. hexValueQuadrant.addColumnDefinition(0.1, false);
  3096. hexValueQuadrant.addColumnDefinition(0.9, false);
  3097. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3098. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3099. labelText.text = "#";
  3100. labelText.color = buttonColor;
  3101. labelText.fontSize = buttonFontSize;
  3102. hexValueQuadrant.addControl(labelText, 0, 0);
  3103. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3104. hexVal.width = 0.96;
  3105. hexVal.height = 0.72;
  3106. hexVal.name = "hexField";
  3107. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3108. hexVal.fontSize = buttonFontSize;
  3109. var minusPound = options.lastColor.split("#");
  3110. hexVal.text = minusPound[1];
  3111. hexVal.color = inputTextColor;
  3112. hexVal.background = inputTextBackgroundColor;
  3113. hexVal.onFocusObservable.add(function () {
  3114. activeField = hexVal.name;
  3115. lastVal = hexVal.text;
  3116. editSwatches(false);
  3117. });
  3118. hexVal.onBlurObservable.add(function () {
  3119. if (hexVal.text.length == 3) {
  3120. var val = hexVal.text.split("");
  3121. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3122. }
  3123. if (hexVal.text == "") {
  3124. hexVal.text = "000000";
  3125. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3126. }
  3127. if (activeField == hexVal.name) {
  3128. activeField = "";
  3129. }
  3130. });
  3131. hexVal.onTextChangedObservable.add(function () {
  3132. var newHexValue = hexVal.text;
  3133. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3134. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3135. hexVal.text = lastVal;
  3136. }
  3137. else {
  3138. if (hexVal.text.length < 6) {
  3139. var leadingZero = 6 - hexVal.text.length;
  3140. for (var i = 0; i < leadingZero; i++) {
  3141. newHexValue = "0" + newHexValue;
  3142. }
  3143. }
  3144. if (hexVal.text.length == 3) {
  3145. var val = hexVal.text.split("");
  3146. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3147. }
  3148. newHexValue = "#" + newHexValue;
  3149. if (activeField == hexVal.name) {
  3150. lastVal = hexVal.text;
  3151. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3152. }
  3153. }
  3154. });
  3155. hexValueQuadrant.addControl(hexVal, 0, 1);
  3156. if (options.savedColors && options.savedColors.length > 0) {
  3157. updateSwatches("", butSave);
  3158. }
  3159. });
  3160. };
  3161. ColorPicker._Epsilon = 0.000001;
  3162. return ColorPicker;
  3163. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3164. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3165. /***/ }),
  3166. /***/ "./2D/controls/container.ts":
  3167. /*!**********************************!*\
  3168. !*** ./2D/controls/container.ts ***!
  3169. \**********************************/
  3170. /*! exports provided: Container */
  3171. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3172. "use strict";
  3173. __webpack_require__.r(__webpack_exports__);
  3174. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3175. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3176. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/perfCounter");
  3177. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3178. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3179. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3180. /**
  3181. * Root class for 2D containers
  3182. * @see http://doc.babylonjs.com/how_to/gui#containers
  3183. */
  3184. var Container = /** @class */ (function (_super) {
  3185. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3186. /**
  3187. * Creates a new Container
  3188. * @param name defines the name of the container
  3189. */
  3190. function Container(name) {
  3191. var _this = _super.call(this, name) || this;
  3192. _this.name = name;
  3193. /** @hidden */
  3194. _this._children = new Array();
  3195. /** @hidden */
  3196. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3197. /** @hidden */
  3198. _this._background = "";
  3199. /** @hidden */
  3200. _this._adaptWidthToChildren = false;
  3201. /** @hidden */
  3202. _this._adaptHeightToChildren = false;
  3203. /**
  3204. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3205. */
  3206. _this.logLayoutCycleErrors = false;
  3207. /**
  3208. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3209. */
  3210. _this.maxLayoutCycle = 3;
  3211. return _this;
  3212. }
  3213. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3214. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3215. get: function () {
  3216. return this._adaptHeightToChildren;
  3217. },
  3218. set: function (value) {
  3219. if (this._adaptHeightToChildren === value) {
  3220. return;
  3221. }
  3222. this._adaptHeightToChildren = value;
  3223. if (value) {
  3224. this.height = "100%";
  3225. }
  3226. this._markAsDirty();
  3227. },
  3228. enumerable: true,
  3229. configurable: true
  3230. });
  3231. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3232. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3233. get: function () {
  3234. return this._adaptWidthToChildren;
  3235. },
  3236. set: function (value) {
  3237. if (this._adaptWidthToChildren === value) {
  3238. return;
  3239. }
  3240. this._adaptWidthToChildren = value;
  3241. if (value) {
  3242. this.width = "100%";
  3243. }
  3244. this._markAsDirty();
  3245. },
  3246. enumerable: true,
  3247. configurable: true
  3248. });
  3249. Object.defineProperty(Container.prototype, "background", {
  3250. /** Gets or sets background color */
  3251. get: function () {
  3252. return this._background;
  3253. },
  3254. set: function (value) {
  3255. if (this._background === value) {
  3256. return;
  3257. }
  3258. this._background = value;
  3259. this._markAsDirty();
  3260. },
  3261. enumerable: true,
  3262. configurable: true
  3263. });
  3264. Object.defineProperty(Container.prototype, "children", {
  3265. /** Gets the list of children */
  3266. get: function () {
  3267. return this._children;
  3268. },
  3269. enumerable: true,
  3270. configurable: true
  3271. });
  3272. Container.prototype._getTypeName = function () {
  3273. return "Container";
  3274. };
  3275. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3276. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3277. var child = _a[_i];
  3278. child._markMatrixAsDirty();
  3279. }
  3280. };
  3281. /**
  3282. * Gets a child using its name
  3283. * @param name defines the child name to look for
  3284. * @returns the child control if found
  3285. */
  3286. Container.prototype.getChildByName = function (name) {
  3287. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3288. var child = _a[_i];
  3289. if (child.name === name) {
  3290. return child;
  3291. }
  3292. }
  3293. return null;
  3294. };
  3295. /**
  3296. * Gets a child using its type and its name
  3297. * @param name defines the child name to look for
  3298. * @param type defines the child type to look for
  3299. * @returns the child control if found
  3300. */
  3301. Container.prototype.getChildByType = function (name, type) {
  3302. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3303. var child = _a[_i];
  3304. if (child.typeName === type) {
  3305. return child;
  3306. }
  3307. }
  3308. return null;
  3309. };
  3310. /**
  3311. * Search for a specific control in children
  3312. * @param control defines the control to look for
  3313. * @returns true if the control is in child list
  3314. */
  3315. Container.prototype.containsControl = function (control) {
  3316. return this.children.indexOf(control) !== -1;
  3317. };
  3318. /**
  3319. * Adds a new control to the current container
  3320. * @param control defines the control to add
  3321. * @returns the current container
  3322. */
  3323. Container.prototype.addControl = function (control) {
  3324. if (!control) {
  3325. return this;
  3326. }
  3327. var index = this._children.indexOf(control);
  3328. if (index !== -1) {
  3329. return this;
  3330. }
  3331. control._link(this._host);
  3332. control._markAllAsDirty();
  3333. this._reOrderControl(control);
  3334. this._markAsDirty();
  3335. return this;
  3336. };
  3337. /**
  3338. * Removes all controls from the current container
  3339. * @returns the current container
  3340. */
  3341. Container.prototype.clearControls = function () {
  3342. var children = this.children.slice();
  3343. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3344. var child = children_1[_i];
  3345. this.removeControl(child);
  3346. }
  3347. return this;
  3348. };
  3349. /**
  3350. * Removes a control from the current container
  3351. * @param control defines the control to remove
  3352. * @returns the current container
  3353. */
  3354. Container.prototype.removeControl = function (control) {
  3355. var index = this._children.indexOf(control);
  3356. if (index !== -1) {
  3357. this._children.splice(index, 1);
  3358. control.parent = null;
  3359. }
  3360. control.linkWithMesh(null);
  3361. if (this._host) {
  3362. this._host._cleanControlAfterRemoval(control);
  3363. }
  3364. this._markAsDirty();
  3365. return this;
  3366. };
  3367. /** @hidden */
  3368. Container.prototype._reOrderControl = function (control) {
  3369. this.removeControl(control);
  3370. var wasAdded = false;
  3371. for (var index = 0; index < this._children.length; index++) {
  3372. if (this._children[index].zIndex > control.zIndex) {
  3373. this._children.splice(index, 0, control);
  3374. wasAdded = true;
  3375. break;
  3376. }
  3377. }
  3378. if (!wasAdded) {
  3379. this._children.push(control);
  3380. }
  3381. control.parent = this;
  3382. this._markAsDirty();
  3383. };
  3384. /** @hidden */
  3385. Container.prototype._offsetLeft = function (offset) {
  3386. _super.prototype._offsetLeft.call(this, offset);
  3387. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3388. var child = _a[_i];
  3389. child._offsetLeft(offset);
  3390. }
  3391. };
  3392. /** @hidden */
  3393. Container.prototype._offsetTop = function (offset) {
  3394. _super.prototype._offsetTop.call(this, offset);
  3395. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3396. var child = _a[_i];
  3397. child._offsetTop(offset);
  3398. }
  3399. };
  3400. /** @hidden */
  3401. Container.prototype._markAllAsDirty = function () {
  3402. _super.prototype._markAllAsDirty.call(this);
  3403. for (var index = 0; index < this._children.length; index++) {
  3404. this._children[index]._markAllAsDirty();
  3405. }
  3406. };
  3407. /** @hidden */
  3408. Container.prototype._localDraw = function (context) {
  3409. if (this._background) {
  3410. context.save();
  3411. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3412. context.shadowColor = this.shadowColor;
  3413. context.shadowBlur = this.shadowBlur;
  3414. context.shadowOffsetX = this.shadowOffsetX;
  3415. context.shadowOffsetY = this.shadowOffsetY;
  3416. }
  3417. context.fillStyle = this._background;
  3418. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3419. context.restore();
  3420. }
  3421. };
  3422. /** @hidden */
  3423. Container.prototype._link = function (host) {
  3424. _super.prototype._link.call(this, host);
  3425. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3426. var child = _a[_i];
  3427. child._link(host);
  3428. }
  3429. };
  3430. /** @hidden */
  3431. Container.prototype._beforeLayout = function () {
  3432. // Do nothing
  3433. };
  3434. /** @hidden */
  3435. Container.prototype._processMeasures = function (parentMeasure, context) {
  3436. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3437. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3438. this._evaluateClippingState(parentMeasure);
  3439. }
  3440. };
  3441. /** @hidden */
  3442. Container.prototype._layout = function (parentMeasure, context) {
  3443. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3444. return false;
  3445. }
  3446. this.host._numLayoutCalls++;
  3447. if (this._isDirty) {
  3448. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3449. }
  3450. var rebuildCount = 0;
  3451. context.save();
  3452. this._applyStates(context);
  3453. this._beforeLayout();
  3454. do {
  3455. var computedWidth = -1;
  3456. var computedHeight = -1;
  3457. this._rebuildLayout = false;
  3458. this._processMeasures(parentMeasure, context);
  3459. if (!this._isClipped) {
  3460. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3461. var child = _a[_i];
  3462. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3463. if (child._layout(this._measureForChildren, context)) {
  3464. if (this.adaptWidthToChildren && child._width.isPixel) {
  3465. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3466. }
  3467. if (this.adaptHeightToChildren && child._height.isPixel) {
  3468. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3469. }
  3470. }
  3471. }
  3472. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3473. if (this.width !== computedWidth + "px") {
  3474. this.width = computedWidth + "px";
  3475. this._rebuildLayout = true;
  3476. }
  3477. }
  3478. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3479. if (this.height !== computedHeight + "px") {
  3480. this.height = computedHeight + "px";
  3481. this._rebuildLayout = true;
  3482. }
  3483. }
  3484. this._postMeasure();
  3485. }
  3486. rebuildCount++;
  3487. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3488. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3489. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3490. }
  3491. context.restore();
  3492. if (this._isDirty) {
  3493. this.invalidateRect();
  3494. this._isDirty = false;
  3495. }
  3496. return true;
  3497. };
  3498. Container.prototype._postMeasure = function () {
  3499. // Do nothing by default
  3500. };
  3501. /** @hidden */
  3502. Container.prototype._draw = function (context, invalidatedRectangle) {
  3503. this._localDraw(context);
  3504. if (this.clipChildren) {
  3505. this._clipForChildren(context);
  3506. }
  3507. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3508. var child = _a[_i];
  3509. // Only redraw parts of the screen that are invalidated
  3510. if (invalidatedRectangle) {
  3511. if (!child._intersectsRect(invalidatedRectangle)) {
  3512. continue;
  3513. }
  3514. }
  3515. child._render(context, invalidatedRectangle);
  3516. }
  3517. };
  3518. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3519. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3520. if (!this.children) {
  3521. return;
  3522. }
  3523. for (var index = 0; index < this.children.length; index++) {
  3524. var item = this.children[index];
  3525. if (!predicate || predicate(item)) {
  3526. results.push(item);
  3527. }
  3528. if (!directDescendantsOnly) {
  3529. item.getDescendantsToRef(results, false, predicate);
  3530. }
  3531. }
  3532. };
  3533. /** @hidden */
  3534. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3535. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3536. return false;
  3537. }
  3538. if (!_super.prototype.contains.call(this, x, y)) {
  3539. return false;
  3540. }
  3541. // Checking backwards to pick closest first
  3542. for (var index = this._children.length - 1; index >= 0; index--) {
  3543. var child = this._children[index];
  3544. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3545. if (child.hoverCursor) {
  3546. this._host._changeCursor(child.hoverCursor);
  3547. }
  3548. return true;
  3549. }
  3550. }
  3551. if (!this.isHitTestVisible) {
  3552. return false;
  3553. }
  3554. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3555. };
  3556. /** @hidden */
  3557. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3558. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3559. this._measureForChildren.copyFrom(this._currentMeasure);
  3560. };
  3561. /** Releases associated resources */
  3562. Container.prototype.dispose = function () {
  3563. _super.prototype.dispose.call(this);
  3564. for (var index = this.children.length - 1; index >= 0; index--) {
  3565. this.children[index].dispose();
  3566. }
  3567. };
  3568. return Container;
  3569. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3570. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3571. /***/ }),
  3572. /***/ "./2D/controls/control.ts":
  3573. /*!********************************!*\
  3574. !*** ./2D/controls/control.ts ***!
  3575. \********************************/
  3576. /*! exports provided: Control */
  3577. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3578. "use strict";
  3579. __webpack_require__.r(__webpack_exports__);
  3580. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3581. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  3582. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3583. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3584. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3585. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3586. /**
  3587. * Root class used for all 2D controls
  3588. * @see http://doc.babylonjs.com/how_to/gui#controls
  3589. */
  3590. var Control = /** @class */ (function () {
  3591. // Functions
  3592. /**
  3593. * Creates a new control
  3594. * @param name defines the name of the control
  3595. */
  3596. function Control(
  3597. /** defines the name of the control */
  3598. name) {
  3599. this.name = name;
  3600. this._alpha = 1;
  3601. this._alphaSet = false;
  3602. this._zIndex = 0;
  3603. /** @hidden */
  3604. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3605. this._fontFamily = "Arial";
  3606. this._fontStyle = "";
  3607. this._fontWeight = "";
  3608. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3609. /** @hidden */
  3610. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3611. /** @hidden */
  3612. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3613. this._color = "";
  3614. this._style = null;
  3615. /** @hidden */
  3616. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3617. /** @hidden */
  3618. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3619. /** @hidden */
  3620. this._isDirty = true;
  3621. /** @hidden */
  3622. this._wasDirty = false;
  3623. /** @hidden */
  3624. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3625. /** @hidden */
  3626. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3627. /** @hidden */
  3628. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3629. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3630. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3631. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3632. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3633. /** @hidden */
  3634. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3635. /** @hidden */
  3636. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3637. this._scaleX = 1.0;
  3638. this._scaleY = 1.0;
  3639. this._rotation = 0;
  3640. this._transformCenterX = 0.5;
  3641. this._transformCenterY = 0.5;
  3642. /** @hidden */
  3643. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3644. /** @hidden */
  3645. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3646. /** @hidden */
  3647. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3648. this._isMatrixDirty = true;
  3649. this._isVisible = true;
  3650. this._isHighlighted = false;
  3651. this._fontSet = false;
  3652. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3653. this._downCount = 0;
  3654. this._enterCount = -1;
  3655. this._doNotRender = false;
  3656. this._downPointerIds = {};
  3657. this._isEnabled = true;
  3658. this._disabledColor = "#9a9a9a";
  3659. /** @hidden */
  3660. this._rebuildLayout = false;
  3661. /** @hidden */
  3662. this._customData = {};
  3663. /** @hidden */
  3664. this._isClipped = false;
  3665. /** @hidden */
  3666. this._automaticSize = false;
  3667. /**
  3668. * Gets or sets an object used to store user defined information for the node
  3669. */
  3670. this.metadata = null;
  3671. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3672. this.isHitTestVisible = true;
  3673. /** Gets or sets a boolean indicating if the control can block pointer events */
  3674. this.isPointerBlocker = false;
  3675. /** Gets or sets a boolean indicating if the control can be focusable */
  3676. this.isFocusInvisible = false;
  3677. /**
  3678. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3679. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  3680. */
  3681. this.clipChildren = true;
  3682. /**
  3683. * Gets or sets a boolean indicating that control content must be clipped
  3684. * Please note that not clipping children may generate issues with adt.useInvalidateRectOptimization so it is recommended to turn this optimization off if you want to use unclipped children
  3685. */
  3686. this.clipContent = true;
  3687. /**
  3688. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3689. */
  3690. this.useBitmapCache = false;
  3691. this._shadowOffsetX = 0;
  3692. this._shadowOffsetY = 0;
  3693. this._shadowBlur = 0;
  3694. this._shadowColor = 'black';
  3695. /** Gets or sets the cursor to use when the control is hovered */
  3696. this.hoverCursor = "";
  3697. /** @hidden */
  3698. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3699. /** @hidden */
  3700. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3701. /**
  3702. * An event triggered when the pointer move over the control.
  3703. */
  3704. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3705. /**
  3706. * An event triggered when the pointer move out of the control.
  3707. */
  3708. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3709. /**
  3710. * An event triggered when the pointer taps the control
  3711. */
  3712. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3713. /**
  3714. * An event triggered when pointer up
  3715. */
  3716. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3717. /**
  3718. * An event triggered when a control is clicked on
  3719. */
  3720. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3721. /**
  3722. * An event triggered when pointer enters the control
  3723. */
  3724. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3725. /**
  3726. * An event triggered when the control is marked as dirty
  3727. */
  3728. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3729. /**
  3730. * An event triggered before drawing the control
  3731. */
  3732. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3733. /**
  3734. * An event triggered after the control was drawn
  3735. */
  3736. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3737. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3738. }
  3739. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3740. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3741. get: function () {
  3742. return this._shadowOffsetX;
  3743. },
  3744. set: function (value) {
  3745. if (this._shadowOffsetX === value) {
  3746. return;
  3747. }
  3748. this._shadowOffsetX = value;
  3749. this._markAsDirty();
  3750. },
  3751. enumerable: true,
  3752. configurable: true
  3753. });
  3754. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3755. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3756. get: function () {
  3757. return this._shadowOffsetY;
  3758. },
  3759. set: function (value) {
  3760. if (this._shadowOffsetY === value) {
  3761. return;
  3762. }
  3763. this._shadowOffsetY = value;
  3764. this._markAsDirty();
  3765. },
  3766. enumerable: true,
  3767. configurable: true
  3768. });
  3769. Object.defineProperty(Control.prototype, "shadowBlur", {
  3770. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3771. get: function () {
  3772. return this._shadowBlur;
  3773. },
  3774. set: function (value) {
  3775. if (this._shadowBlur === value) {
  3776. return;
  3777. }
  3778. this._shadowBlur = value;
  3779. this._markAsDirty();
  3780. },
  3781. enumerable: true,
  3782. configurable: true
  3783. });
  3784. Object.defineProperty(Control.prototype, "shadowColor", {
  3785. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3786. get: function () {
  3787. return this._shadowColor;
  3788. },
  3789. set: function (value) {
  3790. if (this._shadowColor === value) {
  3791. return;
  3792. }
  3793. this._shadowColor = value;
  3794. this._markAsDirty();
  3795. },
  3796. enumerable: true,
  3797. configurable: true
  3798. });
  3799. Object.defineProperty(Control.prototype, "typeName", {
  3800. // Properties
  3801. /** Gets the control type name */
  3802. get: function () {
  3803. return this._getTypeName();
  3804. },
  3805. enumerable: true,
  3806. configurable: true
  3807. });
  3808. /**
  3809. * Get the current class name of the control.
  3810. * @returns current class name
  3811. */
  3812. Control.prototype.getClassName = function () {
  3813. return this._getTypeName();
  3814. };
  3815. Object.defineProperty(Control.prototype, "host", {
  3816. /**
  3817. * Get the hosting AdvancedDynamicTexture
  3818. */
  3819. get: function () {
  3820. return this._host;
  3821. },
  3822. enumerable: true,
  3823. configurable: true
  3824. });
  3825. Object.defineProperty(Control.prototype, "fontOffset", {
  3826. /** Gets or set information about font offsets (used to render and align text) */
  3827. get: function () {
  3828. return this._fontOffset;
  3829. },
  3830. set: function (offset) {
  3831. this._fontOffset = offset;
  3832. },
  3833. enumerable: true,
  3834. configurable: true
  3835. });
  3836. Object.defineProperty(Control.prototype, "alpha", {
  3837. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3838. get: function () {
  3839. return this._alpha;
  3840. },
  3841. set: function (value) {
  3842. if (this._alpha === value) {
  3843. return;
  3844. }
  3845. this._alphaSet = true;
  3846. this._alpha = value;
  3847. this._markAsDirty();
  3848. },
  3849. enumerable: true,
  3850. configurable: true
  3851. });
  3852. Object.defineProperty(Control.prototype, "isHighlighted", {
  3853. /**
  3854. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3855. */
  3856. get: function () {
  3857. return this._isHighlighted;
  3858. },
  3859. set: function (value) {
  3860. if (this._isHighlighted === value) {
  3861. return;
  3862. }
  3863. this._isHighlighted = value;
  3864. this._markAsDirty();
  3865. },
  3866. enumerable: true,
  3867. configurable: true
  3868. });
  3869. Object.defineProperty(Control.prototype, "scaleX", {
  3870. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3871. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3872. */
  3873. get: function () {
  3874. return this._scaleX;
  3875. },
  3876. set: function (value) {
  3877. if (this._scaleX === value) {
  3878. return;
  3879. }
  3880. this._scaleX = value;
  3881. this._markAsDirty();
  3882. this._markMatrixAsDirty();
  3883. },
  3884. enumerable: true,
  3885. configurable: true
  3886. });
  3887. Object.defineProperty(Control.prototype, "scaleY", {
  3888. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3889. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3890. */
  3891. get: function () {
  3892. return this._scaleY;
  3893. },
  3894. set: function (value) {
  3895. if (this._scaleY === value) {
  3896. return;
  3897. }
  3898. this._scaleY = value;
  3899. this._markAsDirty();
  3900. this._markMatrixAsDirty();
  3901. },
  3902. enumerable: true,
  3903. configurable: true
  3904. });
  3905. Object.defineProperty(Control.prototype, "rotation", {
  3906. /** Gets or sets the rotation angle (0 by default)
  3907. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3908. */
  3909. get: function () {
  3910. return this._rotation;
  3911. },
  3912. set: function (value) {
  3913. if (this._rotation === value) {
  3914. return;
  3915. }
  3916. this._rotation = value;
  3917. this._markAsDirty();
  3918. this._markMatrixAsDirty();
  3919. },
  3920. enumerable: true,
  3921. configurable: true
  3922. });
  3923. Object.defineProperty(Control.prototype, "transformCenterY", {
  3924. /** Gets or sets the transformation center on Y axis (0 by default)
  3925. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3926. */
  3927. get: function () {
  3928. return this._transformCenterY;
  3929. },
  3930. set: function (value) {
  3931. if (this._transformCenterY === value) {
  3932. return;
  3933. }
  3934. this._transformCenterY = value;
  3935. this._markAsDirty();
  3936. this._markMatrixAsDirty();
  3937. },
  3938. enumerable: true,
  3939. configurable: true
  3940. });
  3941. Object.defineProperty(Control.prototype, "transformCenterX", {
  3942. /** Gets or sets the transformation center on X axis (0 by default)
  3943. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3944. */
  3945. get: function () {
  3946. return this._transformCenterX;
  3947. },
  3948. set: function (value) {
  3949. if (this._transformCenterX === value) {
  3950. return;
  3951. }
  3952. this._transformCenterX = value;
  3953. this._markAsDirty();
  3954. this._markMatrixAsDirty();
  3955. },
  3956. enumerable: true,
  3957. configurable: true
  3958. });
  3959. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3960. /**
  3961. * Gets or sets the horizontal alignment
  3962. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3963. */
  3964. get: function () {
  3965. return this._horizontalAlignment;
  3966. },
  3967. set: function (value) {
  3968. if (this._horizontalAlignment === value) {
  3969. return;
  3970. }
  3971. this._horizontalAlignment = value;
  3972. this._markAsDirty();
  3973. },
  3974. enumerable: true,
  3975. configurable: true
  3976. });
  3977. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3978. /**
  3979. * Gets or sets the vertical alignment
  3980. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3981. */
  3982. get: function () {
  3983. return this._verticalAlignment;
  3984. },
  3985. set: function (value) {
  3986. if (this._verticalAlignment === value) {
  3987. return;
  3988. }
  3989. this._verticalAlignment = value;
  3990. this._markAsDirty();
  3991. },
  3992. enumerable: true,
  3993. configurable: true
  3994. });
  3995. Object.defineProperty(Control.prototype, "width", {
  3996. /**
  3997. * Gets or sets control width
  3998. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3999. */
  4000. get: function () {
  4001. return this._width.toString(this._host);
  4002. },
  4003. set: function (value) {
  4004. if (this._width.toString(this._host) === value) {
  4005. return;
  4006. }
  4007. if (this._width.fromString(value)) {
  4008. this._markAsDirty();
  4009. }
  4010. },
  4011. enumerable: true,
  4012. configurable: true
  4013. });
  4014. Object.defineProperty(Control.prototype, "widthInPixels", {
  4015. /**
  4016. * Gets or sets the control width in pixel
  4017. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4018. */
  4019. get: function () {
  4020. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4021. },
  4022. set: function (value) {
  4023. if (isNaN(value)) {
  4024. return;
  4025. }
  4026. this.width = value + "px";
  4027. },
  4028. enumerable: true,
  4029. configurable: true
  4030. });
  4031. Object.defineProperty(Control.prototype, "height", {
  4032. /**
  4033. * Gets or sets control height
  4034. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4035. */
  4036. get: function () {
  4037. return this._height.toString(this._host);
  4038. },
  4039. set: function (value) {
  4040. if (this._height.toString(this._host) === value) {
  4041. return;
  4042. }
  4043. if (this._height.fromString(value)) {
  4044. this._markAsDirty();
  4045. }
  4046. },
  4047. enumerable: true,
  4048. configurable: true
  4049. });
  4050. Object.defineProperty(Control.prototype, "heightInPixels", {
  4051. /**
  4052. * Gets or sets control height in pixel
  4053. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4054. */
  4055. get: function () {
  4056. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4057. },
  4058. set: function (value) {
  4059. if (isNaN(value)) {
  4060. return;
  4061. }
  4062. this.height = value + "px";
  4063. },
  4064. enumerable: true,
  4065. configurable: true
  4066. });
  4067. Object.defineProperty(Control.prototype, "fontFamily", {
  4068. /** Gets or set font family */
  4069. get: function () {
  4070. if (!this._fontSet) {
  4071. return "";
  4072. }
  4073. return this._fontFamily;
  4074. },
  4075. set: function (value) {
  4076. if (this._fontFamily === value) {
  4077. return;
  4078. }
  4079. this._fontFamily = value;
  4080. this._resetFontCache();
  4081. },
  4082. enumerable: true,
  4083. configurable: true
  4084. });
  4085. Object.defineProperty(Control.prototype, "fontStyle", {
  4086. /** Gets or sets font style */
  4087. get: function () {
  4088. return this._fontStyle;
  4089. },
  4090. set: function (value) {
  4091. if (this._fontStyle === value) {
  4092. return;
  4093. }
  4094. this._fontStyle = value;
  4095. this._resetFontCache();
  4096. },
  4097. enumerable: true,
  4098. configurable: true
  4099. });
  4100. Object.defineProperty(Control.prototype, "fontWeight", {
  4101. /** Gets or sets font weight */
  4102. get: function () {
  4103. return this._fontWeight;
  4104. },
  4105. set: function (value) {
  4106. if (this._fontWeight === value) {
  4107. return;
  4108. }
  4109. this._fontWeight = value;
  4110. this._resetFontCache();
  4111. },
  4112. enumerable: true,
  4113. configurable: true
  4114. });
  4115. Object.defineProperty(Control.prototype, "style", {
  4116. /**
  4117. * Gets or sets style
  4118. * @see http://doc.babylonjs.com/how_to/gui#styles
  4119. */
  4120. get: function () {
  4121. return this._style;
  4122. },
  4123. set: function (value) {
  4124. var _this = this;
  4125. if (this._style) {
  4126. this._style.onChangedObservable.remove(this._styleObserver);
  4127. this._styleObserver = null;
  4128. }
  4129. this._style = value;
  4130. if (this._style) {
  4131. this._styleObserver = this._style.onChangedObservable.add(function () {
  4132. _this._markAsDirty();
  4133. _this._resetFontCache();
  4134. });
  4135. }
  4136. this._markAsDirty();
  4137. this._resetFontCache();
  4138. },
  4139. enumerable: true,
  4140. configurable: true
  4141. });
  4142. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4143. /** @hidden */
  4144. get: function () {
  4145. return this._fontSize.isPercentage;
  4146. },
  4147. enumerable: true,
  4148. configurable: true
  4149. });
  4150. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4151. /** Gets or sets font size in pixels */
  4152. get: function () {
  4153. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4154. if (fontSizeToUse.isPixel) {
  4155. return fontSizeToUse.getValue(this._host);
  4156. }
  4157. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4158. },
  4159. set: function (value) {
  4160. if (isNaN(value)) {
  4161. return;
  4162. }
  4163. this.fontSize = value + "px";
  4164. },
  4165. enumerable: true,
  4166. configurable: true
  4167. });
  4168. Object.defineProperty(Control.prototype, "fontSize", {
  4169. /** Gets or sets font size */
  4170. get: function () {
  4171. return this._fontSize.toString(this._host);
  4172. },
  4173. set: function (value) {
  4174. if (this._fontSize.toString(this._host) === value) {
  4175. return;
  4176. }
  4177. if (this._fontSize.fromString(value)) {
  4178. this._markAsDirty();
  4179. this._resetFontCache();
  4180. }
  4181. },
  4182. enumerable: true,
  4183. configurable: true
  4184. });
  4185. Object.defineProperty(Control.prototype, "color", {
  4186. /** Gets or sets foreground color */
  4187. get: function () {
  4188. return this._color;
  4189. },
  4190. set: function (value) {
  4191. if (this._color === value) {
  4192. return;
  4193. }
  4194. this._color = value;
  4195. this._markAsDirty();
  4196. },
  4197. enumerable: true,
  4198. configurable: true
  4199. });
  4200. Object.defineProperty(Control.prototype, "zIndex", {
  4201. /** Gets or sets z index which is used to reorder controls on the z axis */
  4202. get: function () {
  4203. return this._zIndex;
  4204. },
  4205. set: function (value) {
  4206. if (this.zIndex === value) {
  4207. return;
  4208. }
  4209. this._zIndex = value;
  4210. if (this.parent) {
  4211. this.parent._reOrderControl(this);
  4212. }
  4213. },
  4214. enumerable: true,
  4215. configurable: true
  4216. });
  4217. Object.defineProperty(Control.prototype, "notRenderable", {
  4218. /** Gets or sets a boolean indicating if the control can be rendered */
  4219. get: function () {
  4220. return this._doNotRender;
  4221. },
  4222. set: function (value) {
  4223. if (this._doNotRender === value) {
  4224. return;
  4225. }
  4226. this._doNotRender = value;
  4227. this._markAsDirty();
  4228. },
  4229. enumerable: true,
  4230. configurable: true
  4231. });
  4232. Object.defineProperty(Control.prototype, "isVisible", {
  4233. /** Gets or sets a boolean indicating if the control is visible */
  4234. get: function () {
  4235. return this._isVisible;
  4236. },
  4237. set: function (value) {
  4238. if (this._isVisible === value) {
  4239. return;
  4240. }
  4241. this._isVisible = value;
  4242. this._markAsDirty(true);
  4243. },
  4244. enumerable: true,
  4245. configurable: true
  4246. });
  4247. Object.defineProperty(Control.prototype, "isDirty", {
  4248. /** Gets a boolean indicating that the control needs to update its rendering */
  4249. get: function () {
  4250. return this._isDirty;
  4251. },
  4252. enumerable: true,
  4253. configurable: true
  4254. });
  4255. Object.defineProperty(Control.prototype, "linkedMesh", {
  4256. /**
  4257. * Gets the current linked mesh (or null if none)
  4258. */
  4259. get: function () {
  4260. return this._linkedMesh;
  4261. },
  4262. enumerable: true,
  4263. configurable: true
  4264. });
  4265. Object.defineProperty(Control.prototype, "paddingLeft", {
  4266. /**
  4267. * Gets or sets a value indicating the padding to use on the left of the control
  4268. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4269. */
  4270. get: function () {
  4271. return this._paddingLeft.toString(this._host);
  4272. },
  4273. set: function (value) {
  4274. if (this._paddingLeft.fromString(value)) {
  4275. this._markAsDirty();
  4276. }
  4277. },
  4278. enumerable: true,
  4279. configurable: true
  4280. });
  4281. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4282. /**
  4283. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4284. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4285. */
  4286. get: function () {
  4287. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4288. },
  4289. set: function (value) {
  4290. if (isNaN(value)) {
  4291. return;
  4292. }
  4293. this.paddingLeft = value + "px";
  4294. },
  4295. enumerable: true,
  4296. configurable: true
  4297. });
  4298. Object.defineProperty(Control.prototype, "paddingRight", {
  4299. /**
  4300. * Gets or sets a value indicating the padding to use on the right of the control
  4301. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4302. */
  4303. get: function () {
  4304. return this._paddingRight.toString(this._host);
  4305. },
  4306. set: function (value) {
  4307. if (this._paddingRight.fromString(value)) {
  4308. this._markAsDirty();
  4309. }
  4310. },
  4311. enumerable: true,
  4312. configurable: true
  4313. });
  4314. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4315. /**
  4316. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4317. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4318. */
  4319. get: function () {
  4320. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4321. },
  4322. set: function (value) {
  4323. if (isNaN(value)) {
  4324. return;
  4325. }
  4326. this.paddingRight = value + "px";
  4327. },
  4328. enumerable: true,
  4329. configurable: true
  4330. });
  4331. Object.defineProperty(Control.prototype, "paddingTop", {
  4332. /**
  4333. * Gets or sets a value indicating the padding to use on the top of the control
  4334. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4335. */
  4336. get: function () {
  4337. return this._paddingTop.toString(this._host);
  4338. },
  4339. set: function (value) {
  4340. if (this._paddingTop.fromString(value)) {
  4341. this._markAsDirty();
  4342. }
  4343. },
  4344. enumerable: true,
  4345. configurable: true
  4346. });
  4347. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4348. /**
  4349. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4350. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4351. */
  4352. get: function () {
  4353. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4354. },
  4355. set: function (value) {
  4356. if (isNaN(value)) {
  4357. return;
  4358. }
  4359. this.paddingTop = value + "px";
  4360. },
  4361. enumerable: true,
  4362. configurable: true
  4363. });
  4364. Object.defineProperty(Control.prototype, "paddingBottom", {
  4365. /**
  4366. * Gets or sets a value indicating the padding to use on the bottom of the control
  4367. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4368. */
  4369. get: function () {
  4370. return this._paddingBottom.toString(this._host);
  4371. },
  4372. set: function (value) {
  4373. if (this._paddingBottom.fromString(value)) {
  4374. this._markAsDirty();
  4375. }
  4376. },
  4377. enumerable: true,
  4378. configurable: true
  4379. });
  4380. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4381. /**
  4382. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4383. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4384. */
  4385. get: function () {
  4386. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4387. },
  4388. set: function (value) {
  4389. if (isNaN(value)) {
  4390. return;
  4391. }
  4392. this.paddingBottom = value + "px";
  4393. },
  4394. enumerable: true,
  4395. configurable: true
  4396. });
  4397. Object.defineProperty(Control.prototype, "left", {
  4398. /**
  4399. * Gets or sets a value indicating the left coordinate of the control
  4400. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4401. */
  4402. get: function () {
  4403. return this._left.toString(this._host);
  4404. },
  4405. set: function (value) {
  4406. if (this._left.fromString(value)) {
  4407. this._markAsDirty();
  4408. }
  4409. },
  4410. enumerable: true,
  4411. configurable: true
  4412. });
  4413. Object.defineProperty(Control.prototype, "leftInPixels", {
  4414. /**
  4415. * Gets or sets a value indicating the left coordinate in pixels of the control
  4416. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4417. */
  4418. get: function () {
  4419. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4420. },
  4421. set: function (value) {
  4422. if (isNaN(value)) {
  4423. return;
  4424. }
  4425. this.left = value + "px";
  4426. },
  4427. enumerable: true,
  4428. configurable: true
  4429. });
  4430. Object.defineProperty(Control.prototype, "top", {
  4431. /**
  4432. * Gets or sets a value indicating the top coordinate of the control
  4433. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4434. */
  4435. get: function () {
  4436. return this._top.toString(this._host);
  4437. },
  4438. set: function (value) {
  4439. if (this._top.fromString(value)) {
  4440. this._markAsDirty();
  4441. }
  4442. },
  4443. enumerable: true,
  4444. configurable: true
  4445. });
  4446. Object.defineProperty(Control.prototype, "topInPixels", {
  4447. /**
  4448. * Gets or sets a value indicating the top coordinate in pixels of the control
  4449. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4450. */
  4451. get: function () {
  4452. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4453. },
  4454. set: function (value) {
  4455. if (isNaN(value)) {
  4456. return;
  4457. }
  4458. this.top = value + "px";
  4459. },
  4460. enumerable: true,
  4461. configurable: true
  4462. });
  4463. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4464. /**
  4465. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4466. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4467. */
  4468. get: function () {
  4469. return this._linkOffsetX.toString(this._host);
  4470. },
  4471. set: function (value) {
  4472. if (this._linkOffsetX.fromString(value)) {
  4473. this._markAsDirty();
  4474. }
  4475. },
  4476. enumerable: true,
  4477. configurable: true
  4478. });
  4479. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4480. /**
  4481. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4482. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4483. */
  4484. get: function () {
  4485. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4486. },
  4487. set: function (value) {
  4488. if (isNaN(value)) {
  4489. return;
  4490. }
  4491. this.linkOffsetX = value + "px";
  4492. },
  4493. enumerable: true,
  4494. configurable: true
  4495. });
  4496. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4497. /**
  4498. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4499. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4500. */
  4501. get: function () {
  4502. return this._linkOffsetY.toString(this._host);
  4503. },
  4504. set: function (value) {
  4505. if (this._linkOffsetY.fromString(value)) {
  4506. this._markAsDirty();
  4507. }
  4508. },
  4509. enumerable: true,
  4510. configurable: true
  4511. });
  4512. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4513. /**
  4514. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4515. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4516. */
  4517. get: function () {
  4518. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4519. },
  4520. set: function (value) {
  4521. if (isNaN(value)) {
  4522. return;
  4523. }
  4524. this.linkOffsetY = value + "px";
  4525. },
  4526. enumerable: true,
  4527. configurable: true
  4528. });
  4529. Object.defineProperty(Control.prototype, "centerX", {
  4530. /** Gets the center coordinate on X axis */
  4531. get: function () {
  4532. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4533. },
  4534. enumerable: true,
  4535. configurable: true
  4536. });
  4537. Object.defineProperty(Control.prototype, "centerY", {
  4538. /** Gets the center coordinate on Y axis */
  4539. get: function () {
  4540. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4541. },
  4542. enumerable: true,
  4543. configurable: true
  4544. });
  4545. Object.defineProperty(Control.prototype, "isEnabled", {
  4546. /** Gets or sets if control is Enabled*/
  4547. get: function () {
  4548. return this._isEnabled;
  4549. },
  4550. set: function (value) {
  4551. if (this._isEnabled === value) {
  4552. return;
  4553. }
  4554. this._isEnabled = value;
  4555. this._markAsDirty();
  4556. },
  4557. enumerable: true,
  4558. configurable: true
  4559. });
  4560. Object.defineProperty(Control.prototype, "disabledColor", {
  4561. /** Gets or sets background color of control if it's disabled*/
  4562. get: function () {
  4563. return this._disabledColor;
  4564. },
  4565. set: function (value) {
  4566. if (this._disabledColor === value) {
  4567. return;
  4568. }
  4569. this._disabledColor = value;
  4570. this._markAsDirty();
  4571. },
  4572. enumerable: true,
  4573. configurable: true
  4574. });
  4575. /** @hidden */
  4576. Control.prototype._getTypeName = function () {
  4577. return "Control";
  4578. };
  4579. /**
  4580. * Gets the first ascendant in the hierarchy of the given type
  4581. * @param className defines the required type
  4582. * @returns the ascendant or null if not found
  4583. */
  4584. Control.prototype.getAscendantOfClass = function (className) {
  4585. if (!this.parent) {
  4586. return null;
  4587. }
  4588. if (this.parent.getClassName() === className) {
  4589. return this.parent;
  4590. }
  4591. return this.parent.getAscendantOfClass(className);
  4592. };
  4593. /** @hidden */
  4594. Control.prototype._resetFontCache = function () {
  4595. this._fontSet = true;
  4596. this._markAsDirty();
  4597. };
  4598. /**
  4599. * Determines if a container is an ascendant of the current control
  4600. * @param container defines the container to look for
  4601. * @returns true if the container is one of the ascendant of the control
  4602. */
  4603. Control.prototype.isAscendant = function (container) {
  4604. if (!this.parent) {
  4605. return false;
  4606. }
  4607. if (this.parent === container) {
  4608. return true;
  4609. }
  4610. return this.parent.isAscendant(container);
  4611. };
  4612. /**
  4613. * Gets coordinates in local control space
  4614. * @param globalCoordinates defines the coordinates to transform
  4615. * @returns the new coordinates in local space
  4616. */
  4617. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4618. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4619. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4620. return result;
  4621. };
  4622. /**
  4623. * Gets coordinates in local control space
  4624. * @param globalCoordinates defines the coordinates to transform
  4625. * @param result defines the target vector2 where to store the result
  4626. * @returns the current control
  4627. */
  4628. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4629. result.x = globalCoordinates.x - this._currentMeasure.left;
  4630. result.y = globalCoordinates.y - this._currentMeasure.top;
  4631. return this;
  4632. };
  4633. /**
  4634. * Gets coordinates in parent local control space
  4635. * @param globalCoordinates defines the coordinates to transform
  4636. * @returns the new coordinates in parent local space
  4637. */
  4638. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4639. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4640. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4641. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4642. return result;
  4643. };
  4644. /**
  4645. * Move the current control to a vector3 position projected onto the screen.
  4646. * @param position defines the target position
  4647. * @param scene defines the hosting scene
  4648. */
  4649. Control.prototype.moveToVector3 = function (position, scene) {
  4650. if (!this._host || this.parent !== this._host._rootContainer) {
  4651. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4652. return;
  4653. }
  4654. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4655. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4656. var globalViewport = this._host._getGlobalViewport(scene);
  4657. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4658. this._moveToProjectedPosition(projectedPosition);
  4659. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4660. this.notRenderable = true;
  4661. return;
  4662. }
  4663. this.notRenderable = false;
  4664. };
  4665. /**
  4666. * Will store all controls that have this control as ascendant in a given array
  4667. * @param results defines the array where to store the descendants
  4668. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  4669. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  4670. */
  4671. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4672. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4673. // Do nothing by default
  4674. };
  4675. /**
  4676. * Will return all controls that have this control as ascendant
  4677. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  4678. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  4679. * @return all child controls
  4680. */
  4681. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4682. var results = new Array();
  4683. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4684. return results;
  4685. };
  4686. /**
  4687. * Link current control with a target mesh
  4688. * @param mesh defines the mesh to link with
  4689. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4690. */
  4691. Control.prototype.linkWithMesh = function (mesh) {
  4692. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4693. if (mesh) {
  4694. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4695. }
  4696. return;
  4697. }
  4698. var index = this._host._linkedControls.indexOf(this);
  4699. if (index !== -1) {
  4700. this._linkedMesh = mesh;
  4701. if (!mesh) {
  4702. this._host._linkedControls.splice(index, 1);
  4703. }
  4704. return;
  4705. }
  4706. else if (!mesh) {
  4707. return;
  4708. }
  4709. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4710. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4711. this._linkedMesh = mesh;
  4712. this._host._linkedControls.push(this);
  4713. };
  4714. /** @hidden */
  4715. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4716. var oldLeft = this._left.getValue(this._host);
  4717. var oldTop = this._top.getValue(this._host);
  4718. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4719. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4720. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4721. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4722. newLeft = oldLeft;
  4723. }
  4724. if (Math.abs(newTop - oldTop) < 0.5) {
  4725. newTop = oldTop;
  4726. }
  4727. }
  4728. this.left = newLeft + "px";
  4729. this.top = newTop + "px";
  4730. this._left.ignoreAdaptiveScaling = true;
  4731. this._top.ignoreAdaptiveScaling = true;
  4732. this._markAsDirty();
  4733. };
  4734. /** @hidden */
  4735. Control.prototype._offsetLeft = function (offset) {
  4736. this._isDirty = true;
  4737. this._currentMeasure.left += offset;
  4738. };
  4739. /** @hidden */
  4740. Control.prototype._offsetTop = function (offset) {
  4741. this._isDirty = true;
  4742. this._currentMeasure.top += offset;
  4743. };
  4744. /** @hidden */
  4745. Control.prototype._markMatrixAsDirty = function () {
  4746. this._isMatrixDirty = true;
  4747. this._flagDescendantsAsMatrixDirty();
  4748. };
  4749. /** @hidden */
  4750. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4751. // No child
  4752. };
  4753. /** @hidden */
  4754. Control.prototype._intersectsRect = function (rect) {
  4755. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4756. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4757. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4758. return false;
  4759. }
  4760. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4761. return false;
  4762. }
  4763. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4764. return false;
  4765. }
  4766. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4767. return false;
  4768. }
  4769. return true;
  4770. };
  4771. /** @hidden */
  4772. Control.prototype.invalidateRect = function () {
  4773. this._transform();
  4774. if (this.host && this.host.useInvalidateRectOptimization) {
  4775. // Rotate by transform to get the measure transformed to global space
  4776. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4777. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4778. // the previous measure is used to properly clear a control that is scaled down
  4779. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4780. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4781. // Expand rect based on shadows
  4782. var shadowOffsetX = this.shadowOffsetX;
  4783. var shadowOffsetY = this.shadowOffsetY;
  4784. var shadowBlur = this.shadowBlur;
  4785. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4786. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4787. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4788. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4789. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left + leftShadowOffset), Math.floor(this._tmpMeasureA.top + topShadowOffset), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width + rightShadowOffset), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height + bottomShadowOffset));
  4790. }
  4791. else {
  4792. this.host.invalidateRect(Math.floor(this._tmpMeasureA.left), Math.floor(this._tmpMeasureA.top), Math.ceil(this._tmpMeasureA.left + this._tmpMeasureA.width), Math.ceil(this._tmpMeasureA.top + this._tmpMeasureA.height));
  4793. }
  4794. }
  4795. };
  4796. /** @hidden */
  4797. Control.prototype._markAsDirty = function (force) {
  4798. if (force === void 0) { force = false; }
  4799. if (!this._isVisible && !force) {
  4800. return;
  4801. }
  4802. this._isDirty = true;
  4803. // Redraw only this rectangle
  4804. if (this._host) {
  4805. this._host.markAsDirty();
  4806. }
  4807. };
  4808. /** @hidden */
  4809. Control.prototype._markAllAsDirty = function () {
  4810. this._markAsDirty();
  4811. if (this._font) {
  4812. this._prepareFont();
  4813. }
  4814. };
  4815. /** @hidden */
  4816. Control.prototype._link = function (host) {
  4817. this._host = host;
  4818. if (this._host) {
  4819. this.uniqueId = this._host.getScene().getUniqueId();
  4820. }
  4821. };
  4822. /** @hidden */
  4823. Control.prototype._transform = function (context) {
  4824. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4825. return;
  4826. }
  4827. // postTranslate
  4828. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4829. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4830. if (context) {
  4831. context.translate(offsetX, offsetY);
  4832. // rotate
  4833. context.rotate(this._rotation);
  4834. // scale
  4835. context.scale(this._scaleX, this._scaleY);
  4836. // preTranslate
  4837. context.translate(-offsetX, -offsetY);
  4838. }
  4839. // Need to update matrices?
  4840. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4841. this._cachedOffsetX = offsetX;
  4842. this._cachedOffsetY = offsetY;
  4843. this._isMatrixDirty = false;
  4844. this._flagDescendantsAsMatrixDirty();
  4845. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4846. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4847. }
  4848. };
  4849. /** @hidden */
  4850. Control.prototype._renderHighlight = function (context) {
  4851. if (!this.isHighlighted) {
  4852. return;
  4853. }
  4854. context.save();
  4855. context.strokeStyle = "#4affff";
  4856. context.lineWidth = 2;
  4857. this._renderHighlightSpecific(context);
  4858. context.restore();
  4859. };
  4860. /** @hidden */
  4861. Control.prototype._renderHighlightSpecific = function (context) {
  4862. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4863. };
  4864. /** @hidden */
  4865. Control.prototype._applyStates = function (context) {
  4866. if (this._isFontSizeInPercentage) {
  4867. this._fontSet = true;
  4868. }
  4869. if (this._fontSet) {
  4870. this._prepareFont();
  4871. this._fontSet = false;
  4872. }
  4873. if (this._font) {
  4874. context.font = this._font;
  4875. }
  4876. if (this._color) {
  4877. context.fillStyle = this._color;
  4878. }
  4879. if (Control.AllowAlphaInheritance) {
  4880. context.globalAlpha *= this._alpha;
  4881. }
  4882. else if (this._alphaSet) {
  4883. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4884. }
  4885. };
  4886. /** @hidden */
  4887. Control.prototype._layout = function (parentMeasure, context) {
  4888. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4889. return false;
  4890. }
  4891. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4892. this.host._numLayoutCalls++;
  4893. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4894. context.save();
  4895. this._applyStates(context);
  4896. var rebuildCount = 0;
  4897. do {
  4898. this._rebuildLayout = false;
  4899. this._processMeasures(parentMeasure, context);
  4900. rebuildCount++;
  4901. } while (this._rebuildLayout && rebuildCount < 3);
  4902. if (rebuildCount >= 3) {
  4903. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4904. }
  4905. context.restore();
  4906. this.invalidateRect();
  4907. this._evaluateClippingState(parentMeasure);
  4908. }
  4909. this._wasDirty = this._isDirty;
  4910. this._isDirty = false;
  4911. return true;
  4912. };
  4913. /** @hidden */
  4914. Control.prototype._processMeasures = function (parentMeasure, context) {
  4915. this._currentMeasure.copyFrom(parentMeasure);
  4916. // Let children take some pre-measurement actions
  4917. this._preMeasure(parentMeasure, context);
  4918. this._measure();
  4919. this._computeAlignment(parentMeasure, context);
  4920. // Convert to int values
  4921. this._currentMeasure.left = this._currentMeasure.left | 0;
  4922. this._currentMeasure.top = this._currentMeasure.top | 0;
  4923. this._currentMeasure.width = this._currentMeasure.width | 0;
  4924. this._currentMeasure.height = this._currentMeasure.height | 0;
  4925. // Let children add more features
  4926. this._additionalProcessing(parentMeasure, context);
  4927. this._cachedParentMeasure.copyFrom(parentMeasure);
  4928. if (this.onDirtyObservable.hasObservers()) {
  4929. this.onDirtyObservable.notifyObservers(this);
  4930. }
  4931. };
  4932. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4933. if (this.parent && this.parent.clipChildren) {
  4934. // Early clip
  4935. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4936. this._isClipped = true;
  4937. return;
  4938. }
  4939. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4940. this._isClipped = true;
  4941. return;
  4942. }
  4943. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4944. this._isClipped = true;
  4945. return;
  4946. }
  4947. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4948. this._isClipped = true;
  4949. return;
  4950. }
  4951. }
  4952. this._isClipped = false;
  4953. };
  4954. /** @hidden */
  4955. Control.prototype._measure = function () {
  4956. // Width / Height
  4957. if (this._width.isPixel) {
  4958. this._currentMeasure.width = this._width.getValue(this._host);
  4959. }
  4960. else {
  4961. this._currentMeasure.width *= this._width.getValue(this._host);
  4962. }
  4963. if (this._height.isPixel) {
  4964. this._currentMeasure.height = this._height.getValue(this._host);
  4965. }
  4966. else {
  4967. this._currentMeasure.height *= this._height.getValue(this._host);
  4968. }
  4969. };
  4970. /** @hidden */
  4971. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4972. var width = this._currentMeasure.width;
  4973. var height = this._currentMeasure.height;
  4974. var parentWidth = parentMeasure.width;
  4975. var parentHeight = parentMeasure.height;
  4976. // Left / top
  4977. var x = 0;
  4978. var y = 0;
  4979. switch (this.horizontalAlignment) {
  4980. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4981. x = 0;
  4982. break;
  4983. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4984. x = parentWidth - width;
  4985. break;
  4986. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4987. x = (parentWidth - width) / 2;
  4988. break;
  4989. }
  4990. switch (this.verticalAlignment) {
  4991. case Control.VERTICAL_ALIGNMENT_TOP:
  4992. y = 0;
  4993. break;
  4994. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4995. y = parentHeight - height;
  4996. break;
  4997. case Control.VERTICAL_ALIGNMENT_CENTER:
  4998. y = (parentHeight - height) / 2;
  4999. break;
  5000. }
  5001. if (this._paddingLeft.isPixel) {
  5002. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5003. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5004. }
  5005. else {
  5006. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5007. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5008. }
  5009. if (this._paddingRight.isPixel) {
  5010. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5011. }
  5012. else {
  5013. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5014. }
  5015. if (this._paddingTop.isPixel) {
  5016. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5017. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5018. }
  5019. else {
  5020. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5021. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5022. }
  5023. if (this._paddingBottom.isPixel) {
  5024. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5025. }
  5026. else {
  5027. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5028. }
  5029. if (this._left.isPixel) {
  5030. this._currentMeasure.left += this._left.getValue(this._host);
  5031. }
  5032. else {
  5033. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5034. }
  5035. if (this._top.isPixel) {
  5036. this._currentMeasure.top += this._top.getValue(this._host);
  5037. }
  5038. else {
  5039. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5040. }
  5041. this._currentMeasure.left += x;
  5042. this._currentMeasure.top += y;
  5043. };
  5044. /** @hidden */
  5045. Control.prototype._preMeasure = function (parentMeasure, context) {
  5046. // Do nothing
  5047. };
  5048. /** @hidden */
  5049. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5050. // Do nothing
  5051. };
  5052. /** @hidden */
  5053. Control.prototype._clipForChildren = function (context) {
  5054. // DO nothing
  5055. };
  5056. Control.prototype._clip = function (context, invalidatedRectangle) {
  5057. context.beginPath();
  5058. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5059. if (invalidatedRectangle) {
  5060. // Rotate the invalidated rect into the control's space
  5061. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5062. // Get the intersection of the rect in context space and the current context
  5063. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5064. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5065. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5066. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5067. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5068. Control._ClipMeasure.copyFrom(intersection);
  5069. }
  5070. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5071. var shadowOffsetX = this.shadowOffsetX;
  5072. var shadowOffsetY = this.shadowOffsetY;
  5073. var shadowBlur = this.shadowBlur;
  5074. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5075. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5076. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5077. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5078. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5079. }
  5080. else {
  5081. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5082. }
  5083. context.clip();
  5084. };
  5085. /** @hidden */
  5086. Control.prototype._render = function (context, invalidatedRectangle) {
  5087. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5088. this._isDirty = false;
  5089. return false;
  5090. }
  5091. this.host._numRenderCalls++;
  5092. context.save();
  5093. this._applyStates(context);
  5094. // Transform
  5095. this._transform(context);
  5096. // Clip
  5097. if (this.clipContent) {
  5098. this._clip(context, invalidatedRectangle);
  5099. }
  5100. if (this.onBeforeDrawObservable.hasObservers()) {
  5101. this.onBeforeDrawObservable.notifyObservers(this);
  5102. }
  5103. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5104. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5105. }
  5106. else {
  5107. this._draw(context, invalidatedRectangle);
  5108. }
  5109. if (this.useBitmapCache && this._wasDirty) {
  5110. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5111. }
  5112. this._renderHighlight(context);
  5113. if (this.onAfterDrawObservable.hasObservers()) {
  5114. this.onAfterDrawObservable.notifyObservers(this);
  5115. }
  5116. context.restore();
  5117. return true;
  5118. };
  5119. /** @hidden */
  5120. Control.prototype._draw = function (context, invalidatedRectangle) {
  5121. // Do nothing
  5122. };
  5123. /**
  5124. * Tests if a given coordinates belong to the current control
  5125. * @param x defines x coordinate to test
  5126. * @param y defines y coordinate to test
  5127. * @returns true if the coordinates are inside the control
  5128. */
  5129. Control.prototype.contains = function (x, y) {
  5130. // Invert transform
  5131. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5132. x = this._transformedPosition.x;
  5133. y = this._transformedPosition.y;
  5134. // Check
  5135. if (x < this._currentMeasure.left) {
  5136. return false;
  5137. }
  5138. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5139. return false;
  5140. }
  5141. if (y < this._currentMeasure.top) {
  5142. return false;
  5143. }
  5144. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5145. return false;
  5146. }
  5147. if (this.isPointerBlocker) {
  5148. this._host._shouldBlockPointer = true;
  5149. }
  5150. return true;
  5151. };
  5152. /** @hidden */
  5153. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5154. if (!this._isEnabled) {
  5155. return false;
  5156. }
  5157. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5158. return false;
  5159. }
  5160. if (!this.contains(x, y)) {
  5161. return false;
  5162. }
  5163. this._processObservables(type, x, y, pointerId, buttonIndex);
  5164. return true;
  5165. };
  5166. /** @hidden */
  5167. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5168. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5169. if (canNotify && this.parent != null) {
  5170. this.parent._onPointerMove(target, coordinates, pointerId);
  5171. }
  5172. };
  5173. /** @hidden */
  5174. Control.prototype._onPointerEnter = function (target) {
  5175. if (!this._isEnabled) {
  5176. return false;
  5177. }
  5178. if (this._enterCount > 0) {
  5179. return false;
  5180. }
  5181. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5182. this._enterCount = 0;
  5183. }
  5184. this._enterCount++;
  5185. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5186. if (canNotify && this.parent != null) {
  5187. this.parent._onPointerEnter(target);
  5188. }
  5189. return true;
  5190. };
  5191. /** @hidden */
  5192. Control.prototype._onPointerOut = function (target, force) {
  5193. if (force === void 0) { force = false; }
  5194. if (!force && (!this._isEnabled || target === this)) {
  5195. return;
  5196. }
  5197. this._enterCount = 0;
  5198. var canNotify = true;
  5199. if (!target.isAscendant(this)) {
  5200. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5201. }
  5202. if (canNotify && this.parent != null) {
  5203. this.parent._onPointerOut(target, force);
  5204. }
  5205. };
  5206. /** @hidden */
  5207. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5208. // Prevent pointerout to lose control context.
  5209. // Event redundancy is checked inside the function.
  5210. this._onPointerEnter(this);
  5211. if (this._downCount !== 0) {
  5212. return false;
  5213. }
  5214. this._downCount++;
  5215. this._downPointerIds[pointerId] = true;
  5216. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5217. if (canNotify && this.parent != null) {
  5218. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5219. }
  5220. return true;
  5221. };
  5222. /** @hidden */
  5223. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5224. if (!this._isEnabled) {
  5225. return;
  5226. }
  5227. this._downCount = 0;
  5228. delete this._downPointerIds[pointerId];
  5229. var canNotifyClick = notifyClick;
  5230. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5231. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5232. }
  5233. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5234. if (canNotify && this.parent != null) {
  5235. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5236. }
  5237. };
  5238. /** @hidden */
  5239. Control.prototype._forcePointerUp = function (pointerId) {
  5240. if (pointerId === void 0) { pointerId = null; }
  5241. if (pointerId !== null) {
  5242. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5243. }
  5244. else {
  5245. for (var key in this._downPointerIds) {
  5246. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5247. }
  5248. }
  5249. };
  5250. /** @hidden */
  5251. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5252. if (!this._isEnabled) {
  5253. return false;
  5254. }
  5255. this._dummyVector2.copyFromFloats(x, y);
  5256. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5257. this._onPointerMove(this, this._dummyVector2, pointerId);
  5258. var previousControlOver = this._host._lastControlOver[pointerId];
  5259. if (previousControlOver && previousControlOver !== this) {
  5260. previousControlOver._onPointerOut(this);
  5261. }
  5262. if (previousControlOver !== this) {
  5263. this._onPointerEnter(this);
  5264. }
  5265. this._host._lastControlOver[pointerId] = this;
  5266. return true;
  5267. }
  5268. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5269. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5270. this._host._registerLastControlDown(this, pointerId);
  5271. this._host._lastPickedControl = this;
  5272. return true;
  5273. }
  5274. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5275. if (this._host._lastControlDown[pointerId]) {
  5276. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5277. }
  5278. delete this._host._lastControlDown[pointerId];
  5279. return true;
  5280. }
  5281. return false;
  5282. };
  5283. Control.prototype._prepareFont = function () {
  5284. if (!this._font && !this._fontSet) {
  5285. return;
  5286. }
  5287. if (this._style) {
  5288. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5289. }
  5290. else {
  5291. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5292. }
  5293. this._fontOffset = Control._GetFontOffset(this._font);
  5294. };
  5295. /** Releases associated resources */
  5296. Control.prototype.dispose = function () {
  5297. this.onDirtyObservable.clear();
  5298. this.onBeforeDrawObservable.clear();
  5299. this.onAfterDrawObservable.clear();
  5300. this.onPointerDownObservable.clear();
  5301. this.onPointerEnterObservable.clear();
  5302. this.onPointerMoveObservable.clear();
  5303. this.onPointerOutObservable.clear();
  5304. this.onPointerUpObservable.clear();
  5305. this.onPointerClickObservable.clear();
  5306. if (this._styleObserver && this._style) {
  5307. this._style.onChangedObservable.remove(this._styleObserver);
  5308. this._styleObserver = null;
  5309. }
  5310. if (this.parent) {
  5311. this.parent.removeControl(this);
  5312. this.parent = null;
  5313. }
  5314. if (this._host) {
  5315. var index = this._host._linkedControls.indexOf(this);
  5316. if (index > -1) {
  5317. this.linkWithMesh(null);
  5318. }
  5319. }
  5320. };
  5321. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5322. /** HORIZONTAL_ALIGNMENT_LEFT */
  5323. get: function () {
  5324. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5325. },
  5326. enumerable: true,
  5327. configurable: true
  5328. });
  5329. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5330. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5331. get: function () {
  5332. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5333. },
  5334. enumerable: true,
  5335. configurable: true
  5336. });
  5337. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5338. /** HORIZONTAL_ALIGNMENT_CENTER */
  5339. get: function () {
  5340. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5341. },
  5342. enumerable: true,
  5343. configurable: true
  5344. });
  5345. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5346. /** VERTICAL_ALIGNMENT_TOP */
  5347. get: function () {
  5348. return Control._VERTICAL_ALIGNMENT_TOP;
  5349. },
  5350. enumerable: true,
  5351. configurable: true
  5352. });
  5353. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5354. /** VERTICAL_ALIGNMENT_BOTTOM */
  5355. get: function () {
  5356. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5357. },
  5358. enumerable: true,
  5359. configurable: true
  5360. });
  5361. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5362. /** VERTICAL_ALIGNMENT_CENTER */
  5363. get: function () {
  5364. return Control._VERTICAL_ALIGNMENT_CENTER;
  5365. },
  5366. enumerable: true,
  5367. configurable: true
  5368. });
  5369. /** @hidden */
  5370. Control._GetFontOffset = function (font) {
  5371. if (Control._FontHeightSizes[font]) {
  5372. return Control._FontHeightSizes[font];
  5373. }
  5374. var text = document.createElement("span");
  5375. text.innerHTML = "Hg";
  5376. text.style.font = font;
  5377. var block = document.createElement("div");
  5378. block.style.display = "inline-block";
  5379. block.style.width = "1px";
  5380. block.style.height = "0px";
  5381. block.style.verticalAlign = "bottom";
  5382. var div = document.createElement("div");
  5383. div.appendChild(text);
  5384. div.appendChild(block);
  5385. document.body.appendChild(div);
  5386. var fontAscent = 0;
  5387. var fontHeight = 0;
  5388. try {
  5389. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5390. block.style.verticalAlign = "baseline";
  5391. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5392. }
  5393. finally {
  5394. document.body.removeChild(div);
  5395. }
  5396. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5397. Control._FontHeightSizes[font] = result;
  5398. return result;
  5399. };
  5400. /** @hidden */
  5401. Control.drawEllipse = function (x, y, width, height, context) {
  5402. context.translate(x, y);
  5403. context.scale(width, height);
  5404. context.beginPath();
  5405. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5406. context.closePath();
  5407. context.scale(1 / width, 1 / height);
  5408. context.translate(-x, -y);
  5409. };
  5410. /**
  5411. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5412. */
  5413. Control.AllowAlphaInheritance = false;
  5414. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5415. // Statics
  5416. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5417. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5418. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5419. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5420. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5421. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5422. Control._FontHeightSizes = {};
  5423. /**
  5424. * Creates a stack panel that can be used to render headers
  5425. * @param control defines the control to associate with the header
  5426. * @param text defines the text of the header
  5427. * @param size defines the size of the header
  5428. * @param options defines options used to configure the header
  5429. * @returns a new StackPanel
  5430. * @ignore
  5431. * @hidden
  5432. */
  5433. Control.AddHeader = function () { };
  5434. return Control;
  5435. }());
  5436. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5437. /***/ }),
  5438. /***/ "./2D/controls/displayGrid.ts":
  5439. /*!************************************!*\
  5440. !*** ./2D/controls/displayGrid.ts ***!
  5441. \************************************/
  5442. /*! exports provided: DisplayGrid */
  5443. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5444. "use strict";
  5445. __webpack_require__.r(__webpack_exports__);
  5446. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5447. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5448. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5449. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5450. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5451. /** Class used to render a grid */
  5452. var DisplayGrid = /** @class */ (function (_super) {
  5453. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5454. /**
  5455. * Creates a new GridDisplayRectangle
  5456. * @param name defines the control name
  5457. */
  5458. function DisplayGrid(name) {
  5459. var _this = _super.call(this, name) || this;
  5460. _this.name = name;
  5461. _this._cellWidth = 20;
  5462. _this._cellHeight = 20;
  5463. _this._minorLineTickness = 1;
  5464. _this._minorLineColor = "DarkGray";
  5465. _this._majorLineTickness = 2;
  5466. _this._majorLineColor = "White";
  5467. _this._majorLineFrequency = 5;
  5468. _this._background = "Black";
  5469. _this._displayMajorLines = true;
  5470. _this._displayMinorLines = true;
  5471. return _this;
  5472. }
  5473. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5474. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5475. get: function () {
  5476. return this._displayMinorLines;
  5477. },
  5478. set: function (value) {
  5479. if (this._displayMinorLines === value) {
  5480. return;
  5481. }
  5482. this._displayMinorLines = value;
  5483. this._markAsDirty();
  5484. },
  5485. enumerable: true,
  5486. configurable: true
  5487. });
  5488. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5489. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5490. get: function () {
  5491. return this._displayMajorLines;
  5492. },
  5493. set: function (value) {
  5494. if (this._displayMajorLines === value) {
  5495. return;
  5496. }
  5497. this._displayMajorLines = value;
  5498. this._markAsDirty();
  5499. },
  5500. enumerable: true,
  5501. configurable: true
  5502. });
  5503. Object.defineProperty(DisplayGrid.prototype, "background", {
  5504. /** Gets or sets background color (Black by default) */
  5505. get: function () {
  5506. return this._background;
  5507. },
  5508. set: function (value) {
  5509. if (this._background === value) {
  5510. return;
  5511. }
  5512. this._background = value;
  5513. this._markAsDirty();
  5514. },
  5515. enumerable: true,
  5516. configurable: true
  5517. });
  5518. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5519. /** Gets or sets the width of each cell (20 by default) */
  5520. get: function () {
  5521. return this._cellWidth;
  5522. },
  5523. set: function (value) {
  5524. this._cellWidth = value;
  5525. this._markAsDirty();
  5526. },
  5527. enumerable: true,
  5528. configurable: true
  5529. });
  5530. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5531. /** Gets or sets the height of each cell (20 by default) */
  5532. get: function () {
  5533. return this._cellHeight;
  5534. },
  5535. set: function (value) {
  5536. this._cellHeight = value;
  5537. this._markAsDirty();
  5538. },
  5539. enumerable: true,
  5540. configurable: true
  5541. });
  5542. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5543. /** Gets or sets the tickness of minor lines (1 by default) */
  5544. get: function () {
  5545. return this._minorLineTickness;
  5546. },
  5547. set: function (value) {
  5548. this._minorLineTickness = value;
  5549. this._markAsDirty();
  5550. },
  5551. enumerable: true,
  5552. configurable: true
  5553. });
  5554. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5555. /** Gets or sets the color of minor lines (DarkGray by default) */
  5556. get: function () {
  5557. return this._minorLineColor;
  5558. },
  5559. set: function (value) {
  5560. this._minorLineColor = value;
  5561. this._markAsDirty();
  5562. },
  5563. enumerable: true,
  5564. configurable: true
  5565. });
  5566. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5567. /** Gets or sets the tickness of major lines (2 by default) */
  5568. get: function () {
  5569. return this._majorLineTickness;
  5570. },
  5571. set: function (value) {
  5572. this._majorLineTickness = value;
  5573. this._markAsDirty();
  5574. },
  5575. enumerable: true,
  5576. configurable: true
  5577. });
  5578. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5579. /** Gets or sets the color of major lines (White by default) */
  5580. get: function () {
  5581. return this._majorLineColor;
  5582. },
  5583. set: function (value) {
  5584. this._majorLineColor = value;
  5585. this._markAsDirty();
  5586. },
  5587. enumerable: true,
  5588. configurable: true
  5589. });
  5590. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5591. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5592. get: function () {
  5593. return this._majorLineFrequency;
  5594. },
  5595. set: function (value) {
  5596. this._majorLineFrequency = value;
  5597. this._markAsDirty();
  5598. },
  5599. enumerable: true,
  5600. configurable: true
  5601. });
  5602. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5603. context.save();
  5604. this._applyStates(context);
  5605. if (this._isEnabled) {
  5606. if (this._background) {
  5607. context.fillStyle = this._background;
  5608. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5609. }
  5610. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5611. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5612. // Minor lines
  5613. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5614. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5615. if (this._displayMinorLines) {
  5616. context.strokeStyle = this._minorLineColor;
  5617. context.lineWidth = this._minorLineTickness;
  5618. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5619. var cellX = left + x * this.cellWidth;
  5620. context.beginPath();
  5621. context.moveTo(cellX, this._currentMeasure.top);
  5622. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5623. context.stroke();
  5624. }
  5625. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5626. var cellY = top_1 + y * this.cellHeight;
  5627. context.beginPath();
  5628. context.moveTo(this._currentMeasure.left, cellY);
  5629. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5630. context.stroke();
  5631. }
  5632. }
  5633. // Major lines
  5634. if (this._displayMajorLines) {
  5635. context.strokeStyle = this._majorLineColor;
  5636. context.lineWidth = this._majorLineTickness;
  5637. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5638. var cellX = left + x * this.cellWidth;
  5639. context.beginPath();
  5640. context.moveTo(cellX, this._currentMeasure.top);
  5641. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5642. context.stroke();
  5643. }
  5644. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5645. var cellY = top_1 + y * this.cellHeight;
  5646. context.moveTo(this._currentMeasure.left, cellY);
  5647. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5648. context.closePath();
  5649. context.stroke();
  5650. }
  5651. }
  5652. }
  5653. context.restore();
  5654. };
  5655. DisplayGrid.prototype._getTypeName = function () {
  5656. return "DisplayGrid";
  5657. };
  5658. return DisplayGrid;
  5659. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5660. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5661. /***/ }),
  5662. /***/ "./2D/controls/ellipse.ts":
  5663. /*!********************************!*\
  5664. !*** ./2D/controls/ellipse.ts ***!
  5665. \********************************/
  5666. /*! exports provided: Ellipse */
  5667. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5668. "use strict";
  5669. __webpack_require__.r(__webpack_exports__);
  5670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5671. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5672. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5673. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5674. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  5675. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5676. /** Class used to create 2D ellipse containers */
  5677. var Ellipse = /** @class */ (function (_super) {
  5678. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5679. /**
  5680. * Creates a new Ellipse
  5681. * @param name defines the control name
  5682. */
  5683. function Ellipse(name) {
  5684. var _this = _super.call(this, name) || this;
  5685. _this.name = name;
  5686. _this._thickness = 1;
  5687. return _this;
  5688. }
  5689. Object.defineProperty(Ellipse.prototype, "thickness", {
  5690. /** Gets or sets border thickness */
  5691. get: function () {
  5692. return this._thickness;
  5693. },
  5694. set: function (value) {
  5695. if (this._thickness === value) {
  5696. return;
  5697. }
  5698. this._thickness = value;
  5699. this._markAsDirty();
  5700. },
  5701. enumerable: true,
  5702. configurable: true
  5703. });
  5704. Ellipse.prototype._getTypeName = function () {
  5705. return "Ellipse";
  5706. };
  5707. Ellipse.prototype._localDraw = function (context) {
  5708. context.save();
  5709. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5710. context.shadowColor = this.shadowColor;
  5711. context.shadowBlur = this.shadowBlur;
  5712. context.shadowOffsetX = this.shadowOffsetX;
  5713. context.shadowOffsetY = this.shadowOffsetY;
  5714. }
  5715. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  5716. if (this._background) {
  5717. context.fillStyle = this._background;
  5718. context.fill();
  5719. }
  5720. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5721. context.shadowBlur = 0;
  5722. context.shadowOffsetX = 0;
  5723. context.shadowOffsetY = 0;
  5724. }
  5725. if (this._thickness) {
  5726. if (this.color) {
  5727. context.strokeStyle = this.color;
  5728. }
  5729. context.lineWidth = this._thickness;
  5730. context.stroke();
  5731. }
  5732. context.restore();
  5733. };
  5734. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5735. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5736. this._measureForChildren.width -= 2 * this._thickness;
  5737. this._measureForChildren.height -= 2 * this._thickness;
  5738. this._measureForChildren.left += this._thickness;
  5739. this._measureForChildren.top += this._thickness;
  5740. };
  5741. Ellipse.prototype._clipForChildren = function (context) {
  5742. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2, this._currentMeasure.height / 2, context);
  5743. context.clip();
  5744. };
  5745. return Ellipse;
  5746. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5747. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5748. /***/ }),
  5749. /***/ "./2D/controls/grid.ts":
  5750. /*!*****************************!*\
  5751. !*** ./2D/controls/grid.ts ***!
  5752. \*****************************/
  5753. /*! exports provided: Grid */
  5754. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5755. "use strict";
  5756. __webpack_require__.r(__webpack_exports__);
  5757. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5758. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5759. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5760. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5761. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5762. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  5763. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5764. /**
  5765. * Class used to create a 2D grid container
  5766. */
  5767. var Grid = /** @class */ (function (_super) {
  5768. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5769. /**
  5770. * Creates a new Grid
  5771. * @param name defines control name
  5772. */
  5773. function Grid(name) {
  5774. var _this = _super.call(this, name) || this;
  5775. _this.name = name;
  5776. _this._rowDefinitions = new Array();
  5777. _this._columnDefinitions = new Array();
  5778. _this._cells = {};
  5779. _this._childControls = new Array();
  5780. return _this;
  5781. }
  5782. Object.defineProperty(Grid.prototype, "columnCount", {
  5783. /**
  5784. * Gets the number of columns
  5785. */
  5786. get: function () {
  5787. return this._columnDefinitions.length;
  5788. },
  5789. enumerable: true,
  5790. configurable: true
  5791. });
  5792. Object.defineProperty(Grid.prototype, "rowCount", {
  5793. /**
  5794. * Gets the number of rows
  5795. */
  5796. get: function () {
  5797. return this._rowDefinitions.length;
  5798. },
  5799. enumerable: true,
  5800. configurable: true
  5801. });
  5802. Object.defineProperty(Grid.prototype, "children", {
  5803. /** Gets the list of children */
  5804. get: function () {
  5805. return this._childControls;
  5806. },
  5807. enumerable: true,
  5808. configurable: true
  5809. });
  5810. Object.defineProperty(Grid.prototype, "cells", {
  5811. /** Gets the list of cells (e.g. the containers) */
  5812. get: function () {
  5813. return this._cells;
  5814. },
  5815. enumerable: true,
  5816. configurable: true
  5817. });
  5818. /**
  5819. * Gets the definition of a specific row
  5820. * @param index defines the index of the row
  5821. * @returns the row definition
  5822. */
  5823. Grid.prototype.getRowDefinition = function (index) {
  5824. if (index < 0 || index >= this._rowDefinitions.length) {
  5825. return null;
  5826. }
  5827. return this._rowDefinitions[index];
  5828. };
  5829. /**
  5830. * Gets the definition of a specific column
  5831. * @param index defines the index of the column
  5832. * @returns the column definition
  5833. */
  5834. Grid.prototype.getColumnDefinition = function (index) {
  5835. if (index < 0 || index >= this._columnDefinitions.length) {
  5836. return null;
  5837. }
  5838. return this._columnDefinitions[index];
  5839. };
  5840. /**
  5841. * Adds a new row to the grid
  5842. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5843. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5844. * @returns the current grid
  5845. */
  5846. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5847. if (isPixel === void 0) { isPixel = false; }
  5848. this._rowDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5849. this._markAsDirty();
  5850. return this;
  5851. };
  5852. /**
  5853. * Adds a new column to the grid
  5854. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5855. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5856. * @returns the current grid
  5857. */
  5858. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5859. if (isPixel === void 0) { isPixel = false; }
  5860. this._columnDefinitions.push(new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE));
  5861. this._markAsDirty();
  5862. return this;
  5863. };
  5864. /**
  5865. * Update a row definition
  5866. * @param index defines the index of the row to update
  5867. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5868. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5869. * @returns the current grid
  5870. */
  5871. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5872. if (isPixel === void 0) { isPixel = false; }
  5873. if (index < 0 || index >= this._rowDefinitions.length) {
  5874. return this;
  5875. }
  5876. var current = this._rowDefinitions[index];
  5877. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5878. return this;
  5879. }
  5880. this._rowDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](height, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5881. this._markAsDirty();
  5882. return this;
  5883. };
  5884. /**
  5885. * Update a column definition
  5886. * @param index defines the index of the column to update
  5887. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5888. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5889. * @returns the current grid
  5890. */
  5891. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5892. if (isPixel === void 0) { isPixel = false; }
  5893. if (index < 0 || index >= this._columnDefinitions.length) {
  5894. return this;
  5895. }
  5896. var current = this._columnDefinitions[index];
  5897. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5898. return this;
  5899. }
  5900. this._columnDefinitions[index] = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](width, isPixel ? _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL : _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE);
  5901. this._markAsDirty();
  5902. return this;
  5903. };
  5904. /**
  5905. * Gets the list of children stored in a specific cell
  5906. * @param row defines the row to check
  5907. * @param column defines the column to check
  5908. * @returns the list of controls
  5909. */
  5910. Grid.prototype.getChildrenAt = function (row, column) {
  5911. var cell = this._cells[row + ":" + column];
  5912. if (!cell) {
  5913. return null;
  5914. }
  5915. return cell.children;
  5916. };
  5917. /**
  5918. * Gets a string representing the child cell info (row x column)
  5919. * @param child defines the control to get info from
  5920. * @returns a string containing the child cell info (row x column)
  5921. */
  5922. Grid.prototype.getChildCellInfo = function (child) {
  5923. return child._tag;
  5924. };
  5925. Grid.prototype._removeCell = function (cell, key) {
  5926. if (!cell) {
  5927. return;
  5928. }
  5929. _super.prototype.removeControl.call(this, cell);
  5930. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5931. var control = _a[_i];
  5932. var childIndex = this._childControls.indexOf(control);
  5933. if (childIndex !== -1) {
  5934. this._childControls.splice(childIndex, 1);
  5935. }
  5936. }
  5937. delete this._cells[key];
  5938. };
  5939. Grid.prototype._offsetCell = function (previousKey, key) {
  5940. if (!this._cells[key]) {
  5941. return;
  5942. }
  5943. this._cells[previousKey] = this._cells[key];
  5944. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5945. var control = _a[_i];
  5946. control._tag = previousKey;
  5947. }
  5948. delete this._cells[key];
  5949. };
  5950. /**
  5951. * Remove a column definition at specified index
  5952. * @param index defines the index of the column to remove
  5953. * @returns the current grid
  5954. */
  5955. Grid.prototype.removeColumnDefinition = function (index) {
  5956. if (index < 0 || index >= this._columnDefinitions.length) {
  5957. return this;
  5958. }
  5959. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5960. var key = x + ":" + index;
  5961. var cell = this._cells[key];
  5962. this._removeCell(cell, key);
  5963. }
  5964. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5965. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5966. var previousKey = x + ":" + (y - 1);
  5967. var key = x + ":" + y;
  5968. this._offsetCell(previousKey, key);
  5969. }
  5970. }
  5971. this._columnDefinitions.splice(index, 1);
  5972. this._markAsDirty();
  5973. return this;
  5974. };
  5975. /**
  5976. * Remove a row definition at specified index
  5977. * @param index defines the index of the row to remove
  5978. * @returns the current grid
  5979. */
  5980. Grid.prototype.removeRowDefinition = function (index) {
  5981. if (index < 0 || index >= this._rowDefinitions.length) {
  5982. return this;
  5983. }
  5984. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5985. var key = index + ":" + y;
  5986. var cell = this._cells[key];
  5987. this._removeCell(cell, key);
  5988. }
  5989. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5990. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5991. var previousKey = x - 1 + ":" + y;
  5992. var key = x + ":" + y;
  5993. this._offsetCell(previousKey, key);
  5994. }
  5995. }
  5996. this._rowDefinitions.splice(index, 1);
  5997. this._markAsDirty();
  5998. return this;
  5999. };
  6000. /**
  6001. * Adds a new control to the current grid
  6002. * @param control defines the control to add
  6003. * @param row defines the row where to add the control (0 by default)
  6004. * @param column defines the column where to add the control (0 by default)
  6005. * @returns the current grid
  6006. */
  6007. Grid.prototype.addControl = function (control, row, column) {
  6008. if (row === void 0) { row = 0; }
  6009. if (column === void 0) { column = 0; }
  6010. if (this._rowDefinitions.length === 0) {
  6011. // Add default row definition
  6012. this.addRowDefinition(1, false);
  6013. }
  6014. if (this._columnDefinitions.length === 0) {
  6015. // Add default column definition
  6016. this.addColumnDefinition(1, false);
  6017. }
  6018. if (this._childControls.indexOf(control) !== -1) {
  6019. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].Warn("Control (Name:" + control.name + ", UniqueId:" + control.uniqueId + ") is already associated with this grid. You must remove it before reattaching it");
  6020. return this;
  6021. }
  6022. var x = Math.min(row, this._rowDefinitions.length - 1);
  6023. var y = Math.min(column, this._columnDefinitions.length - 1);
  6024. var key = x + ":" + y;
  6025. var goodContainer = this._cells[key];
  6026. if (!goodContainer) {
  6027. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6028. this._cells[key] = goodContainer;
  6029. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6030. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6031. _super.prototype.addControl.call(this, goodContainer);
  6032. }
  6033. goodContainer.addControl(control);
  6034. this._childControls.push(control);
  6035. control._tag = key;
  6036. control.parent = this;
  6037. this._markAsDirty();
  6038. return this;
  6039. };
  6040. /**
  6041. * Removes a control from the current container
  6042. * @param control defines the control to remove
  6043. * @returns the current container
  6044. */
  6045. Grid.prototype.removeControl = function (control) {
  6046. var index = this._childControls.indexOf(control);
  6047. if (index !== -1) {
  6048. this._childControls.splice(index, 1);
  6049. }
  6050. var cell = this._cells[control._tag];
  6051. if (cell) {
  6052. cell.removeControl(control);
  6053. control._tag = null;
  6054. }
  6055. this._markAsDirty();
  6056. return this;
  6057. };
  6058. Grid.prototype._getTypeName = function () {
  6059. return "Grid";
  6060. };
  6061. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6062. var widths = [];
  6063. var heights = [];
  6064. var lefts = [];
  6065. var tops = [];
  6066. var availableWidth = this._currentMeasure.width;
  6067. var globalWidthPercentage = 0;
  6068. var availableHeight = this._currentMeasure.height;
  6069. var globalHeightPercentage = 0;
  6070. // Heights
  6071. var index = 0;
  6072. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6073. var value = _a[_i];
  6074. if (value.isPixel) {
  6075. var height = value.getValue(this._host);
  6076. availableHeight -= height;
  6077. heights[index] = height;
  6078. }
  6079. else {
  6080. globalHeightPercentage += value.internalValue;
  6081. }
  6082. index++;
  6083. }
  6084. var top = 0;
  6085. index = 0;
  6086. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6087. var value = _c[_b];
  6088. tops.push(top);
  6089. if (!value.isPixel) {
  6090. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6091. top += height;
  6092. heights[index] = height;
  6093. }
  6094. else {
  6095. top += value.getValue(this._host);
  6096. }
  6097. index++;
  6098. }
  6099. // Widths
  6100. index = 0;
  6101. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6102. var value = _e[_d];
  6103. if (value.isPixel) {
  6104. var width = value.getValue(this._host);
  6105. availableWidth -= width;
  6106. widths[index] = width;
  6107. }
  6108. else {
  6109. globalWidthPercentage += value.internalValue;
  6110. }
  6111. index++;
  6112. }
  6113. var left = 0;
  6114. index = 0;
  6115. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6116. var value = _g[_f];
  6117. lefts.push(left);
  6118. if (!value.isPixel) {
  6119. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6120. left += width;
  6121. widths[index] = width;
  6122. }
  6123. else {
  6124. left += value.getValue(this._host);
  6125. }
  6126. index++;
  6127. }
  6128. definitionCallback(lefts, tops, widths, heights);
  6129. };
  6130. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6131. var _this = this;
  6132. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6133. // Setting child sizes
  6134. for (var key in _this._cells) {
  6135. if (!_this._cells.hasOwnProperty(key)) {
  6136. continue;
  6137. }
  6138. var split = key.split(":");
  6139. var x = parseInt(split[0]);
  6140. var y = parseInt(split[1]);
  6141. var cell = _this._cells[key];
  6142. cell.left = lefts[y] + "px";
  6143. cell.top = tops[x] + "px";
  6144. cell.width = widths[y] + "px";
  6145. cell.height = heights[x] + "px";
  6146. cell._left.ignoreAdaptiveScaling = true;
  6147. cell._top.ignoreAdaptiveScaling = true;
  6148. cell._width.ignoreAdaptiveScaling = true;
  6149. cell._height.ignoreAdaptiveScaling = true;
  6150. }
  6151. });
  6152. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6153. };
  6154. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6155. for (var key in this._cells) {
  6156. if (!this._cells.hasOwnProperty(key)) {
  6157. continue;
  6158. }
  6159. var child = this._cells[key];
  6160. child._markMatrixAsDirty();
  6161. }
  6162. };
  6163. Grid.prototype._renderHighlightSpecific = function (context) {
  6164. var _this = this;
  6165. _super.prototype._renderHighlightSpecific.call(this, context);
  6166. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6167. // Columns
  6168. for (var index = 0; index < lefts.length; index++) {
  6169. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6170. context.beginPath();
  6171. context.moveTo(left, _this._currentMeasure.top);
  6172. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6173. context.stroke();
  6174. }
  6175. // Rows
  6176. for (var index = 0; index < tops.length; index++) {
  6177. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6178. context.beginPath();
  6179. context.moveTo(_this._currentMeasure.left, top_1);
  6180. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6181. context.stroke();
  6182. }
  6183. });
  6184. context.restore();
  6185. };
  6186. /** Releases associated resources */
  6187. Grid.prototype.dispose = function () {
  6188. _super.prototype.dispose.call(this);
  6189. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6190. var control = _a[_i];
  6191. control.dispose();
  6192. }
  6193. this._childControls = [];
  6194. };
  6195. return Grid;
  6196. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6197. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6198. /***/ }),
  6199. /***/ "./2D/controls/image.ts":
  6200. /*!******************************!*\
  6201. !*** ./2D/controls/image.ts ***!
  6202. \******************************/
  6203. /*! exports provided: Image */
  6204. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6205. "use strict";
  6206. __webpack_require__.r(__webpack_exports__);
  6207. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6208. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6209. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  6210. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6211. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6212. /**
  6213. * Class used to create 2D images
  6214. */
  6215. var Image = /** @class */ (function (_super) {
  6216. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6217. /**
  6218. * Creates a new Image
  6219. * @param name defines the control name
  6220. * @param url defines the image url
  6221. */
  6222. function Image(name, url) {
  6223. if (url === void 0) { url = null; }
  6224. var _this = _super.call(this, name) || this;
  6225. _this.name = name;
  6226. _this._workingCanvas = null;
  6227. _this._loaded = false;
  6228. _this._stretch = Image.STRETCH_FILL;
  6229. _this._autoScale = false;
  6230. _this._sourceLeft = 0;
  6231. _this._sourceTop = 0;
  6232. _this._sourceWidth = 0;
  6233. _this._sourceHeight = 0;
  6234. _this._svgAttributesComputationCompleted = false;
  6235. _this._isSVG = false;
  6236. _this._cellWidth = 0;
  6237. _this._cellHeight = 0;
  6238. _this._cellId = -1;
  6239. _this._populateNinePatchSlicesFromImage = false;
  6240. /**
  6241. * Observable notified when the content is loaded
  6242. */
  6243. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6244. /**
  6245. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6246. */
  6247. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6248. _this.source = url;
  6249. return _this;
  6250. }
  6251. Object.defineProperty(Image.prototype, "isLoaded", {
  6252. /**
  6253. * Gets a boolean indicating that the content is loaded
  6254. */
  6255. get: function () {
  6256. return this._loaded;
  6257. },
  6258. enumerable: true,
  6259. configurable: true
  6260. });
  6261. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6262. /**
  6263. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6264. */
  6265. get: function () {
  6266. return this._populateNinePatchSlicesFromImage;
  6267. },
  6268. set: function (value) {
  6269. if (this._populateNinePatchSlicesFromImage === value) {
  6270. return;
  6271. }
  6272. this._populateNinePatchSlicesFromImage = value;
  6273. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6274. this._extractNinePatchSliceDataFromImage();
  6275. }
  6276. },
  6277. enumerable: true,
  6278. configurable: true
  6279. });
  6280. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6281. /**
  6282. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6283. * Beware using this as this will comsume more memory as the image has to be stored twice
  6284. */
  6285. get: function () {
  6286. return this._detectPointerOnOpaqueOnly;
  6287. },
  6288. set: function (value) {
  6289. if (this._detectPointerOnOpaqueOnly === value) {
  6290. return;
  6291. }
  6292. this._detectPointerOnOpaqueOnly = value;
  6293. },
  6294. enumerable: true,
  6295. configurable: true
  6296. });
  6297. Object.defineProperty(Image.prototype, "sliceLeft", {
  6298. /**
  6299. * Gets or sets the left value for slicing (9-patch)
  6300. */
  6301. get: function () {
  6302. return this._sliceLeft;
  6303. },
  6304. set: function (value) {
  6305. if (this._sliceLeft === value) {
  6306. return;
  6307. }
  6308. this._sliceLeft = value;
  6309. this._markAsDirty();
  6310. },
  6311. enumerable: true,
  6312. configurable: true
  6313. });
  6314. Object.defineProperty(Image.prototype, "sliceRight", {
  6315. /**
  6316. * Gets or sets the right value for slicing (9-patch)
  6317. */
  6318. get: function () {
  6319. return this._sliceRight;
  6320. },
  6321. set: function (value) {
  6322. if (this._sliceRight === value) {
  6323. return;
  6324. }
  6325. this._sliceRight = value;
  6326. this._markAsDirty();
  6327. },
  6328. enumerable: true,
  6329. configurable: true
  6330. });
  6331. Object.defineProperty(Image.prototype, "sliceTop", {
  6332. /**
  6333. * Gets or sets the top value for slicing (9-patch)
  6334. */
  6335. get: function () {
  6336. return this._sliceTop;
  6337. },
  6338. set: function (value) {
  6339. if (this._sliceTop === value) {
  6340. return;
  6341. }
  6342. this._sliceTop = value;
  6343. this._markAsDirty();
  6344. },
  6345. enumerable: true,
  6346. configurable: true
  6347. });
  6348. Object.defineProperty(Image.prototype, "sliceBottom", {
  6349. /**
  6350. * Gets or sets the bottom value for slicing (9-patch)
  6351. */
  6352. get: function () {
  6353. return this._sliceBottom;
  6354. },
  6355. set: function (value) {
  6356. if (this._sliceBottom === value) {
  6357. return;
  6358. }
  6359. this._sliceBottom = value;
  6360. this._markAsDirty();
  6361. },
  6362. enumerable: true,
  6363. configurable: true
  6364. });
  6365. Object.defineProperty(Image.prototype, "sourceLeft", {
  6366. /**
  6367. * Gets or sets the left coordinate in the source image
  6368. */
  6369. get: function () {
  6370. return this._sourceLeft;
  6371. },
  6372. set: function (value) {
  6373. if (this._sourceLeft === value) {
  6374. return;
  6375. }
  6376. this._sourceLeft = value;
  6377. this._markAsDirty();
  6378. },
  6379. enumerable: true,
  6380. configurable: true
  6381. });
  6382. Object.defineProperty(Image.prototype, "sourceTop", {
  6383. /**
  6384. * Gets or sets the top coordinate in the source image
  6385. */
  6386. get: function () {
  6387. return this._sourceTop;
  6388. },
  6389. set: function (value) {
  6390. if (this._sourceTop === value) {
  6391. return;
  6392. }
  6393. this._sourceTop = value;
  6394. this._markAsDirty();
  6395. },
  6396. enumerable: true,
  6397. configurable: true
  6398. });
  6399. Object.defineProperty(Image.prototype, "sourceWidth", {
  6400. /**
  6401. * Gets or sets the width to capture in the source image
  6402. */
  6403. get: function () {
  6404. return this._sourceWidth;
  6405. },
  6406. set: function (value) {
  6407. if (this._sourceWidth === value) {
  6408. return;
  6409. }
  6410. this._sourceWidth = value;
  6411. this._markAsDirty();
  6412. },
  6413. enumerable: true,
  6414. configurable: true
  6415. });
  6416. Object.defineProperty(Image.prototype, "sourceHeight", {
  6417. /**
  6418. * Gets or sets the height to capture in the source image
  6419. */
  6420. get: function () {
  6421. return this._sourceHeight;
  6422. },
  6423. set: function (value) {
  6424. if (this._sourceHeight === value) {
  6425. return;
  6426. }
  6427. this._sourceHeight = value;
  6428. this._markAsDirty();
  6429. },
  6430. enumerable: true,
  6431. configurable: true
  6432. });
  6433. Object.defineProperty(Image.prototype, "isSVG", {
  6434. /** Indicates if the format of the image is SVG */
  6435. get: function () {
  6436. return this._isSVG;
  6437. },
  6438. enumerable: true,
  6439. configurable: true
  6440. });
  6441. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6442. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6443. get: function () {
  6444. return this._svgAttributesComputationCompleted;
  6445. },
  6446. enumerable: true,
  6447. configurable: true
  6448. });
  6449. Object.defineProperty(Image.prototype, "autoScale", {
  6450. /**
  6451. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6452. * @see http://doc.babylonjs.com/how_to/gui#image
  6453. */
  6454. get: function () {
  6455. return this._autoScale;
  6456. },
  6457. set: function (value) {
  6458. if (this._autoScale === value) {
  6459. return;
  6460. }
  6461. this._autoScale = value;
  6462. if (value && this._loaded) {
  6463. this.synchronizeSizeWithContent();
  6464. }
  6465. },
  6466. enumerable: true,
  6467. configurable: true
  6468. });
  6469. Object.defineProperty(Image.prototype, "stretch", {
  6470. /** Gets or sets the streching mode used by the image */
  6471. get: function () {
  6472. return this._stretch;
  6473. },
  6474. set: function (value) {
  6475. if (this._stretch === value) {
  6476. return;
  6477. }
  6478. this._stretch = value;
  6479. this._markAsDirty();
  6480. },
  6481. enumerable: true,
  6482. configurable: true
  6483. });
  6484. /** @hidden */
  6485. Image.prototype._rotate90 = function (n, preserveProperties) {
  6486. if (preserveProperties === void 0) { preserveProperties = false; }
  6487. var canvas = document.createElement('canvas');
  6488. var context = canvas.getContext('2d');
  6489. var width = this._domImage.width;
  6490. var height = this._domImage.height;
  6491. canvas.width = height;
  6492. canvas.height = width;
  6493. context.translate(canvas.width / 2, canvas.height / 2);
  6494. context.rotate(n * Math.PI / 2);
  6495. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6496. var dataUrl = canvas.toDataURL("image/jpg");
  6497. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6498. if (preserveProperties) {
  6499. rotatedImage._stretch = this._stretch;
  6500. rotatedImage._autoScale = this._autoScale;
  6501. rotatedImage._cellId = this._cellId;
  6502. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6503. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6504. }
  6505. this._handleRotationForSVGImage(this, rotatedImage, n);
  6506. return rotatedImage;
  6507. };
  6508. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6509. var _this = this;
  6510. if (!srcImage._isSVG) {
  6511. return;
  6512. }
  6513. if (srcImage._svgAttributesComputationCompleted) {
  6514. this._rotate90SourceProperties(srcImage, dstImage, n);
  6515. this._markAsDirty();
  6516. }
  6517. else {
  6518. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6519. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6520. _this._markAsDirty();
  6521. });
  6522. }
  6523. };
  6524. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6525. var _a, _b;
  6526. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6527. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6528. if (n != 0) {
  6529. var mult = n < 0 ? -1 : 1;
  6530. n = n % 4;
  6531. for (var i = 0; i < Math.abs(n); ++i) {
  6532. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6533. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6534. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6535. if (n < 0) {
  6536. dstTop -= dstHeight;
  6537. }
  6538. else {
  6539. dstLeft -= dstWidth;
  6540. }
  6541. srcLeft = dstLeft;
  6542. srcTop = dstTop;
  6543. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6544. }
  6545. }
  6546. dstImage.sourceLeft = dstLeft;
  6547. dstImage.sourceTop = dstTop;
  6548. dstImage.sourceWidth = dstWidth;
  6549. dstImage.sourceHeight = dstHeight;
  6550. };
  6551. Object.defineProperty(Image.prototype, "domImage", {
  6552. get: function () {
  6553. return this._domImage;
  6554. },
  6555. /**
  6556. * Gets or sets the internal DOM image used to render the control
  6557. */
  6558. set: function (value) {
  6559. var _this = this;
  6560. this._domImage = value;
  6561. this._loaded = false;
  6562. if (this._domImage.width) {
  6563. this._onImageLoaded();
  6564. }
  6565. else {
  6566. this._domImage.onload = function () {
  6567. _this._onImageLoaded();
  6568. };
  6569. }
  6570. },
  6571. enumerable: true,
  6572. configurable: true
  6573. });
  6574. Image.prototype._onImageLoaded = function () {
  6575. this._imageWidth = this._domImage.width;
  6576. this._imageHeight = this._domImage.height;
  6577. this._loaded = true;
  6578. if (this._populateNinePatchSlicesFromImage) {
  6579. this._extractNinePatchSliceDataFromImage();
  6580. }
  6581. if (this._autoScale) {
  6582. this.synchronizeSizeWithContent();
  6583. }
  6584. this.onImageLoadedObservable.notifyObservers(this);
  6585. this._markAsDirty();
  6586. };
  6587. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6588. if (!this._workingCanvas) {
  6589. this._workingCanvas = document.createElement('canvas');
  6590. }
  6591. var canvas = this._workingCanvas;
  6592. var context = canvas.getContext('2d');
  6593. var width = this._domImage.width;
  6594. var height = this._domImage.height;
  6595. canvas.width = width;
  6596. canvas.height = height;
  6597. context.drawImage(this._domImage, 0, 0, width, height);
  6598. var imageData = context.getImageData(0, 0, width, height);
  6599. // Left and right
  6600. this._sliceLeft = -1;
  6601. this._sliceRight = -1;
  6602. for (var x = 0; x < width; x++) {
  6603. var alpha = imageData.data[x * 4 + 3];
  6604. if (alpha > 127 && this._sliceLeft === -1) {
  6605. this._sliceLeft = x;
  6606. continue;
  6607. }
  6608. if (alpha < 127 && this._sliceLeft > -1) {
  6609. this._sliceRight = x;
  6610. break;
  6611. }
  6612. }
  6613. // top and bottom
  6614. this._sliceTop = -1;
  6615. this._sliceBottom = -1;
  6616. for (var y = 0; y < height; y++) {
  6617. var alpha = imageData.data[y * width * 4 + 3];
  6618. if (alpha > 127 && this._sliceTop === -1) {
  6619. this._sliceTop = y;
  6620. continue;
  6621. }
  6622. if (alpha < 127 && this._sliceTop > -1) {
  6623. this._sliceBottom = y;
  6624. break;
  6625. }
  6626. }
  6627. };
  6628. Object.defineProperty(Image.prototype, "source", {
  6629. /**
  6630. * Gets or sets image source url
  6631. */
  6632. set: function (value) {
  6633. var _this = this;
  6634. if (this._source === value) {
  6635. return;
  6636. }
  6637. this._loaded = false;
  6638. this._source = value;
  6639. if (value) {
  6640. value = this._svgCheck(value);
  6641. }
  6642. this._domImage = document.createElement("img");
  6643. this._domImage.onload = function () {
  6644. _this._onImageLoaded();
  6645. };
  6646. if (value) {
  6647. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6648. this._domImage.src = value;
  6649. }
  6650. },
  6651. enumerable: true,
  6652. configurable: true
  6653. });
  6654. /**
  6655. * Checks for svg document with icon id present
  6656. */
  6657. Image.prototype._svgCheck = function (value) {
  6658. var _this = this;
  6659. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6660. this._isSVG = true;
  6661. var svgsrc = value.split('#')[0];
  6662. var elemid = value.split('#')[1];
  6663. // check if object alr exist in document
  6664. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6665. if (svgExist) {
  6666. var svgDoc = svgExist.contentDocument;
  6667. // get viewbox width and height, get svg document width and height in px
  6668. if (svgDoc && svgDoc.documentElement) {
  6669. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6670. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6671. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6672. if (vb && docwidth && docheight) {
  6673. this._getSVGAttribs(svgExist, elemid);
  6674. return value;
  6675. }
  6676. }
  6677. // wait for object to load
  6678. svgExist.addEventListener("load", function () {
  6679. _this._getSVGAttribs(svgExist, elemid);
  6680. });
  6681. }
  6682. else {
  6683. // create document object
  6684. var svgImage = document.createElement("object");
  6685. svgImage.data = svgsrc;
  6686. svgImage.type = "image/svg+xml";
  6687. svgImage.width = "0%";
  6688. svgImage.height = "0%";
  6689. document.body.appendChild(svgImage);
  6690. // when the object has loaded, get the element attribs
  6691. svgImage.onload = function () {
  6692. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6693. if (svgobj) {
  6694. _this._getSVGAttribs(svgobj, elemid);
  6695. }
  6696. };
  6697. }
  6698. return svgsrc;
  6699. }
  6700. else {
  6701. return value;
  6702. }
  6703. };
  6704. /**
  6705. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6706. * given external svg file and icon id
  6707. */
  6708. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6709. var svgDoc = svgsrc.contentDocument;
  6710. // get viewbox width and height, get svg document width and height in px
  6711. if (svgDoc && svgDoc.documentElement) {
  6712. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6713. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6714. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6715. // get element bbox and matrix transform
  6716. var elem = svgDoc.getElementById(elemid);
  6717. if (vb && docwidth && docheight) {
  6718. var vb_width = Number(vb.split(" ")[2]);
  6719. var vb_height = Number(vb.split(" ")[3]);
  6720. var elem_bbox = elem.getBBox();
  6721. var elem_matrix_a = 1;
  6722. var elem_matrix_d = 1;
  6723. var elem_matrix_e = 0;
  6724. var elem_matrix_f = 0;
  6725. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6726. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6727. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6728. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6729. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6730. }
  6731. // compute source coordinates and dimensions
  6732. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6733. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6734. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6735. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6736. this._svgAttributesComputationCompleted = true;
  6737. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6738. }
  6739. }
  6740. };
  6741. Object.defineProperty(Image.prototype, "cellWidth", {
  6742. /**
  6743. * Gets or sets the cell width to use when animation sheet is enabled
  6744. * @see http://doc.babylonjs.com/how_to/gui#image
  6745. */
  6746. get: function () {
  6747. return this._cellWidth;
  6748. },
  6749. set: function (value) {
  6750. if (this._cellWidth === value) {
  6751. return;
  6752. }
  6753. this._cellWidth = value;
  6754. this._markAsDirty();
  6755. },
  6756. enumerable: true,
  6757. configurable: true
  6758. });
  6759. Object.defineProperty(Image.prototype, "cellHeight", {
  6760. /**
  6761. * Gets or sets the cell height to use when animation sheet is enabled
  6762. * @see http://doc.babylonjs.com/how_to/gui#image
  6763. */
  6764. get: function () {
  6765. return this._cellHeight;
  6766. },
  6767. set: function (value) {
  6768. if (this._cellHeight === value) {
  6769. return;
  6770. }
  6771. this._cellHeight = value;
  6772. this._markAsDirty();
  6773. },
  6774. enumerable: true,
  6775. configurable: true
  6776. });
  6777. Object.defineProperty(Image.prototype, "cellId", {
  6778. /**
  6779. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6780. * @see http://doc.babylonjs.com/how_to/gui#image
  6781. */
  6782. get: function () {
  6783. return this._cellId;
  6784. },
  6785. set: function (value) {
  6786. if (this._cellId === value) {
  6787. return;
  6788. }
  6789. this._cellId = value;
  6790. this._markAsDirty();
  6791. },
  6792. enumerable: true,
  6793. configurable: true
  6794. });
  6795. /**
  6796. * Tests if a given coordinates belong to the current control
  6797. * @param x defines x coordinate to test
  6798. * @param y defines y coordinate to test
  6799. * @returns true if the coordinates are inside the control
  6800. */
  6801. Image.prototype.contains = function (x, y) {
  6802. if (!_super.prototype.contains.call(this, x, y)) {
  6803. return false;
  6804. }
  6805. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6806. return true;
  6807. }
  6808. var canvas = this._workingCanvas;
  6809. var context = canvas.getContext("2d");
  6810. var width = this._currentMeasure.width | 0;
  6811. var height = this._currentMeasure.height | 0;
  6812. var imageData = context.getImageData(0, 0, width, height).data;
  6813. x = (x - this._currentMeasure.left) | 0;
  6814. y = (y - this._currentMeasure.top) | 0;
  6815. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6816. return pickedPixel > 0;
  6817. };
  6818. Image.prototype._getTypeName = function () {
  6819. return "Image";
  6820. };
  6821. /** Force the control to synchronize with its content */
  6822. Image.prototype.synchronizeSizeWithContent = function () {
  6823. if (!this._loaded) {
  6824. return;
  6825. }
  6826. this.width = this._domImage.width + "px";
  6827. this.height = this._domImage.height + "px";
  6828. };
  6829. Image.prototype._processMeasures = function (parentMeasure, context) {
  6830. if (this._loaded) {
  6831. switch (this._stretch) {
  6832. case Image.STRETCH_NONE:
  6833. break;
  6834. case Image.STRETCH_FILL:
  6835. break;
  6836. case Image.STRETCH_UNIFORM:
  6837. break;
  6838. case Image.STRETCH_NINE_PATCH:
  6839. break;
  6840. case Image.STRETCH_EXTEND:
  6841. if (this._autoScale) {
  6842. this.synchronizeSizeWithContent();
  6843. }
  6844. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6845. this.parent.adaptWidthToChildren = true;
  6846. this.parent.adaptHeightToChildren = true;
  6847. }
  6848. break;
  6849. }
  6850. }
  6851. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6852. };
  6853. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6854. if (!this._detectPointerOnOpaqueOnly) {
  6855. return;
  6856. }
  6857. if (!this._workingCanvas) {
  6858. this._workingCanvas = document.createElement('canvas');
  6859. }
  6860. var canvas = this._workingCanvas;
  6861. var width = this._currentMeasure.width;
  6862. var height = this._currentMeasure.height;
  6863. var context = canvas.getContext("2d");
  6864. canvas.width = width;
  6865. canvas.height = height;
  6866. context.clearRect(0, 0, width, height);
  6867. };
  6868. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6869. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6870. if (!this._detectPointerOnOpaqueOnly) {
  6871. return;
  6872. }
  6873. var canvas = this._workingCanvas;
  6874. context = canvas.getContext("2d");
  6875. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6876. };
  6877. Image.prototype._draw = function (context) {
  6878. context.save();
  6879. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6880. context.shadowColor = this.shadowColor;
  6881. context.shadowBlur = this.shadowBlur;
  6882. context.shadowOffsetX = this.shadowOffsetX;
  6883. context.shadowOffsetY = this.shadowOffsetY;
  6884. }
  6885. var x, y, width, height;
  6886. if (this.cellId == -1) {
  6887. x = this._sourceLeft;
  6888. y = this._sourceTop;
  6889. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6890. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6891. }
  6892. else {
  6893. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6894. var column = (this.cellId / rowCount) >> 0;
  6895. var row = this.cellId % rowCount;
  6896. x = this.cellWidth * row;
  6897. y = this.cellHeight * column;
  6898. width = this.cellWidth;
  6899. height = this.cellHeight;
  6900. }
  6901. this._prepareWorkingCanvasForOpaqueDetection();
  6902. this._applyStates(context);
  6903. if (this._loaded) {
  6904. switch (this._stretch) {
  6905. case Image.STRETCH_NONE:
  6906. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6907. break;
  6908. case Image.STRETCH_FILL:
  6909. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6910. break;
  6911. case Image.STRETCH_UNIFORM:
  6912. var hRatio = this._currentMeasure.width / width;
  6913. var vRatio = this._currentMeasure.height / height;
  6914. var ratio = Math.min(hRatio, vRatio);
  6915. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6916. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6917. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6918. break;
  6919. case Image.STRETCH_EXTEND:
  6920. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6921. break;
  6922. case Image.STRETCH_NINE_PATCH:
  6923. this._renderNinePatch(context);
  6924. break;
  6925. }
  6926. }
  6927. context.restore();
  6928. };
  6929. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6930. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6931. };
  6932. Image.prototype._renderNinePatch = function (context) {
  6933. var height = this._imageHeight;
  6934. var leftWidth = this._sliceLeft;
  6935. var topHeight = this._sliceTop;
  6936. var bottomHeight = this._imageHeight - this._sliceBottom;
  6937. var rightWidth = this._imageWidth - this._sliceRight;
  6938. var left = 0;
  6939. var top = 0;
  6940. if (this._populateNinePatchSlicesFromImage) {
  6941. left = 1;
  6942. top = 1;
  6943. height -= 2;
  6944. leftWidth -= 1;
  6945. topHeight -= 1;
  6946. bottomHeight -= 1;
  6947. rightWidth -= 1;
  6948. }
  6949. var centerWidth = this._sliceRight - this._sliceLeft;
  6950. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  6951. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6952. // Corners
  6953. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6954. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6955. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6956. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6957. // Center
  6958. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  6959. // Borders
  6960. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6961. this._drawImage(context, this._sliceRight, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + this._currentMeasure.width - rightWidth, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6962. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6963. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6964. };
  6965. Image.prototype.dispose = function () {
  6966. _super.prototype.dispose.call(this);
  6967. this.onImageLoadedObservable.clear();
  6968. this.onSVGAttributesComputedObservable.clear();
  6969. };
  6970. // Static
  6971. /** STRETCH_NONE */
  6972. Image.STRETCH_NONE = 0;
  6973. /** STRETCH_FILL */
  6974. Image.STRETCH_FILL = 1;
  6975. /** STRETCH_UNIFORM */
  6976. Image.STRETCH_UNIFORM = 2;
  6977. /** STRETCH_EXTEND */
  6978. Image.STRETCH_EXTEND = 3;
  6979. /** NINE_PATCH */
  6980. Image.STRETCH_NINE_PATCH = 4;
  6981. return Image;
  6982. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6983. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  6984. /***/ }),
  6985. /***/ "./2D/controls/index.ts":
  6986. /*!******************************!*\
  6987. !*** ./2D/controls/index.ts ***!
  6988. \******************************/
  6989. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  6990. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6991. "use strict";
  6992. __webpack_require__.r(__webpack_exports__);
  6993. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6995. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6997. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6999. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7001. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7003. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7005. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  7007. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  7009. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  7011. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  7013. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  7015. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  7017. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  7019. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  7021. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  7023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  7024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  7025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  7026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  7027. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  7029. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  7031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  7032. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  7034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  7035. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  7037. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  7039. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  7041. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  7043. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  7045. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  7047. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  7049. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  7051. /***/ }),
  7052. /***/ "./2D/controls/inputPassword.ts":
  7053. /*!**************************************!*\
  7054. !*** ./2D/controls/inputPassword.ts ***!
  7055. \**************************************/
  7056. /*! exports provided: InputPassword */
  7057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7058. "use strict";
  7059. __webpack_require__.r(__webpack_exports__);
  7060. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7061. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7062. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7063. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  7064. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7065. /**
  7066. * Class used to create a password control
  7067. */
  7068. var InputPassword = /** @class */ (function (_super) {
  7069. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7070. function InputPassword() {
  7071. return _super !== null && _super.apply(this, arguments) || this;
  7072. }
  7073. InputPassword.prototype._beforeRenderText = function (text) {
  7074. var txt = "";
  7075. for (var i = 0; i < text.length; i++) {
  7076. txt += "\u2022";
  7077. }
  7078. return txt;
  7079. };
  7080. return InputPassword;
  7081. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7082. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7083. /***/ }),
  7084. /***/ "./2D/controls/inputText.ts":
  7085. /*!**********************************!*\
  7086. !*** ./2D/controls/inputText.ts ***!
  7087. \**********************************/
  7088. /*! exports provided: InputText */
  7089. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7090. "use strict";
  7091. __webpack_require__.r(__webpack_exports__);
  7092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7093. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7094. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  7095. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7096. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7097. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7098. /**
  7099. * Class used to create input text control
  7100. */
  7101. var InputText = /** @class */ (function (_super) {
  7102. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7103. /**
  7104. * Creates a new InputText
  7105. * @param name defines the control name
  7106. * @param text defines the text of the control
  7107. */
  7108. function InputText(name, text) {
  7109. if (text === void 0) { text = ""; }
  7110. var _this = _super.call(this, name) || this;
  7111. _this.name = name;
  7112. _this._text = "";
  7113. _this._placeholderText = "";
  7114. _this._background = "#222222";
  7115. _this._focusedBackground = "#000000";
  7116. _this._focusedColor = "white";
  7117. _this._placeholderColor = "gray";
  7118. _this._thickness = 1;
  7119. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7120. _this._autoStretchWidth = true;
  7121. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7122. _this._isFocused = false;
  7123. _this._blinkIsEven = false;
  7124. _this._cursorOffset = 0;
  7125. _this._deadKey = false;
  7126. _this._addKey = true;
  7127. _this._currentKey = "";
  7128. _this._isTextHighlightOn = false;
  7129. _this._textHighlightColor = "#d5e0ff";
  7130. _this._highligherOpacity = 0.4;
  7131. _this._highlightedText = "";
  7132. _this._startHighlightIndex = 0;
  7133. _this._endHighlightIndex = 0;
  7134. _this._cursorIndex = -1;
  7135. _this._onFocusSelectAll = false;
  7136. _this._isPointerDown = false;
  7137. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7138. _this.promptMessage = "Please enter text:";
  7139. /** Force disable prompt on mobile device */
  7140. _this.disableMobilePrompt = false;
  7141. /** Observable raised when the text changes */
  7142. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7143. /** Observable raised just before an entered character is to be added */
  7144. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7145. /** Observable raised when the control gets the focus */
  7146. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7147. /** Observable raised when the control loses the focus */
  7148. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7149. /**Observable raised when the text is highlighted */
  7150. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7151. /**Observable raised when copy event is triggered */
  7152. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7153. /** Observable raised when cut event is triggered */
  7154. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7155. /** Observable raised when paste event is triggered */
  7156. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7157. /** Observable raised when a key event was processed */
  7158. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7159. _this.text = text;
  7160. _this.isPointerBlocker = true;
  7161. return _this;
  7162. }
  7163. Object.defineProperty(InputText.prototype, "maxWidth", {
  7164. /** Gets or sets the maximum width allowed by the control */
  7165. get: function () {
  7166. return this._maxWidth.toString(this._host);
  7167. },
  7168. set: function (value) {
  7169. if (this._maxWidth.toString(this._host) === value) {
  7170. return;
  7171. }
  7172. if (this._maxWidth.fromString(value)) {
  7173. this._markAsDirty();
  7174. }
  7175. },
  7176. enumerable: true,
  7177. configurable: true
  7178. });
  7179. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7180. /** Gets the maximum width allowed by the control in pixels */
  7181. get: function () {
  7182. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7183. },
  7184. enumerable: true,
  7185. configurable: true
  7186. });
  7187. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7188. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7189. get: function () {
  7190. return this._highligherOpacity;
  7191. },
  7192. set: function (value) {
  7193. if (this._highligherOpacity === value) {
  7194. return;
  7195. }
  7196. this._highligherOpacity = value;
  7197. this._markAsDirty();
  7198. },
  7199. enumerable: true,
  7200. configurable: true
  7201. });
  7202. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7203. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7204. get: function () {
  7205. return this._onFocusSelectAll;
  7206. },
  7207. set: function (value) {
  7208. if (this._onFocusSelectAll === value) {
  7209. return;
  7210. }
  7211. this._onFocusSelectAll = value;
  7212. this._markAsDirty();
  7213. },
  7214. enumerable: true,
  7215. configurable: true
  7216. });
  7217. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7218. /** Gets or sets the text hightlight color */
  7219. get: function () {
  7220. return this._textHighlightColor;
  7221. },
  7222. set: function (value) {
  7223. if (this._textHighlightColor === value) {
  7224. return;
  7225. }
  7226. this._textHighlightColor = value;
  7227. this._markAsDirty();
  7228. },
  7229. enumerable: true,
  7230. configurable: true
  7231. });
  7232. Object.defineProperty(InputText.prototype, "margin", {
  7233. /** Gets or sets control margin */
  7234. get: function () {
  7235. return this._margin.toString(this._host);
  7236. },
  7237. set: function (value) {
  7238. if (this._margin.toString(this._host) === value) {
  7239. return;
  7240. }
  7241. if (this._margin.fromString(value)) {
  7242. this._markAsDirty();
  7243. }
  7244. },
  7245. enumerable: true,
  7246. configurable: true
  7247. });
  7248. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7249. /** Gets control margin in pixels */
  7250. get: function () {
  7251. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7252. },
  7253. enumerable: true,
  7254. configurable: true
  7255. });
  7256. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7257. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7258. get: function () {
  7259. return this._autoStretchWidth;
  7260. },
  7261. set: function (value) {
  7262. if (this._autoStretchWidth === value) {
  7263. return;
  7264. }
  7265. this._autoStretchWidth = value;
  7266. this._markAsDirty();
  7267. },
  7268. enumerable: true,
  7269. configurable: true
  7270. });
  7271. Object.defineProperty(InputText.prototype, "thickness", {
  7272. /** Gets or sets border thickness */
  7273. get: function () {
  7274. return this._thickness;
  7275. },
  7276. set: function (value) {
  7277. if (this._thickness === value) {
  7278. return;
  7279. }
  7280. this._thickness = value;
  7281. this._markAsDirty();
  7282. },
  7283. enumerable: true,
  7284. configurable: true
  7285. });
  7286. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7287. /** Gets or sets the background color when focused */
  7288. get: function () {
  7289. return this._focusedBackground;
  7290. },
  7291. set: function (value) {
  7292. if (this._focusedBackground === value) {
  7293. return;
  7294. }
  7295. this._focusedBackground = value;
  7296. this._markAsDirty();
  7297. },
  7298. enumerable: true,
  7299. configurable: true
  7300. });
  7301. Object.defineProperty(InputText.prototype, "focusedColor", {
  7302. /** Gets or sets the background color when focused */
  7303. get: function () {
  7304. return this._focusedColor;
  7305. },
  7306. set: function (value) {
  7307. if (this._focusedColor === value) {
  7308. return;
  7309. }
  7310. this._focusedColor = value;
  7311. this._markAsDirty();
  7312. },
  7313. enumerable: true,
  7314. configurable: true
  7315. });
  7316. Object.defineProperty(InputText.prototype, "background", {
  7317. /** Gets or sets the background color */
  7318. get: function () {
  7319. return this._background;
  7320. },
  7321. set: function (value) {
  7322. if (this._background === value) {
  7323. return;
  7324. }
  7325. this._background = value;
  7326. this._markAsDirty();
  7327. },
  7328. enumerable: true,
  7329. configurable: true
  7330. });
  7331. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7332. /** Gets or sets the placeholder color */
  7333. get: function () {
  7334. return this._placeholderColor;
  7335. },
  7336. set: function (value) {
  7337. if (this._placeholderColor === value) {
  7338. return;
  7339. }
  7340. this._placeholderColor = value;
  7341. this._markAsDirty();
  7342. },
  7343. enumerable: true,
  7344. configurable: true
  7345. });
  7346. Object.defineProperty(InputText.prototype, "placeholderText", {
  7347. /** Gets or sets the text displayed when the control is empty */
  7348. get: function () {
  7349. return this._placeholderText;
  7350. },
  7351. set: function (value) {
  7352. if (this._placeholderText === value) {
  7353. return;
  7354. }
  7355. this._placeholderText = value;
  7356. this._markAsDirty();
  7357. },
  7358. enumerable: true,
  7359. configurable: true
  7360. });
  7361. Object.defineProperty(InputText.prototype, "deadKey", {
  7362. /** Gets or sets the dead key flag */
  7363. get: function () {
  7364. return this._deadKey;
  7365. },
  7366. set: function (flag) {
  7367. this._deadKey = flag;
  7368. },
  7369. enumerable: true,
  7370. configurable: true
  7371. });
  7372. Object.defineProperty(InputText.prototype, "highlightedText", {
  7373. /** Gets or sets the highlight text */
  7374. get: function () {
  7375. return this._highlightedText;
  7376. },
  7377. set: function (text) {
  7378. if (this._highlightedText === text) {
  7379. return;
  7380. }
  7381. this._highlightedText = text;
  7382. this._markAsDirty();
  7383. },
  7384. enumerable: true,
  7385. configurable: true
  7386. });
  7387. Object.defineProperty(InputText.prototype, "addKey", {
  7388. /** Gets or sets if the current key should be added */
  7389. get: function () {
  7390. return this._addKey;
  7391. },
  7392. set: function (flag) {
  7393. this._addKey = flag;
  7394. },
  7395. enumerable: true,
  7396. configurable: true
  7397. });
  7398. Object.defineProperty(InputText.prototype, "currentKey", {
  7399. /** Gets or sets the value of the current key being entered */
  7400. get: function () {
  7401. return this._currentKey;
  7402. },
  7403. set: function (key) {
  7404. this._currentKey = key;
  7405. },
  7406. enumerable: true,
  7407. configurable: true
  7408. });
  7409. Object.defineProperty(InputText.prototype, "text", {
  7410. /** Gets or sets the text displayed in the control */
  7411. get: function () {
  7412. return this._text;
  7413. },
  7414. set: function (value) {
  7415. var valueAsString = value.toString(); // Forcing convertion
  7416. if (this._text === valueAsString) {
  7417. return;
  7418. }
  7419. this._text = valueAsString;
  7420. this._markAsDirty();
  7421. this.onTextChangedObservable.notifyObservers(this);
  7422. },
  7423. enumerable: true,
  7424. configurable: true
  7425. });
  7426. Object.defineProperty(InputText.prototype, "width", {
  7427. /** Gets or sets control width */
  7428. get: function () {
  7429. return this._width.toString(this._host);
  7430. },
  7431. set: function (value) {
  7432. if (this._width.toString(this._host) === value) {
  7433. return;
  7434. }
  7435. if (this._width.fromString(value)) {
  7436. this._markAsDirty();
  7437. }
  7438. this.autoStretchWidth = false;
  7439. },
  7440. enumerable: true,
  7441. configurable: true
  7442. });
  7443. /** @hidden */
  7444. InputText.prototype.onBlur = function () {
  7445. this._isFocused = false;
  7446. this._scrollLeft = null;
  7447. this._cursorOffset = 0;
  7448. clearTimeout(this._blinkTimeout);
  7449. this._markAsDirty();
  7450. this.onBlurObservable.notifyObservers(this);
  7451. this._host.unRegisterClipboardEvents();
  7452. if (this._onClipboardObserver) {
  7453. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7454. }
  7455. var scene = this._host.getScene();
  7456. if (this._onPointerDblTapObserver && scene) {
  7457. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7458. }
  7459. };
  7460. /** @hidden */
  7461. InputText.prototype.onFocus = function () {
  7462. var _this = this;
  7463. if (!this._isEnabled) {
  7464. return;
  7465. }
  7466. this._scrollLeft = null;
  7467. this._isFocused = true;
  7468. this._blinkIsEven = false;
  7469. this._cursorOffset = 0;
  7470. this._markAsDirty();
  7471. this.onFocusObservable.notifyObservers(this);
  7472. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7473. var value = prompt(this.promptMessage);
  7474. if (value !== null) {
  7475. this.text = value;
  7476. }
  7477. this._host.focusedControl = null;
  7478. return;
  7479. }
  7480. this._host.registerClipboardEvents();
  7481. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7482. // process clipboard event, can be configured.
  7483. switch (clipboardInfo.type) {
  7484. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7485. _this._onCopyText(clipboardInfo.event);
  7486. _this.onTextCopyObservable.notifyObservers(_this);
  7487. break;
  7488. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7489. _this._onCutText(clipboardInfo.event);
  7490. _this.onTextCutObservable.notifyObservers(_this);
  7491. break;
  7492. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7493. _this._onPasteText(clipboardInfo.event);
  7494. _this.onTextPasteObservable.notifyObservers(_this);
  7495. break;
  7496. default: return;
  7497. }
  7498. });
  7499. var scene = this._host.getScene();
  7500. if (scene) {
  7501. //register the pointer double tap event
  7502. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7503. if (!_this._isFocused) {
  7504. return;
  7505. }
  7506. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7507. _this._processDblClick(pointerInfo);
  7508. }
  7509. });
  7510. }
  7511. if (this._onFocusSelectAll) {
  7512. this._selectAllText();
  7513. }
  7514. };
  7515. InputText.prototype._getTypeName = function () {
  7516. return "InputText";
  7517. };
  7518. /**
  7519. * Function called to get the list of controls that should not steal the focus from this control
  7520. * @returns an array of controls
  7521. */
  7522. InputText.prototype.keepsFocusWith = function () {
  7523. if (!this._connectedVirtualKeyboard) {
  7524. return null;
  7525. }
  7526. return [this._connectedVirtualKeyboard];
  7527. };
  7528. /** @hidden */
  7529. InputText.prototype.processKey = function (keyCode, key, evt) {
  7530. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7531. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7532. return;
  7533. }
  7534. //select all
  7535. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7536. this._selectAllText();
  7537. evt.preventDefault();
  7538. return;
  7539. }
  7540. // Specific cases
  7541. switch (keyCode) {
  7542. case 32: //SPACE
  7543. key = " "; //ie11 key for space is "Spacebar"
  7544. break;
  7545. case 191: //SLASH
  7546. if (evt) {
  7547. evt.preventDefault();
  7548. }
  7549. break;
  7550. case 8: // BACKSPACE
  7551. if (this._text && this._text.length > 0) {
  7552. //delete the highlighted text
  7553. if (this._isTextHighlightOn) {
  7554. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7555. this._isTextHighlightOn = false;
  7556. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7557. this._blinkIsEven = false;
  7558. if (evt) {
  7559. evt.preventDefault();
  7560. }
  7561. return;
  7562. }
  7563. //delete single character
  7564. if (this._cursorOffset === 0) {
  7565. this.text = this._text.substr(0, this._text.length - 1);
  7566. }
  7567. else {
  7568. var deletePosition = this._text.length - this._cursorOffset;
  7569. if (deletePosition > 0) {
  7570. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7571. }
  7572. }
  7573. }
  7574. if (evt) {
  7575. evt.preventDefault();
  7576. }
  7577. return;
  7578. case 46: // DELETE
  7579. if (this._isTextHighlightOn) {
  7580. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7581. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7582. while (decrementor > 0 && this._cursorOffset > 0) {
  7583. this._cursorOffset--;
  7584. }
  7585. this._isTextHighlightOn = false;
  7586. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7587. if (evt) {
  7588. evt.preventDefault();
  7589. }
  7590. return;
  7591. }
  7592. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7593. var deletePosition = this._text.length - this._cursorOffset;
  7594. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7595. this._cursorOffset--;
  7596. }
  7597. if (evt) {
  7598. evt.preventDefault();
  7599. }
  7600. return;
  7601. case 13: // RETURN
  7602. this._host.focusedControl = null;
  7603. this._isTextHighlightOn = false;
  7604. return;
  7605. case 35: // END
  7606. this._cursorOffset = 0;
  7607. this._blinkIsEven = false;
  7608. this._isTextHighlightOn = false;
  7609. this._markAsDirty();
  7610. return;
  7611. case 36: // HOME
  7612. this._cursorOffset = this._text.length;
  7613. this._blinkIsEven = false;
  7614. this._isTextHighlightOn = false;
  7615. this._markAsDirty();
  7616. return;
  7617. case 37: // LEFT
  7618. this._cursorOffset++;
  7619. if (this._cursorOffset > this._text.length) {
  7620. this._cursorOffset = this._text.length;
  7621. }
  7622. if (evt && evt.shiftKey) {
  7623. // update the cursor
  7624. this._blinkIsEven = false;
  7625. // shift + ctrl/cmd + <-
  7626. if (evt.ctrlKey || evt.metaKey) {
  7627. if (!this._isTextHighlightOn) {
  7628. if (this._text.length === this._cursorOffset) {
  7629. return;
  7630. }
  7631. else {
  7632. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7633. }
  7634. }
  7635. this._startHighlightIndex = 0;
  7636. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7637. this._cursorOffset = this._text.length;
  7638. this._isTextHighlightOn = true;
  7639. this._markAsDirty();
  7640. return;
  7641. }
  7642. //store the starting point
  7643. if (!this._isTextHighlightOn) {
  7644. this._isTextHighlightOn = true;
  7645. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7646. }
  7647. //if text is already highlighted
  7648. else if (this._cursorIndex === -1) {
  7649. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7650. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7651. }
  7652. //set the highlight indexes
  7653. if (this._cursorIndex < this._cursorOffset) {
  7654. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7655. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7656. }
  7657. else if (this._cursorIndex > this._cursorOffset) {
  7658. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7659. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7660. }
  7661. else {
  7662. this._isTextHighlightOn = false;
  7663. }
  7664. this._markAsDirty();
  7665. return;
  7666. }
  7667. if (this._isTextHighlightOn) {
  7668. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7669. this._isTextHighlightOn = false;
  7670. }
  7671. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7672. this._cursorOffset = this.text.length;
  7673. evt.preventDefault();
  7674. }
  7675. this._blinkIsEven = false;
  7676. this._isTextHighlightOn = false;
  7677. this._cursorIndex = -1;
  7678. this._markAsDirty();
  7679. return;
  7680. case 39: // RIGHT
  7681. this._cursorOffset--;
  7682. if (this._cursorOffset < 0) {
  7683. this._cursorOffset = 0;
  7684. }
  7685. if (evt && evt.shiftKey) {
  7686. //update the cursor
  7687. this._blinkIsEven = false;
  7688. //shift + ctrl/cmd + ->
  7689. if (evt.ctrlKey || evt.metaKey) {
  7690. if (!this._isTextHighlightOn) {
  7691. if (this._cursorOffset === 0) {
  7692. return;
  7693. }
  7694. else {
  7695. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7696. }
  7697. }
  7698. this._endHighlightIndex = this._text.length;
  7699. this._isTextHighlightOn = true;
  7700. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7701. this._cursorOffset = 0;
  7702. this._markAsDirty();
  7703. return;
  7704. }
  7705. if (!this._isTextHighlightOn) {
  7706. this._isTextHighlightOn = true;
  7707. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7708. }
  7709. //if text is already highlighted
  7710. else if (this._cursorIndex === -1) {
  7711. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7712. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7713. }
  7714. //set the highlight indexes
  7715. if (this._cursorIndex < this._cursorOffset) {
  7716. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7717. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7718. }
  7719. else if (this._cursorIndex > this._cursorOffset) {
  7720. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7721. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7722. }
  7723. else {
  7724. this._isTextHighlightOn = false;
  7725. }
  7726. this._markAsDirty();
  7727. return;
  7728. }
  7729. if (this._isTextHighlightOn) {
  7730. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7731. this._isTextHighlightOn = false;
  7732. }
  7733. //ctr + ->
  7734. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7735. this._cursorOffset = 0;
  7736. evt.preventDefault();
  7737. }
  7738. this._blinkIsEven = false;
  7739. this._isTextHighlightOn = false;
  7740. this._cursorIndex = -1;
  7741. this._markAsDirty();
  7742. return;
  7743. case 222: // Dead
  7744. if (evt) {
  7745. evt.preventDefault();
  7746. }
  7747. this._cursorIndex = -1;
  7748. this.deadKey = true;
  7749. break;
  7750. }
  7751. // Printable characters
  7752. if (key &&
  7753. ((keyCode === -1) || // Direct access
  7754. (keyCode === 32) || // Space
  7755. (keyCode > 47 && keyCode < 64) || // Numbers
  7756. (keyCode > 64 && keyCode < 91) || // Letters
  7757. (keyCode > 159 && keyCode < 193) || // Special characters
  7758. (keyCode > 218 && keyCode < 223) || // Special characters
  7759. (keyCode > 95 && keyCode < 112))) { // Numpad
  7760. this._currentKey = key;
  7761. this.onBeforeKeyAddObservable.notifyObservers(this);
  7762. key = this._currentKey;
  7763. if (this._addKey) {
  7764. if (this._isTextHighlightOn) {
  7765. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7766. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7767. this._isTextHighlightOn = false;
  7768. this._blinkIsEven = false;
  7769. this._markAsDirty();
  7770. }
  7771. else if (this._cursorOffset === 0) {
  7772. this.text += key;
  7773. }
  7774. else {
  7775. var insertPosition = this._text.length - this._cursorOffset;
  7776. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7777. }
  7778. }
  7779. }
  7780. };
  7781. /** @hidden */
  7782. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7783. //update the cursor
  7784. this._blinkIsEven = false;
  7785. if (this._cursorIndex === -1) {
  7786. this._cursorIndex = offset;
  7787. }
  7788. else {
  7789. if (this._cursorIndex < this._cursorOffset) {
  7790. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7791. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7792. }
  7793. else if (this._cursorIndex > this._cursorOffset) {
  7794. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7795. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7796. }
  7797. else {
  7798. this._isTextHighlightOn = false;
  7799. this._markAsDirty();
  7800. return;
  7801. }
  7802. }
  7803. this._isTextHighlightOn = true;
  7804. this._markAsDirty();
  7805. };
  7806. /** @hidden */
  7807. InputText.prototype._processDblClick = function (evt) {
  7808. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7809. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7810. this._endHighlightIndex = this._startHighlightIndex;
  7811. var rWord = /\w+/g, moveLeft, moveRight;
  7812. do {
  7813. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7814. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7815. } while (moveLeft || moveRight);
  7816. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7817. this.onTextHighlightObservable.notifyObservers(this);
  7818. this._isTextHighlightOn = true;
  7819. this._clickedCoordinate = null;
  7820. this._blinkIsEven = true;
  7821. this._cursorIndex = -1;
  7822. this._markAsDirty();
  7823. };
  7824. /** @hidden */
  7825. InputText.prototype._selectAllText = function () {
  7826. this._blinkIsEven = true;
  7827. this._isTextHighlightOn = true;
  7828. this._startHighlightIndex = 0;
  7829. this._endHighlightIndex = this._text.length;
  7830. this._cursorOffset = this._text.length;
  7831. this._cursorIndex = -1;
  7832. this._markAsDirty();
  7833. };
  7834. /**
  7835. * Handles the keyboard event
  7836. * @param evt Defines the KeyboardEvent
  7837. */
  7838. InputText.prototype.processKeyboard = function (evt) {
  7839. // process pressed key
  7840. this.processKey(evt.keyCode, evt.key, evt);
  7841. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7842. };
  7843. /** @hidden */
  7844. InputText.prototype._onCopyText = function (ev) {
  7845. this._isTextHighlightOn = false;
  7846. //when write permission to clipbaord data is denied
  7847. try {
  7848. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7849. }
  7850. catch (_a) { } //pass
  7851. this._host.clipboardData = this._highlightedText;
  7852. };
  7853. /** @hidden */
  7854. InputText.prototype._onCutText = function (ev) {
  7855. if (!this._highlightedText) {
  7856. return;
  7857. }
  7858. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7859. this._isTextHighlightOn = false;
  7860. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7861. //when write permission to clipbaord data is denied
  7862. try {
  7863. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7864. }
  7865. catch (_a) { } //pass
  7866. this._host.clipboardData = this._highlightedText;
  7867. this._highlightedText = "";
  7868. };
  7869. /** @hidden */
  7870. InputText.prototype._onPasteText = function (ev) {
  7871. var data = "";
  7872. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7873. data = ev.clipboardData.getData("text/plain");
  7874. }
  7875. else {
  7876. //get the cached data; returns blank string by default
  7877. data = this._host.clipboardData;
  7878. }
  7879. var insertPosition = this._text.length - this._cursorOffset;
  7880. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7881. };
  7882. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7883. var _this = this;
  7884. context.save();
  7885. this._applyStates(context);
  7886. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7887. context.shadowColor = this.shadowColor;
  7888. context.shadowBlur = this.shadowBlur;
  7889. context.shadowOffsetX = this.shadowOffsetX;
  7890. context.shadowOffsetY = this.shadowOffsetY;
  7891. }
  7892. // Background
  7893. if (this._isFocused) {
  7894. if (this._focusedBackground) {
  7895. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7896. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7897. }
  7898. }
  7899. else if (this._background) {
  7900. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7901. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7902. }
  7903. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7904. context.shadowBlur = 0;
  7905. context.shadowOffsetX = 0;
  7906. context.shadowOffsetY = 0;
  7907. }
  7908. if (!this._fontOffset) {
  7909. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7910. }
  7911. // Text
  7912. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7913. if (this.color) {
  7914. context.fillStyle = this.color;
  7915. }
  7916. var text = this._beforeRenderText(this._text);
  7917. if (!this._isFocused && !this._text && this._placeholderText) {
  7918. text = this._placeholderText;
  7919. if (this._placeholderColor) {
  7920. context.fillStyle = this._placeholderColor;
  7921. }
  7922. }
  7923. this._textWidth = context.measureText(text).width;
  7924. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7925. if (this._autoStretchWidth) {
  7926. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7927. }
  7928. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7929. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7930. context.save();
  7931. context.beginPath();
  7932. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7933. context.clip();
  7934. if (this._isFocused && this._textWidth > availableWidth) {
  7935. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7936. if (!this._scrollLeft) {
  7937. this._scrollLeft = textLeft;
  7938. }
  7939. }
  7940. else {
  7941. this._scrollLeft = clipTextLeft;
  7942. }
  7943. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7944. // Cursor
  7945. if (this._isFocused) {
  7946. // Need to move cursor
  7947. if (this._clickedCoordinate) {
  7948. var rightPosition = this._scrollLeft + this._textWidth;
  7949. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7950. var currentSize = 0;
  7951. this._cursorOffset = 0;
  7952. var previousDist = 0;
  7953. do {
  7954. if (this._cursorOffset) {
  7955. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7956. }
  7957. this._cursorOffset++;
  7958. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7959. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7960. // Find closest move
  7961. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7962. this._cursorOffset--;
  7963. }
  7964. this._blinkIsEven = false;
  7965. this._clickedCoordinate = null;
  7966. }
  7967. // Render cursor
  7968. if (!this._blinkIsEven) {
  7969. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7970. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7971. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7972. if (cursorLeft < clipTextLeft) {
  7973. this._scrollLeft += (clipTextLeft - cursorLeft);
  7974. cursorLeft = clipTextLeft;
  7975. this._markAsDirty();
  7976. }
  7977. else if (cursorLeft > clipTextLeft + availableWidth) {
  7978. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7979. cursorLeft = clipTextLeft + availableWidth;
  7980. this._markAsDirty();
  7981. }
  7982. if (!this._isTextHighlightOn) {
  7983. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7984. }
  7985. }
  7986. clearTimeout(this._blinkTimeout);
  7987. this._blinkTimeout = setTimeout(function () {
  7988. _this._blinkIsEven = !_this._blinkIsEven;
  7989. _this._markAsDirty();
  7990. }, 500);
  7991. //show the highlighted text
  7992. if (this._isTextHighlightOn) {
  7993. clearTimeout(this._blinkTimeout);
  7994. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7995. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7996. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7997. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7998. if (highlightCursorLeft < clipTextLeft) {
  7999. width = width - (clipTextLeft - highlightCursorLeft);
  8000. if (!width) {
  8001. // when using left arrow on text.length > availableWidth;
  8002. // assigns the width of the first letter after clipTextLeft
  8003. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  8004. }
  8005. highlightCursorLeft = clipTextLeft;
  8006. }
  8007. //for transparancy
  8008. context.globalAlpha = this._highligherOpacity;
  8009. context.fillStyle = this._textHighlightColor;
  8010. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8011. context.globalAlpha = 1.0;
  8012. }
  8013. }
  8014. context.restore();
  8015. // Border
  8016. if (this._thickness) {
  8017. if (this._isFocused) {
  8018. if (this.focusedColor) {
  8019. context.strokeStyle = this.focusedColor;
  8020. }
  8021. }
  8022. else {
  8023. if (this.color) {
  8024. context.strokeStyle = this.color;
  8025. }
  8026. }
  8027. context.lineWidth = this._thickness;
  8028. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8029. }
  8030. context.restore();
  8031. };
  8032. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8033. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8034. return false;
  8035. }
  8036. this._clickedCoordinate = coordinates.x;
  8037. this._isTextHighlightOn = false;
  8038. this._highlightedText = "";
  8039. this._cursorIndex = -1;
  8040. this._isPointerDown = true;
  8041. this._host._capturingControl[pointerId] = this;
  8042. if (this._host.focusedControl === this) {
  8043. // Move cursor
  8044. clearTimeout(this._blinkTimeout);
  8045. this._markAsDirty();
  8046. return true;
  8047. }
  8048. if (!this._isEnabled) {
  8049. return false;
  8050. }
  8051. this._host.focusedControl = this;
  8052. return true;
  8053. };
  8054. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  8055. if (this._host.focusedControl === this && this._isPointerDown) {
  8056. this._clickedCoordinate = coordinates.x;
  8057. this._markAsDirty();
  8058. this._updateValueFromCursorIndex(this._cursorOffset);
  8059. }
  8060. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  8061. };
  8062. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8063. this._isPointerDown = false;
  8064. delete this._host._capturingControl[pointerId];
  8065. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8066. };
  8067. InputText.prototype._beforeRenderText = function (text) {
  8068. return text;
  8069. };
  8070. InputText.prototype.dispose = function () {
  8071. _super.prototype.dispose.call(this);
  8072. this.onBlurObservable.clear();
  8073. this.onFocusObservable.clear();
  8074. this.onTextChangedObservable.clear();
  8075. this.onTextCopyObservable.clear();
  8076. this.onTextCutObservable.clear();
  8077. this.onTextPasteObservable.clear();
  8078. this.onTextHighlightObservable.clear();
  8079. this.onKeyboardEventProcessedObservable.clear();
  8080. };
  8081. return InputText;
  8082. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8083. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8084. /***/ }),
  8085. /***/ "./2D/controls/line.ts":
  8086. /*!*****************************!*\
  8087. !*** ./2D/controls/line.ts ***!
  8088. \*****************************/
  8089. /*! exports provided: Line */
  8090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8091. "use strict";
  8092. __webpack_require__.r(__webpack_exports__);
  8093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8094. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8095. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  8096. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  8097. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8098. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8099. /** Class used to render 2D lines */
  8100. var Line = /** @class */ (function (_super) {
  8101. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8102. /**
  8103. * Creates a new Line
  8104. * @param name defines the control name
  8105. */
  8106. function Line(name) {
  8107. var _this = _super.call(this, name) || this;
  8108. _this.name = name;
  8109. _this._lineWidth = 1;
  8110. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8111. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8112. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8113. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8114. _this._dash = new Array();
  8115. _this._automaticSize = true;
  8116. _this.isHitTestVisible = false;
  8117. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8118. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8119. return _this;
  8120. }
  8121. Object.defineProperty(Line.prototype, "dash", {
  8122. /** Gets or sets the dash pattern */
  8123. get: function () {
  8124. return this._dash;
  8125. },
  8126. set: function (value) {
  8127. if (this._dash === value) {
  8128. return;
  8129. }
  8130. this._dash = value;
  8131. this._markAsDirty();
  8132. },
  8133. enumerable: true,
  8134. configurable: true
  8135. });
  8136. Object.defineProperty(Line.prototype, "connectedControl", {
  8137. /** Gets or sets the control connected with the line end */
  8138. get: function () {
  8139. return this._connectedControl;
  8140. },
  8141. set: function (value) {
  8142. var _this = this;
  8143. if (this._connectedControl === value) {
  8144. return;
  8145. }
  8146. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8147. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8148. this._connectedControlDirtyObserver = null;
  8149. }
  8150. if (value) {
  8151. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8152. }
  8153. this._connectedControl = value;
  8154. this._markAsDirty();
  8155. },
  8156. enumerable: true,
  8157. configurable: true
  8158. });
  8159. Object.defineProperty(Line.prototype, "x1", {
  8160. /** Gets or sets start coordinates on X axis */
  8161. get: function () {
  8162. return this._x1.toString(this._host);
  8163. },
  8164. set: function (value) {
  8165. if (this._x1.toString(this._host) === value) {
  8166. return;
  8167. }
  8168. if (this._x1.fromString(value)) {
  8169. this._markAsDirty();
  8170. }
  8171. },
  8172. enumerable: true,
  8173. configurable: true
  8174. });
  8175. Object.defineProperty(Line.prototype, "y1", {
  8176. /** Gets or sets start coordinates on Y axis */
  8177. get: function () {
  8178. return this._y1.toString(this._host);
  8179. },
  8180. set: function (value) {
  8181. if (this._y1.toString(this._host) === value) {
  8182. return;
  8183. }
  8184. if (this._y1.fromString(value)) {
  8185. this._markAsDirty();
  8186. }
  8187. },
  8188. enumerable: true,
  8189. configurable: true
  8190. });
  8191. Object.defineProperty(Line.prototype, "x2", {
  8192. /** Gets or sets end coordinates on X axis */
  8193. get: function () {
  8194. return this._x2.toString(this._host);
  8195. },
  8196. set: function (value) {
  8197. if (this._x2.toString(this._host) === value) {
  8198. return;
  8199. }
  8200. if (this._x2.fromString(value)) {
  8201. this._markAsDirty();
  8202. }
  8203. },
  8204. enumerable: true,
  8205. configurable: true
  8206. });
  8207. Object.defineProperty(Line.prototype, "y2", {
  8208. /** Gets or sets end coordinates on Y axis */
  8209. get: function () {
  8210. return this._y2.toString(this._host);
  8211. },
  8212. set: function (value) {
  8213. if (this._y2.toString(this._host) === value) {
  8214. return;
  8215. }
  8216. if (this._y2.fromString(value)) {
  8217. this._markAsDirty();
  8218. }
  8219. },
  8220. enumerable: true,
  8221. configurable: true
  8222. });
  8223. Object.defineProperty(Line.prototype, "lineWidth", {
  8224. /** Gets or sets line width */
  8225. get: function () {
  8226. return this._lineWidth;
  8227. },
  8228. set: function (value) {
  8229. if (this._lineWidth === value) {
  8230. return;
  8231. }
  8232. this._lineWidth = value;
  8233. this._markAsDirty();
  8234. },
  8235. enumerable: true,
  8236. configurable: true
  8237. });
  8238. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8239. /** Gets or sets horizontal alignment */
  8240. set: function (value) {
  8241. return;
  8242. },
  8243. enumerable: true,
  8244. configurable: true
  8245. });
  8246. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8247. /** Gets or sets vertical alignment */
  8248. set: function (value) {
  8249. return;
  8250. },
  8251. enumerable: true,
  8252. configurable: true
  8253. });
  8254. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8255. get: function () {
  8256. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8257. },
  8258. enumerable: true,
  8259. configurable: true
  8260. });
  8261. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8262. get: function () {
  8263. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8264. },
  8265. enumerable: true,
  8266. configurable: true
  8267. });
  8268. Line.prototype._getTypeName = function () {
  8269. return "Line";
  8270. };
  8271. Line.prototype._draw = function (context) {
  8272. context.save();
  8273. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8274. context.shadowColor = this.shadowColor;
  8275. context.shadowBlur = this.shadowBlur;
  8276. context.shadowOffsetX = this.shadowOffsetX;
  8277. context.shadowOffsetY = this.shadowOffsetY;
  8278. }
  8279. this._applyStates(context);
  8280. context.strokeStyle = this.color;
  8281. context.lineWidth = this._lineWidth;
  8282. context.setLineDash(this._dash);
  8283. context.beginPath();
  8284. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8285. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8286. context.stroke();
  8287. context.restore();
  8288. };
  8289. Line.prototype._measure = function () {
  8290. // Width / Height
  8291. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8292. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8293. };
  8294. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8295. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8296. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8297. };
  8298. /**
  8299. * Move one end of the line given 3D cartesian coordinates.
  8300. * @param position Targeted world position
  8301. * @param scene Scene
  8302. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8303. */
  8304. Line.prototype.moveToVector3 = function (position, scene, end) {
  8305. if (end === void 0) { end = false; }
  8306. if (!this._host || this.parent !== this._host._rootContainer) {
  8307. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8308. return;
  8309. }
  8310. var globalViewport = this._host._getGlobalViewport(scene);
  8311. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8312. this._moveToProjectedPosition(projectedPosition, end);
  8313. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8314. this.notRenderable = true;
  8315. return;
  8316. }
  8317. this.notRenderable = false;
  8318. };
  8319. /**
  8320. * Move one end of the line to a position in screen absolute space.
  8321. * @param projectedPosition Position in screen absolute space (X, Y)
  8322. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8323. */
  8324. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8325. if (end === void 0) { end = false; }
  8326. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8327. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8328. if (end) {
  8329. this.x2 = x;
  8330. this.y2 = y;
  8331. this._x2.ignoreAdaptiveScaling = true;
  8332. this._y2.ignoreAdaptiveScaling = true;
  8333. }
  8334. else {
  8335. this.x1 = x;
  8336. this.y1 = y;
  8337. this._x1.ignoreAdaptiveScaling = true;
  8338. this._y1.ignoreAdaptiveScaling = true;
  8339. }
  8340. };
  8341. return Line;
  8342. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8343. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8344. /***/ }),
  8345. /***/ "./2D/controls/multiLine.ts":
  8346. /*!**********************************!*\
  8347. !*** ./2D/controls/multiLine.ts ***!
  8348. \**********************************/
  8349. /*! exports provided: MultiLine */
  8350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8351. "use strict";
  8352. __webpack_require__.r(__webpack_exports__);
  8353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8355. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/perfCounter");
  8356. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8357. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8358. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8359. /**
  8360. * Class used to create multi line control
  8361. */
  8362. var MultiLine = /** @class */ (function (_super) {
  8363. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8364. /**
  8365. * Creates a new MultiLine
  8366. * @param name defines the control name
  8367. */
  8368. function MultiLine(name) {
  8369. var _this = _super.call(this, name) || this;
  8370. _this.name = name;
  8371. _this._lineWidth = 1;
  8372. /** Function called when a point is updated */
  8373. _this.onPointUpdate = function () {
  8374. _this._markAsDirty();
  8375. };
  8376. _this._automaticSize = true;
  8377. _this.isHitTestVisible = false;
  8378. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8379. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8380. _this._dash = [];
  8381. _this._points = [];
  8382. return _this;
  8383. }
  8384. Object.defineProperty(MultiLine.prototype, "dash", {
  8385. /** Gets or sets dash pattern */
  8386. get: function () {
  8387. return this._dash;
  8388. },
  8389. set: function (value) {
  8390. if (this._dash === value) {
  8391. return;
  8392. }
  8393. this._dash = value;
  8394. this._markAsDirty();
  8395. },
  8396. enumerable: true,
  8397. configurable: true
  8398. });
  8399. /**
  8400. * Gets point stored at specified index
  8401. * @param index defines the index to look for
  8402. * @returns the requested point if found
  8403. */
  8404. MultiLine.prototype.getAt = function (index) {
  8405. if (!this._points[index]) {
  8406. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8407. }
  8408. return this._points[index];
  8409. };
  8410. /**
  8411. * Adds new points to the point collection
  8412. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8413. * @returns the list of created MultiLinePoint
  8414. */
  8415. MultiLine.prototype.add = function () {
  8416. var _this = this;
  8417. var items = [];
  8418. for (var _i = 0; _i < arguments.length; _i++) {
  8419. items[_i] = arguments[_i];
  8420. }
  8421. return items.map(function (item) { return _this.push(item); });
  8422. };
  8423. /**
  8424. * Adds a new point to the point collection
  8425. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8426. * @returns the created MultiLinePoint
  8427. */
  8428. MultiLine.prototype.push = function (item) {
  8429. var point = this.getAt(this._points.length);
  8430. if (item == null) {
  8431. return point;
  8432. }
  8433. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8434. point.mesh = item;
  8435. }
  8436. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8437. point.control = item;
  8438. }
  8439. else if (item.x != null && item.y != null) {
  8440. point.x = item.x;
  8441. point.y = item.y;
  8442. }
  8443. return point;
  8444. };
  8445. /**
  8446. * Remove a specific value or point from the active point collection
  8447. * @param value defines the value or point to remove
  8448. */
  8449. MultiLine.prototype.remove = function (value) {
  8450. var index;
  8451. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8452. index = this._points.indexOf(value);
  8453. if (index === -1) {
  8454. return;
  8455. }
  8456. }
  8457. else {
  8458. index = value;
  8459. }
  8460. var point = this._points[index];
  8461. if (!point) {
  8462. return;
  8463. }
  8464. point.dispose();
  8465. this._points.splice(index, 1);
  8466. };
  8467. /**
  8468. * Resets this object to initial state (no point)
  8469. */
  8470. MultiLine.prototype.reset = function () {
  8471. while (this._points.length > 0) {
  8472. this.remove(this._points.length - 1);
  8473. }
  8474. };
  8475. /**
  8476. * Resets all links
  8477. */
  8478. MultiLine.prototype.resetLinks = function () {
  8479. this._points.forEach(function (point) {
  8480. if (point != null) {
  8481. point.resetLinks();
  8482. }
  8483. });
  8484. };
  8485. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8486. /** Gets or sets line width */
  8487. get: function () {
  8488. return this._lineWidth;
  8489. },
  8490. set: function (value) {
  8491. if (this._lineWidth === value) {
  8492. return;
  8493. }
  8494. this._lineWidth = value;
  8495. this._markAsDirty();
  8496. },
  8497. enumerable: true,
  8498. configurable: true
  8499. });
  8500. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8501. set: function (value) {
  8502. return;
  8503. },
  8504. enumerable: true,
  8505. configurable: true
  8506. });
  8507. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8508. set: function (value) {
  8509. return;
  8510. },
  8511. enumerable: true,
  8512. configurable: true
  8513. });
  8514. MultiLine.prototype._getTypeName = function () {
  8515. return "MultiLine";
  8516. };
  8517. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8518. context.save();
  8519. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8520. context.shadowColor = this.shadowColor;
  8521. context.shadowBlur = this.shadowBlur;
  8522. context.shadowOffsetX = this.shadowOffsetX;
  8523. context.shadowOffsetY = this.shadowOffsetY;
  8524. }
  8525. this._applyStates(context);
  8526. context.strokeStyle = this.color;
  8527. context.lineWidth = this._lineWidth;
  8528. context.setLineDash(this._dash);
  8529. context.beginPath();
  8530. var first = true; //first index is not necessarily 0
  8531. this._points.forEach(function (point) {
  8532. if (!point) {
  8533. return;
  8534. }
  8535. if (first) {
  8536. context.moveTo(point._point.x, point._point.y);
  8537. first = false;
  8538. }
  8539. else {
  8540. context.lineTo(point._point.x, point._point.y);
  8541. }
  8542. });
  8543. context.stroke();
  8544. context.restore();
  8545. };
  8546. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8547. var _this = this;
  8548. this._minX = null;
  8549. this._minY = null;
  8550. this._maxX = null;
  8551. this._maxY = null;
  8552. this._points.forEach(function (point, index) {
  8553. if (!point) {
  8554. return;
  8555. }
  8556. point.translate();
  8557. if (_this._minX == null || point._point.x < _this._minX) {
  8558. _this._minX = point._point.x;
  8559. }
  8560. if (_this._minY == null || point._point.y < _this._minY) {
  8561. _this._minY = point._point.y;
  8562. }
  8563. if (_this._maxX == null || point._point.x > _this._maxX) {
  8564. _this._maxX = point._point.x;
  8565. }
  8566. if (_this._maxY == null || point._point.y > _this._maxY) {
  8567. _this._maxY = point._point.y;
  8568. }
  8569. });
  8570. if (this._minX == null) {
  8571. this._minX = 0;
  8572. }
  8573. if (this._minY == null) {
  8574. this._minY = 0;
  8575. }
  8576. if (this._maxX == null) {
  8577. this._maxX = 0;
  8578. }
  8579. if (this._maxY == null) {
  8580. this._maxY = 0;
  8581. }
  8582. };
  8583. MultiLine.prototype._measure = function () {
  8584. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8585. return;
  8586. }
  8587. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8588. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8589. };
  8590. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8591. if (this._minX == null || this._minY == null) {
  8592. return;
  8593. }
  8594. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8595. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8596. };
  8597. MultiLine.prototype.dispose = function () {
  8598. this.reset();
  8599. _super.prototype.dispose.call(this);
  8600. };
  8601. return MultiLine;
  8602. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8603. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8604. /***/ }),
  8605. /***/ "./2D/controls/radioButton.ts":
  8606. /*!************************************!*\
  8607. !*** ./2D/controls/radioButton.ts ***!
  8608. \************************************/
  8609. /*! exports provided: RadioButton */
  8610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8611. "use strict";
  8612. __webpack_require__.r(__webpack_exports__);
  8613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8615. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  8616. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8617. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8618. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8619. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8620. /**
  8621. * Class used to create radio button controls
  8622. */
  8623. var RadioButton = /** @class */ (function (_super) {
  8624. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8625. /**
  8626. * Creates a new RadioButton
  8627. * @param name defines the control name
  8628. */
  8629. function RadioButton(name) {
  8630. var _this = _super.call(this, name) || this;
  8631. _this.name = name;
  8632. _this._isChecked = false;
  8633. _this._background = "black";
  8634. _this._checkSizeRatio = 0.8;
  8635. _this._thickness = 1;
  8636. /** Gets or sets group name */
  8637. _this.group = "";
  8638. /** Observable raised when isChecked is changed */
  8639. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8640. _this.isPointerBlocker = true;
  8641. return _this;
  8642. }
  8643. Object.defineProperty(RadioButton.prototype, "thickness", {
  8644. /** Gets or sets border thickness */
  8645. get: function () {
  8646. return this._thickness;
  8647. },
  8648. set: function (value) {
  8649. if (this._thickness === value) {
  8650. return;
  8651. }
  8652. this._thickness = value;
  8653. this._markAsDirty();
  8654. },
  8655. enumerable: true,
  8656. configurable: true
  8657. });
  8658. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8659. /** Gets or sets a value indicating the ratio between overall size and check size */
  8660. get: function () {
  8661. return this._checkSizeRatio;
  8662. },
  8663. set: function (value) {
  8664. value = Math.max(Math.min(1, value), 0);
  8665. if (this._checkSizeRatio === value) {
  8666. return;
  8667. }
  8668. this._checkSizeRatio = value;
  8669. this._markAsDirty();
  8670. },
  8671. enumerable: true,
  8672. configurable: true
  8673. });
  8674. Object.defineProperty(RadioButton.prototype, "background", {
  8675. /** Gets or sets background color */
  8676. get: function () {
  8677. return this._background;
  8678. },
  8679. set: function (value) {
  8680. if (this._background === value) {
  8681. return;
  8682. }
  8683. this._background = value;
  8684. this._markAsDirty();
  8685. },
  8686. enumerable: true,
  8687. configurable: true
  8688. });
  8689. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8690. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8691. get: function () {
  8692. return this._isChecked;
  8693. },
  8694. set: function (value) {
  8695. var _this = this;
  8696. if (this._isChecked === value) {
  8697. return;
  8698. }
  8699. this._isChecked = value;
  8700. this._markAsDirty();
  8701. this.onIsCheckedChangedObservable.notifyObservers(value);
  8702. if (this._isChecked && this._host) {
  8703. // Update all controls from same group
  8704. this._host.executeOnAllControls(function (control) {
  8705. if (control === _this) {
  8706. return;
  8707. }
  8708. if (control.group === undefined) {
  8709. return;
  8710. }
  8711. var childRadio = control;
  8712. if (childRadio.group === _this.group) {
  8713. childRadio.isChecked = false;
  8714. }
  8715. });
  8716. }
  8717. },
  8718. enumerable: true,
  8719. configurable: true
  8720. });
  8721. RadioButton.prototype._getTypeName = function () {
  8722. return "RadioButton";
  8723. };
  8724. RadioButton.prototype._draw = function (context) {
  8725. context.save();
  8726. this._applyStates(context);
  8727. var actualWidth = this._currentMeasure.width - this._thickness;
  8728. var actualHeight = this._currentMeasure.height - this._thickness;
  8729. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8730. context.shadowColor = this.shadowColor;
  8731. context.shadowBlur = this.shadowBlur;
  8732. context.shadowOffsetX = this.shadowOffsetX;
  8733. context.shadowOffsetY = this.shadowOffsetY;
  8734. }
  8735. // Outer
  8736. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, this._currentMeasure.width / 2 - this._thickness / 2, this._currentMeasure.height / 2 - this._thickness / 2, context);
  8737. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8738. context.fill();
  8739. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8740. context.shadowBlur = 0;
  8741. context.shadowOffsetX = 0;
  8742. context.shadowOffsetY = 0;
  8743. }
  8744. context.strokeStyle = this.color;
  8745. context.lineWidth = this._thickness;
  8746. context.stroke();
  8747. // Inner
  8748. if (this._isChecked) {
  8749. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8750. var offsetWidth = actualWidth * this._checkSizeRatio;
  8751. var offseHeight = actualHeight * this._checkSizeRatio;
  8752. _control__WEBPACK_IMPORTED_MODULE_2__["Control"].drawEllipse(this._currentMeasure.left + this._currentMeasure.width / 2, this._currentMeasure.top + this._currentMeasure.height / 2, offsetWidth / 2 - this._thickness / 2, offseHeight / 2 - this._thickness / 2, context);
  8753. context.fill();
  8754. }
  8755. context.restore();
  8756. };
  8757. // Events
  8758. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8759. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8760. return false;
  8761. }
  8762. if (!this.isChecked) {
  8763. this.isChecked = true;
  8764. }
  8765. return true;
  8766. };
  8767. /**
  8768. * Utility function to easily create a radio button with a header
  8769. * @param title defines the label to use for the header
  8770. * @param group defines the group to use for the radio button
  8771. * @param isChecked defines the initial state of the radio button
  8772. * @param onValueChanged defines the callback to call when value changes
  8773. * @returns a StackPanel containing the radio button and a textBlock
  8774. */
  8775. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8776. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8777. panel.isVertical = false;
  8778. panel.height = "30px";
  8779. var radio = new RadioButton();
  8780. radio.width = "20px";
  8781. radio.height = "20px";
  8782. radio.isChecked = isChecked;
  8783. radio.color = "green";
  8784. radio.group = group;
  8785. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8786. panel.addControl(radio);
  8787. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8788. header.text = title;
  8789. header.width = "180px";
  8790. header.paddingLeft = "5px";
  8791. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8792. header.color = "white";
  8793. panel.addControl(header);
  8794. return panel;
  8795. };
  8796. return RadioButton;
  8797. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8798. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8799. /***/ }),
  8800. /***/ "./2D/controls/rectangle.ts":
  8801. /*!**********************************!*\
  8802. !*** ./2D/controls/rectangle.ts ***!
  8803. \**********************************/
  8804. /*! exports provided: Rectangle */
  8805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8806. "use strict";
  8807. __webpack_require__.r(__webpack_exports__);
  8808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8809. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8810. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8811. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  8812. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8813. /** Class used to create rectangle container */
  8814. var Rectangle = /** @class */ (function (_super) {
  8815. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8816. /**
  8817. * Creates a new Rectangle
  8818. * @param name defines the control name
  8819. */
  8820. function Rectangle(name) {
  8821. var _this = _super.call(this, name) || this;
  8822. _this.name = name;
  8823. _this._thickness = 1;
  8824. _this._cornerRadius = 0;
  8825. return _this;
  8826. }
  8827. Object.defineProperty(Rectangle.prototype, "thickness", {
  8828. /** Gets or sets border thickness */
  8829. get: function () {
  8830. return this._thickness;
  8831. },
  8832. set: function (value) {
  8833. if (this._thickness === value) {
  8834. return;
  8835. }
  8836. this._thickness = value;
  8837. this._markAsDirty();
  8838. },
  8839. enumerable: true,
  8840. configurable: true
  8841. });
  8842. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8843. /** Gets or sets the corner radius angle */
  8844. get: function () {
  8845. return this._cornerRadius;
  8846. },
  8847. set: function (value) {
  8848. if (value < 0) {
  8849. value = 0;
  8850. }
  8851. if (this._cornerRadius === value) {
  8852. return;
  8853. }
  8854. this._cornerRadius = value;
  8855. this._markAsDirty();
  8856. },
  8857. enumerable: true,
  8858. configurable: true
  8859. });
  8860. Rectangle.prototype._getTypeName = function () {
  8861. return "Rectangle";
  8862. };
  8863. Rectangle.prototype._localDraw = function (context) {
  8864. context.save();
  8865. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8866. context.shadowColor = this.shadowColor;
  8867. context.shadowBlur = this.shadowBlur;
  8868. context.shadowOffsetX = this.shadowOffsetX;
  8869. context.shadowOffsetY = this.shadowOffsetY;
  8870. }
  8871. if (this._background) {
  8872. context.fillStyle = this._background;
  8873. if (this._cornerRadius) {
  8874. this._drawRoundedRect(context, this._thickness / 2);
  8875. context.fill();
  8876. }
  8877. else {
  8878. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8879. }
  8880. }
  8881. if (this._thickness) {
  8882. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8883. context.shadowBlur = 0;
  8884. context.shadowOffsetX = 0;
  8885. context.shadowOffsetY = 0;
  8886. }
  8887. if (this.color) {
  8888. context.strokeStyle = this.color;
  8889. }
  8890. context.lineWidth = this._thickness;
  8891. if (this._cornerRadius) {
  8892. this._drawRoundedRect(context, this._thickness / 2);
  8893. context.stroke();
  8894. }
  8895. else {
  8896. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8897. }
  8898. }
  8899. context.restore();
  8900. };
  8901. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8902. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8903. this._measureForChildren.width -= 2 * this._thickness;
  8904. this._measureForChildren.height -= 2 * this._thickness;
  8905. this._measureForChildren.left += this._thickness;
  8906. this._measureForChildren.top += this._thickness;
  8907. };
  8908. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8909. if (offset === void 0) { offset = 0; }
  8910. var x = this._currentMeasure.left + offset;
  8911. var y = this._currentMeasure.top + offset;
  8912. var width = this._currentMeasure.width - offset * 2;
  8913. var height = this._currentMeasure.height - offset * 2;
  8914. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8915. context.beginPath();
  8916. context.moveTo(x + radius, y);
  8917. context.lineTo(x + width - radius, y);
  8918. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8919. context.lineTo(x + width, y + height - radius);
  8920. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8921. context.lineTo(x + radius, y + height);
  8922. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8923. context.lineTo(x, y + radius);
  8924. context.quadraticCurveTo(x, y, x + radius, y);
  8925. context.closePath();
  8926. };
  8927. Rectangle.prototype._clipForChildren = function (context) {
  8928. if (this._cornerRadius) {
  8929. this._drawRoundedRect(context, this._thickness);
  8930. context.clip();
  8931. }
  8932. };
  8933. return Rectangle;
  8934. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8935. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8936. /***/ }),
  8937. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8938. /*!***************************************************!*\
  8939. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8940. \***************************************************/
  8941. /*! exports provided: ScrollViewer */
  8942. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8943. "use strict";
  8944. __webpack_require__.r(__webpack_exports__);
  8945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8946. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8947. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Misc/perfCounter");
  8948. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8949. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8950. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8951. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8952. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8953. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8954. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  8955. /**
  8956. * Class used to hold a viewer window and sliders in a grid
  8957. */
  8958. var ScrollViewer = /** @class */ (function (_super) {
  8959. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  8960. /**
  8961. * Creates a new ScrollViewer
  8962. * @param name of ScrollViewer
  8963. */
  8964. function ScrollViewer(name, isImageBased) {
  8965. var _this = _super.call(this, name) || this;
  8966. _this._barSize = 20;
  8967. _this._pointerIsOver = false;
  8968. _this._wheelPrecision = 0.05;
  8969. _this._thumbLength = 0.5;
  8970. _this._thumbHeight = 1;
  8971. _this._barImageHeight = 1;
  8972. _this._horizontalBarImageHeight = 1;
  8973. _this._verticalBarImageHeight = 1;
  8974. _this._forceHorizontalBar = false;
  8975. _this._forceVerticalBar = false;
  8976. _this._useImageBar = isImageBased ? isImageBased : false;
  8977. _this.onDirtyObservable.add(function () {
  8978. _this._horizontalBarSpace.color = _this.color;
  8979. _this._verticalBarSpace.color = _this.color;
  8980. _this._dragSpace.color = _this.color;
  8981. });
  8982. _this.onPointerEnterObservable.add(function () {
  8983. _this._pointerIsOver = true;
  8984. });
  8985. _this.onPointerOutObservable.add(function () {
  8986. _this._pointerIsOver = false;
  8987. });
  8988. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8989. if (_this._useImageBar) {
  8990. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8991. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8992. }
  8993. else {
  8994. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8995. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8996. }
  8997. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]("scrollViewer_window");
  8998. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8999. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  9000. _this._grid.addColumnDefinition(1);
  9001. _this._grid.addColumnDefinition(0, true);
  9002. _this._grid.addRowDefinition(1);
  9003. _this._grid.addRowDefinition(0, true);
  9004. _super.prototype.addControl.call(_this, _this._grid);
  9005. _this._grid.addControl(_this._window, 0, 0);
  9006. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  9007. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9008. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  9009. _this._verticalBarSpace.thickness = 1;
  9010. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9011. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9012. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  9013. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9014. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  9015. _this._horizontalBarSpace.thickness = 1;
  9016. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9017. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9018. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  9019. _this._dragSpace.thickness = 1;
  9020. _this._grid.addControl(_this._dragSpace, 1, 1);
  9021. // Colors
  9022. if (!_this._useImageBar) {
  9023. _this.barColor = "grey";
  9024. _this.barBackground = "transparent";
  9025. }
  9026. return _this;
  9027. }
  9028. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9029. /**
  9030. * Gets the horizontal scrollbar
  9031. */
  9032. get: function () {
  9033. return this._horizontalBar;
  9034. },
  9035. enumerable: true,
  9036. configurable: true
  9037. });
  9038. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9039. /**
  9040. * Gets the vertical scrollbar
  9041. */
  9042. get: function () {
  9043. return this._verticalBar;
  9044. },
  9045. enumerable: true,
  9046. configurable: true
  9047. });
  9048. /**
  9049. * Adds a new control to the current container
  9050. * @param control defines the control to add
  9051. * @returns the current container
  9052. */
  9053. ScrollViewer.prototype.addControl = function (control) {
  9054. if (!control) {
  9055. return this;
  9056. }
  9057. this._window.addControl(control);
  9058. return this;
  9059. };
  9060. /**
  9061. * Removes a control from the current container
  9062. * @param control defines the control to remove
  9063. * @returns the current container
  9064. */
  9065. ScrollViewer.prototype.removeControl = function (control) {
  9066. this._window.removeControl(control);
  9067. return this;
  9068. };
  9069. Object.defineProperty(ScrollViewer.prototype, "children", {
  9070. /** Gets the list of children */
  9071. get: function () {
  9072. return this._window.children;
  9073. },
  9074. enumerable: true,
  9075. configurable: true
  9076. });
  9077. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9078. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9079. var child = _a[_i];
  9080. child._markMatrixAsDirty();
  9081. }
  9082. };
  9083. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9084. /**
  9085. * Freezes or unfreezes the controls in the window.
  9086. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9087. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9088. */
  9089. get: function () {
  9090. return this._window.freezeControls;
  9091. },
  9092. set: function (value) {
  9093. this._window.freezeControls = value;
  9094. },
  9095. enumerable: true,
  9096. configurable: true
  9097. });
  9098. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9099. /** Gets the bucket width */
  9100. get: function () {
  9101. return this._window.bucketWidth;
  9102. },
  9103. enumerable: true,
  9104. configurable: true
  9105. });
  9106. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9107. /** Gets the bucket height */
  9108. get: function () {
  9109. return this._window.bucketHeight;
  9110. },
  9111. enumerable: true,
  9112. configurable: true
  9113. });
  9114. /**
  9115. * Sets the bucket sizes.
  9116. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9117. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9118. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9119. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9120. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9121. * used), that's why it is not enabled by default.
  9122. * @param width width of the bucket
  9123. * @param height height of the bucket
  9124. */
  9125. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9126. this._window.setBucketSizes(width, height);
  9127. };
  9128. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9129. /**
  9130. * Forces the horizontal scroll bar to be displayed
  9131. */
  9132. get: function () {
  9133. return this._forceHorizontalBar;
  9134. },
  9135. set: function (value) {
  9136. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9137. this._horizontalBar.isVisible = value;
  9138. this._forceHorizontalBar = value;
  9139. },
  9140. enumerable: true,
  9141. configurable: true
  9142. });
  9143. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9144. /**
  9145. * Forces the vertical scroll bar to be displayed
  9146. */
  9147. get: function () {
  9148. return this._forceVerticalBar;
  9149. },
  9150. set: function (value) {
  9151. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9152. this._verticalBar.isVisible = value;
  9153. this._forceVerticalBar = value;
  9154. },
  9155. enumerable: true,
  9156. configurable: true
  9157. });
  9158. /** Reset the scroll viewer window to initial size */
  9159. ScrollViewer.prototype.resetWindow = function () {
  9160. this._window.width = "100%";
  9161. this._window.height = "100%";
  9162. };
  9163. ScrollViewer.prototype._getTypeName = function () {
  9164. return "ScrollViewer";
  9165. };
  9166. ScrollViewer.prototype._buildClientSizes = function () {
  9167. var ratio = this.host.idealRatio;
  9168. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9169. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9170. this._clientWidth = this._window.parentClientWidth;
  9171. this._clientHeight = this._window.parentClientHeight;
  9172. };
  9173. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9174. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9175. this._buildClientSizes();
  9176. };
  9177. ScrollViewer.prototype._postMeasure = function () {
  9178. _super.prototype._postMeasure.call(this);
  9179. this._updateScroller();
  9180. };
  9181. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9182. /**
  9183. * Gets or sets the mouse wheel precision
  9184. * from 0 to 1 with a default value of 0.05
  9185. * */
  9186. get: function () {
  9187. return this._wheelPrecision;
  9188. },
  9189. set: function (value) {
  9190. if (this._wheelPrecision === value) {
  9191. return;
  9192. }
  9193. if (value < 0) {
  9194. value = 0;
  9195. }
  9196. if (value > 1) {
  9197. value = 1;
  9198. }
  9199. this._wheelPrecision = value;
  9200. },
  9201. enumerable: true,
  9202. configurable: true
  9203. });
  9204. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9205. /** Gets or sets the scroll bar container background color */
  9206. get: function () {
  9207. return this._horizontalBarSpace.background;
  9208. },
  9209. set: function (color) {
  9210. if (this._horizontalBarSpace.background === color) {
  9211. return;
  9212. }
  9213. this._horizontalBarSpace.background = color;
  9214. this._verticalBarSpace.background = color;
  9215. },
  9216. enumerable: true,
  9217. configurable: true
  9218. });
  9219. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9220. /** Gets or sets the bar color */
  9221. get: function () {
  9222. return this._barColor;
  9223. },
  9224. set: function (color) {
  9225. if (this._barColor === color) {
  9226. return;
  9227. }
  9228. this._barColor = color;
  9229. this._horizontalBar.color = color;
  9230. this._verticalBar.color = color;
  9231. },
  9232. enumerable: true,
  9233. configurable: true
  9234. });
  9235. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9236. /** Gets or sets the bar image */
  9237. get: function () {
  9238. return this._barImage;
  9239. },
  9240. set: function (value) {
  9241. if (this._barImage === value) {
  9242. return;
  9243. }
  9244. this._barImage = value;
  9245. var hb = this._horizontalBar;
  9246. var vb = this._verticalBar;
  9247. hb.thumbImage = value;
  9248. vb.thumbImage = value;
  9249. },
  9250. enumerable: true,
  9251. configurable: true
  9252. });
  9253. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9254. /** Gets or sets the horizontal bar image */
  9255. get: function () {
  9256. return this._horizontalBarImage;
  9257. },
  9258. set: function (value) {
  9259. if (this._horizontalBarImage === value) {
  9260. return;
  9261. }
  9262. this._horizontalBarImage = value;
  9263. var hb = this._horizontalBar;
  9264. hb.thumbImage = value;
  9265. },
  9266. enumerable: true,
  9267. configurable: true
  9268. });
  9269. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9270. /** Gets or sets the vertical bar image */
  9271. get: function () {
  9272. return this._verticalBarImage;
  9273. },
  9274. set: function (value) {
  9275. if (this._verticalBarImage === value) {
  9276. return;
  9277. }
  9278. this._verticalBarImage = value;
  9279. var vb = this._verticalBar;
  9280. vb.thumbImage = value;
  9281. },
  9282. enumerable: true,
  9283. configurable: true
  9284. });
  9285. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9286. /** Gets or sets the size of the bar */
  9287. get: function () {
  9288. return this._barSize;
  9289. },
  9290. set: function (value) {
  9291. if (this._barSize === value) {
  9292. return;
  9293. }
  9294. this._barSize = value;
  9295. this._markAsDirty();
  9296. if (this._horizontalBar.isVisible) {
  9297. this._grid.setRowDefinition(1, this._barSize, true);
  9298. }
  9299. if (this._verticalBar.isVisible) {
  9300. this._grid.setColumnDefinition(1, this._barSize, true);
  9301. }
  9302. },
  9303. enumerable: true,
  9304. configurable: true
  9305. });
  9306. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9307. /** Gets or sets the length of the thumb */
  9308. get: function () {
  9309. return this._thumbLength;
  9310. },
  9311. set: function (value) {
  9312. if (this._thumbLength === value) {
  9313. return;
  9314. }
  9315. if (value <= 0) {
  9316. value = 0.1;
  9317. }
  9318. if (value > 1) {
  9319. value = 1;
  9320. }
  9321. this._thumbLength = value;
  9322. var hb = this._horizontalBar;
  9323. var vb = this._verticalBar;
  9324. hb.thumbLength = value;
  9325. vb.thumbLength = value;
  9326. this._markAsDirty();
  9327. },
  9328. enumerable: true,
  9329. configurable: true
  9330. });
  9331. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9332. /** Gets or sets the height of the thumb */
  9333. get: function () {
  9334. return this._thumbHeight;
  9335. },
  9336. set: function (value) {
  9337. if (this._thumbHeight === value) {
  9338. return;
  9339. }
  9340. if (value <= 0) {
  9341. value = 0.1;
  9342. }
  9343. if (value > 1) {
  9344. value = 1;
  9345. }
  9346. this._thumbHeight = value;
  9347. var hb = this._horizontalBar;
  9348. var vb = this._verticalBar;
  9349. hb.thumbHeight = value;
  9350. vb.thumbHeight = value;
  9351. this._markAsDirty();
  9352. },
  9353. enumerable: true,
  9354. configurable: true
  9355. });
  9356. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9357. /** Gets or sets the height of the bar image */
  9358. get: function () {
  9359. return this._barImageHeight;
  9360. },
  9361. set: function (value) {
  9362. if (this._barImageHeight === value) {
  9363. return;
  9364. }
  9365. if (value <= 0) {
  9366. value = 0.1;
  9367. }
  9368. if (value > 1) {
  9369. value = 1;
  9370. }
  9371. this._barImageHeight = value;
  9372. var hb = this._horizontalBar;
  9373. var vb = this._verticalBar;
  9374. hb.barImageHeight = value;
  9375. vb.barImageHeight = value;
  9376. this._markAsDirty();
  9377. },
  9378. enumerable: true,
  9379. configurable: true
  9380. });
  9381. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9382. /** Gets or sets the height of the horizontal bar image */
  9383. get: function () {
  9384. return this._horizontalBarImageHeight;
  9385. },
  9386. set: function (value) {
  9387. if (this._horizontalBarImageHeight === value) {
  9388. return;
  9389. }
  9390. if (value <= 0) {
  9391. value = 0.1;
  9392. }
  9393. if (value > 1) {
  9394. value = 1;
  9395. }
  9396. this._horizontalBarImageHeight = value;
  9397. var hb = this._horizontalBar;
  9398. hb.barImageHeight = value;
  9399. this._markAsDirty();
  9400. },
  9401. enumerable: true,
  9402. configurable: true
  9403. });
  9404. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9405. /** Gets or sets the height of the vertical bar image */
  9406. get: function () {
  9407. return this._verticalBarImageHeight;
  9408. },
  9409. set: function (value) {
  9410. if (this._verticalBarImageHeight === value) {
  9411. return;
  9412. }
  9413. if (value <= 0) {
  9414. value = 0.1;
  9415. }
  9416. if (value > 1) {
  9417. value = 1;
  9418. }
  9419. this._verticalBarImageHeight = value;
  9420. var vb = this._verticalBar;
  9421. vb.barImageHeight = value;
  9422. this._markAsDirty();
  9423. },
  9424. enumerable: true,
  9425. configurable: true
  9426. });
  9427. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9428. /** Gets or sets the bar background */
  9429. get: function () {
  9430. return this._barBackground;
  9431. },
  9432. set: function (color) {
  9433. if (this._barBackground === color) {
  9434. return;
  9435. }
  9436. this._barBackground = color;
  9437. var hb = this._horizontalBar;
  9438. var vb = this._verticalBar;
  9439. hb.background = color;
  9440. vb.background = color;
  9441. this._dragSpace.background = color;
  9442. },
  9443. enumerable: true,
  9444. configurable: true
  9445. });
  9446. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9447. /** Gets or sets the bar background image */
  9448. get: function () {
  9449. return this._barBackgroundImage;
  9450. },
  9451. set: function (value) {
  9452. if (this._barBackgroundImage === value) {
  9453. }
  9454. this._barBackgroundImage = value;
  9455. var hb = this._horizontalBar;
  9456. var vb = this._verticalBar;
  9457. hb.backgroundImage = value;
  9458. vb.backgroundImage = value;
  9459. },
  9460. enumerable: true,
  9461. configurable: true
  9462. });
  9463. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9464. /** Gets or sets the horizontal bar background image */
  9465. get: function () {
  9466. return this._horizontalBarBackgroundImage;
  9467. },
  9468. set: function (value) {
  9469. if (this._horizontalBarBackgroundImage === value) {
  9470. }
  9471. this._horizontalBarBackgroundImage = value;
  9472. var hb = this._horizontalBar;
  9473. hb.backgroundImage = value;
  9474. },
  9475. enumerable: true,
  9476. configurable: true
  9477. });
  9478. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9479. /** Gets or sets the vertical bar background image */
  9480. get: function () {
  9481. return this._verticalBarBackgroundImage;
  9482. },
  9483. set: function (value) {
  9484. if (this._verticalBarBackgroundImage === value) {
  9485. }
  9486. this._verticalBarBackgroundImage = value;
  9487. var vb = this._verticalBar;
  9488. vb.backgroundImage = value;
  9489. },
  9490. enumerable: true,
  9491. configurable: true
  9492. });
  9493. ScrollViewer.prototype._setWindowPosition = function () {
  9494. var ratio = this.host.idealRatio;
  9495. var windowContentsWidth = this._window._currentMeasure.width;
  9496. var windowContentsHeight = this._window._currentMeasure.height;
  9497. var _endLeft = this._clientWidth - windowContentsWidth;
  9498. var _endTop = this._clientHeight - windowContentsHeight;
  9499. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9500. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9501. if (newLeft !== this._window.left) {
  9502. this._window.left = newLeft;
  9503. if (!this.freezeControls) {
  9504. this._rebuildLayout = true;
  9505. }
  9506. }
  9507. if (newTop !== this._window.top) {
  9508. this._window.top = newTop;
  9509. if (!this.freezeControls) {
  9510. this._rebuildLayout = true;
  9511. }
  9512. }
  9513. };
  9514. /** @hidden */
  9515. ScrollViewer.prototype._updateScroller = function () {
  9516. var windowContentsWidth = this._window._currentMeasure.width;
  9517. var windowContentsHeight = this._window._currentMeasure.height;
  9518. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9519. this._grid.setRowDefinition(1, 0, true);
  9520. this._horizontalBar.isVisible = false;
  9521. this._horizontalBar.value = 0;
  9522. this._rebuildLayout = true;
  9523. }
  9524. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9525. this._grid.setRowDefinition(1, this._barSize, true);
  9526. this._horizontalBar.isVisible = true;
  9527. this._rebuildLayout = true;
  9528. }
  9529. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9530. this._grid.setColumnDefinition(1, 0, true);
  9531. this._verticalBar.isVisible = false;
  9532. this._verticalBar.value = 0;
  9533. this._rebuildLayout = true;
  9534. }
  9535. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9536. this._grid.setColumnDefinition(1, this._barSize, true);
  9537. this._verticalBar.isVisible = true;
  9538. this._rebuildLayout = true;
  9539. }
  9540. this._buildClientSizes();
  9541. var ratio = this.host.idealRatio;
  9542. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9543. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9544. };
  9545. ScrollViewer.prototype._link = function (host) {
  9546. _super.prototype._link.call(this, host);
  9547. this._attachWheel();
  9548. };
  9549. /** @hidden */
  9550. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9551. var _this = this;
  9552. barControl.paddingLeft = 0;
  9553. barControl.width = "100%";
  9554. barControl.height = "100%";
  9555. barControl.barOffset = 0;
  9556. barControl.value = 0;
  9557. barControl.maximum = 1;
  9558. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9559. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9560. barControl.isVertical = isVertical;
  9561. barControl.rotation = rotation;
  9562. barControl.isVisible = false;
  9563. barContainer.addControl(barControl);
  9564. barControl.onValueChangedObservable.add(function (value) {
  9565. _this._setWindowPosition();
  9566. });
  9567. };
  9568. /** @hidden */
  9569. ScrollViewer.prototype._attachWheel = function () {
  9570. var _this = this;
  9571. if (!this._host || this._onPointerObserver) {
  9572. return;
  9573. }
  9574. var scene = this._host.getScene();
  9575. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9576. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9577. return;
  9578. }
  9579. if (_this._verticalBar.isVisible == true) {
  9580. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9581. _this._verticalBar.value -= _this._wheelPrecision;
  9582. }
  9583. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9584. _this._verticalBar.value += _this._wheelPrecision;
  9585. }
  9586. }
  9587. if (_this._horizontalBar.isVisible == true) {
  9588. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9589. _this._horizontalBar.value += _this._wheelPrecision;
  9590. }
  9591. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9592. _this._horizontalBar.value -= _this._wheelPrecision;
  9593. }
  9594. }
  9595. });
  9596. };
  9597. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9598. if (!this.isHighlighted) {
  9599. return;
  9600. }
  9601. _super.prototype._renderHighlightSpecific.call(this, context);
  9602. this._grid._renderHighlightSpecific(context);
  9603. context.restore();
  9604. };
  9605. /** Releases associated resources */
  9606. ScrollViewer.prototype.dispose = function () {
  9607. var scene = this._host.getScene();
  9608. if (scene && this._onPointerObserver) {
  9609. scene.onPointerObservable.remove(this._onPointerObserver);
  9610. this._onPointerObserver = null;
  9611. }
  9612. _super.prototype.dispose.call(this);
  9613. };
  9614. return ScrollViewer;
  9615. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9616. babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9617. /***/ }),
  9618. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9619. /*!*********************************************************!*\
  9620. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9621. \*********************************************************/
  9622. /*! exports provided: _ScrollViewerWindow */
  9623. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9624. "use strict";
  9625. __webpack_require__.r(__webpack_exports__);
  9626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9627. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9628. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9629. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9630. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9631. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9632. /**
  9633. * Class used to hold a the container for ScrollViewer
  9634. * @hidden
  9635. */
  9636. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9637. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9638. /**
  9639. * Creates a new ScrollViewerWindow
  9640. * @param name of ScrollViewerWindow
  9641. */
  9642. function _ScrollViewerWindow(name) {
  9643. var _this = _super.call(this, name) || this;
  9644. _this._freezeControls = false;
  9645. _this._bucketWidth = 0;
  9646. _this._bucketHeight = 0;
  9647. _this._buckets = {};
  9648. return _this;
  9649. }
  9650. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9651. get: function () {
  9652. return this._freezeControls;
  9653. },
  9654. set: function (value) {
  9655. if (this._freezeControls === value) {
  9656. return;
  9657. }
  9658. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9659. this._freezeControls = false;
  9660. var textureSize = this.host.getSize();
  9661. var renderWidth = textureSize.width;
  9662. var renderHeight = textureSize.height;
  9663. var context = this.host.getContext();
  9664. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9665. this.host._numLayoutCalls = 0;
  9666. this.host._rootContainer._layout(measure, context);
  9667. // in freeze mode, prepare children measures accordingly
  9668. if (value) {
  9669. this._updateMeasures();
  9670. if (this._useBuckets()) {
  9671. this._makeBuckets();
  9672. }
  9673. }
  9674. this._freezeControls = value;
  9675. this.host.markAsDirty(); // redraw with the (new) current settings
  9676. },
  9677. enumerable: true,
  9678. configurable: true
  9679. });
  9680. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9681. get: function () {
  9682. return this._bucketWidth;
  9683. },
  9684. enumerable: true,
  9685. configurable: true
  9686. });
  9687. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9688. get: function () {
  9689. return this._bucketHeight;
  9690. },
  9691. enumerable: true,
  9692. configurable: true
  9693. });
  9694. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9695. this._bucketWidth = width;
  9696. this._bucketHeight = height;
  9697. if (this._useBuckets()) {
  9698. if (this._freezeControls) {
  9699. this._makeBuckets();
  9700. }
  9701. }
  9702. else {
  9703. this._buckets = {};
  9704. }
  9705. };
  9706. _ScrollViewerWindow.prototype._useBuckets = function () {
  9707. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9708. };
  9709. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9710. this._buckets = {};
  9711. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9712. this._dispatchInBuckets(this._children);
  9713. };
  9714. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9715. for (var i = 0; i < children.length; ++i) {
  9716. var child = children[i];
  9717. var bStartX = Math.max(0, Math.floor((child._currentMeasure.left - this._currentMeasure.left) / this._bucketWidth)), bEndX = Math.floor((child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width - 1) / this._bucketWidth), bStartY = Math.max(0, Math.floor((child._currentMeasure.top - this._currentMeasure.top) / this._bucketHeight)), bEndY = Math.floor((child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height - 1) / this._bucketHeight);
  9718. while (bStartY <= bEndY) {
  9719. for (var x = bStartX; x <= bEndX; ++x) {
  9720. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9721. if (!lstc) {
  9722. lstc = [];
  9723. this._buckets[bucket] = lstc;
  9724. }
  9725. lstc.push(child);
  9726. }
  9727. bStartY++;
  9728. }
  9729. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9730. this._dispatchInBuckets(child._children);
  9731. }
  9732. }
  9733. };
  9734. // reset left and top measures for the window and all its children
  9735. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9736. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9737. this._measureForChildren.left -= left;
  9738. this._measureForChildren.top -= top;
  9739. this._currentMeasure.left -= left;
  9740. this._currentMeasure.top -= top;
  9741. this._updateChildrenMeasures(this._children, left, top);
  9742. };
  9743. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9744. for (var i = 0; i < children.length; ++i) {
  9745. var child = children[i];
  9746. child._currentMeasure.left -= left;
  9747. child._currentMeasure.top -= top;
  9748. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9749. child._customData._origTop = child._currentMeasure.top;
  9750. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9751. this._updateChildrenMeasures(child._children, left, top);
  9752. }
  9753. }
  9754. };
  9755. _ScrollViewerWindow.prototype._getTypeName = function () {
  9756. return "ScrollViewerWindow";
  9757. };
  9758. /** @hidden */
  9759. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9760. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9761. this._parentMeasure = parentMeasure;
  9762. this._measureForChildren.left = this._currentMeasure.left;
  9763. this._measureForChildren.top = this._currentMeasure.top;
  9764. this._measureForChildren.width = parentMeasure.width;
  9765. this._measureForChildren.height = parentMeasure.height;
  9766. };
  9767. /** @hidden */
  9768. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9769. if (this._freezeControls) {
  9770. this.invalidateRect(); // will trigger a redraw of the window
  9771. return false;
  9772. }
  9773. return _super.prototype._layout.call(this, parentMeasure, context);
  9774. };
  9775. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9776. for (var i = 0; i < children.length; ++i) {
  9777. var child = children[i];
  9778. child._currentMeasure.left = child._customData._origLeft + left;
  9779. child._currentMeasure.top = child._customData._origTop + top;
  9780. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9781. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9782. this._scrollChildren(child._children, left, top);
  9783. }
  9784. }
  9785. };
  9786. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9787. var bStartX = Math.max(0, Math.floor(-left / this._bucketWidth)), bEndX = Math.floor((-left + this._parentMeasure.width - 1) / this._bucketWidth), bStartY = Math.max(0, Math.floor(-top / this._bucketHeight)), bEndY = Math.floor((-top + this._parentMeasure.height - 1) / this._bucketHeight);
  9788. while (bStartY <= bEndY) {
  9789. for (var x = bStartX; x <= bEndX; ++x) {
  9790. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9791. if (lstc) {
  9792. for (var i = 0; i < lstc.length; ++i) {
  9793. var child = lstc[i];
  9794. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9795. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9796. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9797. }
  9798. }
  9799. }
  9800. bStartY++;
  9801. }
  9802. };
  9803. /** @hidden */
  9804. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9805. if (!this._freezeControls) {
  9806. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9807. return;
  9808. }
  9809. this._localDraw(context);
  9810. if (this.clipChildren) {
  9811. this._clipForChildren(context);
  9812. }
  9813. var left = this.leftInPixels, top = this.topInPixels;
  9814. if (this._useBuckets()) {
  9815. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  9816. this._scrollChildrenWithBuckets(left, top, left, top);
  9817. }
  9818. else {
  9819. this._scrollChildren(this._children, left, top);
  9820. }
  9821. this._oldLeft = left;
  9822. this._oldTop = top;
  9823. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9824. var child = _a[_i];
  9825. if (!child._intersectsRect(this._parentMeasure)) {
  9826. continue;
  9827. }
  9828. child._render(context, this._parentMeasure);
  9829. }
  9830. };
  9831. _ScrollViewerWindow.prototype._postMeasure = function () {
  9832. if (this._freezeControls) {
  9833. _super.prototype._postMeasure.call(this);
  9834. return;
  9835. }
  9836. var maxWidth = this.parentClientWidth;
  9837. var maxHeight = this.parentClientHeight;
  9838. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9839. var child = _a[_i];
  9840. if (!child.isVisible || child.notRenderable) {
  9841. continue;
  9842. }
  9843. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9844. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9845. }
  9846. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9847. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9848. }
  9849. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9850. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9851. }
  9852. if (this._currentMeasure.width !== maxWidth) {
  9853. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9854. this._currentMeasure.width = maxWidth;
  9855. this._rebuildLayout = true;
  9856. this._isDirty = true;
  9857. }
  9858. if (this._currentMeasure.height !== maxHeight) {
  9859. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9860. this._currentMeasure.height = maxHeight;
  9861. this._rebuildLayout = true;
  9862. this._isDirty = true;
  9863. }
  9864. _super.prototype._postMeasure.call(this);
  9865. };
  9866. return _ScrollViewerWindow;
  9867. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  9868. /***/ }),
  9869. /***/ "./2D/controls/selector.ts":
  9870. /*!*********************************!*\
  9871. !*** ./2D/controls/selector.ts ***!
  9872. \*********************************/
  9873. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9874. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9875. "use strict";
  9876. __webpack_require__.r(__webpack_exports__);
  9877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9878. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9881. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9882. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9883. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9884. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9885. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9886. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9887. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9888. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9889. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9890. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9891. /** Class used to create a RadioGroup
  9892. * which contains groups of radio buttons
  9893. */
  9894. var SelectorGroup = /** @class */ (function () {
  9895. /**
  9896. * Creates a new SelectorGroup
  9897. * @param name of group, used as a group heading
  9898. */
  9899. function SelectorGroup(
  9900. /** name of SelectorGroup */
  9901. name) {
  9902. this.name = name;
  9903. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9904. this._selectors = new Array();
  9905. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9906. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9907. this._groupHeader = this._addGroupHeader(name);
  9908. }
  9909. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9910. /** Gets the groupPanel of the SelectorGroup */
  9911. get: function () {
  9912. return this._groupPanel;
  9913. },
  9914. enumerable: true,
  9915. configurable: true
  9916. });
  9917. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9918. /** Gets the selectors array */
  9919. get: function () {
  9920. return this._selectors;
  9921. },
  9922. enumerable: true,
  9923. configurable: true
  9924. });
  9925. Object.defineProperty(SelectorGroup.prototype, "header", {
  9926. /** Gets and sets the group header */
  9927. get: function () {
  9928. return this._groupHeader.text;
  9929. },
  9930. set: function (label) {
  9931. if (this._groupHeader.text === "label") {
  9932. return;
  9933. }
  9934. this._groupHeader.text = label;
  9935. },
  9936. enumerable: true,
  9937. configurable: true
  9938. });
  9939. /** @hidden */
  9940. SelectorGroup.prototype._addGroupHeader = function (text) {
  9941. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9942. groupHeading.width = 0.9;
  9943. groupHeading.height = "30px";
  9944. groupHeading.textWrapping = true;
  9945. groupHeading.color = "black";
  9946. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9947. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9948. groupHeading.left = "2px";
  9949. this._groupPanel.addControl(groupHeading);
  9950. return groupHeading;
  9951. };
  9952. /** @hidden*/
  9953. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9954. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9955. return;
  9956. }
  9957. return this._selectors[selectorNb];
  9958. };
  9959. /** Removes the selector at the given position
  9960. * @param selectorNb the position of the selector within the group
  9961. */
  9962. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9963. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9964. return;
  9965. }
  9966. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9967. this._selectors.splice(selectorNb, 1);
  9968. };
  9969. return SelectorGroup;
  9970. }());
  9971. /** Class used to create a CheckboxGroup
  9972. * which contains groups of checkbox buttons
  9973. */
  9974. var CheckboxGroup = /** @class */ (function (_super) {
  9975. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  9976. function CheckboxGroup() {
  9977. return _super !== null && _super.apply(this, arguments) || this;
  9978. }
  9979. /** Adds a checkbox as a control
  9980. * @param text is the label for the selector
  9981. * @param func is the function called when the Selector is checked
  9982. * @param checked is true when Selector is checked
  9983. */
  9984. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9985. if (func === void 0) { func = function (s) { }; }
  9986. if (checked === void 0) { checked = false; }
  9987. var checked = checked || false;
  9988. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9989. button.width = "20px";
  9990. button.height = "20px";
  9991. button.color = "#364249";
  9992. button.background = "#CCCCCC";
  9993. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9994. button.onIsCheckedChangedObservable.add(function (state) {
  9995. func(state);
  9996. });
  9997. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9998. _selector.height = "30px";
  9999. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10000. _selector.left = "4px";
  10001. this.groupPanel.addControl(_selector);
  10002. this.selectors.push(_selector);
  10003. button.isChecked = checked;
  10004. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10005. button.color = this.groupPanel.parent.parent.buttonColor;
  10006. button.background = this.groupPanel.parent.parent.buttonBackground;
  10007. }
  10008. };
  10009. /** @hidden */
  10010. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10011. this.selectors[selectorNb].children[1].text = label;
  10012. };
  10013. /** @hidden */
  10014. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10015. this.selectors[selectorNb].children[1].color = color;
  10016. };
  10017. /** @hidden */
  10018. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10019. this.selectors[selectorNb].children[0].color = color;
  10020. };
  10021. /** @hidden */
  10022. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10023. this.selectors[selectorNb].children[0].background = color;
  10024. };
  10025. return CheckboxGroup;
  10026. }(SelectorGroup));
  10027. /** Class used to create a RadioGroup
  10028. * which contains groups of radio buttons
  10029. */
  10030. var RadioGroup = /** @class */ (function (_super) {
  10031. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10032. function RadioGroup() {
  10033. var _this = _super !== null && _super.apply(this, arguments) || this;
  10034. _this._selectNb = 0;
  10035. return _this;
  10036. }
  10037. /** Adds a radio button as a control
  10038. * @param label is the label for the selector
  10039. * @param func is the function called when the Selector is checked
  10040. * @param checked is true when Selector is checked
  10041. */
  10042. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10043. if (func === void 0) { func = function (n) { }; }
  10044. if (checked === void 0) { checked = false; }
  10045. var nb = this._selectNb++;
  10046. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10047. button.name = label;
  10048. button.width = "20px";
  10049. button.height = "20px";
  10050. button.color = "#364249";
  10051. button.background = "#CCCCCC";
  10052. button.group = this.name;
  10053. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10054. button.onIsCheckedChangedObservable.add(function (state) {
  10055. if (state) {
  10056. func(nb);
  10057. }
  10058. });
  10059. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10060. _selector.height = "30px";
  10061. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10062. _selector.left = "4px";
  10063. this.groupPanel.addControl(_selector);
  10064. this.selectors.push(_selector);
  10065. button.isChecked = checked;
  10066. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10067. button.color = this.groupPanel.parent.parent.buttonColor;
  10068. button.background = this.groupPanel.parent.parent.buttonBackground;
  10069. }
  10070. };
  10071. /** @hidden */
  10072. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10073. this.selectors[selectorNb].children[1].text = label;
  10074. };
  10075. /** @hidden */
  10076. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10077. this.selectors[selectorNb].children[1].color = color;
  10078. };
  10079. /** @hidden */
  10080. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10081. this.selectors[selectorNb].children[0].color = color;
  10082. };
  10083. /** @hidden */
  10084. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10085. this.selectors[selectorNb].children[0].background = color;
  10086. };
  10087. return RadioGroup;
  10088. }(SelectorGroup));
  10089. /** Class used to create a SliderGroup
  10090. * which contains groups of slider buttons
  10091. */
  10092. var SliderGroup = /** @class */ (function (_super) {
  10093. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10094. function SliderGroup() {
  10095. return _super !== null && _super.apply(this, arguments) || this;
  10096. }
  10097. /**
  10098. * Adds a slider to the SelectorGroup
  10099. * @param label is the label for the SliderBar
  10100. * @param func is the function called when the Slider moves
  10101. * @param unit is a string describing the units used, eg degrees or metres
  10102. * @param min is the minimum value for the Slider
  10103. * @param max is the maximum value for the Slider
  10104. * @param value is the start value for the Slider between min and max
  10105. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10106. */
  10107. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10108. if (func === void 0) { func = function (v) { }; }
  10109. if (unit === void 0) { unit = "Units"; }
  10110. if (min === void 0) { min = 0; }
  10111. if (max === void 0) { max = 0; }
  10112. if (value === void 0) { value = 0; }
  10113. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10114. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10115. button.name = unit;
  10116. button.value = value;
  10117. button.minimum = min;
  10118. button.maximum = max;
  10119. button.width = 0.9;
  10120. button.height = "20px";
  10121. button.color = "#364249";
  10122. button.background = "#CCCCCC";
  10123. button.borderColor = "black";
  10124. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10125. button.left = "4px";
  10126. button.paddingBottom = "4px";
  10127. button.onValueChangedObservable.add(function (value) {
  10128. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10129. func(value);
  10130. });
  10131. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10132. _selector.height = "60px";
  10133. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10134. _selector.left = "4px";
  10135. _selector.children[0].name = label;
  10136. this.groupPanel.addControl(_selector);
  10137. this.selectors.push(_selector);
  10138. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10139. button.color = this.groupPanel.parent.parent.buttonColor;
  10140. button.background = this.groupPanel.parent.parent.buttonBackground;
  10141. }
  10142. };
  10143. /** @hidden */
  10144. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10145. this.selectors[selectorNb].children[0].name = label;
  10146. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10147. };
  10148. /** @hidden */
  10149. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10150. this.selectors[selectorNb].children[0].color = color;
  10151. };
  10152. /** @hidden */
  10153. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10154. this.selectors[selectorNb].children[1].color = color;
  10155. };
  10156. /** @hidden */
  10157. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10158. this.selectors[selectorNb].children[1].background = color;
  10159. };
  10160. return SliderGroup;
  10161. }(SelectorGroup));
  10162. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10163. * @see http://doc.babylonjs.com/how_to/selector
  10164. */
  10165. var SelectionPanel = /** @class */ (function (_super) {
  10166. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10167. /**
  10168. * Creates a new SelectionPanel
  10169. * @param name of SelectionPanel
  10170. * @param groups is an array of SelectionGroups
  10171. */
  10172. function SelectionPanel(
  10173. /** name of SelectionPanel */
  10174. name,
  10175. /** an array of SelectionGroups */
  10176. groups) {
  10177. if (groups === void 0) { groups = []; }
  10178. var _this = _super.call(this, name) || this;
  10179. _this.name = name;
  10180. _this.groups = groups;
  10181. _this._buttonColor = "#364249";
  10182. _this._buttonBackground = "#CCCCCC";
  10183. _this._headerColor = "black";
  10184. _this._barColor = "white";
  10185. _this._barHeight = "2px";
  10186. _this._spacerHeight = "20px";
  10187. _this._bars = new Array();
  10188. _this._groups = groups;
  10189. _this.thickness = 2;
  10190. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10191. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10192. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10193. _this._panel.top = 5;
  10194. _this._panel.left = 5;
  10195. _this._panel.width = 0.95;
  10196. if (groups.length > 0) {
  10197. for (var i = 0; i < groups.length - 1; i++) {
  10198. _this._panel.addControl(groups[i].groupPanel);
  10199. _this._addSpacer();
  10200. }
  10201. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10202. }
  10203. _this.addControl(_this._panel);
  10204. return _this;
  10205. }
  10206. SelectionPanel.prototype._getTypeName = function () {
  10207. return "SelectionPanel";
  10208. };
  10209. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10210. /** Gets or sets the headerColor */
  10211. get: function () {
  10212. return this._headerColor;
  10213. },
  10214. set: function (color) {
  10215. if (this._headerColor === color) {
  10216. return;
  10217. }
  10218. this._headerColor = color;
  10219. this._setHeaderColor();
  10220. },
  10221. enumerable: true,
  10222. configurable: true
  10223. });
  10224. SelectionPanel.prototype._setHeaderColor = function () {
  10225. for (var i = 0; i < this._groups.length; i++) {
  10226. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10227. }
  10228. };
  10229. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10230. /** Gets or sets the button color */
  10231. get: function () {
  10232. return this._buttonColor;
  10233. },
  10234. set: function (color) {
  10235. if (this._buttonColor === color) {
  10236. return;
  10237. }
  10238. this._buttonColor = color;
  10239. this._setbuttonColor();
  10240. },
  10241. enumerable: true,
  10242. configurable: true
  10243. });
  10244. SelectionPanel.prototype._setbuttonColor = function () {
  10245. for (var i = 0; i < this._groups.length; i++) {
  10246. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10247. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10248. }
  10249. }
  10250. };
  10251. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10252. /** Gets or sets the label color */
  10253. get: function () {
  10254. return this._labelColor;
  10255. },
  10256. set: function (color) {
  10257. if (this._labelColor === color) {
  10258. return;
  10259. }
  10260. this._labelColor = color;
  10261. this._setLabelColor();
  10262. },
  10263. enumerable: true,
  10264. configurable: true
  10265. });
  10266. SelectionPanel.prototype._setLabelColor = function () {
  10267. for (var i = 0; i < this._groups.length; i++) {
  10268. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10269. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10270. }
  10271. }
  10272. };
  10273. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10274. /** Gets or sets the button background */
  10275. get: function () {
  10276. return this._buttonBackground;
  10277. },
  10278. set: function (color) {
  10279. if (this._buttonBackground === color) {
  10280. return;
  10281. }
  10282. this._buttonBackground = color;
  10283. this._setButtonBackground();
  10284. },
  10285. enumerable: true,
  10286. configurable: true
  10287. });
  10288. SelectionPanel.prototype._setButtonBackground = function () {
  10289. for (var i = 0; i < this._groups.length; i++) {
  10290. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10291. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10292. }
  10293. }
  10294. };
  10295. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10296. /** Gets or sets the color of separator bar */
  10297. get: function () {
  10298. return this._barColor;
  10299. },
  10300. set: function (color) {
  10301. if (this._barColor === color) {
  10302. return;
  10303. }
  10304. this._barColor = color;
  10305. this._setBarColor();
  10306. },
  10307. enumerable: true,
  10308. configurable: true
  10309. });
  10310. SelectionPanel.prototype._setBarColor = function () {
  10311. for (var i = 0; i < this._bars.length; i++) {
  10312. this._bars[i].children[0].background = this._barColor;
  10313. }
  10314. };
  10315. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10316. /** Gets or sets the height of separator bar */
  10317. get: function () {
  10318. return this._barHeight;
  10319. },
  10320. set: function (value) {
  10321. if (this._barHeight === value) {
  10322. return;
  10323. }
  10324. this._barHeight = value;
  10325. this._setBarHeight();
  10326. },
  10327. enumerable: true,
  10328. configurable: true
  10329. });
  10330. SelectionPanel.prototype._setBarHeight = function () {
  10331. for (var i = 0; i < this._bars.length; i++) {
  10332. this._bars[i].children[0].height = this._barHeight;
  10333. }
  10334. };
  10335. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10336. /** Gets or sets the height of spacers*/
  10337. get: function () {
  10338. return this._spacerHeight;
  10339. },
  10340. set: function (value) {
  10341. if (this._spacerHeight === value) {
  10342. return;
  10343. }
  10344. this._spacerHeight = value;
  10345. this._setSpacerHeight();
  10346. },
  10347. enumerable: true,
  10348. configurable: true
  10349. });
  10350. SelectionPanel.prototype._setSpacerHeight = function () {
  10351. for (var i = 0; i < this._bars.length; i++) {
  10352. this._bars[i].height = this._spacerHeight;
  10353. }
  10354. };
  10355. /** Adds a bar between groups */
  10356. SelectionPanel.prototype._addSpacer = function () {
  10357. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10358. separator.width = 1;
  10359. separator.height = this._spacerHeight;
  10360. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10361. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10362. bar.width = 1;
  10363. bar.height = this._barHeight;
  10364. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10365. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10366. bar.background = this._barColor;
  10367. bar.color = "transparent";
  10368. separator.addControl(bar);
  10369. this._panel.addControl(separator);
  10370. this._bars.push(separator);
  10371. };
  10372. /** Add a group to the selection panel
  10373. * @param group is the selector group to add
  10374. */
  10375. SelectionPanel.prototype.addGroup = function (group) {
  10376. if (this._groups.length > 0) {
  10377. this._addSpacer();
  10378. }
  10379. this._panel.addControl(group.groupPanel);
  10380. this._groups.push(group);
  10381. group.groupPanel.children[0].color = this._headerColor;
  10382. for (var j = 0; j < group.selectors.length; j++) {
  10383. group._setSelectorButtonColor(j, this._buttonColor);
  10384. group._setSelectorButtonBackground(j, this._buttonBackground);
  10385. }
  10386. };
  10387. /** Remove the group from the given position
  10388. * @param groupNb is the position of the group in the list
  10389. */
  10390. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10391. if (groupNb < 0 || groupNb >= this._groups.length) {
  10392. return;
  10393. }
  10394. var group = this._groups[groupNb];
  10395. this._panel.removeControl(group.groupPanel);
  10396. this._groups.splice(groupNb, 1);
  10397. if (groupNb < this._bars.length) {
  10398. this._panel.removeControl(this._bars[groupNb]);
  10399. this._bars.splice(groupNb, 1);
  10400. }
  10401. };
  10402. /** Change a group header label
  10403. * @param label is the new group header label
  10404. * @param groupNb is the number of the group to relabel
  10405. * */
  10406. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10407. if (groupNb < 0 || groupNb >= this._groups.length) {
  10408. return;
  10409. }
  10410. var group = this._groups[groupNb];
  10411. group.groupPanel.children[0].text = label;
  10412. };
  10413. /** Change selector label to the one given
  10414. * @param label is the new selector label
  10415. * @param groupNb is the number of the groupcontaining the selector
  10416. * @param selectorNb is the number of the selector within a group to relabel
  10417. * */
  10418. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10419. if (groupNb < 0 || groupNb >= this._groups.length) {
  10420. return;
  10421. }
  10422. var group = this._groups[groupNb];
  10423. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10424. return;
  10425. }
  10426. group._setSelectorLabel(selectorNb, label);
  10427. };
  10428. /** For a given group position remove the selector at the given position
  10429. * @param groupNb is the number of the group to remove the selector from
  10430. * @param selectorNb is the number of the selector within the group
  10431. */
  10432. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10433. if (groupNb < 0 || groupNb >= this._groups.length) {
  10434. return;
  10435. }
  10436. var group = this._groups[groupNb];
  10437. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10438. return;
  10439. }
  10440. group.removeSelector(selectorNb);
  10441. };
  10442. /** For a given group position of correct type add a checkbox button
  10443. * @param groupNb is the number of the group to remove the selector from
  10444. * @param label is the label for the selector
  10445. * @param func is the function called when the Selector is checked
  10446. * @param checked is true when Selector is checked
  10447. */
  10448. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10449. if (func === void 0) { func = function () { }; }
  10450. if (checked === void 0) { checked = false; }
  10451. if (groupNb < 0 || groupNb >= this._groups.length) {
  10452. return;
  10453. }
  10454. var group = this._groups[groupNb];
  10455. group.addCheckbox(label, func, checked);
  10456. };
  10457. /** For a given group position of correct type add a radio button
  10458. * @param groupNb is the number of the group to remove the selector from
  10459. * @param label is the label for the selector
  10460. * @param func is the function called when the Selector is checked
  10461. * @param checked is true when Selector is checked
  10462. */
  10463. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10464. if (func === void 0) { func = function () { }; }
  10465. if (checked === void 0) { checked = false; }
  10466. if (groupNb < 0 || groupNb >= this._groups.length) {
  10467. return;
  10468. }
  10469. var group = this._groups[groupNb];
  10470. group.addRadio(label, func, checked);
  10471. };
  10472. /**
  10473. * For a given slider group add a slider
  10474. * @param groupNb is the number of the group to add the slider to
  10475. * @param label is the label for the Slider
  10476. * @param func is the function called when the Slider moves
  10477. * @param unit is a string describing the units used, eg degrees or metres
  10478. * @param min is the minimum value for the Slider
  10479. * @param max is the maximum value for the Slider
  10480. * @param value is the start value for the Slider between min and max
  10481. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10482. */
  10483. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10484. if (func === void 0) { func = function () { }; }
  10485. if (unit === void 0) { unit = "Units"; }
  10486. if (min === void 0) { min = 0; }
  10487. if (max === void 0) { max = 0; }
  10488. if (value === void 0) { value = 0; }
  10489. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10490. if (groupNb < 0 || groupNb >= this._groups.length) {
  10491. return;
  10492. }
  10493. var group = this._groups[groupNb];
  10494. group.addSlider(label, func, unit, min, max, value, onVal);
  10495. };
  10496. return SelectionPanel;
  10497. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10498. /***/ }),
  10499. /***/ "./2D/controls/sliders/baseSlider.ts":
  10500. /*!*******************************************!*\
  10501. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10502. \*******************************************/
  10503. /*! exports provided: BaseSlider */
  10504. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10505. "use strict";
  10506. __webpack_require__.r(__webpack_exports__);
  10507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10508. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10509. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  10510. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10511. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10512. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10513. /**
  10514. * Class used to create slider controls
  10515. */
  10516. var BaseSlider = /** @class */ (function (_super) {
  10517. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10518. /**
  10519. * Creates a new BaseSlider
  10520. * @param name defines the control name
  10521. */
  10522. function BaseSlider(name) {
  10523. var _this = _super.call(this, name) || this;
  10524. _this.name = name;
  10525. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10526. _this._minimum = 0;
  10527. _this._maximum = 100;
  10528. _this._value = 50;
  10529. _this._isVertical = false;
  10530. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10531. _this._isThumbClamped = false;
  10532. _this._displayThumb = true;
  10533. _this._step = 0;
  10534. _this._lastPointerDownID = -1;
  10535. // Shared rendering info
  10536. _this._effectiveBarOffset = 0;
  10537. /** Observable raised when the sldier value changes */
  10538. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10539. // Events
  10540. _this._pointerIsDown = false;
  10541. _this.isPointerBlocker = true;
  10542. return _this;
  10543. }
  10544. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10545. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10546. get: function () {
  10547. return this._displayThumb;
  10548. },
  10549. set: function (value) {
  10550. if (this._displayThumb === value) {
  10551. return;
  10552. }
  10553. this._displayThumb = value;
  10554. this._markAsDirty();
  10555. },
  10556. enumerable: true,
  10557. configurable: true
  10558. });
  10559. Object.defineProperty(BaseSlider.prototype, "step", {
  10560. /** Gets or sets a step to apply to values (0 by default) */
  10561. get: function () {
  10562. return this._step;
  10563. },
  10564. set: function (value) {
  10565. if (this._step === value) {
  10566. return;
  10567. }
  10568. this._step = value;
  10569. this._markAsDirty();
  10570. },
  10571. enumerable: true,
  10572. configurable: true
  10573. });
  10574. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10575. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10576. get: function () {
  10577. return this._barOffset.toString(this._host);
  10578. },
  10579. set: function (value) {
  10580. if (this._barOffset.toString(this._host) === value) {
  10581. return;
  10582. }
  10583. if (this._barOffset.fromString(value)) {
  10584. this._markAsDirty();
  10585. }
  10586. },
  10587. enumerable: true,
  10588. configurable: true
  10589. });
  10590. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10591. /** Gets main bar offset in pixels*/
  10592. get: function () {
  10593. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10594. },
  10595. enumerable: true,
  10596. configurable: true
  10597. });
  10598. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10599. /** Gets or sets thumb width */
  10600. get: function () {
  10601. return this._thumbWidth.toString(this._host);
  10602. },
  10603. set: function (value) {
  10604. if (this._thumbWidth.toString(this._host) === value) {
  10605. return;
  10606. }
  10607. if (this._thumbWidth.fromString(value)) {
  10608. this._markAsDirty();
  10609. }
  10610. },
  10611. enumerable: true,
  10612. configurable: true
  10613. });
  10614. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10615. /** Gets thumb width in pixels */
  10616. get: function () {
  10617. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10618. },
  10619. enumerable: true,
  10620. configurable: true
  10621. });
  10622. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10623. /** Gets or sets minimum value */
  10624. get: function () {
  10625. return this._minimum;
  10626. },
  10627. set: function (value) {
  10628. if (this._minimum === value) {
  10629. return;
  10630. }
  10631. this._minimum = value;
  10632. this._markAsDirty();
  10633. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10634. },
  10635. enumerable: true,
  10636. configurable: true
  10637. });
  10638. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10639. /** Gets or sets maximum value */
  10640. get: function () {
  10641. return this._maximum;
  10642. },
  10643. set: function (value) {
  10644. if (this._maximum === value) {
  10645. return;
  10646. }
  10647. this._maximum = value;
  10648. this._markAsDirty();
  10649. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10650. },
  10651. enumerable: true,
  10652. configurable: true
  10653. });
  10654. Object.defineProperty(BaseSlider.prototype, "value", {
  10655. /** Gets or sets current value */
  10656. get: function () {
  10657. return this._value;
  10658. },
  10659. set: function (value) {
  10660. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10661. if (this._value === value) {
  10662. return;
  10663. }
  10664. this._value = value;
  10665. this._markAsDirty();
  10666. this.onValueChangedObservable.notifyObservers(this._value);
  10667. },
  10668. enumerable: true,
  10669. configurable: true
  10670. });
  10671. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10672. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10673. get: function () {
  10674. return this._isVertical;
  10675. },
  10676. set: function (value) {
  10677. if (this._isVertical === value) {
  10678. return;
  10679. }
  10680. this._isVertical = value;
  10681. this._markAsDirty();
  10682. },
  10683. enumerable: true,
  10684. configurable: true
  10685. });
  10686. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10687. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10688. get: function () {
  10689. return this._isThumbClamped;
  10690. },
  10691. set: function (value) {
  10692. if (this._isThumbClamped === value) {
  10693. return;
  10694. }
  10695. this._isThumbClamped = value;
  10696. this._markAsDirty();
  10697. },
  10698. enumerable: true,
  10699. configurable: true
  10700. });
  10701. BaseSlider.prototype._getTypeName = function () {
  10702. return "BaseSlider";
  10703. };
  10704. BaseSlider.prototype._getThumbPosition = function () {
  10705. if (this.isVertical) {
  10706. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10707. }
  10708. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10709. };
  10710. BaseSlider.prototype._getThumbThickness = function (type) {
  10711. var thumbThickness = 0;
  10712. switch (type) {
  10713. case "circle":
  10714. if (this._thumbWidth.isPixel) {
  10715. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10716. }
  10717. else {
  10718. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10719. }
  10720. break;
  10721. case "rectangle":
  10722. if (this._thumbWidth.isPixel) {
  10723. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10724. }
  10725. else {
  10726. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10727. }
  10728. }
  10729. return thumbThickness;
  10730. };
  10731. BaseSlider.prototype._prepareRenderingData = function (type) {
  10732. // Main bar
  10733. this._effectiveBarOffset = 0;
  10734. this._renderLeft = this._currentMeasure.left;
  10735. this._renderTop = this._currentMeasure.top;
  10736. this._renderWidth = this._currentMeasure.width;
  10737. this._renderHeight = this._currentMeasure.height;
  10738. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10739. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10740. this._effectiveThumbThickness = this._getThumbThickness(type);
  10741. if (this.displayThumb) {
  10742. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10743. }
  10744. //throw error when height is less than width for vertical slider
  10745. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10746. console.error("Height should be greater than width");
  10747. return;
  10748. }
  10749. if (this._barOffset.isPixel) {
  10750. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10751. }
  10752. else {
  10753. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10754. }
  10755. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10756. if (this.isVertical) {
  10757. this._renderLeft += this._effectiveBarOffset;
  10758. if (!this.isThumbClamped && this.displayThumb) {
  10759. this._renderTop += (this._effectiveThumbThickness / 2);
  10760. }
  10761. this._renderHeight = this._backgroundBoxLength;
  10762. this._renderWidth = this._backgroundBoxThickness;
  10763. }
  10764. else {
  10765. this._renderTop += this._effectiveBarOffset;
  10766. if (!this.isThumbClamped && this.displayThumb) {
  10767. this._renderLeft += (this._effectiveThumbThickness / 2);
  10768. }
  10769. this._renderHeight = this._backgroundBoxThickness;
  10770. this._renderWidth = this._backgroundBoxLength;
  10771. }
  10772. };
  10773. /** @hidden */
  10774. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10775. if (this.rotation != 0) {
  10776. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10777. x = this._transformedPosition.x;
  10778. y = this._transformedPosition.y;
  10779. }
  10780. var value;
  10781. if (this._isVertical) {
  10782. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10783. }
  10784. else {
  10785. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10786. }
  10787. var mult = (1 / this._step) | 0;
  10788. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10789. };
  10790. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10791. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10792. return false;
  10793. }
  10794. this._pointerIsDown = true;
  10795. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10796. this._host._capturingControl[pointerId] = this;
  10797. this._lastPointerDownID = pointerId;
  10798. return true;
  10799. };
  10800. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10801. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10802. if (pointerId != this._lastPointerDownID) {
  10803. return;
  10804. }
  10805. if (this._pointerIsDown) {
  10806. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10807. }
  10808. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10809. };
  10810. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10811. this._pointerIsDown = false;
  10812. delete this._host._capturingControl[pointerId];
  10813. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10814. };
  10815. return BaseSlider;
  10816. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10817. /***/ }),
  10818. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10819. /*!*************************************************!*\
  10820. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10821. \*************************************************/
  10822. /*! exports provided: ImageBasedSlider */
  10823. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10824. "use strict";
  10825. __webpack_require__.r(__webpack_exports__);
  10826. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10827. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10828. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10829. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10830. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  10831. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10832. /**
  10833. * Class used to create slider controls based on images
  10834. */
  10835. var ImageBasedSlider = /** @class */ (function (_super) {
  10836. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10837. /**
  10838. * Creates a new ImageBasedSlider
  10839. * @param name defines the control name
  10840. */
  10841. function ImageBasedSlider(name) {
  10842. var _this = _super.call(this, name) || this;
  10843. _this.name = name;
  10844. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10845. return _this;
  10846. }
  10847. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10848. get: function () {
  10849. return this._displayThumb && this.thumbImage != null;
  10850. },
  10851. set: function (value) {
  10852. if (this._displayThumb === value) {
  10853. return;
  10854. }
  10855. this._displayThumb = value;
  10856. this._markAsDirty();
  10857. },
  10858. enumerable: true,
  10859. configurable: true
  10860. });
  10861. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10862. /**
  10863. * Gets or sets the image used to render the background
  10864. */
  10865. get: function () {
  10866. return this._backgroundImage;
  10867. },
  10868. set: function (value) {
  10869. var _this = this;
  10870. if (this._backgroundImage === value) {
  10871. return;
  10872. }
  10873. this._backgroundImage = value;
  10874. if (value && !value.isLoaded) {
  10875. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10876. }
  10877. this._markAsDirty();
  10878. },
  10879. enumerable: true,
  10880. configurable: true
  10881. });
  10882. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10883. /**
  10884. * Gets or sets the image used to render the value bar
  10885. */
  10886. get: function () {
  10887. return this._valueBarImage;
  10888. },
  10889. set: function (value) {
  10890. var _this = this;
  10891. if (this._valueBarImage === value) {
  10892. return;
  10893. }
  10894. this._valueBarImage = value;
  10895. if (value && !value.isLoaded) {
  10896. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10897. }
  10898. this._markAsDirty();
  10899. },
  10900. enumerable: true,
  10901. configurable: true
  10902. });
  10903. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10904. /**
  10905. * Gets or sets the image used to render the thumb
  10906. */
  10907. get: function () {
  10908. return this._thumbImage;
  10909. },
  10910. set: function (value) {
  10911. var _this = this;
  10912. if (this._thumbImage === value) {
  10913. return;
  10914. }
  10915. this._thumbImage = value;
  10916. if (value && !value.isLoaded) {
  10917. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10918. }
  10919. this._markAsDirty();
  10920. },
  10921. enumerable: true,
  10922. configurable: true
  10923. });
  10924. ImageBasedSlider.prototype._getTypeName = function () {
  10925. return "ImageBasedSlider";
  10926. };
  10927. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  10928. context.save();
  10929. this._applyStates(context);
  10930. this._prepareRenderingData("rectangle");
  10931. var thumbPosition = this._getThumbPosition();
  10932. var left = this._renderLeft;
  10933. var top = this._renderTop;
  10934. var width = this._renderWidth;
  10935. var height = this._renderHeight;
  10936. // Background
  10937. if (this._backgroundImage) {
  10938. this._tempMeasure.copyFromFloats(left, top, width, height);
  10939. if (this.isThumbClamped && this.displayThumb) {
  10940. if (this.isVertical) {
  10941. this._tempMeasure.height += this._effectiveThumbThickness;
  10942. }
  10943. else {
  10944. this._tempMeasure.width += this._effectiveThumbThickness;
  10945. }
  10946. }
  10947. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10948. this._backgroundImage._draw(context);
  10949. }
  10950. // Bar
  10951. if (this._valueBarImage) {
  10952. if (this.isVertical) {
  10953. if (this.isThumbClamped && this.displayThumb) {
  10954. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10955. }
  10956. else {
  10957. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10958. }
  10959. }
  10960. else {
  10961. if (this.isThumbClamped && this.displayThumb) {
  10962. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10963. }
  10964. else {
  10965. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10966. }
  10967. }
  10968. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10969. this._valueBarImage._draw(context);
  10970. }
  10971. // Thumb
  10972. if (this.displayThumb) {
  10973. if (this.isVertical) {
  10974. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10975. }
  10976. else {
  10977. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10978. }
  10979. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10980. this._thumbImage._draw(context);
  10981. }
  10982. context.restore();
  10983. };
  10984. return ImageBasedSlider;
  10985. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10986. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  10987. /***/ }),
  10988. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  10989. /*!***********************************************!*\
  10990. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  10991. \***********************************************/
  10992. /*! exports provided: ImageScrollBar */
  10993. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10994. "use strict";
  10995. __webpack_require__.r(__webpack_exports__);
  10996. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  10997. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10998. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10999. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11000. /**
  11001. * Class used to create slider controls
  11002. */
  11003. var ImageScrollBar = /** @class */ (function (_super) {
  11004. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11005. /**
  11006. * Creates a new ImageScrollBar
  11007. * @param name defines the control name
  11008. */
  11009. function ImageScrollBar(name) {
  11010. var _this = _super.call(this, name) || this;
  11011. _this.name = name;
  11012. _this._thumbLength = 0.5;
  11013. _this._thumbHeight = 1;
  11014. _this._barImageHeight = 1;
  11015. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11016. /** Number of 90° rotation to apply on the images when in vertical mode */
  11017. _this.num90RotationInVerticalMode = 1;
  11018. return _this;
  11019. }
  11020. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11021. /**
  11022. * Gets or sets the image used to render the background for horizontal bar
  11023. */
  11024. get: function () {
  11025. return this._backgroundBaseImage;
  11026. },
  11027. set: function (value) {
  11028. var _this = this;
  11029. if (this._backgroundBaseImage === value) {
  11030. return;
  11031. }
  11032. this._backgroundBaseImage = value;
  11033. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11034. if (!value.isLoaded) {
  11035. value.onImageLoadedObservable.addOnce(function () {
  11036. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11037. _this._backgroundImage = rotatedValue;
  11038. if (!rotatedValue.isLoaded) {
  11039. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11040. _this._markAsDirty();
  11041. });
  11042. }
  11043. _this._markAsDirty();
  11044. });
  11045. }
  11046. else {
  11047. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11048. this._markAsDirty();
  11049. }
  11050. }
  11051. else {
  11052. this._backgroundImage = value;
  11053. if (value && !value.isLoaded) {
  11054. value.onImageLoadedObservable.addOnce(function () {
  11055. _this._markAsDirty();
  11056. });
  11057. }
  11058. this._markAsDirty();
  11059. }
  11060. },
  11061. enumerable: true,
  11062. configurable: true
  11063. });
  11064. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11065. /**
  11066. * Gets or sets the image used to render the thumb
  11067. */
  11068. get: function () {
  11069. return this._thumbBaseImage;
  11070. },
  11071. set: function (value) {
  11072. var _this = this;
  11073. if (this._thumbBaseImage === value) {
  11074. return;
  11075. }
  11076. this._thumbBaseImage = value;
  11077. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11078. if (!value.isLoaded) {
  11079. value.onImageLoadedObservable.addOnce(function () {
  11080. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11081. _this._thumbImage = rotatedValue;
  11082. if (!rotatedValue.isLoaded) {
  11083. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11084. _this._markAsDirty();
  11085. });
  11086. }
  11087. _this._markAsDirty();
  11088. });
  11089. }
  11090. else {
  11091. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11092. this._markAsDirty();
  11093. }
  11094. }
  11095. else {
  11096. this._thumbImage = value;
  11097. if (value && !value.isLoaded) {
  11098. value.onImageLoadedObservable.addOnce(function () {
  11099. _this._markAsDirty();
  11100. });
  11101. }
  11102. this._markAsDirty();
  11103. }
  11104. },
  11105. enumerable: true,
  11106. configurable: true
  11107. });
  11108. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11109. /**
  11110. * Gets or sets the length of the thumb
  11111. */
  11112. get: function () {
  11113. return this._thumbLength;
  11114. },
  11115. set: function (value) {
  11116. if (this._thumbLength === value) {
  11117. return;
  11118. }
  11119. this._thumbLength = value;
  11120. this._markAsDirty();
  11121. },
  11122. enumerable: true,
  11123. configurable: true
  11124. });
  11125. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11126. /**
  11127. * Gets or sets the height of the thumb
  11128. */
  11129. get: function () {
  11130. return this._thumbHeight;
  11131. },
  11132. set: function (value) {
  11133. if (this._thumbLength === value) {
  11134. return;
  11135. }
  11136. this._thumbHeight = value;
  11137. this._markAsDirty();
  11138. },
  11139. enumerable: true,
  11140. configurable: true
  11141. });
  11142. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11143. /**
  11144. * Gets or sets the height of the bar image
  11145. */
  11146. get: function () {
  11147. return this._barImageHeight;
  11148. },
  11149. set: function (value) {
  11150. if (this._barImageHeight === value) {
  11151. return;
  11152. }
  11153. this._barImageHeight = value;
  11154. this._markAsDirty();
  11155. },
  11156. enumerable: true,
  11157. configurable: true
  11158. });
  11159. ImageScrollBar.prototype._getTypeName = function () {
  11160. return "ImageScrollBar";
  11161. };
  11162. ImageScrollBar.prototype._getThumbThickness = function () {
  11163. var thumbThickness = 0;
  11164. if (this._thumbWidth.isPixel) {
  11165. thumbThickness = this._thumbWidth.getValue(this._host);
  11166. }
  11167. else {
  11168. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11169. }
  11170. return thumbThickness;
  11171. };
  11172. ImageScrollBar.prototype._draw = function (context) {
  11173. context.save();
  11174. this._applyStates(context);
  11175. this._prepareRenderingData("rectangle");
  11176. var thumbPosition = this._getThumbPosition();
  11177. var left = this._renderLeft;
  11178. var top = this._renderTop;
  11179. var width = this._renderWidth;
  11180. var height = this._renderHeight;
  11181. // Background
  11182. if (this._backgroundImage) {
  11183. this._tempMeasure.copyFromFloats(left, top, width, height);
  11184. if (this.isVertical) {
  11185. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11186. this._tempMeasure.height += this._effectiveThumbThickness;
  11187. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11188. }
  11189. else {
  11190. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11191. this._tempMeasure.width += this._effectiveThumbThickness;
  11192. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11193. }
  11194. this._backgroundImage._draw(context);
  11195. }
  11196. // Thumb
  11197. if (this.isVertical) {
  11198. 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);
  11199. }
  11200. else {
  11201. 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);
  11202. }
  11203. if (this._thumbImage) {
  11204. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11205. this._thumbImage._draw(context);
  11206. }
  11207. context.restore();
  11208. };
  11209. /** @hidden */
  11210. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11211. if (this.rotation != 0) {
  11212. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11213. x = this._transformedPosition.x;
  11214. y = this._transformedPosition.y;
  11215. }
  11216. if (this._first) {
  11217. this._first = false;
  11218. this._originX = x;
  11219. this._originY = y;
  11220. // Check if move is required
  11221. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11222. if (this.isVertical) {
  11223. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11224. }
  11225. else {
  11226. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11227. }
  11228. }
  11229. }
  11230. // Delta mode
  11231. var delta = 0;
  11232. if (this.isVertical) {
  11233. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11234. }
  11235. else {
  11236. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11237. }
  11238. this.value += delta * (this.maximum - this.minimum);
  11239. this._originX = x;
  11240. this._originY = y;
  11241. };
  11242. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11243. this._first = true;
  11244. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11245. };
  11246. return ImageScrollBar;
  11247. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11248. /***/ }),
  11249. /***/ "./2D/controls/sliders/scrollBar.ts":
  11250. /*!******************************************!*\
  11251. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11252. \******************************************/
  11253. /*! exports provided: ScrollBar */
  11254. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11255. "use strict";
  11256. __webpack_require__.r(__webpack_exports__);
  11257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11258. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11259. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11260. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11261. /**
  11262. * Class used to create slider controls
  11263. */
  11264. var ScrollBar = /** @class */ (function (_super) {
  11265. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11266. /**
  11267. * Creates a new Slider
  11268. * @param name defines the control name
  11269. */
  11270. function ScrollBar(name) {
  11271. var _this = _super.call(this, name) || this;
  11272. _this.name = name;
  11273. _this._background = "black";
  11274. _this._borderColor = "white";
  11275. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11276. return _this;
  11277. }
  11278. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11279. /** Gets or sets border color */
  11280. get: function () {
  11281. return this._borderColor;
  11282. },
  11283. set: function (value) {
  11284. if (this._borderColor === value) {
  11285. return;
  11286. }
  11287. this._borderColor = value;
  11288. this._markAsDirty();
  11289. },
  11290. enumerable: true,
  11291. configurable: true
  11292. });
  11293. Object.defineProperty(ScrollBar.prototype, "background", {
  11294. /** Gets or sets background color */
  11295. get: function () {
  11296. return this._background;
  11297. },
  11298. set: function (value) {
  11299. if (this._background === value) {
  11300. return;
  11301. }
  11302. this._background = value;
  11303. this._markAsDirty();
  11304. },
  11305. enumerable: true,
  11306. configurable: true
  11307. });
  11308. ScrollBar.prototype._getTypeName = function () {
  11309. return "Scrollbar";
  11310. };
  11311. ScrollBar.prototype._getThumbThickness = function () {
  11312. var thumbThickness = 0;
  11313. if (this._thumbWidth.isPixel) {
  11314. thumbThickness = this._thumbWidth.getValue(this._host);
  11315. }
  11316. else {
  11317. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11318. }
  11319. return thumbThickness;
  11320. };
  11321. ScrollBar.prototype._draw = function (context) {
  11322. context.save();
  11323. this._applyStates(context);
  11324. this._prepareRenderingData("rectangle");
  11325. var left = this._renderLeft;
  11326. var thumbPosition = this._getThumbPosition();
  11327. context.fillStyle = this._background;
  11328. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11329. // Value bar
  11330. context.fillStyle = this.color;
  11331. // Thumb
  11332. if (this.isVertical) {
  11333. this._tempMeasure.left = left - this._effectiveBarOffset;
  11334. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11335. this._tempMeasure.width = this._currentMeasure.width;
  11336. this._tempMeasure.height = this._effectiveThumbThickness;
  11337. }
  11338. else {
  11339. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11340. this._tempMeasure.top = this._currentMeasure.top;
  11341. this._tempMeasure.width = this._effectiveThumbThickness;
  11342. this._tempMeasure.height = this._currentMeasure.height;
  11343. }
  11344. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11345. context.restore();
  11346. };
  11347. /** @hidden */
  11348. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11349. if (this.rotation != 0) {
  11350. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11351. x = this._transformedPosition.x;
  11352. y = this._transformedPosition.y;
  11353. }
  11354. if (this._first) {
  11355. this._first = false;
  11356. this._originX = x;
  11357. this._originY = y;
  11358. // Check if move is required
  11359. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11360. if (this.isVertical) {
  11361. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11362. }
  11363. else {
  11364. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11365. }
  11366. }
  11367. }
  11368. // Delta mode
  11369. var delta = 0;
  11370. if (this.isVertical) {
  11371. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11372. }
  11373. else {
  11374. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11375. }
  11376. this.value += delta * (this.maximum - this.minimum);
  11377. this._originX = x;
  11378. this._originY = y;
  11379. };
  11380. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11381. this._first = true;
  11382. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11383. };
  11384. return ScrollBar;
  11385. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11386. /***/ }),
  11387. /***/ "./2D/controls/sliders/slider.ts":
  11388. /*!***************************************!*\
  11389. !*** ./2D/controls/sliders/slider.ts ***!
  11390. \***************************************/
  11391. /*! exports provided: Slider */
  11392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11393. "use strict";
  11394. __webpack_require__.r(__webpack_exports__);
  11395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11396. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11397. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11398. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  11399. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11400. /**
  11401. * Class used to create slider controls
  11402. */
  11403. var Slider = /** @class */ (function (_super) {
  11404. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11405. /**
  11406. * Creates a new Slider
  11407. * @param name defines the control name
  11408. */
  11409. function Slider(name) {
  11410. var _this = _super.call(this, name) || this;
  11411. _this.name = name;
  11412. _this._background = "black";
  11413. _this._borderColor = "white";
  11414. _this._isThumbCircle = false;
  11415. _this._displayValueBar = true;
  11416. return _this;
  11417. }
  11418. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11419. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11420. get: function () {
  11421. return this._displayValueBar;
  11422. },
  11423. set: function (value) {
  11424. if (this._displayValueBar === value) {
  11425. return;
  11426. }
  11427. this._displayValueBar = value;
  11428. this._markAsDirty();
  11429. },
  11430. enumerable: true,
  11431. configurable: true
  11432. });
  11433. Object.defineProperty(Slider.prototype, "borderColor", {
  11434. /** Gets or sets border color */
  11435. get: function () {
  11436. return this._borderColor;
  11437. },
  11438. set: function (value) {
  11439. if (this._borderColor === value) {
  11440. return;
  11441. }
  11442. this._borderColor = value;
  11443. this._markAsDirty();
  11444. },
  11445. enumerable: true,
  11446. configurable: true
  11447. });
  11448. Object.defineProperty(Slider.prototype, "background", {
  11449. /** Gets or sets background color */
  11450. get: function () {
  11451. return this._background;
  11452. },
  11453. set: function (value) {
  11454. if (this._background === value) {
  11455. return;
  11456. }
  11457. this._background = value;
  11458. this._markAsDirty();
  11459. },
  11460. enumerable: true,
  11461. configurable: true
  11462. });
  11463. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11464. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11465. get: function () {
  11466. return this._isThumbCircle;
  11467. },
  11468. set: function (value) {
  11469. if (this._isThumbCircle === value) {
  11470. return;
  11471. }
  11472. this._isThumbCircle = value;
  11473. this._markAsDirty();
  11474. },
  11475. enumerable: true,
  11476. configurable: true
  11477. });
  11478. Slider.prototype._getTypeName = function () {
  11479. return "Slider";
  11480. };
  11481. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11482. context.save();
  11483. this._applyStates(context);
  11484. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11485. var left = this._renderLeft;
  11486. var top = this._renderTop;
  11487. var width = this._renderWidth;
  11488. var height = this._renderHeight;
  11489. var radius = 0;
  11490. if (this.isThumbClamped && this.isThumbCircle) {
  11491. if (this.isVertical) {
  11492. top += (this._effectiveThumbThickness / 2);
  11493. }
  11494. else {
  11495. left += (this._effectiveThumbThickness / 2);
  11496. }
  11497. radius = this._backgroundBoxThickness / 2;
  11498. }
  11499. else {
  11500. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11501. }
  11502. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11503. context.shadowColor = this.shadowColor;
  11504. context.shadowBlur = this.shadowBlur;
  11505. context.shadowOffsetX = this.shadowOffsetX;
  11506. context.shadowOffsetY = this.shadowOffsetY;
  11507. }
  11508. var thumbPosition = this._getThumbPosition();
  11509. context.fillStyle = this._background;
  11510. if (this.isVertical) {
  11511. if (this.isThumbClamped) {
  11512. if (this.isThumbCircle) {
  11513. context.beginPath();
  11514. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11515. context.fill();
  11516. context.fillRect(left, top, width, height);
  11517. }
  11518. else {
  11519. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11520. }
  11521. }
  11522. else {
  11523. context.fillRect(left, top, width, height);
  11524. }
  11525. }
  11526. else {
  11527. if (this.isThumbClamped) {
  11528. if (this.isThumbCircle) {
  11529. context.beginPath();
  11530. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11531. context.fill();
  11532. context.fillRect(left, top, width, height);
  11533. }
  11534. else {
  11535. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11536. }
  11537. }
  11538. else {
  11539. context.fillRect(left, top, width, height);
  11540. }
  11541. }
  11542. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11543. context.shadowBlur = 0;
  11544. context.shadowOffsetX = 0;
  11545. context.shadowOffsetY = 0;
  11546. }
  11547. // Value bar
  11548. context.fillStyle = this.color;
  11549. if (this._displayValueBar) {
  11550. if (this.isVertical) {
  11551. if (this.isThumbClamped) {
  11552. if (this.isThumbCircle) {
  11553. context.beginPath();
  11554. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11555. context.fill();
  11556. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11557. }
  11558. else {
  11559. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11560. }
  11561. }
  11562. else {
  11563. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11564. }
  11565. }
  11566. else {
  11567. if (this.isThumbClamped) {
  11568. if (this.isThumbCircle) {
  11569. context.beginPath();
  11570. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11571. context.fill();
  11572. context.fillRect(left, top, thumbPosition, height);
  11573. }
  11574. else {
  11575. context.fillRect(left, top, thumbPosition, height);
  11576. }
  11577. }
  11578. else {
  11579. context.fillRect(left, top, thumbPosition, height);
  11580. }
  11581. }
  11582. }
  11583. // Thumb
  11584. if (this.displayThumb) {
  11585. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11586. context.shadowColor = this.shadowColor;
  11587. context.shadowBlur = this.shadowBlur;
  11588. context.shadowOffsetX = this.shadowOffsetX;
  11589. context.shadowOffsetY = this.shadowOffsetY;
  11590. }
  11591. if (this._isThumbCircle) {
  11592. context.beginPath();
  11593. if (this.isVertical) {
  11594. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11595. }
  11596. else {
  11597. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11598. }
  11599. context.fill();
  11600. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11601. context.shadowBlur = 0;
  11602. context.shadowOffsetX = 0;
  11603. context.shadowOffsetY = 0;
  11604. }
  11605. context.strokeStyle = this._borderColor;
  11606. context.stroke();
  11607. }
  11608. else {
  11609. if (this.isVertical) {
  11610. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11611. }
  11612. else {
  11613. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11614. }
  11615. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11616. context.shadowBlur = 0;
  11617. context.shadowOffsetX = 0;
  11618. context.shadowOffsetY = 0;
  11619. }
  11620. context.strokeStyle = this._borderColor;
  11621. if (this.isVertical) {
  11622. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11623. }
  11624. else {
  11625. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11626. }
  11627. }
  11628. }
  11629. context.restore();
  11630. };
  11631. return Slider;
  11632. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11633. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11634. /***/ }),
  11635. /***/ "./2D/controls/stackPanel.ts":
  11636. /*!***********************************!*\
  11637. !*** ./2D/controls/stackPanel.ts ***!
  11638. \***********************************/
  11639. /*! exports provided: StackPanel */
  11640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11641. "use strict";
  11642. __webpack_require__.r(__webpack_exports__);
  11643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11644. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11645. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  11646. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11647. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11648. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11649. /**
  11650. * Class used to create a 2D stack panel container
  11651. */
  11652. var StackPanel = /** @class */ (function (_super) {
  11653. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11654. /**
  11655. * Creates a new StackPanel
  11656. * @param name defines control name
  11657. */
  11658. function StackPanel(name) {
  11659. var _this = _super.call(this, name) || this;
  11660. _this.name = name;
  11661. _this._isVertical = true;
  11662. _this._manualWidth = false;
  11663. _this._manualHeight = false;
  11664. _this._doNotTrackManualChanges = false;
  11665. /**
  11666. * Gets or sets a boolean indicating that layou warnings should be ignored
  11667. */
  11668. _this.ignoreLayoutWarnings = false;
  11669. return _this;
  11670. }
  11671. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11672. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11673. get: function () {
  11674. return this._isVertical;
  11675. },
  11676. set: function (value) {
  11677. if (this._isVertical === value) {
  11678. return;
  11679. }
  11680. this._isVertical = value;
  11681. this._markAsDirty();
  11682. },
  11683. enumerable: true,
  11684. configurable: true
  11685. });
  11686. Object.defineProperty(StackPanel.prototype, "width", {
  11687. get: function () {
  11688. return this._width.toString(this._host);
  11689. },
  11690. /**
  11691. * Gets or sets panel width.
  11692. * This value should not be set when in horizontal mode as it will be computed automatically
  11693. */
  11694. set: function (value) {
  11695. if (!this._doNotTrackManualChanges) {
  11696. this._manualWidth = true;
  11697. }
  11698. if (this._width.toString(this._host) === value) {
  11699. return;
  11700. }
  11701. if (this._width.fromString(value)) {
  11702. this._markAsDirty();
  11703. }
  11704. },
  11705. enumerable: true,
  11706. configurable: true
  11707. });
  11708. Object.defineProperty(StackPanel.prototype, "height", {
  11709. get: function () {
  11710. return this._height.toString(this._host);
  11711. },
  11712. /**
  11713. * Gets or sets panel height.
  11714. * This value should not be set when in vertical mode as it will be computed automatically
  11715. */
  11716. set: function (value) {
  11717. if (!this._doNotTrackManualChanges) {
  11718. this._manualHeight = true;
  11719. }
  11720. if (this._height.toString(this._host) === value) {
  11721. return;
  11722. }
  11723. if (this._height.fromString(value)) {
  11724. this._markAsDirty();
  11725. }
  11726. },
  11727. enumerable: true,
  11728. configurable: true
  11729. });
  11730. StackPanel.prototype._getTypeName = function () {
  11731. return "StackPanel";
  11732. };
  11733. /** @hidden */
  11734. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11735. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11736. var child = _a[_i];
  11737. if (this._isVertical) {
  11738. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11739. }
  11740. else {
  11741. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11742. }
  11743. }
  11744. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11745. };
  11746. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11747. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11748. this._measureForChildren.copyFrom(parentMeasure);
  11749. this._measureForChildren.left = this._currentMeasure.left;
  11750. this._measureForChildren.top = this._currentMeasure.top;
  11751. if (!this.isVertical || this._manualWidth) {
  11752. this._measureForChildren.width = this._currentMeasure.width;
  11753. }
  11754. if (this.isVertical || this._manualHeight) {
  11755. this._measureForChildren.height = this._currentMeasure.height;
  11756. }
  11757. };
  11758. StackPanel.prototype._postMeasure = function () {
  11759. var stackWidth = 0;
  11760. var stackHeight = 0;
  11761. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11762. var child = _a[_i];
  11763. if (!child.isVisible || child.notRenderable) {
  11764. continue;
  11765. }
  11766. if (this._isVertical) {
  11767. if (child.top !== stackHeight + "px") {
  11768. child.top = stackHeight + "px";
  11769. this._rebuildLayout = true;
  11770. child._top.ignoreAdaptiveScaling = true;
  11771. }
  11772. if (child._height.isPercentage && !child._automaticSize) {
  11773. if (!this.ignoreLayoutWarnings) {
  11774. 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");
  11775. }
  11776. }
  11777. else {
  11778. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11779. }
  11780. }
  11781. else {
  11782. if (child.left !== stackWidth + "px") {
  11783. child.left = stackWidth + "px";
  11784. this._rebuildLayout = true;
  11785. child._left.ignoreAdaptiveScaling = true;
  11786. }
  11787. if (child._width.isPercentage && !child._automaticSize) {
  11788. if (!this.ignoreLayoutWarnings) {
  11789. 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");
  11790. }
  11791. }
  11792. else {
  11793. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11794. }
  11795. }
  11796. }
  11797. this._doNotTrackManualChanges = true;
  11798. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11799. // User can now define their own height and width for stack panel.
  11800. var panelWidthChanged = false;
  11801. var panelHeightChanged = false;
  11802. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11803. var previousHeight = this.height;
  11804. this.height = stackHeight + "px";
  11805. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11806. }
  11807. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11808. var previousWidth = this.width;
  11809. this.width = stackWidth + "px";
  11810. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11811. }
  11812. if (panelHeightChanged) {
  11813. this._height.ignoreAdaptiveScaling = true;
  11814. }
  11815. if (panelWidthChanged) {
  11816. this._width.ignoreAdaptiveScaling = true;
  11817. }
  11818. this._doNotTrackManualChanges = false;
  11819. if (panelWidthChanged || panelHeightChanged) {
  11820. this._rebuildLayout = true;
  11821. }
  11822. _super.prototype._postMeasure.call(this);
  11823. };
  11824. return StackPanel;
  11825. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11826. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11827. /***/ }),
  11828. /***/ "./2D/controls/statics.ts":
  11829. /*!********************************!*\
  11830. !*** ./2D/controls/statics.ts ***!
  11831. \********************************/
  11832. /*! exports provided: name */
  11833. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11834. "use strict";
  11835. __webpack_require__.r(__webpack_exports__);
  11836. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11837. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11838. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11839. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11840. /**
  11841. * Forcing an export so that this code will execute
  11842. * @hidden
  11843. */
  11844. var name = "Statics";
  11845. /**
  11846. * Creates a stack panel that can be used to render headers
  11847. * @param control defines the control to associate with the header
  11848. * @param text defines the text of the header
  11849. * @param size defines the size of the header
  11850. * @param options defines options used to configure the header
  11851. * @returns a new StackPanel
  11852. */
  11853. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11854. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11855. var isHorizontal = options ? options.isHorizontal : true;
  11856. var controlFirst = options ? options.controlFirst : true;
  11857. panel.isVertical = !isHorizontal;
  11858. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11859. header.text = text;
  11860. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11861. if (isHorizontal) {
  11862. header.width = size;
  11863. }
  11864. else {
  11865. header.height = size;
  11866. }
  11867. if (controlFirst) {
  11868. panel.addControl(control);
  11869. panel.addControl(header);
  11870. header.paddingLeft = "5px";
  11871. }
  11872. else {
  11873. panel.addControl(header);
  11874. panel.addControl(control);
  11875. header.paddingRight = "5px";
  11876. }
  11877. header.shadowBlur = control.shadowBlur;
  11878. header.shadowColor = control.shadowColor;
  11879. header.shadowOffsetX = control.shadowOffsetX;
  11880. header.shadowOffsetY = control.shadowOffsetY;
  11881. return panel;
  11882. };
  11883. /***/ }),
  11884. /***/ "./2D/controls/textBlock.ts":
  11885. /*!**********************************!*\
  11886. !*** ./2D/controls/textBlock.ts ***!
  11887. \**********************************/
  11888. /*! exports provided: TextWrapping, TextBlock */
  11889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11890. "use strict";
  11891. __webpack_require__.r(__webpack_exports__);
  11892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  11893. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  11894. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11895. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  11896. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11897. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  11898. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11899. /**
  11900. * Enum that determines the text-wrapping mode to use.
  11901. */
  11902. var TextWrapping;
  11903. (function (TextWrapping) {
  11904. /**
  11905. * Clip the text when it's larger than Control.width; this is the default mode.
  11906. */
  11907. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  11908. /**
  11909. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  11910. */
  11911. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  11912. /**
  11913. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  11914. */
  11915. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  11916. })(TextWrapping || (TextWrapping = {}));
  11917. /**
  11918. * Class used to create text block control
  11919. */
  11920. var TextBlock = /** @class */ (function (_super) {
  11921. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  11922. /**
  11923. * Creates a new TextBlock object
  11924. * @param name defines the name of the control
  11925. * @param text defines the text to display (emptry string by default)
  11926. */
  11927. function TextBlock(
  11928. /**
  11929. * Defines the name of the control
  11930. */
  11931. name, text) {
  11932. if (text === void 0) { text = ""; }
  11933. var _this = _super.call(this, name) || this;
  11934. _this.name = name;
  11935. _this._text = "";
  11936. _this._textWrapping = TextWrapping.Clip;
  11937. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11938. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11939. _this._resizeToFit = false;
  11940. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11941. _this._outlineWidth = 0;
  11942. _this._outlineColor = "white";
  11943. /**
  11944. * An event triggered after the text is changed
  11945. */
  11946. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11947. /**
  11948. * An event triggered after the text was broken up into lines
  11949. */
  11950. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11951. _this.text = text;
  11952. return _this;
  11953. }
  11954. Object.defineProperty(TextBlock.prototype, "lines", {
  11955. /**
  11956. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11957. */
  11958. get: function () {
  11959. return this._lines;
  11960. },
  11961. enumerable: true,
  11962. configurable: true
  11963. });
  11964. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11965. /**
  11966. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11967. */
  11968. get: function () {
  11969. return this._resizeToFit;
  11970. },
  11971. /**
  11972. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11973. */
  11974. set: function (value) {
  11975. if (this._resizeToFit === value) {
  11976. return;
  11977. }
  11978. this._resizeToFit = value;
  11979. if (this._resizeToFit) {
  11980. this._width.ignoreAdaptiveScaling = true;
  11981. this._height.ignoreAdaptiveScaling = true;
  11982. }
  11983. this._markAsDirty();
  11984. },
  11985. enumerable: true,
  11986. configurable: true
  11987. });
  11988. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  11989. /**
  11990. * Gets or sets a boolean indicating if text must be wrapped
  11991. */
  11992. get: function () {
  11993. return this._textWrapping;
  11994. },
  11995. /**
  11996. * Gets or sets a boolean indicating if text must be wrapped
  11997. */
  11998. set: function (value) {
  11999. if (this._textWrapping === value) {
  12000. return;
  12001. }
  12002. this._textWrapping = +value;
  12003. this._markAsDirty();
  12004. },
  12005. enumerable: true,
  12006. configurable: true
  12007. });
  12008. Object.defineProperty(TextBlock.prototype, "text", {
  12009. /**
  12010. * Gets or sets text to display
  12011. */
  12012. get: function () {
  12013. return this._text;
  12014. },
  12015. /**
  12016. * Gets or sets text to display
  12017. */
  12018. set: function (value) {
  12019. if (this._text === value) {
  12020. return;
  12021. }
  12022. this._text = value;
  12023. this._markAsDirty();
  12024. this.onTextChangedObservable.notifyObservers(this);
  12025. },
  12026. enumerable: true,
  12027. configurable: true
  12028. });
  12029. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12030. /**
  12031. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12032. */
  12033. get: function () {
  12034. return this._textHorizontalAlignment;
  12035. },
  12036. /**
  12037. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12038. */
  12039. set: function (value) {
  12040. if (this._textHorizontalAlignment === value) {
  12041. return;
  12042. }
  12043. this._textHorizontalAlignment = value;
  12044. this._markAsDirty();
  12045. },
  12046. enumerable: true,
  12047. configurable: true
  12048. });
  12049. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12050. /**
  12051. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12052. */
  12053. get: function () {
  12054. return this._textVerticalAlignment;
  12055. },
  12056. /**
  12057. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12058. */
  12059. set: function (value) {
  12060. if (this._textVerticalAlignment === value) {
  12061. return;
  12062. }
  12063. this._textVerticalAlignment = value;
  12064. this._markAsDirty();
  12065. },
  12066. enumerable: true,
  12067. configurable: true
  12068. });
  12069. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12070. /**
  12071. * Gets or sets line spacing value
  12072. */
  12073. get: function () {
  12074. return this._lineSpacing.toString(this._host);
  12075. },
  12076. /**
  12077. * Gets or sets line spacing value
  12078. */
  12079. set: function (value) {
  12080. if (this._lineSpacing.fromString(value)) {
  12081. this._markAsDirty();
  12082. }
  12083. },
  12084. enumerable: true,
  12085. configurable: true
  12086. });
  12087. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12088. /**
  12089. * Gets or sets outlineWidth of the text to display
  12090. */
  12091. get: function () {
  12092. return this._outlineWidth;
  12093. },
  12094. /**
  12095. * Gets or sets outlineWidth of the text to display
  12096. */
  12097. set: function (value) {
  12098. if (this._outlineWidth === value) {
  12099. return;
  12100. }
  12101. this._outlineWidth = value;
  12102. this._markAsDirty();
  12103. },
  12104. enumerable: true,
  12105. configurable: true
  12106. });
  12107. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12108. /**
  12109. * Gets or sets outlineColor of the text to display
  12110. */
  12111. get: function () {
  12112. return this._outlineColor;
  12113. },
  12114. /**
  12115. * Gets or sets outlineColor of the text to display
  12116. */
  12117. set: function (value) {
  12118. if (this._outlineColor === value) {
  12119. return;
  12120. }
  12121. this._outlineColor = value;
  12122. this._markAsDirty();
  12123. },
  12124. enumerable: true,
  12125. configurable: true
  12126. });
  12127. TextBlock.prototype._getTypeName = function () {
  12128. return "TextBlock";
  12129. };
  12130. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12131. if (!this._fontOffset) {
  12132. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12133. }
  12134. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12135. // Prepare lines
  12136. this._lines = this._breakLines(this._currentMeasure.width, context);
  12137. this.onLinesReadyObservable.notifyObservers(this);
  12138. var maxLineWidth = 0;
  12139. for (var i = 0; i < this._lines.length; i++) {
  12140. var line = this._lines[i];
  12141. if (line.width > maxLineWidth) {
  12142. maxLineWidth = line.width;
  12143. }
  12144. }
  12145. if (this._resizeToFit) {
  12146. if (this._textWrapping === TextWrapping.Clip) {
  12147. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  12148. if (newWidth !== this._width.internalValue) {
  12149. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12150. this._rebuildLayout = true;
  12151. }
  12152. }
  12153. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  12154. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12155. var lineSpacing = 0;
  12156. if (this._lineSpacing.isPixel) {
  12157. lineSpacing = this._lineSpacing.getValue(this._host);
  12158. }
  12159. else {
  12160. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12161. }
  12162. newHeight += (this._lines.length - 1) * lineSpacing;
  12163. }
  12164. if (newHeight !== this._height.internalValue) {
  12165. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12166. this._rebuildLayout = true;
  12167. }
  12168. }
  12169. };
  12170. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12171. var width = this._currentMeasure.width;
  12172. var x = 0;
  12173. switch (this._textHorizontalAlignment) {
  12174. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12175. x = 0;
  12176. break;
  12177. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12178. x = width - textWidth;
  12179. break;
  12180. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12181. x = (width - textWidth) / 2;
  12182. break;
  12183. }
  12184. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12185. context.shadowColor = this.shadowColor;
  12186. context.shadowBlur = this.shadowBlur;
  12187. context.shadowOffsetX = this.shadowOffsetX;
  12188. context.shadowOffsetY = this.shadowOffsetY;
  12189. }
  12190. if (this.outlineWidth) {
  12191. context.strokeText(text, this._currentMeasure.left + x, y);
  12192. }
  12193. context.fillText(text, this._currentMeasure.left + x, y);
  12194. };
  12195. /** @hidden */
  12196. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12197. context.save();
  12198. this._applyStates(context);
  12199. // Render lines
  12200. this._renderLines(context);
  12201. context.restore();
  12202. };
  12203. TextBlock.prototype._applyStates = function (context) {
  12204. _super.prototype._applyStates.call(this, context);
  12205. if (this.outlineWidth) {
  12206. context.lineWidth = this.outlineWidth;
  12207. context.strokeStyle = this.outlineColor;
  12208. }
  12209. };
  12210. TextBlock.prototype._breakLines = function (refWidth, context) {
  12211. var lines = [];
  12212. var _lines = this.text.split("\n");
  12213. if (this._textWrapping === TextWrapping.Ellipsis) {
  12214. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12215. var _line = _lines_1[_i];
  12216. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12217. }
  12218. }
  12219. else if (this._textWrapping === TextWrapping.WordWrap) {
  12220. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12221. var _line = _lines_2[_a];
  12222. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12223. }
  12224. }
  12225. else {
  12226. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12227. var _line = _lines_3[_b];
  12228. lines.push(this._parseLine(_line, context));
  12229. }
  12230. }
  12231. return lines;
  12232. };
  12233. TextBlock.prototype._parseLine = function (line, context) {
  12234. if (line === void 0) { line = ''; }
  12235. return { text: line, width: context.measureText(line).width };
  12236. };
  12237. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12238. if (line === void 0) { line = ''; }
  12239. var lineWidth = context.measureText(line).width;
  12240. if (lineWidth > width) {
  12241. line += '…';
  12242. }
  12243. while (line.length > 2 && lineWidth > width) {
  12244. line = line.slice(0, -2) + '…';
  12245. lineWidth = context.measureText(line).width;
  12246. }
  12247. return { text: line, width: lineWidth };
  12248. };
  12249. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12250. if (line === void 0) { line = ''; }
  12251. var lines = [];
  12252. var words = line.split(' ');
  12253. var lineWidth = 0;
  12254. for (var n = 0; n < words.length; n++) {
  12255. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12256. var metrics = context.measureText(testLine);
  12257. var testWidth = metrics.width;
  12258. if (testWidth > width && n > 0) {
  12259. lines.push({ text: line, width: lineWidth });
  12260. line = words[n];
  12261. lineWidth = context.measureText(line).width;
  12262. }
  12263. else {
  12264. lineWidth = testWidth;
  12265. line = testLine;
  12266. }
  12267. }
  12268. lines.push({ text: line, width: lineWidth });
  12269. return lines;
  12270. };
  12271. TextBlock.prototype._renderLines = function (context) {
  12272. var height = this._currentMeasure.height;
  12273. var rootY = 0;
  12274. switch (this._textVerticalAlignment) {
  12275. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12276. rootY = this._fontOffset.ascent;
  12277. break;
  12278. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12279. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12280. break;
  12281. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12282. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12283. break;
  12284. }
  12285. rootY += this._currentMeasure.top;
  12286. for (var i = 0; i < this._lines.length; i++) {
  12287. var line = this._lines[i];
  12288. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12289. if (this._lineSpacing.isPixel) {
  12290. rootY += this._lineSpacing.getValue(this._host);
  12291. }
  12292. else {
  12293. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12294. }
  12295. }
  12296. this._drawText(line.text, line.width, rootY, context);
  12297. rootY += this._fontOffset.height;
  12298. }
  12299. };
  12300. /**
  12301. * Given a width constraint applied on the text block, find the expected height
  12302. * @returns expected height
  12303. */
  12304. TextBlock.prototype.computeExpectedHeight = function () {
  12305. if (this.text && this.widthInPixels) {
  12306. var context_1 = document.createElement('canvas').getContext('2d');
  12307. if (context_1) {
  12308. this._applyStates(context_1);
  12309. if (!this._fontOffset) {
  12310. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12311. }
  12312. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12313. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12314. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12315. var lineSpacing = 0;
  12316. if (this._lineSpacing.isPixel) {
  12317. lineSpacing = this._lineSpacing.getValue(this._host);
  12318. }
  12319. else {
  12320. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12321. }
  12322. newHeight += (lines.length - 1) * lineSpacing;
  12323. }
  12324. return newHeight;
  12325. }
  12326. }
  12327. return 0;
  12328. };
  12329. TextBlock.prototype.dispose = function () {
  12330. _super.prototype.dispose.call(this);
  12331. this.onTextChangedObservable.clear();
  12332. };
  12333. return TextBlock;
  12334. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12335. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12336. /***/ }),
  12337. /***/ "./2D/controls/virtualKeyboard.ts":
  12338. /*!****************************************!*\
  12339. !*** ./2D/controls/virtualKeyboard.ts ***!
  12340. \****************************************/
  12341. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12342. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12343. "use strict";
  12344. __webpack_require__.r(__webpack_exports__);
  12345. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12347. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12348. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  12349. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12350. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12351. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12352. /**
  12353. * Class used to store key control properties
  12354. */
  12355. var KeyPropertySet = /** @class */ (function () {
  12356. function KeyPropertySet() {
  12357. }
  12358. return KeyPropertySet;
  12359. }());
  12360. /**
  12361. * Class used to create virtual keyboard
  12362. */
  12363. var VirtualKeyboard = /** @class */ (function (_super) {
  12364. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12365. function VirtualKeyboard() {
  12366. var _this = _super !== null && _super.apply(this, arguments) || this;
  12367. /** Observable raised when a key is pressed */
  12368. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12369. /** Gets or sets default key button width */
  12370. _this.defaultButtonWidth = "40px";
  12371. /** Gets or sets default key button height */
  12372. _this.defaultButtonHeight = "40px";
  12373. /** Gets or sets default key button left padding */
  12374. _this.defaultButtonPaddingLeft = "2px";
  12375. /** Gets or sets default key button right padding */
  12376. _this.defaultButtonPaddingRight = "2px";
  12377. /** Gets or sets default key button top padding */
  12378. _this.defaultButtonPaddingTop = "2px";
  12379. /** Gets or sets default key button bottom padding */
  12380. _this.defaultButtonPaddingBottom = "2px";
  12381. /** Gets or sets default key button foreground color */
  12382. _this.defaultButtonColor = "#DDD";
  12383. /** Gets or sets default key button background color */
  12384. _this.defaultButtonBackground = "#070707";
  12385. /** Gets or sets shift button foreground color */
  12386. _this.shiftButtonColor = "#7799FF";
  12387. /** Gets or sets shift button thickness*/
  12388. _this.selectedShiftThickness = 1;
  12389. /** Gets shift key state */
  12390. _this.shiftState = 0;
  12391. _this._currentlyConnectedInputText = null;
  12392. _this._connectedInputTexts = [];
  12393. _this._onKeyPressObserver = null;
  12394. return _this;
  12395. }
  12396. VirtualKeyboard.prototype._getTypeName = function () {
  12397. return "VirtualKeyboard";
  12398. };
  12399. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12400. var _this = this;
  12401. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12402. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12403. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12404. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12405. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12406. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12407. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12408. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12409. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12410. button.thickness = 0;
  12411. button.isFocusInvisible = true;
  12412. button.shadowColor = this.shadowColor;
  12413. button.shadowBlur = this.shadowBlur;
  12414. button.shadowOffsetX = this.shadowOffsetX;
  12415. button.shadowOffsetY = this.shadowOffsetY;
  12416. button.onPointerUpObservable.add(function () {
  12417. _this.onKeyPressObservable.notifyObservers(key);
  12418. });
  12419. return button;
  12420. };
  12421. /**
  12422. * Adds a new row of keys
  12423. * @param keys defines the list of keys to add
  12424. * @param propertySets defines the associated property sets
  12425. */
  12426. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12427. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12428. panel.isVertical = false;
  12429. panel.isFocusInvisible = true;
  12430. var maxKey = null;
  12431. for (var i = 0; i < keys.length; i++) {
  12432. var properties = null;
  12433. if (propertySets && propertySets.length === keys.length) {
  12434. properties = propertySets[i];
  12435. }
  12436. var key = this._createKey(keys[i], properties);
  12437. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12438. maxKey = key;
  12439. }
  12440. panel.addControl(key);
  12441. }
  12442. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12443. this.addControl(panel);
  12444. };
  12445. /**
  12446. * Set the shift key to a specific state
  12447. * @param shiftState defines the new shift state
  12448. */
  12449. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12450. if (!this.children) {
  12451. return;
  12452. }
  12453. for (var i = 0; i < this.children.length; i++) {
  12454. var row = this.children[i];
  12455. if (!row || !row.children) {
  12456. continue;
  12457. }
  12458. var rowContainer = row;
  12459. for (var j = 0; j < rowContainer.children.length; j++) {
  12460. var button = rowContainer.children[j];
  12461. if (!button || !button.children[0]) {
  12462. continue;
  12463. }
  12464. var button_tblock = button.children[0];
  12465. if (button_tblock.text === "\u21E7") {
  12466. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12467. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12468. }
  12469. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12470. }
  12471. }
  12472. };
  12473. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12474. /** Gets the input text control currently attached to the keyboard */
  12475. get: function () {
  12476. return this._currentlyConnectedInputText;
  12477. },
  12478. enumerable: true,
  12479. configurable: true
  12480. });
  12481. /**
  12482. * Connects the keyboard with an input text control
  12483. *
  12484. * @param input defines the target control
  12485. */
  12486. VirtualKeyboard.prototype.connect = function (input) {
  12487. var _this = this;
  12488. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12489. if (inputTextAlreadyConnected) {
  12490. return;
  12491. }
  12492. if (this._onKeyPressObserver === null) {
  12493. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12494. if (!_this._currentlyConnectedInputText) {
  12495. return;
  12496. }
  12497. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12498. switch (key) {
  12499. case "\u21E7":
  12500. _this.shiftState++;
  12501. if (_this.shiftState > 2) {
  12502. _this.shiftState = 0;
  12503. }
  12504. _this.applyShiftState(_this.shiftState);
  12505. return;
  12506. case "\u2190":
  12507. _this._currentlyConnectedInputText.processKey(8);
  12508. return;
  12509. case "\u21B5":
  12510. _this._currentlyConnectedInputText.processKey(13);
  12511. return;
  12512. }
  12513. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12514. if (_this.shiftState === 1) {
  12515. _this.shiftState = 0;
  12516. _this.applyShiftState(_this.shiftState);
  12517. }
  12518. });
  12519. }
  12520. this.isVisible = false;
  12521. this._currentlyConnectedInputText = input;
  12522. input._connectedVirtualKeyboard = this;
  12523. // Events hooking
  12524. var onFocusObserver = input.onFocusObservable.add(function () {
  12525. _this._currentlyConnectedInputText = input;
  12526. input._connectedVirtualKeyboard = _this;
  12527. _this.isVisible = true;
  12528. });
  12529. var onBlurObserver = input.onBlurObservable.add(function () {
  12530. input._connectedVirtualKeyboard = null;
  12531. _this._currentlyConnectedInputText = null;
  12532. _this.isVisible = false;
  12533. });
  12534. this._connectedInputTexts.push({
  12535. input: input,
  12536. onBlurObserver: onBlurObserver,
  12537. onFocusObserver: onFocusObserver
  12538. });
  12539. };
  12540. /**
  12541. * Disconnects the keyboard from connected InputText controls
  12542. *
  12543. * @param input optionally defines a target control, otherwise all are disconnected
  12544. */
  12545. VirtualKeyboard.prototype.disconnect = function (input) {
  12546. var _this = this;
  12547. if (input) {
  12548. // .find not available on IE
  12549. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12550. if (filtered.length === 1) {
  12551. this._removeConnectedInputObservables(filtered[0]);
  12552. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12553. if (this._currentlyConnectedInputText === input) {
  12554. this._currentlyConnectedInputText = null;
  12555. }
  12556. }
  12557. }
  12558. else {
  12559. this._connectedInputTexts.forEach(function (connectedInputText) {
  12560. _this._removeConnectedInputObservables(connectedInputText);
  12561. });
  12562. this._connectedInputTexts = [];
  12563. }
  12564. if (this._connectedInputTexts.length === 0) {
  12565. this._currentlyConnectedInputText = null;
  12566. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12567. this._onKeyPressObserver = null;
  12568. }
  12569. };
  12570. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12571. connectedInputText.input._connectedVirtualKeyboard = null;
  12572. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12573. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12574. };
  12575. /**
  12576. * Release all resources
  12577. */
  12578. VirtualKeyboard.prototype.dispose = function () {
  12579. _super.prototype.dispose.call(this);
  12580. this.disconnect();
  12581. };
  12582. // Statics
  12583. /**
  12584. * Creates a new keyboard using a default layout
  12585. *
  12586. * @param name defines control name
  12587. * @returns a new VirtualKeyboard
  12588. */
  12589. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12590. var returnValue = new VirtualKeyboard(name);
  12591. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12592. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12593. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12594. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12595. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12596. return returnValue;
  12597. };
  12598. return VirtualKeyboard;
  12599. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12600. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12601. /***/ }),
  12602. /***/ "./2D/index.ts":
  12603. /*!*********************!*\
  12604. !*** ./2D/index.ts ***!
  12605. \*********************/
  12606. /*! 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 */
  12607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12608. "use strict";
  12609. __webpack_require__.r(__webpack_exports__);
  12610. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12643. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12645. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12647. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12650. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12652. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12654. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12656. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12658. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12660. /***/ }),
  12661. /***/ "./2D/math2D.ts":
  12662. /*!**********************!*\
  12663. !*** ./2D/math2D.ts ***!
  12664. \**********************/
  12665. /*! exports provided: Vector2WithInfo, Matrix2D */
  12666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12667. "use strict";
  12668. __webpack_require__.r(__webpack_exports__);
  12669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12670. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12671. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12672. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12673. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12674. /**
  12675. * Class used to transport Vector2 information for pointer events
  12676. */
  12677. var Vector2WithInfo = /** @class */ (function (_super) {
  12678. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12679. /**
  12680. * Creates a new Vector2WithInfo
  12681. * @param source defines the vector2 data to transport
  12682. * @param buttonIndex defines the current mouse button index
  12683. */
  12684. function Vector2WithInfo(source,
  12685. /** defines the current mouse button index */
  12686. buttonIndex) {
  12687. if (buttonIndex === void 0) { buttonIndex = 0; }
  12688. var _this = _super.call(this, source.x, source.y) || this;
  12689. _this.buttonIndex = buttonIndex;
  12690. return _this;
  12691. }
  12692. return Vector2WithInfo;
  12693. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12694. /** Class used to provide 2D matrix features */
  12695. var Matrix2D = /** @class */ (function () {
  12696. /**
  12697. * Creates a new matrix
  12698. * @param m00 defines value for (0, 0)
  12699. * @param m01 defines value for (0, 1)
  12700. * @param m10 defines value for (1, 0)
  12701. * @param m11 defines value for (1, 1)
  12702. * @param m20 defines value for (2, 0)
  12703. * @param m21 defines value for (2, 1)
  12704. */
  12705. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12706. /** Gets the internal array of 6 floats used to store matrix data */
  12707. this.m = new Float32Array(6);
  12708. this.fromValues(m00, m01, m10, m11, m20, m21);
  12709. }
  12710. /**
  12711. * Fills the matrix from direct values
  12712. * @param m00 defines value for (0, 0)
  12713. * @param m01 defines value for (0, 1)
  12714. * @param m10 defines value for (1, 0)
  12715. * @param m11 defines value for (1, 1)
  12716. * @param m20 defines value for (2, 0)
  12717. * @param m21 defines value for (2, 1)
  12718. * @returns the current modified matrix
  12719. */
  12720. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12721. this.m[0] = m00;
  12722. this.m[1] = m01;
  12723. this.m[2] = m10;
  12724. this.m[3] = m11;
  12725. this.m[4] = m20;
  12726. this.m[5] = m21;
  12727. return this;
  12728. };
  12729. /**
  12730. * Gets matrix determinant
  12731. * @returns the determinant
  12732. */
  12733. Matrix2D.prototype.determinant = function () {
  12734. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12735. };
  12736. /**
  12737. * Inverses the matrix and stores it in a target matrix
  12738. * @param result defines the target matrix
  12739. * @returns the current matrix
  12740. */
  12741. Matrix2D.prototype.invertToRef = function (result) {
  12742. var l0 = this.m[0];
  12743. var l1 = this.m[1];
  12744. var l2 = this.m[2];
  12745. var l3 = this.m[3];
  12746. var l4 = this.m[4];
  12747. var l5 = this.m[5];
  12748. var det = this.determinant();
  12749. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12750. result.m[0] = 0;
  12751. result.m[1] = 0;
  12752. result.m[2] = 0;
  12753. result.m[3] = 0;
  12754. result.m[4] = 0;
  12755. result.m[5] = 0;
  12756. return this;
  12757. }
  12758. var detDiv = 1 / det;
  12759. var det4 = l2 * l5 - l3 * l4;
  12760. var det5 = l1 * l4 - l0 * l5;
  12761. result.m[0] = l3 * detDiv;
  12762. result.m[1] = -l1 * detDiv;
  12763. result.m[2] = -l2 * detDiv;
  12764. result.m[3] = l0 * detDiv;
  12765. result.m[4] = det4 * detDiv;
  12766. result.m[5] = det5 * detDiv;
  12767. return this;
  12768. };
  12769. /**
  12770. * Multiplies the current matrix with another one
  12771. * @param other defines the second operand
  12772. * @param result defines the target matrix
  12773. * @returns the current matrix
  12774. */
  12775. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12776. var l0 = this.m[0];
  12777. var l1 = this.m[1];
  12778. var l2 = this.m[2];
  12779. var l3 = this.m[3];
  12780. var l4 = this.m[4];
  12781. var l5 = this.m[5];
  12782. var r0 = other.m[0];
  12783. var r1 = other.m[1];
  12784. var r2 = other.m[2];
  12785. var r3 = other.m[3];
  12786. var r4 = other.m[4];
  12787. var r5 = other.m[5];
  12788. result.m[0] = l0 * r0 + l1 * r2;
  12789. result.m[1] = l0 * r1 + l1 * r3;
  12790. result.m[2] = l2 * r0 + l3 * r2;
  12791. result.m[3] = l2 * r1 + l3 * r3;
  12792. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12793. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12794. return this;
  12795. };
  12796. /**
  12797. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12798. * @param x defines the x coordinate to transform
  12799. * @param y defines the x coordinate to transform
  12800. * @param result defines the target vector2
  12801. * @returns the current matrix
  12802. */
  12803. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12804. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12805. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12806. return this;
  12807. };
  12808. // Statics
  12809. /**
  12810. * Creates an identity matrix
  12811. * @returns a new matrix
  12812. */
  12813. Matrix2D.Identity = function () {
  12814. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12815. };
  12816. /**
  12817. * Creates a translation matrix and stores it in a target matrix
  12818. * @param x defines the x coordinate of the translation
  12819. * @param y defines the y coordinate of the translation
  12820. * @param result defines the target matrix
  12821. */
  12822. Matrix2D.TranslationToRef = function (x, y, result) {
  12823. result.fromValues(1, 0, 0, 1, x, y);
  12824. };
  12825. /**
  12826. * Creates a scaling matrix and stores it in a target matrix
  12827. * @param x defines the x coordinate of the scaling
  12828. * @param y defines the y coordinate of the scaling
  12829. * @param result defines the target matrix
  12830. */
  12831. Matrix2D.ScalingToRef = function (x, y, result) {
  12832. result.fromValues(x, 0, 0, y, 0, 0);
  12833. };
  12834. /**
  12835. * Creates a rotation matrix and stores it in a target matrix
  12836. * @param angle defines the rotation angle
  12837. * @param result defines the target matrix
  12838. */
  12839. Matrix2D.RotationToRef = function (angle, result) {
  12840. var s = Math.sin(angle);
  12841. var c = Math.cos(angle);
  12842. result.fromValues(c, s, -s, c, 0, 0);
  12843. };
  12844. /**
  12845. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12846. * @param tx defines the x coordinate of the translation
  12847. * @param ty defines the y coordinate of the translation
  12848. * @param angle defines the rotation angle
  12849. * @param scaleX defines the x coordinate of the scaling
  12850. * @param scaleY defines the y coordinate of the scaling
  12851. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12852. * @param result defines the target matrix
  12853. */
  12854. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12855. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12856. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12857. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12858. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12859. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12860. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12861. if (parentMatrix) {
  12862. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12863. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12864. }
  12865. else {
  12866. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12867. }
  12868. };
  12869. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12870. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12871. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12872. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12873. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12874. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12875. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12876. return Matrix2D;
  12877. }());
  12878. /***/ }),
  12879. /***/ "./2D/measure.ts":
  12880. /*!***********************!*\
  12881. !*** ./2D/measure.ts ***!
  12882. \***********************/
  12883. /*! exports provided: Measure */
  12884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12885. "use strict";
  12886. __webpack_require__.r(__webpack_exports__);
  12887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12888. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  12889. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12890. var tmpRect = [
  12891. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12892. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12893. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12894. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12895. ];
  12896. var tmpRect2 = [
  12897. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12898. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12899. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12900. new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12901. ];
  12902. var tmpV1 = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12903. var tmpV2 = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12904. /**
  12905. * Class used to store 2D control sizes
  12906. */
  12907. var Measure = /** @class */ (function () {
  12908. /**
  12909. * Creates a new measure
  12910. * @param left defines left coordinate
  12911. * @param top defines top coordinate
  12912. * @param width defines width dimension
  12913. * @param height defines height dimension
  12914. */
  12915. function Measure(
  12916. /** defines left coordinate */
  12917. left,
  12918. /** defines top coordinate */
  12919. top,
  12920. /** defines width dimension */
  12921. width,
  12922. /** defines height dimension */
  12923. height) {
  12924. this.left = left;
  12925. this.top = top;
  12926. this.width = width;
  12927. this.height = height;
  12928. }
  12929. /**
  12930. * Copy from another measure
  12931. * @param other defines the other measure to copy from
  12932. */
  12933. Measure.prototype.copyFrom = function (other) {
  12934. this.left = other.left;
  12935. this.top = other.top;
  12936. this.width = other.width;
  12937. this.height = other.height;
  12938. };
  12939. /**
  12940. * Copy from a group of 4 floats
  12941. * @param left defines left coordinate
  12942. * @param top defines top coordinate
  12943. * @param width defines width dimension
  12944. * @param height defines height dimension
  12945. */
  12946. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12947. this.left = left;
  12948. this.top = top;
  12949. this.width = width;
  12950. this.height = height;
  12951. };
  12952. /**
  12953. * Computes the axis aligned bounding box measure for two given measures
  12954. * @param a Input measure
  12955. * @param b Input measure
  12956. * @param result the resulting bounding measure
  12957. */
  12958. Measure.CombineToRef = function (a, b, result) {
  12959. var left = Math.min(a.left, b.left);
  12960. var top = Math.min(a.top, b.top);
  12961. var right = Math.max(a.left + a.width, b.left + b.width);
  12962. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12963. result.left = left;
  12964. result.top = top;
  12965. result.width = right - left;
  12966. result.height = bottom - top;
  12967. };
  12968. /**
  12969. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  12970. * @param transform the matrix to transform the measure before computing the AABB
  12971. * @param result the resulting AABB
  12972. */
  12973. Measure.prototype.transformToRef = function (transform, result) {
  12974. tmpRect[0].copyFromFloats(this.left, this.top);
  12975. tmpRect[1].copyFromFloats(this.left + this.width, this.top);
  12976. tmpRect[2].copyFromFloats(this.left + this.width, this.top + this.height);
  12977. tmpRect[3].copyFromFloats(this.left, this.top + this.height);
  12978. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  12979. tmpV2.copyFromFloats(0, 0);
  12980. for (var i = 0; i < 4; i++) {
  12981. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  12982. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  12983. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  12984. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  12985. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  12986. }
  12987. result.left = tmpV1.x;
  12988. result.top = tmpV1.y;
  12989. result.width = tmpV2.x - tmpV1.x;
  12990. result.height = tmpV2.y - tmpV1.y;
  12991. };
  12992. /**
  12993. * Check equality between this measure and another one
  12994. * @param other defines the other measures
  12995. * @returns true if both measures are equals
  12996. */
  12997. Measure.prototype.isEqualsTo = function (other) {
  12998. if (this.left !== other.left) {
  12999. return false;
  13000. }
  13001. if (this.top !== other.top) {
  13002. return false;
  13003. }
  13004. if (this.width !== other.width) {
  13005. return false;
  13006. }
  13007. if (this.height !== other.height) {
  13008. return false;
  13009. }
  13010. return true;
  13011. };
  13012. /**
  13013. * Creates an empty measure
  13014. * @returns a new measure
  13015. */
  13016. Measure.Empty = function () {
  13017. return new Measure(0, 0, 0, 0);
  13018. };
  13019. return Measure;
  13020. }());
  13021. /***/ }),
  13022. /***/ "./2D/multiLinePoint.ts":
  13023. /*!******************************!*\
  13024. !*** ./2D/multiLinePoint.ts ***!
  13025. \******************************/
  13026. /*! exports provided: MultiLinePoint */
  13027. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13028. "use strict";
  13029. __webpack_require__.r(__webpack_exports__);
  13030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13031. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13032. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  13033. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13034. /**
  13035. * Class used to store a point for a MultiLine object.
  13036. * The point can be pure 2D coordinates, a mesh or a control
  13037. */
  13038. var MultiLinePoint = /** @class */ (function () {
  13039. /**
  13040. * Creates a new MultiLinePoint
  13041. * @param multiLine defines the source MultiLine object
  13042. */
  13043. function MultiLinePoint(multiLine) {
  13044. this._multiLine = multiLine;
  13045. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13046. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13047. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13048. }
  13049. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13050. /** Gets or sets x coordinate */
  13051. get: function () {
  13052. return this._x.toString(this._multiLine._host);
  13053. },
  13054. set: function (value) {
  13055. if (this._x.toString(this._multiLine._host) === value) {
  13056. return;
  13057. }
  13058. if (this._x.fromString(value)) {
  13059. this._multiLine._markAsDirty();
  13060. }
  13061. },
  13062. enumerable: true,
  13063. configurable: true
  13064. });
  13065. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13066. /** Gets or sets y coordinate */
  13067. get: function () {
  13068. return this._y.toString(this._multiLine._host);
  13069. },
  13070. set: function (value) {
  13071. if (this._y.toString(this._multiLine._host) === value) {
  13072. return;
  13073. }
  13074. if (this._y.fromString(value)) {
  13075. this._multiLine._markAsDirty();
  13076. }
  13077. },
  13078. enumerable: true,
  13079. configurable: true
  13080. });
  13081. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13082. /** Gets or sets the control associated with this point */
  13083. get: function () {
  13084. return this._control;
  13085. },
  13086. set: function (value) {
  13087. if (this._control === value) {
  13088. return;
  13089. }
  13090. if (this._control && this._controlObserver) {
  13091. this._control.onDirtyObservable.remove(this._controlObserver);
  13092. this._controlObserver = null;
  13093. }
  13094. this._control = value;
  13095. if (this._control) {
  13096. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13097. }
  13098. this._multiLine._markAsDirty();
  13099. },
  13100. enumerable: true,
  13101. configurable: true
  13102. });
  13103. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13104. /** Gets or sets the mesh associated with this point */
  13105. get: function () {
  13106. return this._mesh;
  13107. },
  13108. set: function (value) {
  13109. if (this._mesh === value) {
  13110. return;
  13111. }
  13112. if (this._mesh && this._meshObserver) {
  13113. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13114. }
  13115. this._mesh = value;
  13116. if (this._mesh) {
  13117. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13118. }
  13119. this._multiLine._markAsDirty();
  13120. },
  13121. enumerable: true,
  13122. configurable: true
  13123. });
  13124. /** Resets links */
  13125. MultiLinePoint.prototype.resetLinks = function () {
  13126. this.control = null;
  13127. this.mesh = null;
  13128. };
  13129. /**
  13130. * Gets a translation vector
  13131. * @returns the translation vector
  13132. */
  13133. MultiLinePoint.prototype.translate = function () {
  13134. this._point = this._translatePoint();
  13135. return this._point;
  13136. };
  13137. MultiLinePoint.prototype._translatePoint = function () {
  13138. if (this._mesh != null) {
  13139. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13140. }
  13141. else if (this._control != null) {
  13142. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  13143. }
  13144. else {
  13145. var host = this._multiLine._host;
  13146. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13147. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13148. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  13149. }
  13150. };
  13151. /** Release associated resources */
  13152. MultiLinePoint.prototype.dispose = function () {
  13153. this.resetLinks();
  13154. };
  13155. return MultiLinePoint;
  13156. }());
  13157. /***/ }),
  13158. /***/ "./2D/style.ts":
  13159. /*!*********************!*\
  13160. !*** ./2D/style.ts ***!
  13161. \*********************/
  13162. /*! exports provided: Style */
  13163. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13164. "use strict";
  13165. __webpack_require__.r(__webpack_exports__);
  13166. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13167. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  13168. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13169. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13170. /**
  13171. * Define a style used by control to automatically setup properties based on a template.
  13172. * Only support font related properties so far
  13173. */
  13174. var Style = /** @class */ (function () {
  13175. /**
  13176. * Creates a new style object
  13177. * @param host defines the AdvancedDynamicTexture which hosts this style
  13178. */
  13179. function Style(host) {
  13180. this._fontFamily = "Arial";
  13181. this._fontStyle = "";
  13182. this._fontWeight = "";
  13183. /** @hidden */
  13184. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13185. /**
  13186. * Observable raised when the style values are changed
  13187. */
  13188. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13189. this._host = host;
  13190. }
  13191. Object.defineProperty(Style.prototype, "fontSize", {
  13192. /**
  13193. * Gets or sets the font size
  13194. */
  13195. get: function () {
  13196. return this._fontSize.toString(this._host);
  13197. },
  13198. set: function (value) {
  13199. if (this._fontSize.toString(this._host) === value) {
  13200. return;
  13201. }
  13202. if (this._fontSize.fromString(value)) {
  13203. this.onChangedObservable.notifyObservers(this);
  13204. }
  13205. },
  13206. enumerable: true,
  13207. configurable: true
  13208. });
  13209. Object.defineProperty(Style.prototype, "fontFamily", {
  13210. /**
  13211. * Gets or sets the font family
  13212. */
  13213. get: function () {
  13214. return this._fontFamily;
  13215. },
  13216. set: function (value) {
  13217. if (this._fontFamily === value) {
  13218. return;
  13219. }
  13220. this._fontFamily = value;
  13221. this.onChangedObservable.notifyObservers(this);
  13222. },
  13223. enumerable: true,
  13224. configurable: true
  13225. });
  13226. Object.defineProperty(Style.prototype, "fontStyle", {
  13227. /**
  13228. * Gets or sets the font style
  13229. */
  13230. get: function () {
  13231. return this._fontStyle;
  13232. },
  13233. set: function (value) {
  13234. if (this._fontStyle === value) {
  13235. return;
  13236. }
  13237. this._fontStyle = value;
  13238. this.onChangedObservable.notifyObservers(this);
  13239. },
  13240. enumerable: true,
  13241. configurable: true
  13242. });
  13243. Object.defineProperty(Style.prototype, "fontWeight", {
  13244. /** Gets or sets font weight */
  13245. get: function () {
  13246. return this._fontWeight;
  13247. },
  13248. set: function (value) {
  13249. if (this._fontWeight === value) {
  13250. return;
  13251. }
  13252. this._fontWeight = value;
  13253. this.onChangedObservable.notifyObservers(this);
  13254. },
  13255. enumerable: true,
  13256. configurable: true
  13257. });
  13258. /** Dispose all associated resources */
  13259. Style.prototype.dispose = function () {
  13260. this.onChangedObservable.clear();
  13261. };
  13262. return Style;
  13263. }());
  13264. /***/ }),
  13265. /***/ "./2D/valueAndUnit.ts":
  13266. /*!****************************!*\
  13267. !*** ./2D/valueAndUnit.ts ***!
  13268. \****************************/
  13269. /*! exports provided: ValueAndUnit */
  13270. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13271. "use strict";
  13272. __webpack_require__.r(__webpack_exports__);
  13273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13274. /**
  13275. * Class used to specific a value and its associated unit
  13276. */
  13277. var ValueAndUnit = /** @class */ (function () {
  13278. /**
  13279. * Creates a new ValueAndUnit
  13280. * @param value defines the value to store
  13281. * @param unit defines the unit to store
  13282. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13283. */
  13284. function ValueAndUnit(value,
  13285. /** defines the unit to store */
  13286. unit,
  13287. /** defines a boolean indicating if the value can be negative */
  13288. negativeValueAllowed) {
  13289. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13290. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13291. this.unit = unit;
  13292. this.negativeValueAllowed = negativeValueAllowed;
  13293. this._value = 1;
  13294. /**
  13295. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13296. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13297. */
  13298. this.ignoreAdaptiveScaling = false;
  13299. this._value = value;
  13300. this._originalUnit = unit;
  13301. }
  13302. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13303. /** Gets a boolean indicating if the value is a percentage */
  13304. get: function () {
  13305. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13306. },
  13307. enumerable: true,
  13308. configurable: true
  13309. });
  13310. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13311. /** Gets a boolean indicating if the value is store as pixel */
  13312. get: function () {
  13313. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13314. },
  13315. enumerable: true,
  13316. configurable: true
  13317. });
  13318. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13319. /** Gets direct internal value */
  13320. get: function () {
  13321. return this._value;
  13322. },
  13323. enumerable: true,
  13324. configurable: true
  13325. });
  13326. /**
  13327. * Gets value as pixel
  13328. * @param host defines the root host
  13329. * @param refValue defines the reference value for percentages
  13330. * @returns the value as pixel
  13331. */
  13332. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13333. if (this.isPixel) {
  13334. return this.getValue(host);
  13335. }
  13336. return this.getValue(host) * refValue;
  13337. };
  13338. /**
  13339. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13340. * @param value defines the value to store
  13341. * @param unit defines the unit to store
  13342. * @returns the current ValueAndUnit
  13343. */
  13344. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13345. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13346. this._value = value;
  13347. this.unit = unit;
  13348. return this;
  13349. };
  13350. /**
  13351. * Gets the value accordingly to its unit
  13352. * @param host defines the root host
  13353. * @returns the value
  13354. */
  13355. ValueAndUnit.prototype.getValue = function (host) {
  13356. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13357. var width = 0;
  13358. var height = 0;
  13359. if (host.idealWidth) {
  13360. width = (this._value * host.getSize().width) / host.idealWidth;
  13361. }
  13362. if (host.idealHeight) {
  13363. height = (this._value * host.getSize().height) / host.idealHeight;
  13364. }
  13365. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13366. return window.innerWidth < window.innerHeight ? width : height;
  13367. }
  13368. if (host.idealWidth) { // horizontal
  13369. return width;
  13370. }
  13371. if (host.idealHeight) { // vertical
  13372. return height;
  13373. }
  13374. }
  13375. return this._value;
  13376. };
  13377. /**
  13378. * Gets a string representation of the value
  13379. * @param host defines the root host
  13380. * @param decimals defines an optional number of decimals to display
  13381. * @returns a string
  13382. */
  13383. ValueAndUnit.prototype.toString = function (host, decimals) {
  13384. switch (this.unit) {
  13385. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13386. var percentage = this.getValue(host) * 100;
  13387. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13388. case ValueAndUnit.UNITMODE_PIXEL:
  13389. var pixels = this.getValue(host);
  13390. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13391. }
  13392. return this.unit.toString();
  13393. };
  13394. /**
  13395. * Store a value parsed from a string
  13396. * @param source defines the source string
  13397. * @returns true if the value was successfully parsed
  13398. */
  13399. ValueAndUnit.prototype.fromString = function (source) {
  13400. var match = ValueAndUnit._Regex.exec(source.toString());
  13401. if (!match || match.length === 0) {
  13402. return false;
  13403. }
  13404. var sourceValue = parseFloat(match[1]);
  13405. var sourceUnit = this._originalUnit;
  13406. if (!this.negativeValueAllowed) {
  13407. if (sourceValue < 0) {
  13408. sourceValue = 0;
  13409. }
  13410. }
  13411. if (match.length === 4) {
  13412. switch (match[3]) {
  13413. case "px":
  13414. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13415. break;
  13416. case "%":
  13417. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13418. sourceValue /= 100.0;
  13419. break;
  13420. }
  13421. }
  13422. if (sourceValue === this._value && sourceUnit === this.unit) {
  13423. return false;
  13424. }
  13425. this._value = sourceValue;
  13426. this.unit = sourceUnit;
  13427. return true;
  13428. };
  13429. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13430. /** UNITMODE_PERCENTAGE */
  13431. get: function () {
  13432. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13433. },
  13434. enumerable: true,
  13435. configurable: true
  13436. });
  13437. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13438. /** UNITMODE_PIXEL */
  13439. get: function () {
  13440. return ValueAndUnit._UNITMODE_PIXEL;
  13441. },
  13442. enumerable: true,
  13443. configurable: true
  13444. });
  13445. // Static
  13446. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13447. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13448. ValueAndUnit._UNITMODE_PIXEL = 1;
  13449. return ValueAndUnit;
  13450. }());
  13451. /***/ }),
  13452. /***/ "./2D/xmlLoader.ts":
  13453. /*!*************************!*\
  13454. !*** ./2D/xmlLoader.ts ***!
  13455. \*************************/
  13456. /*! exports provided: XmlLoader */
  13457. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13458. "use strict";
  13459. __webpack_require__.r(__webpack_exports__);
  13460. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13461. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/perfCounter");
  13462. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13463. /**
  13464. * Class used to load GUI via XML.
  13465. */
  13466. var XmlLoader = /** @class */ (function () {
  13467. /**
  13468. * Create a new xml loader
  13469. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13470. */
  13471. function XmlLoader(parentClass) {
  13472. if (parentClass === void 0) { parentClass = null; }
  13473. this._nodes = {};
  13474. this._nodeTypes = {
  13475. element: 1,
  13476. attribute: 2,
  13477. text: 3
  13478. };
  13479. this._isLoaded = false;
  13480. this._objectAttributes = {
  13481. "textHorizontalAlignment": 1,
  13482. "textVerticalAlignment": 2,
  13483. "horizontalAlignment": 3,
  13484. "verticalAlignment": 4,
  13485. "stretch": 5,
  13486. };
  13487. if (parentClass) {
  13488. this._parentClass = parentClass;
  13489. }
  13490. }
  13491. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13492. var element = window;
  13493. if (this._parentClass) {
  13494. element = this._parentClass;
  13495. }
  13496. var value = attributeValue;
  13497. value = value.split(".");
  13498. for (var i = 0; i < value.length; i++) {
  13499. element = element[value[i]];
  13500. }
  13501. return element;
  13502. };
  13503. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13504. var attribute = attributeName.split(".");
  13505. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13506. return className[attribute[1]];
  13507. };
  13508. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13509. if (linkParent === void 0) { linkParent = true; }
  13510. try {
  13511. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13512. var guiNode = new className();
  13513. if (parent && linkParent) {
  13514. parent.addControl(guiNode);
  13515. }
  13516. for (var i = 0; i < node.attributes.length; i++) {
  13517. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13518. continue;
  13519. }
  13520. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13521. var element = this._getChainElement(node.attributes[i].value);
  13522. guiNode[node.attributes[i].name].add(element);
  13523. continue;
  13524. }
  13525. else if (node.attributes[i].name == "linkWithMesh") {
  13526. if (this._parentClass) {
  13527. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13528. }
  13529. else {
  13530. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13531. }
  13532. }
  13533. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13534. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13535. guiNode[node.attributes[i].name] = element;
  13536. }
  13537. else if (!this._objectAttributes[node.attributes[i].name]) {
  13538. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13539. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13540. }
  13541. else {
  13542. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13543. }
  13544. }
  13545. else {
  13546. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13547. }
  13548. }
  13549. if (!node.attributes.getNamedItem("id")) {
  13550. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13551. return guiNode;
  13552. }
  13553. var id = node.attributes.getNamedItem("id").value;
  13554. if (id.startsWith("{{") && id.endsWith("}}")) {
  13555. id = this._getChainElement(id.substring(2, id.length - 2));
  13556. }
  13557. if (!this._nodes[id]) {
  13558. this._nodes[id] = guiNode;
  13559. }
  13560. else {
  13561. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13562. }
  13563. return guiNode;
  13564. }
  13565. catch (e) {
  13566. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13567. }
  13568. };
  13569. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13570. var width;
  13571. var height;
  13572. var columns;
  13573. var rows = node.children;
  13574. var cells;
  13575. var isPixel = false;
  13576. var cellNode;
  13577. var rowNumber = -1;
  13578. var columnNumber = -1;
  13579. var totalColumnsNumber = 0;
  13580. for (var i = 0; i < rows.length; i++) {
  13581. if (rows[i].nodeType != this._nodeTypes.element) {
  13582. continue;
  13583. }
  13584. if (rows[i].nodeName != "Row") {
  13585. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13586. }
  13587. rowNumber += 1;
  13588. columns = rows[i].children;
  13589. if (!rows[i].attributes.getNamedItem("height")) {
  13590. throw "XmlLoader Exception : Height must be defined for grid rows";
  13591. }
  13592. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13593. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13594. guiNode.addRowDefinition(height, isPixel);
  13595. for (var j = 0; j < columns.length; j++) {
  13596. if (columns[j].nodeType != this._nodeTypes.element) {
  13597. continue;
  13598. }
  13599. if (columns[j].nodeName != "Column") {
  13600. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13601. }
  13602. columnNumber += 1;
  13603. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13604. 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.";
  13605. }
  13606. if (rowNumber == 0) {
  13607. if (!columns[j].attributes.getNamedItem("width")) {
  13608. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13609. }
  13610. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13611. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13612. guiNode.addColumnDefinition(width, isPixel);
  13613. }
  13614. cells = columns[j].children;
  13615. for (var k = 0; k < cells.length; k++) {
  13616. if (cells[k].nodeType != this._nodeTypes.element) {
  13617. continue;
  13618. }
  13619. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13620. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13621. if (cells[k].firstChild) {
  13622. this._parseXml(cells[k].firstChild, cellNode);
  13623. }
  13624. }
  13625. }
  13626. if (rowNumber == 0) {
  13627. totalColumnsNumber = columnNumber;
  13628. }
  13629. columnNumber = -1;
  13630. }
  13631. if (node.nextSibling) {
  13632. this._parseXml(node.nextSibling, parent);
  13633. }
  13634. };
  13635. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13636. if (node.firstChild) {
  13637. this._parseXml(node.firstChild, guiNode);
  13638. }
  13639. if (node.nextSibling) {
  13640. this._parseXml(node.nextSibling, parent);
  13641. }
  13642. };
  13643. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13644. if (this._parentClass) {
  13645. this._parentClass[variable] = source[iterator];
  13646. }
  13647. else {
  13648. window[variable] = source[iterator];
  13649. }
  13650. if (node.firstChild) {
  13651. this._parseXml(node.firstChild, guiNode, true);
  13652. }
  13653. };
  13654. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13655. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13656. if (!dataSource.includes(" in ")) {
  13657. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13658. }
  13659. else {
  13660. var isArray = true;
  13661. var splittedSource = dataSource.split(" in ");
  13662. if (splittedSource.length < 2) {
  13663. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13664. }
  13665. var source = splittedSource[1];
  13666. if (source.startsWith("{") && source.endsWith("}")) {
  13667. isArray = false;
  13668. }
  13669. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13670. source = source.substring(1, source.length - 1);
  13671. }
  13672. if (this._parentClass) {
  13673. source = this._parentClass[source];
  13674. }
  13675. else {
  13676. source = window[source];
  13677. }
  13678. if (isArray) {
  13679. for (var i = 0; i < source.length; i++) {
  13680. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13681. }
  13682. }
  13683. else {
  13684. for (var i in source) {
  13685. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13686. }
  13687. }
  13688. if (node.nextSibling) {
  13689. this._parseXml(node.nextSibling, parent);
  13690. }
  13691. }
  13692. };
  13693. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13694. if (generated === void 0) { generated = false; }
  13695. if (node.nodeType != this._nodeTypes.element) {
  13696. if (node.nextSibling) {
  13697. this._parseXml(node.nextSibling, parent, generated);
  13698. }
  13699. return;
  13700. }
  13701. if (generated) {
  13702. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13703. }
  13704. var guiNode = this._createGuiElement(node, parent);
  13705. if (node.nodeName == "Grid") {
  13706. this._parseGrid(node, guiNode, parent);
  13707. }
  13708. else if (!node.attributes.getNamedItem("dataSource")) {
  13709. this._parseElement(node, guiNode, parent);
  13710. }
  13711. else {
  13712. this._parseElementsFromSource(node, guiNode, parent);
  13713. }
  13714. };
  13715. /**
  13716. * Gets if the loading has finished.
  13717. * @returns whether the loading has finished or not
  13718. */
  13719. XmlLoader.prototype.isLoaded = function () {
  13720. return this._isLoaded;
  13721. };
  13722. /**
  13723. * Gets a loaded node / control by id.
  13724. * @param id the Controls id set in the xml
  13725. * @returns element of type Control
  13726. */
  13727. XmlLoader.prototype.getNodeById = function (id) {
  13728. return this._nodes[id];
  13729. };
  13730. /**
  13731. * Gets all loaded nodes / controls
  13732. * @returns Array of controls
  13733. */
  13734. XmlLoader.prototype.getNodes = function () {
  13735. return this._nodes;
  13736. };
  13737. /**
  13738. * Initiates the xml layout loading
  13739. * @param xmlFile defines the xml layout to load
  13740. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13741. * @param callback defines the callback called on layout load.
  13742. */
  13743. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13744. var xhttp = new XMLHttpRequest();
  13745. xhttp.onreadystatechange = function () {
  13746. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13747. if (!xhttp.responseXML) {
  13748. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13749. }
  13750. var xmlDoc = xhttp.responseXML.documentElement;
  13751. this._parseXml(xmlDoc.firstChild, rootNode);
  13752. this._isLoaded = true;
  13753. if (callback) {
  13754. callback();
  13755. }
  13756. }
  13757. }.bind(this);
  13758. xhttp.open("GET", xmlFile, true);
  13759. xhttp.send();
  13760. };
  13761. return XmlLoader;
  13762. }());
  13763. /***/ }),
  13764. /***/ "./3D/controls/abstractButton3D.ts":
  13765. /*!*****************************************!*\
  13766. !*** ./3D/controls/abstractButton3D.ts ***!
  13767. \*****************************************/
  13768. /*! exports provided: AbstractButton3D */
  13769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13770. "use strict";
  13771. __webpack_require__.r(__webpack_exports__);
  13772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13773. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13774. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13775. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13776. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13777. /**
  13778. * Class used as a root to all buttons
  13779. */
  13780. var AbstractButton3D = /** @class */ (function (_super) {
  13781. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13782. /**
  13783. * Creates a new button
  13784. * @param name defines the control name
  13785. */
  13786. function AbstractButton3D(name) {
  13787. return _super.call(this, name) || this;
  13788. }
  13789. AbstractButton3D.prototype._getTypeName = function () {
  13790. return "AbstractButton3D";
  13791. };
  13792. // Mesh association
  13793. AbstractButton3D.prototype._createNode = function (scene) {
  13794. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13795. };
  13796. return AbstractButton3D;
  13797. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13798. /***/ }),
  13799. /***/ "./3D/controls/button3D.ts":
  13800. /*!*********************************!*\
  13801. !*** ./3D/controls/button3D.ts ***!
  13802. \*********************************/
  13803. /*! exports provided: Button3D */
  13804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13805. "use strict";
  13806. __webpack_require__.r(__webpack_exports__);
  13807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13808. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13809. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  13810. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13811. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13812. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13813. /**
  13814. * Class used to create a button in 3D
  13815. */
  13816. var Button3D = /** @class */ (function (_super) {
  13817. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13818. /**
  13819. * Creates a new button
  13820. * @param name defines the control name
  13821. */
  13822. function Button3D(name) {
  13823. var _this = _super.call(this, name) || this;
  13824. _this._contentResolution = 512;
  13825. _this._contentScaleRatio = 2;
  13826. // Default animations
  13827. _this.pointerEnterAnimation = function () {
  13828. if (!_this.mesh) {
  13829. return;
  13830. }
  13831. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13832. };
  13833. _this.pointerOutAnimation = function () {
  13834. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13835. };
  13836. _this.pointerDownAnimation = function () {
  13837. if (!_this.mesh) {
  13838. return;
  13839. }
  13840. _this.mesh.scaling.scaleInPlace(0.95);
  13841. };
  13842. _this.pointerUpAnimation = function () {
  13843. if (!_this.mesh) {
  13844. return;
  13845. }
  13846. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13847. };
  13848. return _this;
  13849. }
  13850. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13851. /**
  13852. * Gets or sets the texture resolution used to render content (512 by default)
  13853. */
  13854. get: function () {
  13855. return this._contentResolution;
  13856. },
  13857. set: function (value) {
  13858. if (this._contentResolution === value) {
  13859. return;
  13860. }
  13861. this._contentResolution = value;
  13862. this._resetContent();
  13863. },
  13864. enumerable: true,
  13865. configurable: true
  13866. });
  13867. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13868. /**
  13869. * Gets or sets the texture scale ratio used to render content (2 by default)
  13870. */
  13871. get: function () {
  13872. return this._contentScaleRatio;
  13873. },
  13874. set: function (value) {
  13875. if (this._contentScaleRatio === value) {
  13876. return;
  13877. }
  13878. this._contentScaleRatio = value;
  13879. this._resetContent();
  13880. },
  13881. enumerable: true,
  13882. configurable: true
  13883. });
  13884. Button3D.prototype._disposeFacadeTexture = function () {
  13885. if (this._facadeTexture) {
  13886. this._facadeTexture.dispose();
  13887. this._facadeTexture = null;
  13888. }
  13889. };
  13890. Button3D.prototype._resetContent = function () {
  13891. this._disposeFacadeTexture();
  13892. this.content = this._content;
  13893. };
  13894. Object.defineProperty(Button3D.prototype, "content", {
  13895. /**
  13896. * Gets or sets the GUI 2D content used to display the button's facade
  13897. */
  13898. get: function () {
  13899. return this._content;
  13900. },
  13901. set: function (value) {
  13902. this._content = value;
  13903. if (!this._host || !this._host.utilityLayer) {
  13904. return;
  13905. }
  13906. if (!this._facadeTexture) {
  13907. 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);
  13908. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  13909. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  13910. this._facadeTexture.premulAlpha = true;
  13911. }
  13912. else {
  13913. this._facadeTexture.rootContainer.clearControls();
  13914. }
  13915. this._facadeTexture.addControl(value);
  13916. this._applyFacade(this._facadeTexture);
  13917. },
  13918. enumerable: true,
  13919. configurable: true
  13920. });
  13921. /**
  13922. * Apply the facade texture (created from the content property).
  13923. * This function can be overloaded by child classes
  13924. * @param facadeTexture defines the AdvancedDynamicTexture to use
  13925. */
  13926. Button3D.prototype._applyFacade = function (facadeTexture) {
  13927. this._currentMaterial.emissiveTexture = facadeTexture;
  13928. };
  13929. Button3D.prototype._getTypeName = function () {
  13930. return "Button3D";
  13931. };
  13932. // Mesh association
  13933. Button3D.prototype._createNode = function (scene) {
  13934. var faceUV = new Array(6);
  13935. for (var i = 0; i < 6; i++) {
  13936. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  13937. }
  13938. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  13939. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  13940. width: 1.0,
  13941. height: 1.0,
  13942. depth: 0.08,
  13943. faceUV: faceUV
  13944. }, scene);
  13945. return mesh;
  13946. };
  13947. Button3D.prototype._affectMaterial = function (mesh) {
  13948. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  13949. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13950. mesh.material = material;
  13951. this._currentMaterial = material;
  13952. this._resetContent();
  13953. };
  13954. /**
  13955. * Releases all associated resources
  13956. */
  13957. Button3D.prototype.dispose = function () {
  13958. _super.prototype.dispose.call(this);
  13959. this._disposeFacadeTexture();
  13960. if (this._currentMaterial) {
  13961. this._currentMaterial.dispose();
  13962. }
  13963. };
  13964. return Button3D;
  13965. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  13966. /***/ }),
  13967. /***/ "./3D/controls/container3D.ts":
  13968. /*!************************************!*\
  13969. !*** ./3D/controls/container3D.ts ***!
  13970. \************************************/
  13971. /*! exports provided: Container3D */
  13972. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13973. "use strict";
  13974. __webpack_require__.r(__webpack_exports__);
  13975. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  13976. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13977. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/perfCounter");
  13978. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13979. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13980. /**
  13981. * Class used to create containers for controls
  13982. */
  13983. var Container3D = /** @class */ (function (_super) {
  13984. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  13985. /**
  13986. * Creates a new container
  13987. * @param name defines the container name
  13988. */
  13989. function Container3D(name) {
  13990. var _this = _super.call(this, name) || this;
  13991. _this._blockLayout = false;
  13992. /**
  13993. * Gets the list of child controls
  13994. */
  13995. _this._children = new Array();
  13996. return _this;
  13997. }
  13998. Object.defineProperty(Container3D.prototype, "children", {
  13999. /**
  14000. * Gets the list of child controls
  14001. */
  14002. get: function () {
  14003. return this._children;
  14004. },
  14005. enumerable: true,
  14006. configurable: true
  14007. });
  14008. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14009. /**
  14010. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14011. * This is helpful to optimize layout operation when adding multiple children in a row
  14012. */
  14013. get: function () {
  14014. return this._blockLayout;
  14015. },
  14016. set: function (value) {
  14017. if (this._blockLayout === value) {
  14018. return;
  14019. }
  14020. this._blockLayout = value;
  14021. if (!this._blockLayout) {
  14022. this._arrangeChildren();
  14023. }
  14024. },
  14025. enumerable: true,
  14026. configurable: true
  14027. });
  14028. /**
  14029. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14030. * @returns the current container
  14031. */
  14032. Container3D.prototype.updateLayout = function () {
  14033. this._arrangeChildren();
  14034. return this;
  14035. };
  14036. /**
  14037. * Gets a boolean indicating if the given control is in the children of this control
  14038. * @param control defines the control to check
  14039. * @returns true if the control is in the child list
  14040. */
  14041. Container3D.prototype.containsControl = function (control) {
  14042. return this._children.indexOf(control) !== -1;
  14043. };
  14044. /**
  14045. * Adds a control to the children of this control
  14046. * @param control defines the control to add
  14047. * @returns the current container
  14048. */
  14049. Container3D.prototype.addControl = function (control) {
  14050. var index = this._children.indexOf(control);
  14051. if (index !== -1) {
  14052. return this;
  14053. }
  14054. control.parent = this;
  14055. control._host = this._host;
  14056. this._children.push(control);
  14057. if (this._host.utilityLayer) {
  14058. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14059. if (control.node) {
  14060. control.node.parent = this.node;
  14061. }
  14062. if (!this.blockLayout) {
  14063. this._arrangeChildren();
  14064. }
  14065. }
  14066. return this;
  14067. };
  14068. /**
  14069. * This function will be called everytime a new control is added
  14070. */
  14071. Container3D.prototype._arrangeChildren = function () {
  14072. };
  14073. Container3D.prototype._createNode = function (scene) {
  14074. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14075. };
  14076. /**
  14077. * Removes a control from the children of this control
  14078. * @param control defines the control to remove
  14079. * @returns the current container
  14080. */
  14081. Container3D.prototype.removeControl = function (control) {
  14082. var index = this._children.indexOf(control);
  14083. if (index !== -1) {
  14084. this._children.splice(index, 1);
  14085. control.parent = null;
  14086. control._disposeNode();
  14087. }
  14088. return this;
  14089. };
  14090. Container3D.prototype._getTypeName = function () {
  14091. return "Container3D";
  14092. };
  14093. /**
  14094. * Releases all associated resources
  14095. */
  14096. Container3D.prototype.dispose = function () {
  14097. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14098. var control = _a[_i];
  14099. control.dispose();
  14100. }
  14101. this._children = [];
  14102. _super.prototype.dispose.call(this);
  14103. };
  14104. /** Control rotation will remain unchanged */
  14105. Container3D.UNSET_ORIENTATION = 0;
  14106. /** Control will rotate to make it look at sphere central axis */
  14107. Container3D.FACEORIGIN_ORIENTATION = 1;
  14108. /** Control will rotate to make it look back at sphere central axis */
  14109. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14110. /** Control will rotate to look at z axis (0, 0, 1) */
  14111. Container3D.FACEFORWARD_ORIENTATION = 3;
  14112. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14113. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14114. return Container3D;
  14115. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14116. /***/ }),
  14117. /***/ "./3D/controls/control3D.ts":
  14118. /*!**********************************!*\
  14119. !*** ./3D/controls/control3D.ts ***!
  14120. \**********************************/
  14121. /*! exports provided: Control3D */
  14122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14123. "use strict";
  14124. __webpack_require__.r(__webpack_exports__);
  14125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14126. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  14127. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14128. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14129. /**
  14130. * Class used as base class for controls
  14131. */
  14132. var Control3D = /** @class */ (function () {
  14133. /**
  14134. * Creates a new control
  14135. * @param name defines the control name
  14136. */
  14137. function Control3D(
  14138. /** Defines the control name */
  14139. name) {
  14140. this.name = name;
  14141. this._downCount = 0;
  14142. this._enterCount = -1;
  14143. this._downPointerIds = {};
  14144. this._isVisible = true;
  14145. /**
  14146. * An event triggered when the pointer move over the control
  14147. */
  14148. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14149. /**
  14150. * An event triggered when the pointer move out of the control
  14151. */
  14152. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14153. /**
  14154. * An event triggered when the pointer taps the control
  14155. */
  14156. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14157. /**
  14158. * An event triggered when pointer is up
  14159. */
  14160. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14161. /**
  14162. * An event triggered when a control is clicked on (with a mouse)
  14163. */
  14164. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14165. /**
  14166. * An event triggered when pointer enters the control
  14167. */
  14168. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14169. // Behaviors
  14170. this._behaviors = new Array();
  14171. }
  14172. Object.defineProperty(Control3D.prototype, "position", {
  14173. /** Gets or sets the control position in world space */
  14174. get: function () {
  14175. if (!this._node) {
  14176. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14177. }
  14178. return this._node.position;
  14179. },
  14180. set: function (value) {
  14181. if (!this._node) {
  14182. return;
  14183. }
  14184. this._node.position = value;
  14185. },
  14186. enumerable: true,
  14187. configurable: true
  14188. });
  14189. Object.defineProperty(Control3D.prototype, "scaling", {
  14190. /** Gets or sets the control scaling in world space */
  14191. get: function () {
  14192. if (!this._node) {
  14193. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14194. }
  14195. return this._node.scaling;
  14196. },
  14197. set: function (value) {
  14198. if (!this._node) {
  14199. return;
  14200. }
  14201. this._node.scaling = value;
  14202. },
  14203. enumerable: true,
  14204. configurable: true
  14205. });
  14206. Object.defineProperty(Control3D.prototype, "behaviors", {
  14207. /**
  14208. * Gets the list of attached behaviors
  14209. * @see http://doc.babylonjs.com/features/behaviour
  14210. */
  14211. get: function () {
  14212. return this._behaviors;
  14213. },
  14214. enumerable: true,
  14215. configurable: true
  14216. });
  14217. /**
  14218. * Attach a behavior to the control
  14219. * @see http://doc.babylonjs.com/features/behaviour
  14220. * @param behavior defines the behavior to attach
  14221. * @returns the current control
  14222. */
  14223. Control3D.prototype.addBehavior = function (behavior) {
  14224. var _this = this;
  14225. var index = this._behaviors.indexOf(behavior);
  14226. if (index !== -1) {
  14227. return this;
  14228. }
  14229. behavior.init();
  14230. var scene = this._host.scene;
  14231. if (scene.isLoading) {
  14232. // We defer the attach when the scene will be loaded
  14233. scene.onDataLoadedObservable.addOnce(function () {
  14234. behavior.attach(_this);
  14235. });
  14236. }
  14237. else {
  14238. behavior.attach(this);
  14239. }
  14240. this._behaviors.push(behavior);
  14241. return this;
  14242. };
  14243. /**
  14244. * Remove an attached behavior
  14245. * @see http://doc.babylonjs.com/features/behaviour
  14246. * @param behavior defines the behavior to attach
  14247. * @returns the current control
  14248. */
  14249. Control3D.prototype.removeBehavior = function (behavior) {
  14250. var index = this._behaviors.indexOf(behavior);
  14251. if (index === -1) {
  14252. return this;
  14253. }
  14254. this._behaviors[index].detach();
  14255. this._behaviors.splice(index, 1);
  14256. return this;
  14257. };
  14258. /**
  14259. * Gets an attached behavior by name
  14260. * @param name defines the name of the behavior to look for
  14261. * @see http://doc.babylonjs.com/features/behaviour
  14262. * @returns null if behavior was not found else the requested behavior
  14263. */
  14264. Control3D.prototype.getBehaviorByName = function (name) {
  14265. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14266. var behavior = _a[_i];
  14267. if (behavior.name === name) {
  14268. return behavior;
  14269. }
  14270. }
  14271. return null;
  14272. };
  14273. Object.defineProperty(Control3D.prototype, "isVisible", {
  14274. /** Gets or sets a boolean indicating if the control is visible */
  14275. get: function () {
  14276. return this._isVisible;
  14277. },
  14278. set: function (value) {
  14279. if (this._isVisible === value) {
  14280. return;
  14281. }
  14282. this._isVisible = value;
  14283. var mesh = this.mesh;
  14284. if (mesh) {
  14285. mesh.setEnabled(value);
  14286. }
  14287. },
  14288. enumerable: true,
  14289. configurable: true
  14290. });
  14291. Object.defineProperty(Control3D.prototype, "typeName", {
  14292. /**
  14293. * Gets a string representing the class name
  14294. */
  14295. get: function () {
  14296. return this._getTypeName();
  14297. },
  14298. enumerable: true,
  14299. configurable: true
  14300. });
  14301. /**
  14302. * Get the current class name of the control.
  14303. * @returns current class name
  14304. */
  14305. Control3D.prototype.getClassName = function () {
  14306. return this._getTypeName();
  14307. };
  14308. Control3D.prototype._getTypeName = function () {
  14309. return "Control3D";
  14310. };
  14311. Object.defineProperty(Control3D.prototype, "node", {
  14312. /**
  14313. * Gets the transform node used by this control
  14314. */
  14315. get: function () {
  14316. return this._node;
  14317. },
  14318. enumerable: true,
  14319. configurable: true
  14320. });
  14321. Object.defineProperty(Control3D.prototype, "mesh", {
  14322. /**
  14323. * Gets the mesh used to render this control
  14324. */
  14325. get: function () {
  14326. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14327. return this._node;
  14328. }
  14329. return null;
  14330. },
  14331. enumerable: true,
  14332. configurable: true
  14333. });
  14334. /**
  14335. * Link the control as child of the given node
  14336. * @param node defines the node to link to. Use null to unlink the control
  14337. * @returns the current control
  14338. */
  14339. Control3D.prototype.linkToTransformNode = function (node) {
  14340. if (this._node) {
  14341. this._node.parent = node;
  14342. }
  14343. return this;
  14344. };
  14345. /** @hidden **/
  14346. Control3D.prototype._prepareNode = function (scene) {
  14347. if (!this._node) {
  14348. this._node = this._createNode(scene);
  14349. if (!this.node) {
  14350. return;
  14351. }
  14352. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14353. this._node.position = this.position;
  14354. this._node.scaling = this.scaling;
  14355. var mesh = this.mesh;
  14356. if (mesh) {
  14357. mesh.isPickable = true;
  14358. this._affectMaterial(mesh);
  14359. }
  14360. }
  14361. };
  14362. /**
  14363. * Node creation.
  14364. * Can be overriden by children
  14365. * @param scene defines the scene where the node must be attached
  14366. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14367. */
  14368. Control3D.prototype._createNode = function (scene) {
  14369. // Do nothing by default
  14370. return null;
  14371. };
  14372. /**
  14373. * Affect a material to the given mesh
  14374. * @param mesh defines the mesh which will represent the control
  14375. */
  14376. Control3D.prototype._affectMaterial = function (mesh) {
  14377. mesh.material = null;
  14378. };
  14379. // Pointers
  14380. /** @hidden */
  14381. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14382. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14383. };
  14384. /** @hidden */
  14385. Control3D.prototype._onPointerEnter = function (target) {
  14386. if (this._enterCount > 0) {
  14387. return false;
  14388. }
  14389. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14390. this._enterCount = 0;
  14391. }
  14392. this._enterCount++;
  14393. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14394. if (this.pointerEnterAnimation) {
  14395. this.pointerEnterAnimation();
  14396. }
  14397. return true;
  14398. };
  14399. /** @hidden */
  14400. Control3D.prototype._onPointerOut = function (target) {
  14401. this._enterCount = 0;
  14402. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14403. if (this.pointerOutAnimation) {
  14404. this.pointerOutAnimation();
  14405. }
  14406. };
  14407. /** @hidden */
  14408. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14409. if (this._downCount !== 0) {
  14410. this._downCount++;
  14411. return false;
  14412. }
  14413. this._downCount++;
  14414. this._downPointerIds[pointerId] = true;
  14415. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14416. if (this.pointerDownAnimation) {
  14417. this.pointerDownAnimation();
  14418. }
  14419. return true;
  14420. };
  14421. /** @hidden */
  14422. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14423. this._downCount--;
  14424. delete this._downPointerIds[pointerId];
  14425. if (this._downCount < 0) {
  14426. // Handle if forcePointerUp was called prior to this
  14427. this._downCount = 0;
  14428. return;
  14429. }
  14430. if (this._downCount == 0) {
  14431. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14432. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14433. }
  14434. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14435. if (this.pointerUpAnimation) {
  14436. this.pointerUpAnimation();
  14437. }
  14438. }
  14439. };
  14440. /** @hidden */
  14441. Control3D.prototype.forcePointerUp = function (pointerId) {
  14442. if (pointerId === void 0) { pointerId = null; }
  14443. if (pointerId !== null) {
  14444. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14445. }
  14446. else {
  14447. for (var key in this._downPointerIds) {
  14448. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14449. }
  14450. if (this._downCount > 0) {
  14451. this._downCount = 1;
  14452. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14453. }
  14454. }
  14455. };
  14456. /** @hidden */
  14457. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14458. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14459. this._onPointerMove(this, pickedPoint);
  14460. var previousControlOver = this._host._lastControlOver[pointerId];
  14461. if (previousControlOver && previousControlOver !== this) {
  14462. previousControlOver._onPointerOut(this);
  14463. }
  14464. if (previousControlOver !== this) {
  14465. this._onPointerEnter(this);
  14466. }
  14467. this._host._lastControlOver[pointerId] = this;
  14468. return true;
  14469. }
  14470. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14471. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14472. this._host._lastControlDown[pointerId] = this;
  14473. this._host._lastPickedControl = this;
  14474. return true;
  14475. }
  14476. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14477. if (this._host._lastControlDown[pointerId]) {
  14478. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14479. }
  14480. delete this._host._lastControlDown[pointerId];
  14481. return true;
  14482. }
  14483. return false;
  14484. };
  14485. /** @hidden */
  14486. Control3D.prototype._disposeNode = function () {
  14487. if (this._node) {
  14488. this._node.dispose();
  14489. this._node = null;
  14490. }
  14491. };
  14492. /**
  14493. * Releases all associated resources
  14494. */
  14495. Control3D.prototype.dispose = function () {
  14496. this.onPointerDownObservable.clear();
  14497. this.onPointerEnterObservable.clear();
  14498. this.onPointerMoveObservable.clear();
  14499. this.onPointerOutObservable.clear();
  14500. this.onPointerUpObservable.clear();
  14501. this.onPointerClickObservable.clear();
  14502. this._disposeNode();
  14503. // Behaviors
  14504. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14505. var behavior = _a[_i];
  14506. behavior.detach();
  14507. }
  14508. };
  14509. return Control3D;
  14510. }());
  14511. /***/ }),
  14512. /***/ "./3D/controls/cylinderPanel.ts":
  14513. /*!**************************************!*\
  14514. !*** ./3D/controls/cylinderPanel.ts ***!
  14515. \**************************************/
  14516. /*! exports provided: CylinderPanel */
  14517. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14518. "use strict";
  14519. __webpack_require__.r(__webpack_exports__);
  14520. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14521. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14522. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  14523. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14524. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14525. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14526. /**
  14527. * Class used to create a container panel deployed on the surface of a cylinder
  14528. */
  14529. var CylinderPanel = /** @class */ (function (_super) {
  14530. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14531. function CylinderPanel() {
  14532. var _this = _super !== null && _super.apply(this, arguments) || this;
  14533. _this._radius = 5.0;
  14534. return _this;
  14535. }
  14536. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14537. /**
  14538. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14539. */
  14540. get: function () {
  14541. return this._radius;
  14542. },
  14543. set: function (value) {
  14544. var _this = this;
  14545. if (this._radius === value) {
  14546. return;
  14547. }
  14548. this._radius = value;
  14549. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14550. _this._arrangeChildren();
  14551. });
  14552. },
  14553. enumerable: true,
  14554. configurable: true
  14555. });
  14556. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14557. var mesh = control.mesh;
  14558. if (!mesh) {
  14559. return;
  14560. }
  14561. var newPos = this._cylindricalMapping(nodePosition);
  14562. control.position = newPos;
  14563. switch (this.orientation) {
  14564. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14565. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14566. break;
  14567. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14568. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14569. break;
  14570. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14571. break;
  14572. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14573. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14574. break;
  14575. }
  14576. };
  14577. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14578. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14579. var yAngle = (source.x / this._radius);
  14580. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14581. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14582. };
  14583. return CylinderPanel;
  14584. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14585. /***/ }),
  14586. /***/ "./3D/controls/holographicButton.ts":
  14587. /*!******************************************!*\
  14588. !*** ./3D/controls/holographicButton.ts ***!
  14589. \******************************************/
  14590. /*! exports provided: HolographicButton */
  14591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14592. "use strict";
  14593. __webpack_require__.r(__webpack_exports__);
  14594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14595. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14596. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14597. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  14598. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  14599. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14600. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14601. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14602. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14603. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14604. /**
  14605. * Class used to create a holographic button in 3D
  14606. */
  14607. var HolographicButton = /** @class */ (function (_super) {
  14608. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14609. /**
  14610. * Creates a new button
  14611. * @param name defines the control name
  14612. */
  14613. function HolographicButton(name, shareMaterials) {
  14614. if (shareMaterials === void 0) { shareMaterials = true; }
  14615. var _this = _super.call(this, name) || this;
  14616. _this._shareMaterials = true;
  14617. _this._shareMaterials = shareMaterials;
  14618. // Default animations
  14619. _this.pointerEnterAnimation = function () {
  14620. if (!_this.mesh) {
  14621. return;
  14622. }
  14623. _this._frontPlate.setEnabled(true);
  14624. };
  14625. _this.pointerOutAnimation = function () {
  14626. if (!_this.mesh) {
  14627. return;
  14628. }
  14629. _this._frontPlate.setEnabled(false);
  14630. };
  14631. return _this;
  14632. }
  14633. HolographicButton.prototype._disposeTooltip = function () {
  14634. this._tooltipFade = null;
  14635. if (this._tooltipTextBlock) {
  14636. this._tooltipTextBlock.dispose();
  14637. }
  14638. if (this._tooltipTexture) {
  14639. this._tooltipTexture.dispose();
  14640. }
  14641. if (this._tooltipMesh) {
  14642. this._tooltipMesh.dispose();
  14643. }
  14644. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14645. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14646. };
  14647. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14648. get: function () {
  14649. return this._backPlate.renderingGroupId;
  14650. },
  14651. /**
  14652. * Rendering ground id of all the mesh in the button
  14653. */
  14654. set: function (id) {
  14655. this._backPlate.renderingGroupId = id;
  14656. this._textPlate.renderingGroupId = id;
  14657. this._frontPlate.renderingGroupId = id;
  14658. if (this._tooltipMesh) {
  14659. this._tooltipMesh.renderingGroupId = id;
  14660. }
  14661. },
  14662. enumerable: true,
  14663. configurable: true
  14664. });
  14665. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14666. get: function () {
  14667. if (this._tooltipTextBlock) {
  14668. return this._tooltipTextBlock.text;
  14669. }
  14670. return null;
  14671. },
  14672. /**
  14673. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14674. */
  14675. set: function (text) {
  14676. var _this = this;
  14677. if (!text) {
  14678. this._disposeTooltip();
  14679. return;
  14680. }
  14681. if (!this._tooltipFade) {
  14682. // Create tooltip with mesh and text
  14683. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14684. 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);
  14685. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14686. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14687. tooltipBackground.material = mat;
  14688. tooltipBackground.isPickable = false;
  14689. this._tooltipMesh.addChild(tooltipBackground);
  14690. tooltipBackground.position.z = 0.05;
  14691. this._tooltipMesh.scaling.y = 1 / 3;
  14692. this._tooltipMesh.position.y = 0.7;
  14693. this._tooltipMesh.position.z = -0.15;
  14694. this._tooltipMesh.isPickable = false;
  14695. this._tooltipMesh.parent = this._backPlate;
  14696. // Create text texture for the tooltip
  14697. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14698. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14699. this._tooltipTextBlock.scaleY = 3;
  14700. this._tooltipTextBlock.color = "white";
  14701. this._tooltipTextBlock.fontSize = 130;
  14702. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14703. // Add hover action to tooltip
  14704. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14705. this._tooltipFade.delay = 500;
  14706. this._tooltipMesh.addBehavior(this._tooltipFade);
  14707. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14708. if (_this._tooltipFade) {
  14709. _this._tooltipFade.fadeIn(true);
  14710. }
  14711. });
  14712. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14713. if (_this._tooltipFade) {
  14714. _this._tooltipFade.fadeIn(false);
  14715. }
  14716. });
  14717. }
  14718. if (this._tooltipTextBlock) {
  14719. this._tooltipTextBlock.text = text;
  14720. }
  14721. },
  14722. enumerable: true,
  14723. configurable: true
  14724. });
  14725. Object.defineProperty(HolographicButton.prototype, "text", {
  14726. /**
  14727. * Gets or sets text for the button
  14728. */
  14729. get: function () {
  14730. return this._text;
  14731. },
  14732. set: function (value) {
  14733. if (this._text === value) {
  14734. return;
  14735. }
  14736. this._text = value;
  14737. this._rebuildContent();
  14738. },
  14739. enumerable: true,
  14740. configurable: true
  14741. });
  14742. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14743. /**
  14744. * Gets or sets the image url for the button
  14745. */
  14746. get: function () {
  14747. return this._imageUrl;
  14748. },
  14749. set: function (value) {
  14750. if (this._imageUrl === value) {
  14751. return;
  14752. }
  14753. this._imageUrl = value;
  14754. this._rebuildContent();
  14755. },
  14756. enumerable: true,
  14757. configurable: true
  14758. });
  14759. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14760. /**
  14761. * Gets the back material used by this button
  14762. */
  14763. get: function () {
  14764. return this._backMaterial;
  14765. },
  14766. enumerable: true,
  14767. configurable: true
  14768. });
  14769. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14770. /**
  14771. * Gets the front material used by this button
  14772. */
  14773. get: function () {
  14774. return this._frontMaterial;
  14775. },
  14776. enumerable: true,
  14777. configurable: true
  14778. });
  14779. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14780. /**
  14781. * Gets the plate material used by this button
  14782. */
  14783. get: function () {
  14784. return this._plateMaterial;
  14785. },
  14786. enumerable: true,
  14787. configurable: true
  14788. });
  14789. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14790. /**
  14791. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14792. */
  14793. get: function () {
  14794. return this._shareMaterials;
  14795. },
  14796. enumerable: true,
  14797. configurable: true
  14798. });
  14799. HolographicButton.prototype._getTypeName = function () {
  14800. return "HolographicButton";
  14801. };
  14802. HolographicButton.prototype._rebuildContent = function () {
  14803. this._disposeFacadeTexture();
  14804. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14805. panel.isVertical = true;
  14806. if (this._imageUrl) {
  14807. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14808. image.source = this._imageUrl;
  14809. image.paddingTop = "40px";
  14810. image.height = "180px";
  14811. image.width = "100px";
  14812. image.paddingBottom = "40px";
  14813. panel.addControl(image);
  14814. }
  14815. if (this._text) {
  14816. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14817. text.text = this._text;
  14818. text.color = "white";
  14819. text.height = "30px";
  14820. text.fontSize = 24;
  14821. panel.addControl(text);
  14822. }
  14823. if (this._frontPlate) {
  14824. this.content = panel;
  14825. }
  14826. };
  14827. // Mesh association
  14828. HolographicButton.prototype._createNode = function (scene) {
  14829. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14830. width: 1.0,
  14831. height: 1.0,
  14832. depth: 0.08
  14833. }, scene);
  14834. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14835. width: 1.0,
  14836. height: 1.0,
  14837. depth: 0.08
  14838. }, scene);
  14839. this._frontPlate.parent = this._backPlate;
  14840. this._frontPlate.position.z = -0.08;
  14841. this._frontPlate.isPickable = false;
  14842. this._frontPlate.setEnabled(false);
  14843. this._textPlate = _super.prototype._createNode.call(this, scene);
  14844. this._textPlate.parent = this._backPlate;
  14845. this._textPlate.position.z = -0.08;
  14846. this._textPlate.isPickable = false;
  14847. return this._backPlate;
  14848. };
  14849. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14850. this._plateMaterial.emissiveTexture = facadeTexture;
  14851. this._plateMaterial.opacityTexture = facadeTexture;
  14852. };
  14853. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14854. var _this = this;
  14855. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14856. this._backMaterial.renderHoverLight = true;
  14857. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14858. if (pickedPoint) {
  14859. _this._backMaterial.hoverPosition = pickedPoint;
  14860. _this._backMaterial.hoverColor.a = 1.0;
  14861. }
  14862. else {
  14863. _this._backMaterial.hoverColor.a = 0;
  14864. }
  14865. });
  14866. };
  14867. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14868. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14869. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14870. this._frontMaterial.alpha = 0.5; // Additive
  14871. this._frontMaterial.renderBorders = true;
  14872. };
  14873. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14874. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14875. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14876. };
  14877. HolographicButton.prototype._affectMaterial = function (mesh) {
  14878. // Back
  14879. if (this._shareMaterials) {
  14880. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14881. this._createBackMaterial(mesh);
  14882. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14883. }
  14884. else {
  14885. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14886. }
  14887. // Front
  14888. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  14889. this._createFrontMaterial(mesh);
  14890. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  14891. }
  14892. else {
  14893. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  14894. }
  14895. }
  14896. else {
  14897. this._createBackMaterial(mesh);
  14898. this._createFrontMaterial(mesh);
  14899. }
  14900. this._createPlateMaterial(mesh);
  14901. this._backPlate.material = this._backMaterial;
  14902. this._frontPlate.material = this._frontMaterial;
  14903. this._textPlate.material = this._plateMaterial;
  14904. this._rebuildContent();
  14905. };
  14906. /**
  14907. * Releases all associated resources
  14908. */
  14909. HolographicButton.prototype.dispose = function () {
  14910. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  14911. this._disposeTooltip();
  14912. if (!this.shareMaterials) {
  14913. this._backMaterial.dispose();
  14914. this._frontMaterial.dispose();
  14915. this._plateMaterial.dispose();
  14916. if (this._pickedPointObserver) {
  14917. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  14918. this._pickedPointObserver = null;
  14919. }
  14920. }
  14921. };
  14922. return HolographicButton;
  14923. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14924. /***/ }),
  14925. /***/ "./3D/controls/index.ts":
  14926. /*!******************************!*\
  14927. !*** ./3D/controls/index.ts ***!
  14928. \******************************/
  14929. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  14930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14931. "use strict";
  14932. __webpack_require__.r(__webpack_exports__);
  14933. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14935. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14937. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  14939. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  14941. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  14942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  14943. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  14944. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  14945. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  14946. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  14947. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  14948. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  14949. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  14950. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  14951. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  14952. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  14953. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  14954. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  14955. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14956. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  14957. /***/ }),
  14958. /***/ "./3D/controls/meshButton3D.ts":
  14959. /*!*************************************!*\
  14960. !*** ./3D/controls/meshButton3D.ts ***!
  14961. \*************************************/
  14962. /*! exports provided: MeshButton3D */
  14963. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14964. "use strict";
  14965. __webpack_require__.r(__webpack_exports__);
  14966. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  14967. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14968. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14969. /**
  14970. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  14971. */
  14972. var MeshButton3D = /** @class */ (function (_super) {
  14973. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  14974. /**
  14975. * Creates a new 3D button based on a mesh
  14976. * @param mesh mesh to become a 3D button
  14977. * @param name defines the control name
  14978. */
  14979. function MeshButton3D(mesh, name) {
  14980. var _this = _super.call(this, name) || this;
  14981. _this._currentMesh = mesh;
  14982. /**
  14983. * Provides a default behavior on hover/out & up/down
  14984. * Override those function to create your own desired behavior specific to your mesh
  14985. */
  14986. _this.pointerEnterAnimation = function () {
  14987. if (!_this.mesh) {
  14988. return;
  14989. }
  14990. _this.mesh.scaling.scaleInPlace(1.1);
  14991. };
  14992. _this.pointerOutAnimation = function () {
  14993. if (!_this.mesh) {
  14994. return;
  14995. }
  14996. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  14997. };
  14998. _this.pointerDownAnimation = function () {
  14999. if (!_this.mesh) {
  15000. return;
  15001. }
  15002. _this.mesh.scaling.scaleInPlace(0.95);
  15003. };
  15004. _this.pointerUpAnimation = function () {
  15005. if (!_this.mesh) {
  15006. return;
  15007. }
  15008. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15009. };
  15010. return _this;
  15011. }
  15012. MeshButton3D.prototype._getTypeName = function () {
  15013. return "MeshButton3D";
  15014. };
  15015. // Mesh association
  15016. MeshButton3D.prototype._createNode = function (scene) {
  15017. var _this = this;
  15018. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15019. mesh.metadata = _this;
  15020. });
  15021. return this._currentMesh;
  15022. };
  15023. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15024. };
  15025. return MeshButton3D;
  15026. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15027. /***/ }),
  15028. /***/ "./3D/controls/planePanel.ts":
  15029. /*!***********************************!*\
  15030. !*** ./3D/controls/planePanel.ts ***!
  15031. \***********************************/
  15032. /*! exports provided: PlanePanel */
  15033. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15034. "use strict";
  15035. __webpack_require__.r(__webpack_exports__);
  15036. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15037. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15038. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  15039. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  15040. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15041. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15042. /**
  15043. * Class used to create a container panel deployed on the surface of a plane
  15044. */
  15045. var PlanePanel = /** @class */ (function (_super) {
  15046. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15047. function PlanePanel() {
  15048. return _super !== null && _super.apply(this, arguments) || this;
  15049. }
  15050. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15051. var mesh = control.mesh;
  15052. if (!mesh) {
  15053. return;
  15054. }
  15055. control.position = nodePosition.clone();
  15056. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15057. target.copyFrom(nodePosition);
  15058. switch (this.orientation) {
  15059. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15060. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15061. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15062. mesh.lookAt(target);
  15063. break;
  15064. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15065. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15066. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15067. mesh.lookAt(target);
  15068. break;
  15069. }
  15070. };
  15071. return PlanePanel;
  15072. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15073. /***/ }),
  15074. /***/ "./3D/controls/scatterPanel.ts":
  15075. /*!*************************************!*\
  15076. !*** ./3D/controls/scatterPanel.ts ***!
  15077. \*************************************/
  15078. /*! exports provided: ScatterPanel */
  15079. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15080. "use strict";
  15081. __webpack_require__.r(__webpack_exports__);
  15082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15083. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15084. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15085. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15086. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15087. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15088. /**
  15089. * Class used to create a container panel where items get randomized planar mapping
  15090. */
  15091. var ScatterPanel = /** @class */ (function (_super) {
  15092. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15093. function ScatterPanel() {
  15094. var _this = _super !== null && _super.apply(this, arguments) || this;
  15095. _this._iteration = 100.0;
  15096. return _this;
  15097. }
  15098. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15099. /**
  15100. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15101. */
  15102. get: function () {
  15103. return this._iteration;
  15104. },
  15105. set: function (value) {
  15106. var _this = this;
  15107. if (this._iteration === value) {
  15108. return;
  15109. }
  15110. this._iteration = value;
  15111. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15112. _this._arrangeChildren();
  15113. });
  15114. },
  15115. enumerable: true,
  15116. configurable: true
  15117. });
  15118. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15119. var mesh = control.mesh;
  15120. var newPos = this._scatterMapping(nodePosition);
  15121. if (!mesh) {
  15122. return;
  15123. }
  15124. switch (this.orientation) {
  15125. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15126. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15127. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15128. break;
  15129. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15130. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15131. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15132. break;
  15133. }
  15134. control.position = newPos;
  15135. };
  15136. ScatterPanel.prototype._scatterMapping = function (source) {
  15137. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15138. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15139. return source;
  15140. };
  15141. ScatterPanel.prototype._finalProcessing = function () {
  15142. var meshes = [];
  15143. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15144. var child = _a[_i];
  15145. if (!child.mesh) {
  15146. continue;
  15147. }
  15148. meshes.push(child.mesh);
  15149. }
  15150. for (var count = 0; count < this._iteration; count++) {
  15151. meshes.sort(function (a, b) {
  15152. var distance1 = a.position.lengthSquared();
  15153. var distance2 = b.position.lengthSquared();
  15154. if (distance1 < distance2) {
  15155. return 1;
  15156. }
  15157. else if (distance1 > distance2) {
  15158. return -1;
  15159. }
  15160. return 0;
  15161. });
  15162. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15163. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15164. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15165. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15166. for (var i = 0; i < meshes.length - 1; i++) {
  15167. for (var j = i + 1; j < meshes.length; j++) {
  15168. if (i != j) {
  15169. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15170. // Ignore Z axis
  15171. difference2D.x = difference.x;
  15172. difference2D.y = difference.y;
  15173. var combinedRadius = cellSize;
  15174. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15175. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15176. distance -= minSeparation;
  15177. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15178. difference2D.normalize();
  15179. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15180. meshes[j].position.addInPlace(difference);
  15181. meshes[i].position.subtractInPlace(difference);
  15182. }
  15183. }
  15184. }
  15185. }
  15186. }
  15187. };
  15188. return ScatterPanel;
  15189. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15190. /***/ }),
  15191. /***/ "./3D/controls/spherePanel.ts":
  15192. /*!************************************!*\
  15193. !*** ./3D/controls/spherePanel.ts ***!
  15194. \************************************/
  15195. /*! exports provided: SpherePanel */
  15196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15197. "use strict";
  15198. __webpack_require__.r(__webpack_exports__);
  15199. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15200. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15201. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15202. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15203. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15204. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15205. /**
  15206. * Class used to create a container panel deployed on the surface of a sphere
  15207. */
  15208. var SpherePanel = /** @class */ (function (_super) {
  15209. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15210. function SpherePanel() {
  15211. var _this = _super !== null && _super.apply(this, arguments) || this;
  15212. _this._radius = 5.0;
  15213. return _this;
  15214. }
  15215. Object.defineProperty(SpherePanel.prototype, "radius", {
  15216. /**
  15217. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15218. */
  15219. get: function () {
  15220. return this._radius;
  15221. },
  15222. set: function (value) {
  15223. var _this = this;
  15224. if (this._radius === value) {
  15225. return;
  15226. }
  15227. this._radius = value;
  15228. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15229. _this._arrangeChildren();
  15230. });
  15231. },
  15232. enumerable: true,
  15233. configurable: true
  15234. });
  15235. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15236. var mesh = control.mesh;
  15237. if (!mesh) {
  15238. return;
  15239. }
  15240. var newPos = this._sphericalMapping(nodePosition);
  15241. control.position = newPos;
  15242. switch (this.orientation) {
  15243. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15244. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15245. break;
  15246. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15247. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15248. break;
  15249. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15250. break;
  15251. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15252. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15253. break;
  15254. }
  15255. };
  15256. SpherePanel.prototype._sphericalMapping = function (source) {
  15257. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15258. var xAngle = (source.y / this._radius);
  15259. var yAngle = -(source.x / this._radius);
  15260. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15261. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15262. };
  15263. return SpherePanel;
  15264. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15265. /***/ }),
  15266. /***/ "./3D/controls/stackPanel3D.ts":
  15267. /*!*************************************!*\
  15268. !*** ./3D/controls/stackPanel3D.ts ***!
  15269. \*************************************/
  15270. /*! exports provided: StackPanel3D */
  15271. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15272. "use strict";
  15273. __webpack_require__.r(__webpack_exports__);
  15274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15275. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15276. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15277. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15278. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15279. /**
  15280. * Class used to create a stack panel in 3D on XY plane
  15281. */
  15282. var StackPanel3D = /** @class */ (function (_super) {
  15283. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15284. /**
  15285. * Creates new StackPanel
  15286. * @param isVertical
  15287. */
  15288. function StackPanel3D(isVertical) {
  15289. if (isVertical === void 0) { isVertical = false; }
  15290. var _this = _super.call(this) || this;
  15291. _this._isVertical = false;
  15292. /**
  15293. * Gets or sets the distance between elements
  15294. */
  15295. _this.margin = 0.1;
  15296. _this._isVertical = isVertical;
  15297. return _this;
  15298. }
  15299. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15300. /**
  15301. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15302. */
  15303. get: function () {
  15304. return this._isVertical;
  15305. },
  15306. set: function (value) {
  15307. var _this = this;
  15308. if (this._isVertical === value) {
  15309. return;
  15310. }
  15311. this._isVertical = value;
  15312. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15313. _this._arrangeChildren();
  15314. });
  15315. },
  15316. enumerable: true,
  15317. configurable: true
  15318. });
  15319. StackPanel3D.prototype._arrangeChildren = function () {
  15320. var width = 0;
  15321. var height = 0;
  15322. var controlCount = 0;
  15323. var extendSizes = [];
  15324. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15325. // Measure
  15326. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15327. var child = _a[_i];
  15328. if (!child.mesh) {
  15329. continue;
  15330. }
  15331. controlCount++;
  15332. child.mesh.computeWorldMatrix(true);
  15333. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15334. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15335. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15336. extendSizes.push(extendSize);
  15337. if (this._isVertical) {
  15338. height += extendSize.y;
  15339. }
  15340. else {
  15341. width += extendSize.x;
  15342. }
  15343. }
  15344. if (this._isVertical) {
  15345. height += (controlCount - 1) * this.margin / 2;
  15346. }
  15347. else {
  15348. width += (controlCount - 1) * this.margin / 2;
  15349. }
  15350. // Arrange
  15351. var offset;
  15352. if (this._isVertical) {
  15353. offset = -height;
  15354. }
  15355. else {
  15356. offset = -width;
  15357. }
  15358. var index = 0;
  15359. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15360. var child = _c[_b];
  15361. if (!child.mesh) {
  15362. continue;
  15363. }
  15364. controlCount--;
  15365. var extendSize = extendSizes[index++];
  15366. if (this._isVertical) {
  15367. child.position.y = offset + extendSize.y;
  15368. child.position.x = 0;
  15369. offset += extendSize.y * 2;
  15370. }
  15371. else {
  15372. child.position.x = offset + extendSize.x;
  15373. child.position.y = 0;
  15374. offset += extendSize.x * 2;
  15375. }
  15376. offset += (controlCount > 0 ? this.margin : 0);
  15377. }
  15378. };
  15379. return StackPanel3D;
  15380. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15381. /***/ }),
  15382. /***/ "./3D/controls/volumeBasedPanel.ts":
  15383. /*!*****************************************!*\
  15384. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15385. \*****************************************/
  15386. /*! exports provided: VolumeBasedPanel */
  15387. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15388. "use strict";
  15389. __webpack_require__.r(__webpack_exports__);
  15390. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15391. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15392. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/perfCounter");
  15393. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15394. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15395. /**
  15396. * Abstract class used to create a container panel deployed on the surface of a volume
  15397. */
  15398. var VolumeBasedPanel = /** @class */ (function (_super) {
  15399. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15400. /**
  15401. * Creates new VolumeBasedPanel
  15402. */
  15403. function VolumeBasedPanel() {
  15404. var _this = _super.call(this) || this;
  15405. _this._columns = 10;
  15406. _this._rows = 0;
  15407. _this._rowThenColum = true;
  15408. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15409. /**
  15410. * Gets or sets the distance between elements
  15411. */
  15412. _this.margin = 0;
  15413. return _this;
  15414. }
  15415. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15416. /**
  15417. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15418. * | Value | Type | Description |
  15419. * | ----- | ----------------------------------- | ----------- |
  15420. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15421. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15422. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15423. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15424. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15425. */
  15426. get: function () {
  15427. return this._orientation;
  15428. },
  15429. set: function (value) {
  15430. var _this = this;
  15431. if (this._orientation === value) {
  15432. return;
  15433. }
  15434. this._orientation = value;
  15435. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15436. _this._arrangeChildren();
  15437. });
  15438. },
  15439. enumerable: true,
  15440. configurable: true
  15441. });
  15442. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15443. /**
  15444. * Gets or sets the number of columns requested (10 by default).
  15445. * The panel will automatically compute the number of rows based on number of child controls.
  15446. */
  15447. get: function () {
  15448. return this._columns;
  15449. },
  15450. set: function (value) {
  15451. var _this = this;
  15452. if (this._columns === value) {
  15453. return;
  15454. }
  15455. this._columns = value;
  15456. this._rowThenColum = true;
  15457. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15458. _this._arrangeChildren();
  15459. });
  15460. },
  15461. enumerable: true,
  15462. configurable: true
  15463. });
  15464. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15465. /**
  15466. * Gets or sets a the number of rows requested.
  15467. * The panel will automatically compute the number of columns based on number of child controls.
  15468. */
  15469. get: function () {
  15470. return this._rows;
  15471. },
  15472. set: function (value) {
  15473. var _this = this;
  15474. if (this._rows === value) {
  15475. return;
  15476. }
  15477. this._rows = value;
  15478. this._rowThenColum = false;
  15479. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15480. _this._arrangeChildren();
  15481. });
  15482. },
  15483. enumerable: true,
  15484. configurable: true
  15485. });
  15486. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15487. this._cellWidth = 0;
  15488. this._cellHeight = 0;
  15489. var rows = 0;
  15490. var columns = 0;
  15491. var controlCount = 0;
  15492. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15493. // Measure
  15494. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15495. var child = _a[_i];
  15496. if (!child.mesh) {
  15497. continue;
  15498. }
  15499. controlCount++;
  15500. child.mesh.computeWorldMatrix(true);
  15501. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15502. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15503. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15504. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15505. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15506. diff.scaleInPlace(0.5);
  15507. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15508. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15509. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15510. }
  15511. this._cellWidth += this.margin * 2;
  15512. this._cellHeight += this.margin * 2;
  15513. // Arrange
  15514. if (this._rowThenColum) {
  15515. columns = this._columns;
  15516. rows = Math.ceil(controlCount / this._columns);
  15517. }
  15518. else {
  15519. rows = this._rows;
  15520. columns = Math.ceil(controlCount / this._rows);
  15521. }
  15522. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15523. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15524. var nodeGrid = [];
  15525. var cellCounter = 0;
  15526. if (this._rowThenColum) {
  15527. for (var r = 0; r < rows; r++) {
  15528. for (var c = 0; c < columns; c++) {
  15529. 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));
  15530. cellCounter++;
  15531. if (cellCounter > controlCount) {
  15532. break;
  15533. }
  15534. }
  15535. }
  15536. }
  15537. else {
  15538. for (var c = 0; c < columns; c++) {
  15539. for (var r = 0; r < rows; r++) {
  15540. 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));
  15541. cellCounter++;
  15542. if (cellCounter > controlCount) {
  15543. break;
  15544. }
  15545. }
  15546. }
  15547. }
  15548. cellCounter = 0;
  15549. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15550. var child = _c[_b];
  15551. if (!child.mesh) {
  15552. continue;
  15553. }
  15554. this._mapGridNode(child, nodeGrid[cellCounter]);
  15555. cellCounter++;
  15556. }
  15557. this._finalProcessing();
  15558. };
  15559. /** Child classes can implement this function to provide additional processing */
  15560. VolumeBasedPanel.prototype._finalProcessing = function () {
  15561. };
  15562. return VolumeBasedPanel;
  15563. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15564. /***/ }),
  15565. /***/ "./3D/gui3DManager.ts":
  15566. /*!****************************!*\
  15567. !*** ./3D/gui3DManager.ts ***!
  15568. \****************************/
  15569. /*! exports provided: GUI3DManager */
  15570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15571. "use strict";
  15572. __webpack_require__.r(__webpack_exports__);
  15573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15574. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/perfCounter");
  15575. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15576. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15577. /**
  15578. * Class used to manage 3D user interface
  15579. * @see http://doc.babylonjs.com/how_to/gui3d
  15580. */
  15581. var GUI3DManager = /** @class */ (function () {
  15582. /**
  15583. * Creates a new GUI3DManager
  15584. * @param scene
  15585. */
  15586. function GUI3DManager(scene) {
  15587. var _this = this;
  15588. /** @hidden */
  15589. this._lastControlOver = {};
  15590. /** @hidden */
  15591. this._lastControlDown = {};
  15592. /**
  15593. * Observable raised when the point picked by the pointer events changed
  15594. */
  15595. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15596. // Shared resources
  15597. /** @hidden */
  15598. this._sharedMaterials = {};
  15599. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15600. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15601. _this._sceneDisposeObserver = null;
  15602. _this._utilityLayer = null;
  15603. _this.dispose();
  15604. });
  15605. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15606. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15607. this._utilityLayer.pickUtilitySceneFirst = false;
  15608. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15609. return mesh && mesh.metadata && mesh.metadata._node;
  15610. };
  15611. // Root
  15612. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15613. this._rootContainer._host = this;
  15614. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15615. // Events
  15616. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15617. _this._handlePointerOut(pointerId, true);
  15618. });
  15619. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15620. _this._doPicking(pi);
  15621. });
  15622. // Scene
  15623. this._utilityLayer.utilityLayerScene.autoClear = false;
  15624. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15625. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15626. }
  15627. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15628. /** Gets the hosting scene */
  15629. get: function () {
  15630. return this._scene;
  15631. },
  15632. enumerable: true,
  15633. configurable: true
  15634. });
  15635. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15636. /** Gets associated utility layer */
  15637. get: function () {
  15638. return this._utilityLayer;
  15639. },
  15640. enumerable: true,
  15641. configurable: true
  15642. });
  15643. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15644. var previousControlOver = this._lastControlOver[pointerId];
  15645. if (previousControlOver) {
  15646. previousControlOver._onPointerOut(previousControlOver);
  15647. delete this._lastControlOver[pointerId];
  15648. }
  15649. if (isPointerUp) {
  15650. if (this._lastControlDown[pointerId]) {
  15651. this._lastControlDown[pointerId].forcePointerUp();
  15652. delete this._lastControlDown[pointerId];
  15653. }
  15654. }
  15655. this.onPickedPointChangedObservable.notifyObservers(null);
  15656. };
  15657. GUI3DManager.prototype._doPicking = function (pi) {
  15658. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15659. return false;
  15660. }
  15661. var pointerEvent = (pi.event);
  15662. var pointerId = pointerEvent.pointerId || 0;
  15663. var buttonIndex = pointerEvent.button;
  15664. var pickingInfo = pi.pickInfo;
  15665. if (!pickingInfo || !pickingInfo.hit) {
  15666. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15667. return false;
  15668. }
  15669. var control = (pickingInfo.pickedMesh.metadata);
  15670. if (pickingInfo.pickedPoint) {
  15671. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15672. }
  15673. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15674. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15675. if (this._lastControlOver[pointerId]) {
  15676. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15677. }
  15678. delete this._lastControlOver[pointerId];
  15679. }
  15680. }
  15681. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15682. if (this._lastControlDown[pointerEvent.pointerId]) {
  15683. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15684. delete this._lastControlDown[pointerEvent.pointerId];
  15685. }
  15686. if (pointerEvent.pointerType === "touch") {
  15687. this._handlePointerOut(pointerId, false);
  15688. }
  15689. }
  15690. return true;
  15691. };
  15692. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15693. /**
  15694. * Gets the root container
  15695. */
  15696. get: function () {
  15697. return this._rootContainer;
  15698. },
  15699. enumerable: true,
  15700. configurable: true
  15701. });
  15702. /**
  15703. * Gets a boolean indicating if the given control is in the root child list
  15704. * @param control defines the control to check
  15705. * @returns true if the control is in the root child list
  15706. */
  15707. GUI3DManager.prototype.containsControl = function (control) {
  15708. return this._rootContainer.containsControl(control);
  15709. };
  15710. /**
  15711. * Adds a control to the root child list
  15712. * @param control defines the control to add
  15713. * @returns the current manager
  15714. */
  15715. GUI3DManager.prototype.addControl = function (control) {
  15716. this._rootContainer.addControl(control);
  15717. return this;
  15718. };
  15719. /**
  15720. * Removes a control from the root child list
  15721. * @param control defines the control to remove
  15722. * @returns the current container
  15723. */
  15724. GUI3DManager.prototype.removeControl = function (control) {
  15725. this._rootContainer.removeControl(control);
  15726. return this;
  15727. };
  15728. /**
  15729. * Releases all associated resources
  15730. */
  15731. GUI3DManager.prototype.dispose = function () {
  15732. this._rootContainer.dispose();
  15733. for (var materialName in this._sharedMaterials) {
  15734. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15735. continue;
  15736. }
  15737. this._sharedMaterials[materialName].dispose();
  15738. }
  15739. this._sharedMaterials = {};
  15740. if (this._pointerOutObserver && this._utilityLayer) {
  15741. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15742. this._pointerOutObserver = null;
  15743. }
  15744. this.onPickedPointChangedObservable.clear();
  15745. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15746. if (utilityLayerScene) {
  15747. if (this._pointerObserver) {
  15748. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15749. this._pointerObserver = null;
  15750. }
  15751. }
  15752. if (this._scene) {
  15753. if (this._sceneDisposeObserver) {
  15754. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15755. this._sceneDisposeObserver = null;
  15756. }
  15757. }
  15758. if (this._utilityLayer) {
  15759. this._utilityLayer.dispose();
  15760. }
  15761. };
  15762. return GUI3DManager;
  15763. }());
  15764. /***/ }),
  15765. /***/ "./3D/index.ts":
  15766. /*!*********************!*\
  15767. !*** ./3D/index.ts ***!
  15768. \*********************/
  15769. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15771. "use strict";
  15772. __webpack_require__.r(__webpack_exports__);
  15773. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15786. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15789. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15790. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15791. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15792. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15793. /***/ }),
  15794. /***/ "./3D/materials/fluentMaterial.ts":
  15795. /*!****************************************!*\
  15796. !*** ./3D/materials/fluentMaterial.ts ***!
  15797. \****************************************/
  15798. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15799. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15800. "use strict";
  15801. __webpack_require__.r(__webpack_exports__);
  15802. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15804. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15805. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/perfCounter");
  15806. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15807. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15808. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15809. /** @hidden */
  15810. var FluentMaterialDefines = /** @class */ (function (_super) {
  15811. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15812. function FluentMaterialDefines() {
  15813. var _this = _super.call(this) || this;
  15814. _this.INNERGLOW = false;
  15815. _this.BORDER = false;
  15816. _this.HOVERLIGHT = false;
  15817. _this.TEXTURE = false;
  15818. _this.rebuild();
  15819. return _this;
  15820. }
  15821. return FluentMaterialDefines;
  15822. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15823. /**
  15824. * Class used to render controls with fluent desgin
  15825. */
  15826. var FluentMaterial = /** @class */ (function (_super) {
  15827. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15828. /**
  15829. * Creates a new Fluent material
  15830. * @param name defines the name of the material
  15831. * @param scene defines the hosting scene
  15832. */
  15833. function FluentMaterial(name, scene) {
  15834. var _this = _super.call(this, name, scene) || this;
  15835. /**
  15836. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15837. */
  15838. _this.innerGlowColorIntensity = 0.5;
  15839. /**
  15840. * Gets or sets the inner glow color (white by default)
  15841. */
  15842. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15843. /**
  15844. * Gets or sets alpha value (default is 1.0)
  15845. */
  15846. _this.alpha = 1.0;
  15847. /**
  15848. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15849. */
  15850. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15851. /**
  15852. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15853. */
  15854. _this.renderBorders = false;
  15855. /**
  15856. * Gets or sets border width (default is 0.5)
  15857. */
  15858. _this.borderWidth = 0.5;
  15859. /**
  15860. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15861. */
  15862. _this.edgeSmoothingValue = 0.02;
  15863. /**
  15864. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15865. */
  15866. _this.borderMinValue = 0.1;
  15867. /**
  15868. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15869. */
  15870. _this.renderHoverLight = false;
  15871. /**
  15872. * Gets or sets the radius used to render the hover light (default is 1.0)
  15873. */
  15874. _this.hoverRadius = 1.0;
  15875. /**
  15876. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15877. */
  15878. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15879. /**
  15880. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15881. */
  15882. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15883. return _this;
  15884. }
  15885. FluentMaterial.prototype.needAlphaBlending = function () {
  15886. return this.alpha !== 1.0;
  15887. };
  15888. FluentMaterial.prototype.needAlphaTesting = function () {
  15889. return false;
  15890. };
  15891. FluentMaterial.prototype.getAlphaTestTexture = function () {
  15892. return null;
  15893. };
  15894. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  15895. if (this.isFrozen) {
  15896. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  15897. return true;
  15898. }
  15899. }
  15900. if (!subMesh._materialDefines) {
  15901. subMesh._materialDefines = new FluentMaterialDefines();
  15902. }
  15903. var scene = this.getScene();
  15904. var defines = subMesh._materialDefines;
  15905. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  15906. if (defines._renderId === scene.getRenderId()) {
  15907. return true;
  15908. }
  15909. }
  15910. if (defines._areTexturesDirty) {
  15911. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  15912. defines.BORDER = this.renderBorders;
  15913. defines.HOVERLIGHT = this.renderHoverLight;
  15914. if (this._albedoTexture) {
  15915. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  15916. return false;
  15917. }
  15918. else {
  15919. defines.TEXTURE = true;
  15920. }
  15921. }
  15922. else {
  15923. defines.TEXTURE = false;
  15924. }
  15925. }
  15926. var engine = scene.getEngine();
  15927. // Get correct effect
  15928. if (defines.isDirty) {
  15929. defines.markAsProcessed();
  15930. scene.resetCachedMaterial();
  15931. //Attributes
  15932. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  15933. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  15934. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  15935. var shaderName = "fluent";
  15936. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  15937. "hoverColor", "hoverPosition", "hoverRadius"
  15938. ];
  15939. var samplers = ["albedoSampler"];
  15940. var uniformBuffers = new Array();
  15941. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  15942. uniformsNames: uniforms,
  15943. uniformBuffersNames: uniformBuffers,
  15944. samplers: samplers,
  15945. defines: defines,
  15946. maxSimultaneousLights: 4
  15947. });
  15948. var join = defines.toString();
  15949. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  15950. attributes: attribs,
  15951. uniformsNames: uniforms,
  15952. uniformBuffersNames: uniformBuffers,
  15953. samplers: samplers,
  15954. defines: join,
  15955. fallbacks: null,
  15956. onCompiled: this.onCompiled,
  15957. onError: this.onError,
  15958. indexParameters: { maxSimultaneousLights: 4 }
  15959. }, engine));
  15960. }
  15961. if (!subMesh.effect || !subMesh.effect.isReady()) {
  15962. return false;
  15963. }
  15964. defines._renderId = scene.getRenderId();
  15965. subMesh.effect._wasPreviouslyReady = true;
  15966. return true;
  15967. };
  15968. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  15969. var scene = this.getScene();
  15970. var defines = subMesh._materialDefines;
  15971. if (!defines) {
  15972. return;
  15973. }
  15974. var effect = subMesh.effect;
  15975. if (!effect) {
  15976. return;
  15977. }
  15978. this._activeEffect = effect;
  15979. // Matrices
  15980. this.bindOnlyWorldMatrix(world);
  15981. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  15982. if (this._mustRebind(scene, effect)) {
  15983. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  15984. if (defines.INNERGLOW) {
  15985. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  15986. }
  15987. if (defines.BORDER) {
  15988. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  15989. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  15990. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  15991. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15992. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15993. }
  15994. if (defines.HOVERLIGHT) {
  15995. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  15996. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  15997. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  15998. }
  15999. if (defines.TEXTURE) {
  16000. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  16001. }
  16002. }
  16003. this._afterBind(mesh, this._activeEffect);
  16004. };
  16005. FluentMaterial.prototype.getActiveTextures = function () {
  16006. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16007. return activeTextures;
  16008. };
  16009. FluentMaterial.prototype.hasTexture = function (texture) {
  16010. if (_super.prototype.hasTexture.call(this, texture)) {
  16011. return true;
  16012. }
  16013. return false;
  16014. };
  16015. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16016. _super.prototype.dispose.call(this, forceDisposeEffect);
  16017. };
  16018. FluentMaterial.prototype.clone = function (name) {
  16019. var _this = this;
  16020. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16021. };
  16022. FluentMaterial.prototype.serialize = function () {
  16023. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16024. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16025. return serializationObject;
  16026. };
  16027. FluentMaterial.prototype.getClassName = function () {
  16028. return "FluentMaterial";
  16029. };
  16030. // Statics
  16031. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16032. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16033. };
  16034. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16035. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16036. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16037. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16038. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16039. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16040. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16041. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16042. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16043. ], FluentMaterial.prototype, "alpha", void 0);
  16044. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16045. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16046. ], FluentMaterial.prototype, "albedoColor", void 0);
  16047. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16048. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16049. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16050. ], FluentMaterial.prototype, "renderBorders", void 0);
  16051. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16052. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16053. ], FluentMaterial.prototype, "borderWidth", void 0);
  16054. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16055. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16056. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16057. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16058. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16059. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16060. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16061. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16062. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16063. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16064. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16065. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16066. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16067. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16068. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16069. ], FluentMaterial.prototype, "hoverColor", void 0);
  16070. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16071. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16072. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16073. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16074. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16075. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16076. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16077. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16078. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16079. return FluentMaterial;
  16080. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16081. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16082. /***/ }),
  16083. /***/ "./3D/materials/index.ts":
  16084. /*!*******************************!*\
  16085. !*** ./3D/materials/index.ts ***!
  16086. \*******************************/
  16087. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16088. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16089. "use strict";
  16090. __webpack_require__.r(__webpack_exports__);
  16091. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16094. /***/ }),
  16095. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16096. /*!*************************************************!*\
  16097. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16098. \*************************************************/
  16099. /*! exports provided: fluentPixelShader */
  16100. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16101. "use strict";
  16102. __webpack_require__.r(__webpack_exports__);
  16103. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16104. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  16105. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16106. var name = 'fluentPixelShader';
  16107. 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}";
  16108. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16109. /** @hidden */
  16110. var fluentPixelShader = { name: name, shader: shader };
  16111. /***/ }),
  16112. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16113. /*!***********************************************!*\
  16114. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16115. \***********************************************/
  16116. /*! exports provided: fluentVertexShader */
  16117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16118. "use strict";
  16119. __webpack_require__.r(__webpack_exports__);
  16120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16121. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/perfCounter");
  16122. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16123. var name = 'fluentVertexShader';
  16124. 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";
  16125. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16126. /** @hidden */
  16127. var fluentVertexShader = { name: name, shader: shader };
  16128. /***/ }),
  16129. /***/ "./3D/vector3WithInfo.ts":
  16130. /*!*******************************!*\
  16131. !*** ./3D/vector3WithInfo.ts ***!
  16132. \*******************************/
  16133. /*! exports provided: Vector3WithInfo */
  16134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16135. "use strict";
  16136. __webpack_require__.r(__webpack_exports__);
  16137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16138. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16139. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Misc/perfCounter");
  16140. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  16141. /**
  16142. * Class used to transport Vector3 information for pointer events
  16143. */
  16144. var Vector3WithInfo = /** @class */ (function (_super) {
  16145. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16146. /**
  16147. * Creates a new Vector3WithInfo
  16148. * @param source defines the vector3 data to transport
  16149. * @param buttonIndex defines the current mouse button index
  16150. */
  16151. function Vector3WithInfo(source,
  16152. /** defines the current mouse button index */
  16153. buttonIndex) {
  16154. if (buttonIndex === void 0) { buttonIndex = 0; }
  16155. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16156. _this.buttonIndex = buttonIndex;
  16157. return _this;
  16158. }
  16159. return Vector3WithInfo;
  16160. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16161. /***/ }),
  16162. /***/ "./index.ts":
  16163. /*!******************!*\
  16164. !*** ./index.ts ***!
  16165. \******************/
  16166. /*! 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 */
  16167. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16168. "use strict";
  16169. __webpack_require__.r(__webpack_exports__);
  16170. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16212. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16229. /***/ }),
  16230. /***/ "./legacy/legacy.ts":
  16231. /*!**************************!*\
  16232. !*** ./legacy/legacy.ts ***!
  16233. \**************************/
  16234. /*! 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 */
  16235. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16236. "use strict";
  16237. __webpack_require__.r(__webpack_exports__);
  16238. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16296. /**
  16297. * Legacy support, defining window.BABYLON.GUI (global variable).
  16298. *
  16299. * This is the entry point for the UMD module.
  16300. * The entry point for a future ESM package should be index.ts
  16301. */
  16302. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16303. if (typeof globalObject !== "undefined") {
  16304. globalObject.BABYLON = globalObject.BABYLON || {};
  16305. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16306. }
  16307. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16308. /***/ }),
  16309. /***/ "babylonjs/Misc/perfCounter":
  16310. /*!****************************************************************************************************!*\
  16311. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16312. \****************************************************************************************************/
  16313. /*! no static exports found */
  16314. /***/ (function(module, exports) {
  16315. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_perfCounter__;
  16316. /***/ })
  16317. /******/ });
  16318. });
  16319. //# sourceMappingURL=babylon.gui.js.map