babylon.gui.js 760 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459
  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_Maths_math_vector__) {
  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. !*** D:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet */
  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__, "__createBinding", function() { return __createBinding; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; });
  128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; });
  129. /*! *****************************************************************************
  130. Copyright (c) Microsoft Corporation.
  131. Permission to use, copy, modify, and/or distribute this software for any
  132. purpose with or without fee is hereby granted.
  133. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  134. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  135. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  136. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  137. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  138. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  139. PERFORMANCE OF THIS SOFTWARE.
  140. ***************************************************************************** */
  141. /* global Reflect, Promise */
  142. var extendStatics = function(d, b) {
  143. extendStatics = Object.setPrototypeOf ||
  144. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  145. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  146. return extendStatics(d, b);
  147. };
  148. function __extends(d, b) {
  149. extendStatics(d, b);
  150. function __() { this.constructor = d; }
  151. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  152. }
  153. var __assign = function() {
  154. __assign = Object.assign || function __assign(t) {
  155. for (var s, i = 1, n = arguments.length; i < n; i++) {
  156. s = arguments[i];
  157. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  158. }
  159. return t;
  160. }
  161. return __assign.apply(this, arguments);
  162. }
  163. function __rest(s, e) {
  164. var t = {};
  165. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  166. t[p] = s[p];
  167. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  168. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  169. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  170. t[p[i]] = s[p[i]];
  171. }
  172. return t;
  173. }
  174. function __decorate(decorators, target, key, desc) {
  175. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  176. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  177. 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;
  178. return c > 3 && r && Object.defineProperty(target, key, r), r;
  179. }
  180. function __param(paramIndex, decorator) {
  181. return function (target, key) { decorator(target, key, paramIndex); }
  182. }
  183. function __metadata(metadataKey, metadataValue) {
  184. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  185. }
  186. function __awaiter(thisArg, _arguments, P, generator) {
  187. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  188. return new (P || (P = Promise))(function (resolve, reject) {
  189. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  190. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  191. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  192. step((generator = generator.apply(thisArg, _arguments || [])).next());
  193. });
  194. }
  195. function __generator(thisArg, body) {
  196. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  197. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  198. function verb(n) { return function (v) { return step([n, v]); }; }
  199. function step(op) {
  200. if (f) throw new TypeError("Generator is already executing.");
  201. while (_) try {
  202. 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;
  203. if (y = 0, t) op = [op[0] & 2, t.value];
  204. switch (op[0]) {
  205. case 0: case 1: t = op; break;
  206. case 4: _.label++; return { value: op[1], done: false };
  207. case 5: _.label++; y = op[1]; op = [0]; continue;
  208. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  209. default:
  210. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  211. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  212. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  213. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  214. if (t[2]) _.ops.pop();
  215. _.trys.pop(); continue;
  216. }
  217. op = body.call(thisArg, _);
  218. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  219. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  220. }
  221. }
  222. var __createBinding = Object.create ? (function(o, m, k, k2) {
  223. if (k2 === undefined) k2 = k;
  224. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  225. }) : (function(o, m, k, k2) {
  226. if (k2 === undefined) k2 = k;
  227. o[k2] = m[k];
  228. });
  229. function __exportStar(m, exports) {
  230. for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
  231. }
  232. function __values(o) {
  233. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  234. if (m) return m.call(o);
  235. if (o && typeof o.length === "number") return {
  236. next: function () {
  237. if (o && i >= o.length) o = void 0;
  238. return { value: o && o[i++], done: !o };
  239. }
  240. };
  241. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  242. }
  243. function __read(o, n) {
  244. var m = typeof Symbol === "function" && o[Symbol.iterator];
  245. if (!m) return o;
  246. var i = m.call(o), r, ar = [], e;
  247. try {
  248. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  249. }
  250. catch (error) { e = { error: error }; }
  251. finally {
  252. try {
  253. if (r && !r.done && (m = i["return"])) m.call(i);
  254. }
  255. finally { if (e) throw e.error; }
  256. }
  257. return ar;
  258. }
  259. function __spread() {
  260. for (var ar = [], i = 0; i < arguments.length; i++)
  261. ar = ar.concat(__read(arguments[i]));
  262. return ar;
  263. }
  264. function __spreadArrays() {
  265. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  266. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  267. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  268. r[k] = a[j];
  269. return r;
  270. };
  271. function __await(v) {
  272. return this instanceof __await ? (this.v = v, this) : new __await(v);
  273. }
  274. function __asyncGenerator(thisArg, _arguments, generator) {
  275. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  276. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  277. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  278. 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); }); }; }
  279. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  280. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  281. function fulfill(value) { resume("next", value); }
  282. function reject(value) { resume("throw", value); }
  283. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  284. }
  285. function __asyncDelegator(o) {
  286. var i, p;
  287. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  288. 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; }
  289. }
  290. function __asyncValues(o) {
  291. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  292. var m = o[Symbol.asyncIterator], i;
  293. 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);
  294. 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); }); }; }
  295. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  296. }
  297. function __makeTemplateObject(cooked, raw) {
  298. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  299. return cooked;
  300. };
  301. var __setModuleDefault = Object.create ? (function(o, v) {
  302. Object.defineProperty(o, "default", { enumerable: true, value: v });
  303. }) : function(o, v) {
  304. o["default"] = v;
  305. };
  306. function __importStar(mod) {
  307. if (mod && mod.__esModule) return mod;
  308. var result = {};
  309. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  310. __setModuleDefault(result, mod);
  311. return result;
  312. }
  313. function __importDefault(mod) {
  314. return (mod && mod.__esModule) ? mod : { default: mod };
  315. }
  316. function __classPrivateFieldGet(receiver, privateMap) {
  317. if (!privateMap.has(receiver)) {
  318. throw new TypeError("attempted to get private field on non-instance");
  319. }
  320. return privateMap.get(receiver);
  321. }
  322. function __classPrivateFieldSet(receiver, privateMap, value) {
  323. if (!privateMap.has(receiver)) {
  324. throw new TypeError("attempted to set private field on non-instance");
  325. }
  326. privateMap.set(receiver, value);
  327. return value;
  328. }
  329. /***/ }),
  330. /***/ "../../node_modules/webpack/buildin/global.js":
  331. /*!***********************************!*\
  332. !*** (webpack)/buildin/global.js ***!
  333. \***********************************/
  334. /*! no static exports found */
  335. /***/ (function(module, exports) {
  336. var g;
  337. // This works in non-strict mode
  338. g = (function() {
  339. return this;
  340. })();
  341. try {
  342. // This works if eval is allowed (see CSP)
  343. g = g || new Function("return this")();
  344. } catch (e) {
  345. // This works if the window reference is available
  346. if (typeof window === "object") g = window;
  347. }
  348. // g can still be undefined, but nothing to do about it...
  349. // We return undefined, instead of nothing here, so it's
  350. // easier to handle this case. if(!global) { ...}
  351. module.exports = g;
  352. /***/ }),
  353. /***/ "./2D/adtInstrumentation.ts":
  354. /*!**********************************!*\
  355. !*** ./2D/adtInstrumentation.ts ***!
  356. \**********************************/
  357. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  359. "use strict";
  360. __webpack_require__.r(__webpack_exports__);
  361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  362. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Maths/math.vector");
  363. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  364. /**
  365. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  366. */
  367. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  368. /**
  369. * Instantiates a new advanced dynamic texture instrumentation.
  370. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  371. * @param texture Defines the AdvancedDynamicTexture to instrument
  372. */
  373. function AdvancedDynamicTextureInstrumentation(
  374. /**
  375. * Define the instrumented AdvancedDynamicTexture.
  376. */
  377. texture) {
  378. this.texture = texture;
  379. this._captureRenderTime = false;
  380. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  381. this._captureLayoutTime = false;
  382. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  383. // Observers
  384. this._onBeginRenderObserver = null;
  385. this._onEndRenderObserver = null;
  386. this._onBeginLayoutObserver = null;
  387. this._onEndLayoutObserver = null;
  388. }
  389. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  390. // Properties
  391. /**
  392. * Gets the perf counter used to capture render time
  393. */
  394. get: function () {
  395. return this._renderTime;
  396. },
  397. enumerable: false,
  398. configurable: true
  399. });
  400. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  401. /**
  402. * Gets the perf counter used to capture layout time
  403. */
  404. get: function () {
  405. return this._layoutTime;
  406. },
  407. enumerable: false,
  408. configurable: true
  409. });
  410. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  411. /**
  412. * Enable or disable the render time capture
  413. */
  414. get: function () {
  415. return this._captureRenderTime;
  416. },
  417. set: function (value) {
  418. var _this = this;
  419. if (value === this._captureRenderTime) {
  420. return;
  421. }
  422. this._captureRenderTime = value;
  423. if (value) {
  424. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  425. _this._renderTime.beginMonitoring();
  426. });
  427. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  428. _this._renderTime.endMonitoring(true);
  429. });
  430. }
  431. else {
  432. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  433. this._onBeginRenderObserver = null;
  434. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  435. this._onEndRenderObserver = null;
  436. }
  437. },
  438. enumerable: false,
  439. configurable: true
  440. });
  441. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  442. /**
  443. * Enable or disable the layout time capture
  444. */
  445. get: function () {
  446. return this._captureLayoutTime;
  447. },
  448. set: function (value) {
  449. var _this = this;
  450. if (value === this._captureLayoutTime) {
  451. return;
  452. }
  453. this._captureLayoutTime = value;
  454. if (value) {
  455. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  456. _this._layoutTime.beginMonitoring();
  457. });
  458. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  459. _this._layoutTime.endMonitoring(true);
  460. });
  461. }
  462. else {
  463. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  464. this._onBeginLayoutObserver = null;
  465. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  466. this._onEndLayoutObserver = null;
  467. }
  468. },
  469. enumerable: false,
  470. configurable: true
  471. });
  472. /**
  473. * Dispose and release associated resources.
  474. */
  475. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  476. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  477. this._onBeginRenderObserver = null;
  478. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  479. this._onEndRenderObserver = null;
  480. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  481. this._onBeginLayoutObserver = null;
  482. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  483. this._onEndLayoutObserver = null;
  484. this.texture = null;
  485. };
  486. return AdvancedDynamicTextureInstrumentation;
  487. }());
  488. /***/ }),
  489. /***/ "./2D/advancedDynamicTexture.ts":
  490. /*!**************************************!*\
  491. !*** ./2D/advancedDynamicTexture.ts ***!
  492. \**************************************/
  493. /*! exports provided: AdvancedDynamicTexture */
  494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  495. "use strict";
  496. __webpack_require__.r(__webpack_exports__);
  497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  498. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  499. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  500. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  501. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  502. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  503. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  504. /**
  505. * Class used to create texture to support 2D GUI elements
  506. * @see https://doc.babylonjs.com/how_to/gui
  507. */
  508. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  509. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  510. /**
  511. * Creates a new AdvancedDynamicTexture
  512. * @param name defines the name of the texture
  513. * @param width defines the width of the texture
  514. * @param height defines the height of the texture
  515. * @param scene defines the hosting scene
  516. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  517. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  518. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  519. */
  520. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode, invertY) {
  521. if (width === void 0) { width = 0; }
  522. if (height === void 0) { height = 0; }
  523. if (generateMipMaps === void 0) { generateMipMaps = false; }
  524. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  525. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA, invertY) || this;
  526. _this._isDirty = false;
  527. /** @hidden */
  528. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  529. /** @hidden */
  530. _this._lastControlOver = {};
  531. /** @hidden */
  532. _this._lastControlDown = {};
  533. /** @hidden */
  534. _this._capturingControl = {};
  535. /** @hidden */
  536. _this._linkedControls = new Array();
  537. _this._isFullscreen = false;
  538. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  539. _this._idealWidth = 0;
  540. _this._idealHeight = 0;
  541. _this._useSmallestIdeal = false;
  542. _this._renderAtIdealSize = false;
  543. _this._blockNextFocusCheck = false;
  544. _this._renderScale = 1;
  545. _this._cursorChanged = false;
  546. _this._defaultMousePointerId = 0;
  547. /** @hidden */
  548. _this._numLayoutCalls = 0;
  549. /** @hidden */
  550. _this._numRenderCalls = 0;
  551. /**
  552. * Define type to string to ensure compatibility across browsers
  553. * Safari doesn't support DataTransfer constructor
  554. */
  555. _this._clipboardData = "";
  556. /**
  557. * Observable event triggered each time an clipboard event is received from the rendering canvas
  558. */
  559. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  560. /**
  561. * Observable event triggered each time a pointer down is intercepted by a control
  562. */
  563. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  564. /**
  565. * Observable event triggered before layout is evaluated
  566. */
  567. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  568. /**
  569. * Observable event triggered after the layout was evaluated
  570. */
  571. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  572. /**
  573. * Observable event triggered before the texture is rendered
  574. */
  575. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  576. /**
  577. * Observable event triggered after the texture was rendered
  578. */
  579. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  580. /**
  581. * Gets or sets a boolean defining if alpha is stored as premultiplied
  582. */
  583. _this.premulAlpha = false;
  584. _this._useInvalidateRectOptimization = true;
  585. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  586. _this._invalidatedRectangle = null;
  587. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  588. /** @hidden */
  589. _this.onClipboardCopy = function (rawEvt) {
  590. var evt = rawEvt;
  591. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  592. _this.onClipboardObservable.notifyObservers(ev);
  593. evt.preventDefault();
  594. };
  595. /** @hidden */
  596. _this.onClipboardCut = function (rawEvt) {
  597. var evt = rawEvt;
  598. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  599. _this.onClipboardObservable.notifyObservers(ev);
  600. evt.preventDefault();
  601. };
  602. /** @hidden */
  603. _this.onClipboardPaste = function (rawEvt) {
  604. var evt = rawEvt;
  605. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  606. _this.onClipboardObservable.notifyObservers(ev);
  607. evt.preventDefault();
  608. };
  609. scene = _this.getScene();
  610. if (!scene || !_this._texture) {
  611. return _this;
  612. }
  613. _this._rootElement = scene.getEngine().getInputElement();
  614. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  615. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  616. if (!_this._focusedControl) {
  617. return;
  618. }
  619. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  620. _this._focusedControl.processKeyboard(info.event);
  621. }
  622. info.skipOnPointerObservable = true;
  623. });
  624. _this._rootContainer._link(_this);
  625. _this.hasAlpha = true;
  626. if (!width || !height) {
  627. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  628. _this._onResize();
  629. }
  630. _this._texture.isReady = true;
  631. return _this;
  632. }
  633. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  634. /** Gets the number of layout calls made the last time the ADT has been rendered */
  635. get: function () {
  636. return this._numLayoutCalls;
  637. },
  638. enumerable: false,
  639. configurable: true
  640. });
  641. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  642. /** Gets the number of render calls made the last time the ADT has been rendered */
  643. get: function () {
  644. return this._numRenderCalls;
  645. },
  646. enumerable: false,
  647. configurable: true
  648. });
  649. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  650. /**
  651. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  652. * Useful when you want more antialiasing
  653. */
  654. get: function () {
  655. return this._renderScale;
  656. },
  657. set: function (value) {
  658. if (value === this._renderScale) {
  659. return;
  660. }
  661. this._renderScale = value;
  662. this._onResize();
  663. },
  664. enumerable: false,
  665. configurable: true
  666. });
  667. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  668. /** Gets or sets the background color */
  669. get: function () {
  670. return this._background;
  671. },
  672. set: function (value) {
  673. if (this._background === value) {
  674. return;
  675. }
  676. this._background = value;
  677. this.markAsDirty();
  678. },
  679. enumerable: false,
  680. configurable: true
  681. });
  682. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  683. /**
  684. * Gets or sets the ideal width used to design controls.
  685. * The GUI will then rescale everything accordingly
  686. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  687. */
  688. get: function () {
  689. return this._idealWidth;
  690. },
  691. set: function (value) {
  692. if (this._idealWidth === value) {
  693. return;
  694. }
  695. this._idealWidth = value;
  696. this.markAsDirty();
  697. this._rootContainer._markAllAsDirty();
  698. },
  699. enumerable: false,
  700. configurable: true
  701. });
  702. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  703. /**
  704. * Gets or sets the ideal height used to design controls.
  705. * The GUI will then rescale everything accordingly
  706. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  707. */
  708. get: function () {
  709. return this._idealHeight;
  710. },
  711. set: function (value) {
  712. if (this._idealHeight === value) {
  713. return;
  714. }
  715. this._idealHeight = value;
  716. this.markAsDirty();
  717. this._rootContainer._markAllAsDirty();
  718. },
  719. enumerable: false,
  720. configurable: true
  721. });
  722. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  723. /**
  724. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  725. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  726. */
  727. get: function () {
  728. return this._useSmallestIdeal;
  729. },
  730. set: function (value) {
  731. if (this._useSmallestIdeal === value) {
  732. return;
  733. }
  734. this._useSmallestIdeal = value;
  735. this.markAsDirty();
  736. this._rootContainer._markAllAsDirty();
  737. },
  738. enumerable: false,
  739. configurable: true
  740. });
  741. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  742. /**
  743. * Gets or sets a boolean indicating if adaptive scaling must be used
  744. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  745. */
  746. get: function () {
  747. return this._renderAtIdealSize;
  748. },
  749. set: function (value) {
  750. if (this._renderAtIdealSize === value) {
  751. return;
  752. }
  753. this._renderAtIdealSize = value;
  754. this._onResize();
  755. },
  756. enumerable: false,
  757. configurable: true
  758. });
  759. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  760. /**
  761. * Gets the ratio used when in "ideal mode"
  762. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  763. * */
  764. get: function () {
  765. var rwidth = 0;
  766. var rheight = 0;
  767. if (this._idealWidth) {
  768. rwidth = (this.getSize().width) / this._idealWidth;
  769. }
  770. if (this._idealHeight) {
  771. rheight = (this.getSize().height) / this._idealHeight;
  772. }
  773. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  774. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  775. }
  776. if (this._idealWidth) { // horizontal
  777. return rwidth;
  778. }
  779. if (this._idealHeight) { // vertical
  780. return rheight;
  781. }
  782. return 1;
  783. },
  784. enumerable: false,
  785. configurable: true
  786. });
  787. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  788. /**
  789. * Gets the underlying layer used to render the texture when in fullscreen mode
  790. */
  791. get: function () {
  792. return this._layerToDispose;
  793. },
  794. enumerable: false,
  795. configurable: true
  796. });
  797. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  798. /**
  799. * Gets the root container control
  800. */
  801. get: function () {
  802. return this._rootContainer;
  803. },
  804. enumerable: false,
  805. configurable: true
  806. });
  807. /**
  808. * Returns an array containing the root container.
  809. * This is mostly used to let the Inspector introspects the ADT
  810. * @returns an array containing the rootContainer
  811. */
  812. AdvancedDynamicTexture.prototype.getChildren = function () {
  813. return [this._rootContainer];
  814. };
  815. /**
  816. * Will return all controls that are inside this texture
  817. * @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
  818. * @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
  819. * @return all child controls
  820. */
  821. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  822. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  823. };
  824. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  825. /**
  826. * Gets or sets the current focused control
  827. */
  828. get: function () {
  829. return this._focusedControl;
  830. },
  831. set: function (control) {
  832. if (this._focusedControl == control) {
  833. return;
  834. }
  835. if (this._focusedControl) {
  836. this._focusedControl.onBlur();
  837. }
  838. if (control) {
  839. control.onFocus();
  840. }
  841. this._focusedControl = control;
  842. },
  843. enumerable: false,
  844. configurable: true
  845. });
  846. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  847. /**
  848. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  849. */
  850. get: function () {
  851. if (!this.layer) {
  852. return true;
  853. }
  854. return (!this.layer.isBackground);
  855. },
  856. set: function (value) {
  857. if (!this.layer) {
  858. return;
  859. }
  860. if (this.layer.isBackground === !value) {
  861. return;
  862. }
  863. this.layer.isBackground = !value;
  864. },
  865. enumerable: false,
  866. configurable: true
  867. });
  868. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  869. /**
  870. * Gets or set information about clipboardData
  871. */
  872. get: function () {
  873. return this._clipboardData;
  874. },
  875. set: function (value) {
  876. this._clipboardData = value;
  877. },
  878. enumerable: false,
  879. configurable: true
  880. });
  881. /**
  882. * Get the current class name of the texture useful for serialization or dynamic coding.
  883. * @returns "AdvancedDynamicTexture"
  884. */
  885. AdvancedDynamicTexture.prototype.getClassName = function () {
  886. return "AdvancedDynamicTexture";
  887. };
  888. /**
  889. * Function used to execute a function on all controls
  890. * @param func defines the function to execute
  891. * @param container defines the container where controls belong. If null the root container will be used
  892. */
  893. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  894. if (!container) {
  895. container = this._rootContainer;
  896. }
  897. func(container);
  898. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  899. var child = _a[_i];
  900. if (child.children) {
  901. this.executeOnAllControls(func, child);
  902. continue;
  903. }
  904. func(child);
  905. }
  906. };
  907. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  908. /**
  909. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  910. */
  911. get: function () {
  912. return this._useInvalidateRectOptimization;
  913. },
  914. set: function (value) {
  915. this._useInvalidateRectOptimization = value;
  916. },
  917. enumerable: false,
  918. configurable: true
  919. });
  920. /**
  921. * Invalidates a rectangle area on the gui texture
  922. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  923. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  924. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  925. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  926. */
  927. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  928. if (!this._useInvalidateRectOptimization) {
  929. return;
  930. }
  931. if (!this._invalidatedRectangle) {
  932. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  933. }
  934. else {
  935. // Compute intersection
  936. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  937. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  938. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  939. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  940. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  941. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  942. }
  943. };
  944. /**
  945. * Marks the texture as dirty forcing a complete update
  946. */
  947. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  948. this._isDirty = true;
  949. };
  950. /**
  951. * Helper function used to create a new style
  952. * @returns a new style
  953. * @see https://doc.babylonjs.com/how_to/gui#styles
  954. */
  955. AdvancedDynamicTexture.prototype.createStyle = function () {
  956. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  957. };
  958. /**
  959. * Adds a new control to the root container
  960. * @param control defines the control to add
  961. * @returns the current texture
  962. */
  963. AdvancedDynamicTexture.prototype.addControl = function (control) {
  964. this._rootContainer.addControl(control);
  965. return this;
  966. };
  967. /**
  968. * Removes a control from the root container
  969. * @param control defines the control to remove
  970. * @returns the current texture
  971. */
  972. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  973. this._rootContainer.removeControl(control);
  974. return this;
  975. };
  976. /**
  977. * Release all resources
  978. */
  979. AdvancedDynamicTexture.prototype.dispose = function () {
  980. var scene = this.getScene();
  981. if (!scene) {
  982. return;
  983. }
  984. this._rootElement = null;
  985. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  986. if (this._resizeObserver) {
  987. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  988. }
  989. if (this._pointerMoveObserver) {
  990. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  991. }
  992. if (this._pointerObserver) {
  993. scene.onPointerObservable.remove(this._pointerObserver);
  994. }
  995. if (this._preKeyboardObserver) {
  996. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  997. }
  998. if (this._canvasPointerOutObserver) {
  999. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  1000. }
  1001. if (this._canvasBlurObserver) {
  1002. scene.getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver);
  1003. }
  1004. if (this._layerToDispose) {
  1005. this._layerToDispose.texture = null;
  1006. this._layerToDispose.dispose();
  1007. this._layerToDispose = null;
  1008. }
  1009. this._rootContainer.dispose();
  1010. this.onClipboardObservable.clear();
  1011. this.onControlPickedObservable.clear();
  1012. this.onBeginRenderObservable.clear();
  1013. this.onEndRenderObservable.clear();
  1014. this.onBeginLayoutObservable.clear();
  1015. this.onEndLayoutObservable.clear();
  1016. _super.prototype.dispose.call(this);
  1017. };
  1018. AdvancedDynamicTexture.prototype._onResize = function () {
  1019. var scene = this.getScene();
  1020. if (!scene) {
  1021. return;
  1022. }
  1023. // Check size
  1024. var engine = scene.getEngine();
  1025. var textureSize = this.getSize();
  1026. var renderWidth = engine.getRenderWidth() * this._renderScale;
  1027. var renderHeight = engine.getRenderHeight() * this._renderScale;
  1028. if (this._renderAtIdealSize) {
  1029. if (this._idealWidth) {
  1030. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  1031. renderWidth = this._idealWidth;
  1032. }
  1033. else if (this._idealHeight) {
  1034. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1035. renderHeight = this._idealHeight;
  1036. }
  1037. }
  1038. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1039. this.scaleTo(renderWidth, renderHeight);
  1040. this.markAsDirty();
  1041. if (this._idealWidth || this._idealHeight) {
  1042. this._rootContainer._markAllAsDirty();
  1043. }
  1044. }
  1045. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1046. };
  1047. /** @hidden */
  1048. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1049. var engine = scene.getEngine();
  1050. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1051. };
  1052. /**
  1053. * Get screen coordinates for a vector3
  1054. * @param position defines the position to project
  1055. * @param worldMatrix defines the world matrix to use
  1056. * @returns the projected position
  1057. */
  1058. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1059. var scene = this.getScene();
  1060. if (!scene) {
  1061. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1062. }
  1063. var globalViewport = this._getGlobalViewport(scene);
  1064. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1065. projectedPosition.scaleInPlace(this.renderScale);
  1066. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1067. };
  1068. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1069. if (this._layerToDispose) {
  1070. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1071. return;
  1072. }
  1073. }
  1074. if (this._isFullscreen && this._linkedControls.length) {
  1075. var scene = this.getScene();
  1076. if (!scene) {
  1077. return;
  1078. }
  1079. var globalViewport = this._getGlobalViewport(scene);
  1080. var _loop_1 = function (control) {
  1081. if (!control.isVisible) {
  1082. return "continue";
  1083. }
  1084. var mesh = control._linkedMesh;
  1085. if (!mesh || mesh.isDisposed()) {
  1086. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1087. control.linkWithMesh(null);
  1088. });
  1089. return "continue";
  1090. }
  1091. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1092. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1093. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1094. control.notRenderable = true;
  1095. return "continue";
  1096. }
  1097. control.notRenderable = false;
  1098. // Account for RenderScale.
  1099. projectedPosition.scaleInPlace(this_1.renderScale);
  1100. control._moveToProjectedPosition(projectedPosition);
  1101. };
  1102. var this_1 = this;
  1103. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1104. var control = _a[_i];
  1105. _loop_1(control);
  1106. }
  1107. }
  1108. if (!this._isDirty && !this._rootContainer.isDirty) {
  1109. return;
  1110. }
  1111. this._isDirty = false;
  1112. this._render();
  1113. this.update(true, this.premulAlpha);
  1114. };
  1115. AdvancedDynamicTexture.prototype._render = function () {
  1116. var textureSize = this.getSize();
  1117. var renderWidth = textureSize.width;
  1118. var renderHeight = textureSize.height;
  1119. var context = this.getContext();
  1120. context.font = "18px Arial";
  1121. context.strokeStyle = "white";
  1122. // Layout
  1123. this.onBeginLayoutObservable.notifyObservers(this);
  1124. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1125. this._numLayoutCalls = 0;
  1126. this._rootContainer._layout(measure, context);
  1127. this.onEndLayoutObservable.notifyObservers(this);
  1128. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1129. // Clear
  1130. if (this._invalidatedRectangle) {
  1131. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1132. }
  1133. else {
  1134. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1135. }
  1136. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1137. if (this._background) {
  1138. context.save();
  1139. context.fillStyle = this._background;
  1140. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1141. context.restore();
  1142. }
  1143. // Render
  1144. this.onBeginRenderObservable.notifyObservers(this);
  1145. this._numRenderCalls = 0;
  1146. this._rootContainer._render(context, this._invalidatedRectangle);
  1147. this.onEndRenderObservable.notifyObservers(this);
  1148. this._invalidatedRectangle = null;
  1149. };
  1150. /** @hidden */
  1151. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1152. if (this._rootElement) {
  1153. this._rootElement.style.cursor = cursor;
  1154. this._cursorChanged = true;
  1155. }
  1156. };
  1157. /** @hidden */
  1158. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1159. this._lastControlDown[pointerId] = control;
  1160. this.onControlPickedObservable.notifyObservers(control);
  1161. };
  1162. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1163. var scene = this.getScene();
  1164. if (!scene) {
  1165. return;
  1166. }
  1167. var engine = scene.getEngine();
  1168. var textureSize = this.getSize();
  1169. if (this._isFullscreen) {
  1170. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1171. var viewport = camera.viewport;
  1172. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1173. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1174. }
  1175. if (this._capturingControl[pointerId]) {
  1176. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1177. return;
  1178. }
  1179. this._cursorChanged = false;
  1180. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  1181. this._changeCursor("");
  1182. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1183. if (this._lastControlOver[pointerId]) {
  1184. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1185. delete this._lastControlOver[pointerId];
  1186. }
  1187. }
  1188. }
  1189. if (!this._cursorChanged) {
  1190. this._changeCursor("");
  1191. }
  1192. this._manageFocus();
  1193. };
  1194. /** @hidden */
  1195. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1196. for (var pointerId in list) {
  1197. if (!list.hasOwnProperty(pointerId)) {
  1198. continue;
  1199. }
  1200. var lastControlOver = list[pointerId];
  1201. if (lastControlOver === control) {
  1202. delete list[pointerId];
  1203. }
  1204. }
  1205. };
  1206. /** @hidden */
  1207. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1208. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1209. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1210. };
  1211. /** Attach to all scene events required to support pointer events */
  1212. AdvancedDynamicTexture.prototype.attach = function () {
  1213. var _this = this;
  1214. var scene = this.getScene();
  1215. if (!scene) {
  1216. return;
  1217. }
  1218. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1219. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1220. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1221. return;
  1222. }
  1223. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1224. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1225. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN
  1226. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  1227. return;
  1228. }
  1229. if (!scene) {
  1230. return;
  1231. }
  1232. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE && pi.event.pointerId) {
  1233. _this._defaultMousePointerId = pi.event.pointerId; // This is required to make sure we have the correct pointer ID for wheel
  1234. }
  1235. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1236. var engine = scene.getEngine();
  1237. if (!camera) {
  1238. tempViewport.x = 0;
  1239. tempViewport.y = 0;
  1240. tempViewport.width = engine.getRenderWidth();
  1241. tempViewport.height = engine.getRenderHeight();
  1242. }
  1243. else {
  1244. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1245. }
  1246. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1247. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1248. _this._shouldBlockPointer = false;
  1249. // Do picking modifies _shouldBlockPointer
  1250. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1251. _this._doPicking(x, y, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
  1252. // Avoid overwriting a true skipOnPointerObservable to false
  1253. if (_this._shouldBlockPointer) {
  1254. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1255. }
  1256. });
  1257. this._attachToOnPointerOut(scene);
  1258. this._attachToOnBlur(scene);
  1259. };
  1260. /**
  1261. * Register the clipboard Events onto the canvas
  1262. */
  1263. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1264. self.addEventListener("copy", this.onClipboardCopy, false);
  1265. self.addEventListener("cut", this.onClipboardCut, false);
  1266. self.addEventListener("paste", this.onClipboardPaste, false);
  1267. };
  1268. /**
  1269. * Unregister the clipboard Events from the canvas
  1270. */
  1271. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1272. self.removeEventListener("copy", this.onClipboardCopy);
  1273. self.removeEventListener("cut", this.onClipboardCut);
  1274. self.removeEventListener("paste", this.onClipboardPaste);
  1275. };
  1276. /**
  1277. * Connect the texture to a hosting mesh to enable interactions
  1278. * @param mesh defines the mesh to attach to
  1279. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1280. */
  1281. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1282. var _this = this;
  1283. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1284. var scene = this.getScene();
  1285. if (!scene) {
  1286. return;
  1287. }
  1288. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1289. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1290. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1291. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1292. return;
  1293. }
  1294. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1295. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1296. var uv = pi.pickInfo.getTextureCoordinates();
  1297. if (uv) {
  1298. var size = _this.getSize();
  1299. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1300. }
  1301. }
  1302. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1303. if (_this._lastControlDown[pointerId]) {
  1304. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1305. }
  1306. delete _this._lastControlDown[pointerId];
  1307. if (_this.focusedControl) {
  1308. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1309. var canMoveFocus = true;
  1310. if (friendlyControls) {
  1311. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1312. var control = friendlyControls_1[_i];
  1313. // Same host, no need to keep the focus
  1314. if (_this === control._host) {
  1315. continue;
  1316. }
  1317. // Different hosts
  1318. var otherHost = control._host;
  1319. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1320. canMoveFocus = false;
  1321. break;
  1322. }
  1323. }
  1324. }
  1325. if (canMoveFocus) {
  1326. _this.focusedControl = null;
  1327. }
  1328. }
  1329. }
  1330. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1331. if (_this._lastControlOver[pointerId]) {
  1332. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1333. }
  1334. delete _this._lastControlOver[pointerId];
  1335. }
  1336. });
  1337. mesh.enablePointerMoveEvents = supportPointerMove;
  1338. this._attachToOnPointerOut(scene);
  1339. this._attachToOnBlur(scene);
  1340. };
  1341. /**
  1342. * Move the focus to a specific control
  1343. * @param control defines the control which will receive the focus
  1344. */
  1345. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1346. this.focusedControl = control;
  1347. this._lastPickedControl = control;
  1348. this._blockNextFocusCheck = true;
  1349. };
  1350. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1351. if (this._blockNextFocusCheck) {
  1352. this._blockNextFocusCheck = false;
  1353. this._lastPickedControl = this._focusedControl;
  1354. return;
  1355. }
  1356. // Focus management
  1357. if (this._focusedControl) {
  1358. if (this._focusedControl !== this._lastPickedControl) {
  1359. if (this._lastPickedControl.isFocusInvisible) {
  1360. return;
  1361. }
  1362. this.focusedControl = null;
  1363. }
  1364. }
  1365. };
  1366. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1367. var _this = this;
  1368. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1369. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1370. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1371. }
  1372. delete _this._lastControlOver[pointerEvent.pointerId];
  1373. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1374. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1375. delete _this._lastControlDown[pointerEvent.pointerId];
  1376. }
  1377. });
  1378. };
  1379. AdvancedDynamicTexture.prototype._attachToOnBlur = function (scene) {
  1380. var _this = this;
  1381. this._canvasBlurObserver = scene.getEngine().onCanvasBlurObservable.add(function (pointerEvent) {
  1382. Object.entries(_this._lastControlDown).forEach(function (_a) {
  1383. var key = _a[0], value = _a[1];
  1384. value._onCanvasBlur();
  1385. });
  1386. _this._lastControlDown = {};
  1387. });
  1388. };
  1389. // Statics
  1390. /**
  1391. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1392. * @param mesh defines the mesh which will receive the texture
  1393. * @param width defines the texture width (1024 by default)
  1394. * @param height defines the texture height (1024 by default)
  1395. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1396. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1397. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  1398. * @returns a new AdvancedDynamicTexture
  1399. */
  1400. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting, invertY) {
  1401. if (width === void 0) { width = 1024; }
  1402. if (height === void 0) { height = 1024; }
  1403. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1404. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1405. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, invertY);
  1406. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1407. material.backFaceCulling = false;
  1408. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1409. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1410. if (onlyAlphaTesting) {
  1411. material.diffuseTexture = result;
  1412. material.emissiveTexture = result;
  1413. result.hasAlpha = true;
  1414. }
  1415. else {
  1416. material.emissiveTexture = result;
  1417. material.opacityTexture = result;
  1418. }
  1419. mesh.material = material;
  1420. result.attachToMesh(mesh, supportPointerMove);
  1421. return result;
  1422. };
  1423. /**
  1424. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1425. * In this mode the texture will rely on a layer for its rendering.
  1426. * This allows it to be treated like any other layer.
  1427. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1428. * LayerMask is set through advancedTexture.layer.layerMask
  1429. * @param name defines name for the texture
  1430. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1431. * @param scene defines the hsoting scene
  1432. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1433. * @returns a new AdvancedDynamicTexture
  1434. */
  1435. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1436. if (foreground === void 0) { foreground = true; }
  1437. if (scene === void 0) { scene = null; }
  1438. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1439. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1440. // Display
  1441. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1442. layer.texture = result;
  1443. result._layerToDispose = layer;
  1444. result._isFullscreen = true;
  1445. // Attach
  1446. result.attach();
  1447. return result;
  1448. };
  1449. return AdvancedDynamicTexture;
  1450. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1451. /***/ }),
  1452. /***/ "./2D/controls/button.ts":
  1453. /*!*******************************!*\
  1454. !*** ./2D/controls/button.ts ***!
  1455. \*******************************/
  1456. /*! exports provided: Button */
  1457. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1458. "use strict";
  1459. __webpack_require__.r(__webpack_exports__);
  1460. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1461. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1462. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1463. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1464. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1465. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1466. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  1467. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1468. /**
  1469. * Class used to create 2D buttons
  1470. */
  1471. var Button = /** @class */ (function (_super) {
  1472. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1473. /**
  1474. * Creates a new Button
  1475. * @param name defines the name of the button
  1476. */
  1477. function Button(name) {
  1478. var _this = _super.call(this, name) || this;
  1479. _this.name = name;
  1480. /**
  1481. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1482. */
  1483. _this.delegatePickingToChildren = false;
  1484. _this.thickness = 1;
  1485. _this.isPointerBlocker = true;
  1486. var alphaStore = null;
  1487. _this.pointerEnterAnimation = function () {
  1488. alphaStore = _this.alpha;
  1489. _this.alpha -= 0.1;
  1490. };
  1491. _this.pointerOutAnimation = function () {
  1492. if (alphaStore !== null) {
  1493. _this.alpha = alphaStore;
  1494. }
  1495. };
  1496. _this.pointerDownAnimation = function () {
  1497. _this.scaleX -= 0.05;
  1498. _this.scaleY -= 0.05;
  1499. };
  1500. _this.pointerUpAnimation = function () {
  1501. _this.scaleX += 0.05;
  1502. _this.scaleY += 0.05;
  1503. };
  1504. return _this;
  1505. }
  1506. Object.defineProperty(Button.prototype, "image", {
  1507. /**
  1508. * Returns the image part of the button (if any)
  1509. */
  1510. get: function () {
  1511. return this._image;
  1512. },
  1513. enumerable: false,
  1514. configurable: true
  1515. });
  1516. Object.defineProperty(Button.prototype, "textBlock", {
  1517. /**
  1518. * Returns the image part of the button (if any)
  1519. */
  1520. get: function () {
  1521. return this._textBlock;
  1522. },
  1523. enumerable: false,
  1524. configurable: true
  1525. });
  1526. Button.prototype._getTypeName = function () {
  1527. return "Button";
  1528. };
  1529. // While being a container, the button behaves like a control.
  1530. /** @hidden */
  1531. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1532. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1533. return false;
  1534. }
  1535. if (!_super.prototype.contains.call(this, x, y)) {
  1536. return false;
  1537. }
  1538. if (this.delegatePickingToChildren) {
  1539. var contains = false;
  1540. for (var index = this._children.length - 1; index >= 0; index--) {
  1541. var child = this._children[index];
  1542. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1543. contains = true;
  1544. break;
  1545. }
  1546. }
  1547. if (!contains) {
  1548. return false;
  1549. }
  1550. }
  1551. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  1552. return true;
  1553. };
  1554. /** @hidden */
  1555. Button.prototype._onPointerEnter = function (target) {
  1556. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1557. return false;
  1558. }
  1559. if (this.pointerEnterAnimation) {
  1560. this.pointerEnterAnimation();
  1561. }
  1562. return true;
  1563. };
  1564. /** @hidden */
  1565. Button.prototype._onPointerOut = function (target, force) {
  1566. if (force === void 0) { force = false; }
  1567. if (this.pointerOutAnimation) {
  1568. this.pointerOutAnimation();
  1569. }
  1570. _super.prototype._onPointerOut.call(this, target, force);
  1571. };
  1572. /** @hidden */
  1573. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1574. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1575. return false;
  1576. }
  1577. if (this.pointerDownAnimation) {
  1578. this.pointerDownAnimation();
  1579. }
  1580. return true;
  1581. };
  1582. /** @hidden */
  1583. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1584. if (this.pointerUpAnimation) {
  1585. this.pointerUpAnimation();
  1586. }
  1587. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1588. };
  1589. // Statics
  1590. /**
  1591. * Creates a new button made with an image and a text
  1592. * @param name defines the name of the button
  1593. * @param text defines the text of the button
  1594. * @param imageUrl defines the url of the image
  1595. * @returns a new Button
  1596. */
  1597. Button.CreateImageButton = function (name, text, imageUrl) {
  1598. var result = new Button(name);
  1599. // Adding text
  1600. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1601. textBlock.textWrapping = true;
  1602. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1603. textBlock.paddingLeft = "20%";
  1604. result.addControl(textBlock);
  1605. // Adding image
  1606. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1607. iconImage.width = "20%";
  1608. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1609. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1610. result.addControl(iconImage);
  1611. // Store
  1612. result._image = iconImage;
  1613. result._textBlock = textBlock;
  1614. return result;
  1615. };
  1616. /**
  1617. * Creates a new button made with an image
  1618. * @param name defines the name of the button
  1619. * @param imageUrl defines the url of the image
  1620. * @returns a new Button
  1621. */
  1622. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1623. var result = new Button(name);
  1624. // Adding image
  1625. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1626. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1627. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1628. result.addControl(iconImage);
  1629. // Store
  1630. result._image = iconImage;
  1631. return result;
  1632. };
  1633. /**
  1634. * Creates a new button made with a text
  1635. * @param name defines the name of the button
  1636. * @param text defines the text of the button
  1637. * @returns a new Button
  1638. */
  1639. Button.CreateSimpleButton = function (name, text) {
  1640. var result = new Button(name);
  1641. // Adding text
  1642. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1643. textBlock.textWrapping = true;
  1644. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1645. result.addControl(textBlock);
  1646. // Store
  1647. result._textBlock = textBlock;
  1648. return result;
  1649. };
  1650. /**
  1651. * Creates a new button made with an image and a centered text
  1652. * @param name defines the name of the button
  1653. * @param text defines the text of the button
  1654. * @param imageUrl defines the url of the image
  1655. * @returns a new Button
  1656. */
  1657. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1658. var result = new Button(name);
  1659. // Adding image
  1660. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1661. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1662. result.addControl(iconImage);
  1663. // Adding text
  1664. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1665. textBlock.textWrapping = true;
  1666. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1667. result.addControl(textBlock);
  1668. // Store
  1669. result._image = iconImage;
  1670. result._textBlock = textBlock;
  1671. return result;
  1672. };
  1673. return Button;
  1674. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1675. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1676. /***/ }),
  1677. /***/ "./2D/controls/checkbox.ts":
  1678. /*!*********************************!*\
  1679. !*** ./2D/controls/checkbox.ts ***!
  1680. \*********************************/
  1681. /*! exports provided: Checkbox */
  1682. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1683. "use strict";
  1684. __webpack_require__.r(__webpack_exports__);
  1685. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1686. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1687. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  1688. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1689. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1690. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1691. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1692. /**
  1693. * Class used to represent a 2D checkbox
  1694. */
  1695. var Checkbox = /** @class */ (function (_super) {
  1696. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1697. /**
  1698. * Creates a new CheckBox
  1699. * @param name defines the control name
  1700. */
  1701. function Checkbox(name) {
  1702. var _this = _super.call(this, name) || this;
  1703. _this.name = name;
  1704. _this._isChecked = false;
  1705. _this._background = "black";
  1706. _this._checkSizeRatio = 0.8;
  1707. _this._thickness = 1;
  1708. /**
  1709. * Observable raised when isChecked property changes
  1710. */
  1711. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1712. _this.isPointerBlocker = true;
  1713. return _this;
  1714. }
  1715. Object.defineProperty(Checkbox.prototype, "thickness", {
  1716. /** Gets or sets border thickness */
  1717. get: function () {
  1718. return this._thickness;
  1719. },
  1720. set: function (value) {
  1721. if (this._thickness === value) {
  1722. return;
  1723. }
  1724. this._thickness = value;
  1725. this._markAsDirty();
  1726. },
  1727. enumerable: false,
  1728. configurable: true
  1729. });
  1730. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1731. /** Gets or sets a value indicating the ratio between overall size and check size */
  1732. get: function () {
  1733. return this._checkSizeRatio;
  1734. },
  1735. set: function (value) {
  1736. value = Math.max(Math.min(1, value), 0);
  1737. if (this._checkSizeRatio === value) {
  1738. return;
  1739. }
  1740. this._checkSizeRatio = value;
  1741. this._markAsDirty();
  1742. },
  1743. enumerable: false,
  1744. configurable: true
  1745. });
  1746. Object.defineProperty(Checkbox.prototype, "background", {
  1747. /** Gets or sets background color */
  1748. get: function () {
  1749. return this._background;
  1750. },
  1751. set: function (value) {
  1752. if (this._background === value) {
  1753. return;
  1754. }
  1755. this._background = value;
  1756. this._markAsDirty();
  1757. },
  1758. enumerable: false,
  1759. configurable: true
  1760. });
  1761. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1762. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1763. get: function () {
  1764. return this._isChecked;
  1765. },
  1766. set: function (value) {
  1767. if (this._isChecked === value) {
  1768. return;
  1769. }
  1770. this._isChecked = value;
  1771. this._markAsDirty();
  1772. this.onIsCheckedChangedObservable.notifyObservers(value);
  1773. },
  1774. enumerable: false,
  1775. configurable: true
  1776. });
  1777. Checkbox.prototype._getTypeName = function () {
  1778. return "Checkbox";
  1779. };
  1780. /** @hidden */
  1781. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1782. context.save();
  1783. this._applyStates(context);
  1784. var actualWidth = this._currentMeasure.width - this._thickness;
  1785. var actualHeight = this._currentMeasure.height - this._thickness;
  1786. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1787. context.shadowColor = this.shadowColor;
  1788. context.shadowBlur = this.shadowBlur;
  1789. context.shadowOffsetX = this.shadowOffsetX;
  1790. context.shadowOffsetY = this.shadowOffsetY;
  1791. }
  1792. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1793. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1794. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1795. context.shadowBlur = 0;
  1796. context.shadowOffsetX = 0;
  1797. context.shadowOffsetY = 0;
  1798. }
  1799. if (this._isChecked) {
  1800. context.fillStyle = this._isEnabled ? this.color : this._disabledColorItem;
  1801. var offsetWidth = actualWidth * this._checkSizeRatio;
  1802. var offseHeight = actualHeight * this._checkSizeRatio;
  1803. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1804. }
  1805. context.strokeStyle = this.color;
  1806. context.lineWidth = this._thickness;
  1807. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1808. context.restore();
  1809. };
  1810. // Events
  1811. /** @hidden */
  1812. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1813. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1814. return false;
  1815. }
  1816. this.isChecked = !this.isChecked;
  1817. return true;
  1818. };
  1819. /**
  1820. * Utility function to easily create a checkbox with a header
  1821. * @param title defines the label to use for the header
  1822. * @param onValueChanged defines the callback to call when value changes
  1823. * @returns a StackPanel containing the checkbox and a textBlock
  1824. */
  1825. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1826. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1827. panel.isVertical = false;
  1828. panel.height = "30px";
  1829. var checkbox = new Checkbox();
  1830. checkbox.width = "20px";
  1831. checkbox.height = "20px";
  1832. checkbox.isChecked = true;
  1833. checkbox.color = "green";
  1834. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1835. panel.addControl(checkbox);
  1836. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1837. header.text = title;
  1838. header.width = "180px";
  1839. header.paddingLeft = "5px";
  1840. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1841. header.color = "white";
  1842. panel.addControl(header);
  1843. return panel;
  1844. };
  1845. return Checkbox;
  1846. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1847. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1848. /***/ }),
  1849. /***/ "./2D/controls/colorpicker.ts":
  1850. /*!************************************!*\
  1851. !*** ./2D/controls/colorpicker.ts ***!
  1852. \************************************/
  1853. /*! exports provided: ColorPicker */
  1854. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1855. "use strict";
  1856. __webpack_require__.r(__webpack_exports__);
  1857. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1858. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1859. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  1860. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1861. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1862. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1863. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1864. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1865. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1866. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1867. /** Class used to create color pickers */
  1868. var ColorPicker = /** @class */ (function (_super) {
  1869. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1870. /**
  1871. * Creates a new ColorPicker
  1872. * @param name defines the control name
  1873. */
  1874. function ColorPicker(name) {
  1875. var _this = _super.call(this, name) || this;
  1876. _this.name = name;
  1877. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1878. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1879. _this._pointerStartedOnSquare = false;
  1880. _this._pointerStartedOnWheel = false;
  1881. _this._squareLeft = 0;
  1882. _this._squareTop = 0;
  1883. _this._squareSize = 0;
  1884. _this._h = 360;
  1885. _this._s = 1;
  1886. _this._v = 1;
  1887. _this._lastPointerDownID = -1;
  1888. /**
  1889. * Observable raised when the value changes
  1890. */
  1891. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1892. // Events
  1893. _this._pointerIsDown = false;
  1894. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1895. _this.size = "200px";
  1896. _this.isPointerBlocker = true;
  1897. return _this;
  1898. }
  1899. Object.defineProperty(ColorPicker.prototype, "value", {
  1900. /** Gets or sets the color of the color picker */
  1901. get: function () {
  1902. return this._value;
  1903. },
  1904. set: function (value) {
  1905. if (this._value.equals(value)) {
  1906. return;
  1907. }
  1908. this._value.copyFrom(value);
  1909. this._value.toHSVToRef(this._tmpColor);
  1910. this._h = this._tmpColor.r;
  1911. this._s = Math.max(this._tmpColor.g, 0.00001);
  1912. this._v = Math.max(this._tmpColor.b, 0.00001);
  1913. this._markAsDirty();
  1914. if (this._value.r <= ColorPicker._Epsilon) {
  1915. this._value.r = 0;
  1916. }
  1917. if (this._value.g <= ColorPicker._Epsilon) {
  1918. this._value.g = 0;
  1919. }
  1920. if (this._value.b <= ColorPicker._Epsilon) {
  1921. this._value.b = 0;
  1922. }
  1923. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1924. this._value.r = 1.0;
  1925. }
  1926. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1927. this._value.g = 1.0;
  1928. }
  1929. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1930. this._value.b = 1.0;
  1931. }
  1932. this.onValueChangedObservable.notifyObservers(this._value);
  1933. },
  1934. enumerable: false,
  1935. configurable: true
  1936. });
  1937. Object.defineProperty(ColorPicker.prototype, "width", {
  1938. /**
  1939. * Gets or sets control width
  1940. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1941. */
  1942. get: function () {
  1943. return this._width.toString(this._host);
  1944. },
  1945. set: function (value) {
  1946. if (this._width.toString(this._host) === value) {
  1947. return;
  1948. }
  1949. if (this._width.fromString(value)) {
  1950. this._height.fromString(value);
  1951. this._markAsDirty();
  1952. }
  1953. },
  1954. enumerable: false,
  1955. configurable: true
  1956. });
  1957. Object.defineProperty(ColorPicker.prototype, "height", {
  1958. /**
  1959. * Gets or sets control height
  1960. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1961. */
  1962. get: function () {
  1963. return this._height.toString(this._host);
  1964. },
  1965. /** Gets or sets control height */
  1966. set: function (value) {
  1967. if (this._height.toString(this._host) === value) {
  1968. return;
  1969. }
  1970. if (this._height.fromString(value)) {
  1971. this._width.fromString(value);
  1972. this._markAsDirty();
  1973. }
  1974. },
  1975. enumerable: false,
  1976. configurable: true
  1977. });
  1978. Object.defineProperty(ColorPicker.prototype, "size", {
  1979. /** Gets or sets control size */
  1980. get: function () {
  1981. return this.width;
  1982. },
  1983. set: function (value) {
  1984. this.width = value;
  1985. },
  1986. enumerable: false,
  1987. configurable: true
  1988. });
  1989. ColorPicker.prototype._getTypeName = function () {
  1990. return "ColorPicker";
  1991. };
  1992. /** @hidden */
  1993. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1994. if (parentMeasure.width < parentMeasure.height) {
  1995. this._currentMeasure.height = parentMeasure.width;
  1996. }
  1997. else {
  1998. this._currentMeasure.width = parentMeasure.height;
  1999. }
  2000. };
  2001. ColorPicker.prototype._updateSquareProps = function () {
  2002. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2003. var wheelThickness = radius * .2;
  2004. var innerDiameter = (radius - wheelThickness) * 2;
  2005. var squareSize = innerDiameter / (Math.sqrt(2));
  2006. var offset = radius - squareSize * .5;
  2007. this._squareLeft = this._currentMeasure.left + offset;
  2008. this._squareTop = this._currentMeasure.top + offset;
  2009. this._squareSize = squareSize;
  2010. };
  2011. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  2012. var lgh = context.createLinearGradient(left, top, width + left, top);
  2013. lgh.addColorStop(0, '#fff');
  2014. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  2015. context.fillStyle = lgh;
  2016. context.fillRect(left, top, width, height);
  2017. var lgv = context.createLinearGradient(left, top, left, height + top);
  2018. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  2019. lgv.addColorStop(1, '#000');
  2020. context.fillStyle = lgv;
  2021. context.fillRect(left, top, width, height);
  2022. };
  2023. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  2024. context.beginPath();
  2025. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  2026. context.lineWidth = 3;
  2027. context.strokeStyle = '#333333';
  2028. context.stroke();
  2029. context.beginPath();
  2030. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  2031. context.lineWidth = 3;
  2032. context.strokeStyle = '#ffffff';
  2033. context.stroke();
  2034. };
  2035. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  2036. var canvas = document.createElement("canvas");
  2037. canvas.width = radius * 2;
  2038. canvas.height = radius * 2;
  2039. var context = canvas.getContext("2d");
  2040. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  2041. var data = image.data;
  2042. var color = this._tmpColor;
  2043. var maxDistSq = radius * radius;
  2044. var innerRadius = radius - thickness;
  2045. var minDistSq = innerRadius * innerRadius;
  2046. for (var x = -radius; x < radius; x++) {
  2047. for (var y = -radius; y < radius; y++) {
  2048. var distSq = x * x + y * y;
  2049. if (distSq > maxDistSq || distSq < minDistSq) {
  2050. continue;
  2051. }
  2052. var dist = Math.sqrt(distSq);
  2053. var ang = Math.atan2(y, x);
  2054. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  2055. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  2056. data[index] = color.r * 255;
  2057. data[index + 1] = color.g * 255;
  2058. data[index + 2] = color.b * 255;
  2059. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2060. //apply less alpha to bigger color pickers
  2061. var alphaAmount = .2;
  2062. var maxAlpha = .2;
  2063. var minAlpha = .04;
  2064. var lowerRadius = 50;
  2065. var upperRadius = 150;
  2066. if (radius < lowerRadius) {
  2067. alphaAmount = maxAlpha;
  2068. }
  2069. else if (radius > upperRadius) {
  2070. alphaAmount = minAlpha;
  2071. }
  2072. else {
  2073. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2074. }
  2075. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2076. if (alphaRatio < alphaAmount) {
  2077. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2078. }
  2079. else if (alphaRatio > 1 - alphaAmount) {
  2080. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2081. }
  2082. else {
  2083. data[index + 3] = 255;
  2084. }
  2085. }
  2086. }
  2087. context.putImageData(image, 0, 0);
  2088. return canvas;
  2089. };
  2090. /** @hidden */
  2091. ColorPicker.prototype._draw = function (context) {
  2092. context.save();
  2093. this._applyStates(context);
  2094. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2095. var wheelThickness = radius * .2;
  2096. var left = this._currentMeasure.left;
  2097. var top = this._currentMeasure.top;
  2098. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2099. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2100. }
  2101. this._updateSquareProps();
  2102. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2103. context.shadowColor = this.shadowColor;
  2104. context.shadowBlur = this.shadowBlur;
  2105. context.shadowOffsetX = this.shadowOffsetX;
  2106. context.shadowOffsetY = this.shadowOffsetY;
  2107. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2108. }
  2109. context.drawImage(this._colorWheelCanvas, left, top);
  2110. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2111. context.shadowBlur = 0;
  2112. context.shadowOffsetX = 0;
  2113. context.shadowOffsetY = 0;
  2114. }
  2115. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2116. var cx = this._squareLeft + this._squareSize * this._s;
  2117. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2118. this._drawCircle(cx, cy, radius * .04, context);
  2119. var dist = radius - wheelThickness * .5;
  2120. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2121. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2122. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2123. context.restore();
  2124. };
  2125. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2126. if (this._pointerStartedOnWheel) {
  2127. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2128. var centerX = radius + this._currentMeasure.left;
  2129. var centerY = radius + this._currentMeasure.top;
  2130. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2131. }
  2132. else if (this._pointerStartedOnSquare) {
  2133. this._updateSquareProps();
  2134. this._s = (x - this._squareLeft) / this._squareSize;
  2135. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2136. this._s = Math.min(this._s, 1);
  2137. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2138. this._v = Math.min(this._v, 1);
  2139. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2140. }
  2141. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2142. this.value = this._tmpColor;
  2143. };
  2144. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2145. this._updateSquareProps();
  2146. var left = this._squareLeft;
  2147. var top = this._squareTop;
  2148. var size = this._squareSize;
  2149. if (x >= left && x <= left + size &&
  2150. y >= top && y <= top + size) {
  2151. return true;
  2152. }
  2153. return false;
  2154. };
  2155. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2156. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2157. var centerX = radius + this._currentMeasure.left;
  2158. var centerY = radius + this._currentMeasure.top;
  2159. var wheelThickness = radius * .2;
  2160. var innerRadius = radius - wheelThickness;
  2161. var radiusSq = radius * radius;
  2162. var innerRadiusSq = innerRadius * innerRadius;
  2163. var dx = x - centerX;
  2164. var dy = y - centerY;
  2165. var distSq = dx * dx + dy * dy;
  2166. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2167. return true;
  2168. }
  2169. return false;
  2170. };
  2171. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2172. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2173. return false;
  2174. }
  2175. this._pointerIsDown = true;
  2176. this._pointerStartedOnSquare = false;
  2177. this._pointerStartedOnWheel = false;
  2178. // Invert transform
  2179. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2180. var x = this._transformedPosition.x;
  2181. var y = this._transformedPosition.y;
  2182. if (this._isPointOnSquare(x, y)) {
  2183. this._pointerStartedOnSquare = true;
  2184. }
  2185. else if (this._isPointOnWheel(x, y)) {
  2186. this._pointerStartedOnWheel = true;
  2187. }
  2188. this._updateValueFromPointer(x, y);
  2189. this._host._capturingControl[pointerId] = this;
  2190. this._lastPointerDownID = pointerId;
  2191. return true;
  2192. };
  2193. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2194. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2195. if (pointerId != this._lastPointerDownID) {
  2196. return;
  2197. }
  2198. // Invert transform
  2199. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2200. var x = this._transformedPosition.x;
  2201. var y = this._transformedPosition.y;
  2202. if (this._pointerIsDown) {
  2203. this._updateValueFromPointer(x, y);
  2204. }
  2205. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2206. };
  2207. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2208. this._pointerIsDown = false;
  2209. delete this._host._capturingControl[pointerId];
  2210. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2211. };
  2212. ColorPicker.prototype._onCanvasBlur = function () {
  2213. this._forcePointerUp();
  2214. _super.prototype._onCanvasBlur.call(this);
  2215. };
  2216. /**
  2217. * This function expands the color picker by creating a color picker dialog with manual
  2218. * color value input and the ability to save colors into an array to be used later in
  2219. * subsequent launches of the dialogue.
  2220. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2221. * @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.
  2222. * @returns picked color as a hex string and the saved colors array as hex strings.
  2223. */
  2224. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2225. return new Promise(function (resolve, reject) {
  2226. // Default options
  2227. options.pickerWidth = options.pickerWidth || "640px";
  2228. options.pickerHeight = options.pickerHeight || "400px";
  2229. options.headerHeight = options.headerHeight || "35px";
  2230. options.lastColor = options.lastColor || "#000000";
  2231. options.swatchLimit = options.swatchLimit || 20;
  2232. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2233. // Window size settings
  2234. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2235. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2236. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2237. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2238. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2239. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2240. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2241. // Button Colors
  2242. var buttonColor = "#c0c0c0";
  2243. var buttonBackgroundColor = "#535353";
  2244. var buttonBackgroundHoverColor = "#414141";
  2245. var buttonBackgroundClickColor = "515151";
  2246. var buttonDisabledColor = "#555555";
  2247. var buttonDisabledBackgroundColor = "#454545";
  2248. var currentSwatchesOutlineColor = "#404040";
  2249. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2250. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2251. var iconColorDark = "#aaaaaa";
  2252. var iconColorLight = "#ffffff";
  2253. var closeIconColor;
  2254. // Button settings
  2255. var buttonFontSize;
  2256. var butEdit;
  2257. var buttonWidth;
  2258. var buttonHeight;
  2259. // Input Text Colors
  2260. var inputFieldLabels = ["R", "G", "B"];
  2261. var inputTextBackgroundColor = "#454545";
  2262. var inputTextColor = "#f0f0f0";
  2263. // This is the current color as set by either the picker or by entering a value
  2264. var currentColor;
  2265. // This int is used for naming swatches and serves as the index for calling them from the list
  2266. var swatchNumber;
  2267. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2268. var swatchDrawer;
  2269. var editSwatchMode = false;
  2270. // Color InputText fields that will be updated upon value change
  2271. var picker;
  2272. var rValInt;
  2273. var gValInt;
  2274. var bValInt;
  2275. var rValDec;
  2276. var gValDec;
  2277. var bValDec;
  2278. var hexVal;
  2279. var newSwatch;
  2280. var lastVal;
  2281. var activeField;
  2282. /**
  2283. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2284. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2285. * are will receive no update. This is to prevent the input from the user being overwritten.
  2286. */
  2287. function updateValues(value, inputField) {
  2288. activeField = inputField;
  2289. var pickedColor = value.toHexString();
  2290. newSwatch.background = pickedColor;
  2291. if (rValInt.name != activeField) {
  2292. rValInt.text = Math.floor(value.r * 255).toString();
  2293. }
  2294. if (gValInt.name != activeField) {
  2295. gValInt.text = Math.floor(value.g * 255).toString();
  2296. }
  2297. if (bValInt.name != activeField) {
  2298. bValInt.text = Math.floor(value.b * 255).toString();
  2299. }
  2300. if (rValDec.name != activeField) {
  2301. rValDec.text = value.r.toString();
  2302. }
  2303. if (gValDec.name != activeField) {
  2304. gValDec.text = value.g.toString();
  2305. }
  2306. if (bValDec.name != activeField) {
  2307. bValDec.text = value.b.toString();
  2308. }
  2309. if (hexVal.name != activeField) {
  2310. var minusPound = pickedColor.split("#");
  2311. hexVal.text = minusPound[1];
  2312. }
  2313. if (picker.name != activeField) {
  2314. picker.value = value;
  2315. }
  2316. }
  2317. // 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.
  2318. function updateInt(field, channel) {
  2319. var newValue = field.text;
  2320. var checkVal = /[^0-9]/g.test(newValue);
  2321. if (checkVal) {
  2322. field.text = lastVal;
  2323. return;
  2324. }
  2325. else {
  2326. if (newValue != "") {
  2327. if (Math.floor(parseInt(newValue)) < 0) {
  2328. newValue = "0";
  2329. }
  2330. else if (Math.floor(parseInt(newValue)) > 255) {
  2331. newValue = "255";
  2332. }
  2333. else if (isNaN(parseInt(newValue))) {
  2334. newValue = "0";
  2335. }
  2336. }
  2337. if (activeField == field.name) {
  2338. lastVal = newValue;
  2339. }
  2340. }
  2341. if (newValue != "") {
  2342. newValue = parseInt(newValue).toString();
  2343. field.text = newValue;
  2344. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2345. if (activeField == field.name) {
  2346. if (channel == "r") {
  2347. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2348. }
  2349. else if (channel == "g") {
  2350. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2351. }
  2352. else {
  2353. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2354. }
  2355. }
  2356. }
  2357. }
  2358. // 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.
  2359. function updateFloat(field, channel) {
  2360. var newValue = field.text;
  2361. var checkVal = /[^0-9\.]/g.test(newValue);
  2362. if (checkVal) {
  2363. field.text = lastVal;
  2364. return;
  2365. }
  2366. else {
  2367. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2368. if (parseFloat(newValue) < 0.0) {
  2369. newValue = "0.0";
  2370. }
  2371. else if (parseFloat(newValue) > 1.0) {
  2372. newValue = "1.0";
  2373. }
  2374. else if (isNaN(parseFloat(newValue))) {
  2375. newValue = "0.0";
  2376. }
  2377. }
  2378. if (activeField == field.name) {
  2379. lastVal = newValue;
  2380. }
  2381. }
  2382. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2383. newValue = parseFloat(newValue).toString();
  2384. field.text = newValue;
  2385. }
  2386. else {
  2387. newValue = "0.0";
  2388. }
  2389. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2390. if (activeField == field.name) {
  2391. if (channel == "r") {
  2392. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2393. }
  2394. else if (channel == "g") {
  2395. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2396. }
  2397. else {
  2398. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2399. }
  2400. }
  2401. }
  2402. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2403. function deleteSwatch(index) {
  2404. if (options.savedColors) {
  2405. options.savedColors.splice(index, 1);
  2406. }
  2407. if (options.savedColors && options.savedColors.length == 0) {
  2408. setEditButtonVisibility(false);
  2409. editSwatchMode = false;
  2410. }
  2411. }
  2412. // Creates and styles an individual swatch when updateSwatches is called.
  2413. function createSwatch() {
  2414. if (options.savedColors && options.savedColors[swatchNumber]) {
  2415. if (editSwatchMode) {
  2416. var icon = "b";
  2417. }
  2418. else {
  2419. var icon = "";
  2420. }
  2421. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2422. swatch.fontFamily = "BabylonJSglyphs";
  2423. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2424. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2425. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2426. if (swatchLuminence > luminanceLimit) {
  2427. swatch.color = iconColorDark;
  2428. }
  2429. else {
  2430. swatch.color = iconColorLight;
  2431. }
  2432. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2433. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2434. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2435. swatch.background = options.savedColors[swatchNumber];
  2436. swatch.thickness = 2;
  2437. var metadata_1 = swatchNumber;
  2438. swatch.pointerDownAnimation = function () {
  2439. swatch.thickness = 4;
  2440. };
  2441. swatch.pointerUpAnimation = function () {
  2442. swatch.thickness = 3;
  2443. };
  2444. swatch.pointerEnterAnimation = function () {
  2445. swatch.thickness = 3;
  2446. };
  2447. swatch.pointerOutAnimation = function () {
  2448. swatch.thickness = 2;
  2449. };
  2450. swatch.onPointerClickObservable.add(function () {
  2451. if (!editSwatchMode) {
  2452. if (options.savedColors) {
  2453. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2454. }
  2455. }
  2456. else {
  2457. deleteSwatch(metadata_1);
  2458. updateSwatches("", butSave);
  2459. }
  2460. });
  2461. return swatch;
  2462. }
  2463. else {
  2464. return null;
  2465. }
  2466. }
  2467. // Mode switch to render button text and close symbols on swatch controls
  2468. function editSwatches(mode) {
  2469. if (mode !== undefined) {
  2470. editSwatchMode = mode;
  2471. }
  2472. if (editSwatchMode) {
  2473. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2474. var thisButton = swatchDrawer.children[i];
  2475. thisButton.textBlock.text = "b";
  2476. }
  2477. if (butEdit !== undefined) {
  2478. butEdit.textBlock.text = "Done";
  2479. }
  2480. }
  2481. else {
  2482. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2483. var thisButton = swatchDrawer.children[i];
  2484. thisButton.textBlock.text = "";
  2485. }
  2486. if (butEdit !== undefined) {
  2487. butEdit.textBlock.text = "Edit";
  2488. }
  2489. }
  2490. }
  2491. /**
  2492. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2493. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2494. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2495. * saved colors there are and how many can be stored per row.
  2496. */
  2497. function updateSwatches(color, button) {
  2498. if (options.savedColors) {
  2499. if (color != "") {
  2500. options.savedColors.push(color);
  2501. }
  2502. swatchNumber = 0;
  2503. swatchDrawer.clearControls();
  2504. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2505. if (rowCount == 0) {
  2506. var gutterCount = 0;
  2507. }
  2508. else {
  2509. var gutterCount = rowCount + 1;
  2510. }
  2511. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2512. var currentRows = swatchDrawer.rowCount;
  2513. for (var i = 0; i < currentRows; i++) {
  2514. swatchDrawer.removeRowDefinition(0);
  2515. }
  2516. for (var i = 0; i < rowCount + gutterCount; i++) {
  2517. if (i % 2) {
  2518. swatchDrawer.addRowDefinition(swatchSize, true);
  2519. }
  2520. else {
  2521. swatchDrawer.addRowDefinition(gutterSize, true);
  2522. }
  2523. }
  2524. }
  2525. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2526. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2527. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2528. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2529. var totalButtonsThisRow = options.numSwatchesPerLine;
  2530. }
  2531. else {
  2532. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2533. }
  2534. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2535. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2536. if (x > options.numSwatchesPerLine) {
  2537. continue;
  2538. }
  2539. var swatch = createSwatch();
  2540. if (swatch != null) {
  2541. swatchDrawer.addControl(swatch, y, w);
  2542. w += 2;
  2543. swatchNumber++;
  2544. }
  2545. else {
  2546. continue;
  2547. }
  2548. }
  2549. }
  2550. if (options.savedColors.length >= options.swatchLimit) {
  2551. disableButton(button, true);
  2552. }
  2553. else {
  2554. disableButton(button, false);
  2555. }
  2556. }
  2557. }
  2558. // Shows or hides edit swatches button depending on if there are saved swatches
  2559. function setEditButtonVisibility(enableButton) {
  2560. if (enableButton) {
  2561. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2562. butEdit.width = buttonWidth;
  2563. butEdit.height = buttonHeight;
  2564. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2565. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2566. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2567. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2568. butEdit.thickness = 2;
  2569. butEdit.color = buttonColor;
  2570. butEdit.fontSize = buttonFontSize;
  2571. butEdit.background = buttonBackgroundColor;
  2572. butEdit.onPointerEnterObservable.add(function () {
  2573. butEdit.background = buttonBackgroundHoverColor;
  2574. });
  2575. butEdit.onPointerOutObservable.add(function () {
  2576. butEdit.background = buttonBackgroundColor;
  2577. });
  2578. butEdit.pointerDownAnimation = function () {
  2579. butEdit.background = buttonBackgroundClickColor;
  2580. };
  2581. butEdit.pointerUpAnimation = function () {
  2582. butEdit.background = buttonBackgroundHoverColor;
  2583. };
  2584. butEdit.onPointerClickObservable.add(function () {
  2585. if (editSwatchMode) {
  2586. editSwatchMode = false;
  2587. }
  2588. else {
  2589. editSwatchMode = true;
  2590. }
  2591. editSwatches();
  2592. });
  2593. pickerGrid.addControl(butEdit, 1, 0);
  2594. }
  2595. else {
  2596. pickerGrid.removeControl(butEdit);
  2597. }
  2598. }
  2599. // Called when the user hits the limit of saved colors in the drawer.
  2600. function disableButton(button, disabled) {
  2601. if (disabled) {
  2602. button.color = buttonDisabledColor;
  2603. button.background = buttonDisabledBackgroundColor;
  2604. }
  2605. else {
  2606. button.color = buttonColor;
  2607. button.background = buttonBackgroundColor;
  2608. }
  2609. }
  2610. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2611. function closePicker(color) {
  2612. if (options.savedColors && options.savedColors.length > 0) {
  2613. resolve({
  2614. savedColors: options.savedColors,
  2615. pickedColor: color
  2616. });
  2617. }
  2618. else {
  2619. resolve({
  2620. pickedColor: color
  2621. });
  2622. }
  2623. advancedTexture.removeControl(dialogContainer);
  2624. }
  2625. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2626. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2627. dialogContainer.name = "Dialog Container";
  2628. dialogContainer.width = options.pickerWidth;
  2629. if (options.savedColors) {
  2630. dialogContainer.height = containerSize;
  2631. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2632. dialogContainer.addRowDefinition(topRow, false);
  2633. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2634. }
  2635. else {
  2636. dialogContainer.height = options.pickerHeight;
  2637. dialogContainer.addRowDefinition(1.0, false);
  2638. }
  2639. advancedTexture.addControl(dialogContainer);
  2640. // Swatch drawer which contains all saved color buttons
  2641. if (options.savedColors) {
  2642. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2643. swatchDrawer.name = "Swatch Drawer";
  2644. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2645. swatchDrawer.background = buttonBackgroundColor;
  2646. swatchDrawer.width = options.pickerWidth;
  2647. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2648. if (initialRows == 0) {
  2649. var gutterCount = 0;
  2650. }
  2651. else {
  2652. var gutterCount = initialRows + 1;
  2653. }
  2654. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2655. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2656. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2657. if (i % 2 != 0) {
  2658. swatchDrawer.addRowDefinition(swatchSize, true);
  2659. }
  2660. else {
  2661. swatchDrawer.addRowDefinition(gutterSize, true);
  2662. }
  2663. }
  2664. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2665. if (i % 2 != 0) {
  2666. swatchDrawer.addColumnDefinition(swatchSize, true);
  2667. }
  2668. else {
  2669. swatchDrawer.addColumnDefinition(gutterSize, true);
  2670. }
  2671. }
  2672. dialogContainer.addControl(swatchDrawer, 1, 0);
  2673. }
  2674. // Picker container
  2675. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2676. pickerPanel.name = "Picker Panel";
  2677. pickerPanel.height = options.pickerHeight;
  2678. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2679. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2680. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2681. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2682. dialogContainer.addControl(pickerPanel, 0, 0);
  2683. // Picker container header
  2684. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2685. header.name = "Dialogue Header Bar";
  2686. header.background = "#cccccc";
  2687. header.thickness = 0;
  2688. pickerPanel.addControl(header, 0, 0);
  2689. // Header close button
  2690. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2691. closeButton.fontFamily = "BabylonJSglyphs";
  2692. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2693. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2694. closeButton.color = closeIconColor.toHexString();
  2695. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2696. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2697. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2698. closeButton.height = closeButton.width = options.headerHeight;
  2699. closeButton.background = header.background;
  2700. closeButton.thickness = 0;
  2701. closeButton.pointerDownAnimation = function () {
  2702. };
  2703. closeButton.pointerUpAnimation = function () {
  2704. closeButton.background = header.background;
  2705. };
  2706. closeButton.pointerEnterAnimation = function () {
  2707. closeButton.color = header.background;
  2708. closeButton.background = "red";
  2709. };
  2710. closeButton.pointerOutAnimation = function () {
  2711. closeButton.color = closeIconColor.toHexString();
  2712. closeButton.background = header.background;
  2713. };
  2714. closeButton.onPointerClickObservable.add(function () {
  2715. closePicker(currentSwatch.background);
  2716. });
  2717. pickerPanel.addControl(closeButton, 0, 0);
  2718. // Dialog container body
  2719. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2720. dialogBody.name = "Dialogue Body";
  2721. dialogBody.background = buttonBackgroundColor;
  2722. var dialogBodyCols = [0.4375, 0.5625];
  2723. dialogBody.addRowDefinition(1.0, false);
  2724. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2725. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2726. pickerPanel.addControl(dialogBody, 1, 0);
  2727. // Picker grid
  2728. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2729. pickerGrid.name = "Picker Grid";
  2730. pickerGrid.addRowDefinition(0.85, false);
  2731. pickerGrid.addRowDefinition(0.15, false);
  2732. dialogBody.addControl(pickerGrid, 0, 0);
  2733. // Picker control
  2734. picker = new ColorPicker();
  2735. picker.name = "GUI Color Picker";
  2736. if (options.pickerHeight < options.pickerWidth) {
  2737. picker.width = 0.89;
  2738. }
  2739. else {
  2740. picker.height = 0.89;
  2741. }
  2742. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2743. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2744. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2745. picker.onPointerDownObservable.add(function () {
  2746. activeField = picker.name;
  2747. lastVal = "";
  2748. editSwatches(false);
  2749. });
  2750. picker.onValueChangedObservable.add(function (value) {
  2751. if (activeField == picker.name) {
  2752. updateValues(value, picker.name);
  2753. }
  2754. });
  2755. pickerGrid.addControl(picker, 0, 0);
  2756. // Picker body right quarant
  2757. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2758. pickerBodyRight.name = "Dialogue Right Half";
  2759. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2760. var pickerBodyRightRows = [0.514, 0.486];
  2761. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2762. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2763. dialogBody.addControl(pickerBodyRight, 1, 1);
  2764. // Picker container swatches and buttons
  2765. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2766. pickerSwatchesButtons.name = "Swatches and Buttons";
  2767. var pickerButtonsCol = [0.417, 0.583];
  2768. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2769. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2770. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2771. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2772. // Picker Swatches quadrant
  2773. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2774. pickerSwatches.name = "New and Current Swatches";
  2775. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2776. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2777. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2778. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2779. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2780. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2781. // Active swatches
  2782. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2783. activeSwatches.name = "Active Swatches";
  2784. activeSwatches.width = 0.67;
  2785. activeSwatches.addRowDefinition(0.5, false);
  2786. activeSwatches.addRowDefinition(0.5, false);
  2787. pickerSwatches.addControl(activeSwatches, 2, 0);
  2788. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2789. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2790. if (options.pickerWidth > options.pickerHeight) {
  2791. var labelTextSize = labelHeight;
  2792. }
  2793. else {
  2794. var labelTextSize = labelWidth;
  2795. }
  2796. // New color swatch and previous color button
  2797. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2798. newText.text = "new";
  2799. newText.name = "New Color Label";
  2800. newText.color = buttonColor;
  2801. newText.fontSize = labelTextSize;
  2802. pickerSwatches.addControl(newText, 1, 0);
  2803. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2804. newSwatch.name = "New Color Swatch";
  2805. newSwatch.background = options.lastColor;
  2806. newSwatch.thickness = 0;
  2807. activeSwatches.addControl(newSwatch, 0, 0);
  2808. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2809. currentSwatch.background = options.lastColor;
  2810. currentSwatch.thickness = 0;
  2811. currentSwatch.onPointerClickObservable.add(function () {
  2812. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2813. updateValues(revertColor, currentSwatch.name);
  2814. editSwatches(false);
  2815. });
  2816. currentSwatch.pointerDownAnimation = function () { };
  2817. currentSwatch.pointerUpAnimation = function () { };
  2818. currentSwatch.pointerEnterAnimation = function () { };
  2819. currentSwatch.pointerOutAnimation = function () { };
  2820. activeSwatches.addControl(currentSwatch, 1, 0);
  2821. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2822. swatchOutline.name = "Swatch Outline";
  2823. swatchOutline.width = 0.67;
  2824. swatchOutline.thickness = 2;
  2825. swatchOutline.color = currentSwatchesOutlineColor;
  2826. swatchOutline.isHitTestVisible = false;
  2827. pickerSwatches.addControl(swatchOutline, 2, 0);
  2828. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2829. currentText.name = "Current Color Label";
  2830. currentText.text = "current";
  2831. currentText.color = buttonColor;
  2832. currentText.fontSize = labelTextSize;
  2833. pickerSwatches.addControl(currentText, 3, 0);
  2834. // Buttons grid
  2835. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2836. buttonGrid.name = "Button Grid";
  2837. buttonGrid.height = 0.8;
  2838. var buttonGridRows = 1 / 3;
  2839. buttonGrid.addRowDefinition(buttonGridRows, false);
  2840. buttonGrid.addRowDefinition(buttonGridRows, false);
  2841. buttonGrid.addRowDefinition(buttonGridRows, false);
  2842. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2843. // Determine pixel width and height for all buttons from overall panel dimensions
  2844. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2845. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2846. // Determine button type size
  2847. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2848. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2849. }
  2850. else {
  2851. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2852. }
  2853. // Panel Buttons
  2854. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2855. butOK.width = buttonWidth;
  2856. butOK.height = buttonHeight;
  2857. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2858. butOK.thickness = 2;
  2859. butOK.color = buttonColor;
  2860. butOK.fontSize = buttonFontSize;
  2861. butOK.background = buttonBackgroundColor;
  2862. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2863. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2864. butOK.pointerDownAnimation = function () {
  2865. butOK.background = buttonBackgroundClickColor;
  2866. };
  2867. butOK.pointerUpAnimation = function () {
  2868. butOK.background = buttonBackgroundHoverColor;
  2869. };
  2870. butOK.onPointerClickObservable.add(function () {
  2871. editSwatches(false);
  2872. closePicker(newSwatch.background);
  2873. });
  2874. buttonGrid.addControl(butOK, 0, 0);
  2875. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2876. butCancel.width = buttonWidth;
  2877. butCancel.height = buttonHeight;
  2878. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2879. butCancel.thickness = 2;
  2880. butCancel.color = buttonColor;
  2881. butCancel.fontSize = buttonFontSize;
  2882. butCancel.background = buttonBackgroundColor;
  2883. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2884. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2885. butCancel.pointerDownAnimation = function () {
  2886. butCancel.background = buttonBackgroundClickColor;
  2887. };
  2888. butCancel.pointerUpAnimation = function () {
  2889. butCancel.background = buttonBackgroundHoverColor;
  2890. };
  2891. butCancel.onPointerClickObservable.add(function () {
  2892. editSwatches(false);
  2893. closePicker(currentSwatch.background);
  2894. });
  2895. buttonGrid.addControl(butCancel, 1, 0);
  2896. if (options.savedColors) {
  2897. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2898. butSave.width = buttonWidth;
  2899. butSave.height = buttonHeight;
  2900. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2901. butSave.thickness = 2;
  2902. butSave.fontSize = buttonFontSize;
  2903. if (options.savedColors.length < options.swatchLimit) {
  2904. butSave.color = buttonColor;
  2905. butSave.background = buttonBackgroundColor;
  2906. }
  2907. else {
  2908. disableButton(butSave, true);
  2909. }
  2910. butSave.onPointerEnterObservable.add(function () {
  2911. if (options.savedColors) {
  2912. if (options.savedColors.length < options.swatchLimit) {
  2913. butSave.background = buttonBackgroundHoverColor;
  2914. }
  2915. }
  2916. });
  2917. butSave.onPointerOutObservable.add(function () {
  2918. if (options.savedColors) {
  2919. if (options.savedColors.length < options.swatchLimit) {
  2920. butSave.background = buttonBackgroundColor;
  2921. }
  2922. }
  2923. });
  2924. butSave.pointerDownAnimation = function () {
  2925. if (options.savedColors) {
  2926. if (options.savedColors.length < options.swatchLimit) {
  2927. butSave.background = buttonBackgroundClickColor;
  2928. }
  2929. }
  2930. };
  2931. butSave.pointerUpAnimation = function () {
  2932. if (options.savedColors) {
  2933. if (options.savedColors.length < options.swatchLimit) {
  2934. butSave.background = buttonBackgroundHoverColor;
  2935. }
  2936. }
  2937. };
  2938. butSave.onPointerClickObservable.add(function () {
  2939. if (options.savedColors) {
  2940. if (options.savedColors.length == 0) {
  2941. setEditButtonVisibility(true);
  2942. }
  2943. if (options.savedColors.length < options.swatchLimit) {
  2944. updateSwatches(newSwatch.background, butSave);
  2945. }
  2946. editSwatches(false);
  2947. }
  2948. });
  2949. if (options.savedColors.length > 0) {
  2950. setEditButtonVisibility(true);
  2951. }
  2952. buttonGrid.addControl(butSave, 2, 0);
  2953. }
  2954. // Picker color values input
  2955. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2956. pickerColorValues.name = "Dialog Lower Right";
  2957. pickerColorValues.addRowDefinition(0.02, false);
  2958. pickerColorValues.addRowDefinition(0.63, false);
  2959. pickerColorValues.addRowDefinition(0.21, false);
  2960. pickerColorValues.addRowDefinition(0.14, false);
  2961. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2962. // RGB values text boxes
  2963. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2964. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2965. rgbValuesQuadrant.name = "RGB Values";
  2966. rgbValuesQuadrant.width = 0.82;
  2967. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2968. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2969. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2970. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2971. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2972. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2973. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2974. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2975. for (var i = 0; i < inputFieldLabels.length; i++) {
  2976. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2977. labelText.text = inputFieldLabels[i];
  2978. labelText.color = buttonColor;
  2979. labelText.fontSize = buttonFontSize;
  2980. rgbValuesQuadrant.addControl(labelText, i, 0);
  2981. }
  2982. // Input fields for RGB values
  2983. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2984. rValInt.width = 0.83;
  2985. rValInt.height = 0.72;
  2986. rValInt.name = "rIntField";
  2987. rValInt.fontSize = buttonFontSize;
  2988. rValInt.text = (currentColor.r * 255).toString();
  2989. rValInt.color = inputTextColor;
  2990. rValInt.background = inputTextBackgroundColor;
  2991. rValInt.onFocusObservable.add(function () {
  2992. activeField = rValInt.name;
  2993. lastVal = rValInt.text;
  2994. editSwatches(false);
  2995. });
  2996. rValInt.onBlurObservable.add(function () {
  2997. if (rValInt.text == "") {
  2998. rValInt.text = "0";
  2999. }
  3000. updateInt(rValInt, "r");
  3001. if (activeField == rValInt.name) {
  3002. activeField = "";
  3003. }
  3004. });
  3005. rValInt.onTextChangedObservable.add(function () {
  3006. if (activeField == rValInt.name) {
  3007. updateInt(rValInt, "r");
  3008. }
  3009. });
  3010. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  3011. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3012. gValInt.width = 0.83;
  3013. gValInt.height = 0.72;
  3014. gValInt.name = "gIntField";
  3015. gValInt.fontSize = buttonFontSize;
  3016. gValInt.text = (currentColor.g * 255).toString();
  3017. gValInt.color = inputTextColor;
  3018. gValInt.background = inputTextBackgroundColor;
  3019. gValInt.onFocusObservable.add(function () {
  3020. activeField = gValInt.name;
  3021. lastVal = gValInt.text;
  3022. editSwatches(false);
  3023. });
  3024. gValInt.onBlurObservable.add(function () {
  3025. if (gValInt.text == "") {
  3026. gValInt.text = "0";
  3027. }
  3028. updateInt(gValInt, "g");
  3029. if (activeField == gValInt.name) {
  3030. activeField = "";
  3031. }
  3032. });
  3033. gValInt.onTextChangedObservable.add(function () {
  3034. if (activeField == gValInt.name) {
  3035. updateInt(gValInt, "g");
  3036. }
  3037. });
  3038. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  3039. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3040. bValInt.width = 0.83;
  3041. bValInt.height = 0.72;
  3042. bValInt.name = "bIntField";
  3043. bValInt.fontSize = buttonFontSize;
  3044. bValInt.text = (currentColor.b * 255).toString();
  3045. bValInt.color = inputTextColor;
  3046. bValInt.background = inputTextBackgroundColor;
  3047. bValInt.onFocusObservable.add(function () {
  3048. activeField = bValInt.name;
  3049. lastVal = bValInt.text;
  3050. editSwatches(false);
  3051. });
  3052. bValInt.onBlurObservable.add(function () {
  3053. if (bValInt.text == "") {
  3054. bValInt.text = "0";
  3055. }
  3056. updateInt(bValInt, "b");
  3057. if (activeField == bValInt.name) {
  3058. activeField = "";
  3059. }
  3060. });
  3061. bValInt.onTextChangedObservable.add(function () {
  3062. if (activeField == bValInt.name) {
  3063. updateInt(bValInt, "b");
  3064. }
  3065. });
  3066. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3067. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3068. rValDec.width = 0.95;
  3069. rValDec.height = 0.72;
  3070. rValDec.name = "rDecField";
  3071. rValDec.fontSize = buttonFontSize;
  3072. rValDec.text = currentColor.r.toString();
  3073. rValDec.color = inputTextColor;
  3074. rValDec.background = inputTextBackgroundColor;
  3075. rValDec.onFocusObservable.add(function () {
  3076. activeField = rValDec.name;
  3077. lastVal = rValDec.text;
  3078. editSwatches(false);
  3079. });
  3080. rValDec.onBlurObservable.add(function () {
  3081. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3082. rValDec.text = "0";
  3083. updateFloat(rValDec, "r");
  3084. }
  3085. if (activeField == rValDec.name) {
  3086. activeField = "";
  3087. }
  3088. });
  3089. rValDec.onTextChangedObservable.add(function () {
  3090. if (activeField == rValDec.name) {
  3091. updateFloat(rValDec, "r");
  3092. }
  3093. });
  3094. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3095. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3096. gValDec.width = 0.95;
  3097. gValDec.height = 0.72;
  3098. gValDec.name = "gDecField";
  3099. gValDec.fontSize = buttonFontSize;
  3100. gValDec.text = currentColor.g.toString();
  3101. gValDec.color = inputTextColor;
  3102. gValDec.background = inputTextBackgroundColor;
  3103. gValDec.onFocusObservable.add(function () {
  3104. activeField = gValDec.name;
  3105. lastVal = gValDec.text;
  3106. editSwatches(false);
  3107. });
  3108. gValDec.onBlurObservable.add(function () {
  3109. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3110. gValDec.text = "0";
  3111. updateFloat(gValDec, "g");
  3112. }
  3113. if (activeField == gValDec.name) {
  3114. activeField = "";
  3115. }
  3116. });
  3117. gValDec.onTextChangedObservable.add(function () {
  3118. if (activeField == gValDec.name) {
  3119. updateFloat(gValDec, "g");
  3120. }
  3121. });
  3122. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3123. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3124. bValDec.width = 0.95;
  3125. bValDec.height = 0.72;
  3126. bValDec.name = "bDecField";
  3127. bValDec.fontSize = buttonFontSize;
  3128. bValDec.text = currentColor.b.toString();
  3129. bValDec.color = inputTextColor;
  3130. bValDec.background = inputTextBackgroundColor;
  3131. bValDec.onFocusObservable.add(function () {
  3132. activeField = bValDec.name;
  3133. lastVal = bValDec.text;
  3134. editSwatches(false);
  3135. });
  3136. bValDec.onBlurObservable.add(function () {
  3137. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3138. bValDec.text = "0";
  3139. updateFloat(bValDec, "b");
  3140. }
  3141. if (activeField == bValDec.name) {
  3142. activeField = "";
  3143. }
  3144. });
  3145. bValDec.onTextChangedObservable.add(function () {
  3146. if (activeField == bValDec.name) {
  3147. updateFloat(bValDec, "b");
  3148. }
  3149. });
  3150. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3151. // Hex value input
  3152. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3153. hexValueQuadrant.name = "Hex Value";
  3154. hexValueQuadrant.width = 0.82;
  3155. hexValueQuadrant.addRowDefinition(1.0, false);
  3156. hexValueQuadrant.addColumnDefinition(0.1, false);
  3157. hexValueQuadrant.addColumnDefinition(0.9, false);
  3158. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3159. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3160. labelText.text = "#";
  3161. labelText.color = buttonColor;
  3162. labelText.fontSize = buttonFontSize;
  3163. hexValueQuadrant.addControl(labelText, 0, 0);
  3164. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3165. hexVal.width = 0.96;
  3166. hexVal.height = 0.72;
  3167. hexVal.name = "hexField";
  3168. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3169. hexVal.fontSize = buttonFontSize;
  3170. var minusPound = options.lastColor.split("#");
  3171. hexVal.text = minusPound[1];
  3172. hexVal.color = inputTextColor;
  3173. hexVal.background = inputTextBackgroundColor;
  3174. hexVal.onFocusObservable.add(function () {
  3175. activeField = hexVal.name;
  3176. lastVal = hexVal.text;
  3177. editSwatches(false);
  3178. });
  3179. hexVal.onBlurObservable.add(function () {
  3180. if (hexVal.text.length == 3) {
  3181. var val = hexVal.text.split("");
  3182. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3183. }
  3184. if (hexVal.text == "") {
  3185. hexVal.text = "000000";
  3186. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3187. }
  3188. if (activeField == hexVal.name) {
  3189. activeField = "";
  3190. }
  3191. });
  3192. hexVal.onTextChangedObservable.add(function () {
  3193. var newHexValue = hexVal.text;
  3194. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3195. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3196. hexVal.text = lastVal;
  3197. }
  3198. else {
  3199. if (hexVal.text.length < 6) {
  3200. var leadingZero = 6 - hexVal.text.length;
  3201. for (var i = 0; i < leadingZero; i++) {
  3202. newHexValue = "0" + newHexValue;
  3203. }
  3204. }
  3205. if (hexVal.text.length == 3) {
  3206. var val = hexVal.text.split("");
  3207. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3208. }
  3209. newHexValue = "#" + newHexValue;
  3210. if (activeField == hexVal.name) {
  3211. lastVal = hexVal.text;
  3212. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3213. }
  3214. }
  3215. });
  3216. hexValueQuadrant.addControl(hexVal, 0, 1);
  3217. if (options.savedColors && options.savedColors.length > 0) {
  3218. updateSwatches("", butSave);
  3219. }
  3220. });
  3221. };
  3222. ColorPicker._Epsilon = 0.000001;
  3223. return ColorPicker;
  3224. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3225. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3226. /***/ }),
  3227. /***/ "./2D/controls/container.ts":
  3228. /*!**********************************!*\
  3229. !*** ./2D/controls/container.ts ***!
  3230. \**********************************/
  3231. /*! exports provided: Container */
  3232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3233. "use strict";
  3234. __webpack_require__.r(__webpack_exports__);
  3235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3236. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3237. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Maths/math.vector");
  3238. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3239. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3240. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3241. /**
  3242. * Root class for 2D containers
  3243. * @see https://doc.babylonjs.com/how_to/gui#containers
  3244. */
  3245. var Container = /** @class */ (function (_super) {
  3246. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3247. /**
  3248. * Creates a new Container
  3249. * @param name defines the name of the container
  3250. */
  3251. function Container(name) {
  3252. var _this = _super.call(this, name) || this;
  3253. _this.name = name;
  3254. /** @hidden */
  3255. _this._children = new Array();
  3256. /** @hidden */
  3257. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3258. /** @hidden */
  3259. _this._background = "";
  3260. /** @hidden */
  3261. _this._adaptWidthToChildren = false;
  3262. /** @hidden */
  3263. _this._adaptHeightToChildren = false;
  3264. /**
  3265. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3266. */
  3267. _this.logLayoutCycleErrors = false;
  3268. /**
  3269. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3270. */
  3271. _this.maxLayoutCycle = 3;
  3272. return _this;
  3273. }
  3274. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3275. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3276. get: function () {
  3277. return this._adaptHeightToChildren;
  3278. },
  3279. set: function (value) {
  3280. if (this._adaptHeightToChildren === value) {
  3281. return;
  3282. }
  3283. this._adaptHeightToChildren = value;
  3284. if (value) {
  3285. this.height = "100%";
  3286. }
  3287. this._markAsDirty();
  3288. },
  3289. enumerable: false,
  3290. configurable: true
  3291. });
  3292. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3293. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3294. get: function () {
  3295. return this._adaptWidthToChildren;
  3296. },
  3297. set: function (value) {
  3298. if (this._adaptWidthToChildren === value) {
  3299. return;
  3300. }
  3301. this._adaptWidthToChildren = value;
  3302. if (value) {
  3303. this.width = "100%";
  3304. }
  3305. this._markAsDirty();
  3306. },
  3307. enumerable: false,
  3308. configurable: true
  3309. });
  3310. Object.defineProperty(Container.prototype, "background", {
  3311. /** Gets or sets background color */
  3312. get: function () {
  3313. return this._background;
  3314. },
  3315. set: function (value) {
  3316. if (this._background === value) {
  3317. return;
  3318. }
  3319. this._background = value;
  3320. this._markAsDirty();
  3321. },
  3322. enumerable: false,
  3323. configurable: true
  3324. });
  3325. Object.defineProperty(Container.prototype, "children", {
  3326. /** Gets the list of children */
  3327. get: function () {
  3328. return this._children;
  3329. },
  3330. enumerable: false,
  3331. configurable: true
  3332. });
  3333. Container.prototype._getTypeName = function () {
  3334. return "Container";
  3335. };
  3336. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3337. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3338. var child = _a[_i];
  3339. child._markMatrixAsDirty();
  3340. }
  3341. };
  3342. /**
  3343. * Gets a child using its name
  3344. * @param name defines the child name to look for
  3345. * @returns the child control if found
  3346. */
  3347. Container.prototype.getChildByName = function (name) {
  3348. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3349. var child = _a[_i];
  3350. if (child.name === name) {
  3351. return child;
  3352. }
  3353. }
  3354. return null;
  3355. };
  3356. /**
  3357. * Gets a child using its type and its name
  3358. * @param name defines the child name to look for
  3359. * @param type defines the child type to look for
  3360. * @returns the child control if found
  3361. */
  3362. Container.prototype.getChildByType = function (name, type) {
  3363. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3364. var child = _a[_i];
  3365. if (child.typeName === type) {
  3366. return child;
  3367. }
  3368. }
  3369. return null;
  3370. };
  3371. /**
  3372. * Search for a specific control in children
  3373. * @param control defines the control to look for
  3374. * @returns true if the control is in child list
  3375. */
  3376. Container.prototype.containsControl = function (control) {
  3377. return this.children.indexOf(control) !== -1;
  3378. };
  3379. /**
  3380. * Adds a new control to the current container
  3381. * @param control defines the control to add
  3382. * @returns the current container
  3383. */
  3384. Container.prototype.addControl = function (control) {
  3385. if (!control) {
  3386. return this;
  3387. }
  3388. var index = this._children.indexOf(control);
  3389. if (index !== -1) {
  3390. return this;
  3391. }
  3392. control._link(this._host);
  3393. control._markAllAsDirty();
  3394. this._reOrderControl(control);
  3395. this._markAsDirty();
  3396. return this;
  3397. };
  3398. /**
  3399. * Removes all controls from the current container
  3400. * @returns the current container
  3401. */
  3402. Container.prototype.clearControls = function () {
  3403. var children = this.children.slice();
  3404. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3405. var child = children_1[_i];
  3406. this.removeControl(child);
  3407. }
  3408. return this;
  3409. };
  3410. /**
  3411. * Removes a control from the current container
  3412. * @param control defines the control to remove
  3413. * @returns the current container
  3414. */
  3415. Container.prototype.removeControl = function (control) {
  3416. var index = this._children.indexOf(control);
  3417. if (index !== -1) {
  3418. this._children.splice(index, 1);
  3419. control.parent = null;
  3420. }
  3421. control.linkWithMesh(null);
  3422. if (this._host) {
  3423. this._host._cleanControlAfterRemoval(control);
  3424. }
  3425. this._markAsDirty();
  3426. return this;
  3427. };
  3428. /** @hidden */
  3429. Container.prototype._reOrderControl = function (control) {
  3430. this.removeControl(control);
  3431. var wasAdded = false;
  3432. for (var index = 0; index < this._children.length; index++) {
  3433. if (this._children[index].zIndex > control.zIndex) {
  3434. this._children.splice(index, 0, control);
  3435. wasAdded = true;
  3436. break;
  3437. }
  3438. }
  3439. if (!wasAdded) {
  3440. this._children.push(control);
  3441. }
  3442. control.parent = this;
  3443. this._markAsDirty();
  3444. };
  3445. /** @hidden */
  3446. Container.prototype._offsetLeft = function (offset) {
  3447. _super.prototype._offsetLeft.call(this, offset);
  3448. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3449. var child = _a[_i];
  3450. child._offsetLeft(offset);
  3451. }
  3452. };
  3453. /** @hidden */
  3454. Container.prototype._offsetTop = function (offset) {
  3455. _super.prototype._offsetTop.call(this, offset);
  3456. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3457. var child = _a[_i];
  3458. child._offsetTop(offset);
  3459. }
  3460. };
  3461. /** @hidden */
  3462. Container.prototype._markAllAsDirty = function () {
  3463. _super.prototype._markAllAsDirty.call(this);
  3464. for (var index = 0; index < this._children.length; index++) {
  3465. this._children[index]._markAllAsDirty();
  3466. }
  3467. };
  3468. /** @hidden */
  3469. Container.prototype._localDraw = function (context) {
  3470. if (this._background) {
  3471. context.save();
  3472. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3473. context.shadowColor = this.shadowColor;
  3474. context.shadowBlur = this.shadowBlur;
  3475. context.shadowOffsetX = this.shadowOffsetX;
  3476. context.shadowOffsetY = this.shadowOffsetY;
  3477. }
  3478. context.fillStyle = this._background;
  3479. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3480. context.restore();
  3481. }
  3482. };
  3483. /** @hidden */
  3484. Container.prototype._link = function (host) {
  3485. _super.prototype._link.call(this, host);
  3486. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3487. var child = _a[_i];
  3488. child._link(host);
  3489. }
  3490. };
  3491. /** @hidden */
  3492. Container.prototype._beforeLayout = function () {
  3493. // Do nothing
  3494. };
  3495. /** @hidden */
  3496. Container.prototype._processMeasures = function (parentMeasure, context) {
  3497. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3498. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3499. this._evaluateClippingState(parentMeasure);
  3500. }
  3501. };
  3502. /** @hidden */
  3503. Container.prototype._layout = function (parentMeasure, context) {
  3504. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3505. return false;
  3506. }
  3507. this.host._numLayoutCalls++;
  3508. if (this._isDirty) {
  3509. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3510. }
  3511. var rebuildCount = 0;
  3512. context.save();
  3513. this._applyStates(context);
  3514. this._beforeLayout();
  3515. do {
  3516. var computedWidth = -1;
  3517. var computedHeight = -1;
  3518. this._rebuildLayout = false;
  3519. this._processMeasures(parentMeasure, context);
  3520. if (!this._isClipped) {
  3521. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3522. var child = _a[_i];
  3523. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3524. if (child._layout(this._measureForChildren, context)) {
  3525. if (this.adaptWidthToChildren && child._width.isPixel) {
  3526. computedWidth = Math.max(computedWidth, child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels);
  3527. }
  3528. if (this.adaptHeightToChildren && child._height.isPixel) {
  3529. computedHeight = Math.max(computedHeight, child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels);
  3530. }
  3531. }
  3532. }
  3533. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3534. computedWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  3535. if (this.width !== computedWidth + "px") {
  3536. this.width = computedWidth + "px";
  3537. this._rebuildLayout = true;
  3538. }
  3539. }
  3540. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3541. computedHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  3542. if (this.height !== computedHeight + "px") {
  3543. this.height = computedHeight + "px";
  3544. this._rebuildLayout = true;
  3545. }
  3546. }
  3547. this._postMeasure();
  3548. }
  3549. rebuildCount++;
  3550. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3551. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3552. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3553. }
  3554. context.restore();
  3555. if (this._isDirty) {
  3556. this.invalidateRect();
  3557. this._isDirty = false;
  3558. }
  3559. return true;
  3560. };
  3561. Container.prototype._postMeasure = function () {
  3562. // Do nothing by default
  3563. };
  3564. /** @hidden */
  3565. Container.prototype._draw = function (context, invalidatedRectangle) {
  3566. this._localDraw(context);
  3567. if (this.clipChildren) {
  3568. this._clipForChildren(context);
  3569. }
  3570. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3571. var child = _a[_i];
  3572. // Only redraw parts of the screen that are invalidated
  3573. if (invalidatedRectangle) {
  3574. if (!child._intersectsRect(invalidatedRectangle)) {
  3575. continue;
  3576. }
  3577. }
  3578. child._render(context, invalidatedRectangle);
  3579. }
  3580. };
  3581. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3582. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3583. if (!this.children) {
  3584. return;
  3585. }
  3586. for (var index = 0; index < this.children.length; index++) {
  3587. var item = this.children[index];
  3588. if (!predicate || predicate(item)) {
  3589. results.push(item);
  3590. }
  3591. if (!directDescendantsOnly) {
  3592. item.getDescendantsToRef(results, false, predicate);
  3593. }
  3594. }
  3595. };
  3596. /** @hidden */
  3597. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  3598. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3599. return false;
  3600. }
  3601. if (!_super.prototype.contains.call(this, x, y)) {
  3602. return false;
  3603. }
  3604. // Checking backwards to pick closest first
  3605. for (var index = this._children.length - 1; index >= 0; index--) {
  3606. var child = this._children[index];
  3607. if (child._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  3608. if (child.hoverCursor) {
  3609. this._host._changeCursor(child.hoverCursor);
  3610. }
  3611. return true;
  3612. }
  3613. }
  3614. if (!this.isHitTestVisible) {
  3615. return false;
  3616. }
  3617. return this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  3618. };
  3619. /** @hidden */
  3620. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3621. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3622. this._measureForChildren.copyFrom(this._currentMeasure);
  3623. };
  3624. /** Releases associated resources */
  3625. Container.prototype.dispose = function () {
  3626. _super.prototype.dispose.call(this);
  3627. for (var index = this.children.length - 1; index >= 0; index--) {
  3628. this.children[index].dispose();
  3629. }
  3630. };
  3631. return Container;
  3632. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3633. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3634. /***/ }),
  3635. /***/ "./2D/controls/control.ts":
  3636. /*!********************************!*\
  3637. !*** ./2D/controls/control.ts ***!
  3638. \********************************/
  3639. /*! exports provided: Control */
  3640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3641. "use strict";
  3642. __webpack_require__.r(__webpack_exports__);
  3643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3644. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  3645. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3646. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3647. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3648. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3649. /**
  3650. * Root class used for all 2D controls
  3651. * @see https://doc.babylonjs.com/how_to/gui#controls
  3652. */
  3653. var Control = /** @class */ (function () {
  3654. // Functions
  3655. /**
  3656. * Creates a new control
  3657. * @param name defines the name of the control
  3658. */
  3659. function Control(
  3660. /** defines the name of the control */
  3661. name) {
  3662. this.name = name;
  3663. this._alpha = 1;
  3664. this._alphaSet = false;
  3665. this._zIndex = 0;
  3666. /** @hidden */
  3667. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3668. this._fontFamily = "Arial";
  3669. this._fontStyle = "";
  3670. this._fontWeight = "";
  3671. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3672. /** @hidden */
  3673. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3674. /** @hidden */
  3675. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3676. this._color = "";
  3677. this._style = null;
  3678. /** @hidden */
  3679. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3680. /** @hidden */
  3681. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3682. /** @hidden */
  3683. this._isDirty = true;
  3684. /** @hidden */
  3685. this._wasDirty = false;
  3686. /** @hidden */
  3687. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3688. /** @hidden */
  3689. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3690. /** @hidden */
  3691. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3692. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3693. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3694. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3695. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3696. /** @hidden */
  3697. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3698. /** @hidden */
  3699. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3700. this._scaleX = 1.0;
  3701. this._scaleY = 1.0;
  3702. this._rotation = 0;
  3703. this._transformCenterX = 0.5;
  3704. this._transformCenterY = 0.5;
  3705. /** @hidden */
  3706. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3707. /** @hidden */
  3708. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3709. /** @hidden */
  3710. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3711. this._isMatrixDirty = true;
  3712. this._isVisible = true;
  3713. this._isHighlighted = false;
  3714. this._fontSet = false;
  3715. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3716. this._downCount = 0;
  3717. this._enterCount = -1;
  3718. this._doNotRender = false;
  3719. this._downPointerIds = {};
  3720. this._isEnabled = true;
  3721. this._disabledColor = "#9a9a9a";
  3722. this._disabledColorItem = "#6a6a6a";
  3723. /** @hidden */
  3724. this._rebuildLayout = false;
  3725. /** @hidden */
  3726. this._customData = {};
  3727. /** @hidden */
  3728. this._isClipped = false;
  3729. /** @hidden */
  3730. this._automaticSize = false;
  3731. /**
  3732. * Gets or sets an object used to store user defined information for the node
  3733. */
  3734. this.metadata = null;
  3735. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3736. this.isHitTestVisible = true;
  3737. /** Gets or sets a boolean indicating if the control can block pointer events */
  3738. this.isPointerBlocker = false;
  3739. /** Gets or sets a boolean indicating if the control can be focusable */
  3740. this.isFocusInvisible = false;
  3741. /**
  3742. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3743. * 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
  3744. */
  3745. this.clipChildren = true;
  3746. /**
  3747. * Gets or sets a boolean indicating that control content must be clipped
  3748. * 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
  3749. */
  3750. this.clipContent = true;
  3751. /**
  3752. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3753. */
  3754. this.useBitmapCache = false;
  3755. this._shadowOffsetX = 0;
  3756. this._shadowOffsetY = 0;
  3757. this._shadowBlur = 0;
  3758. this._shadowColor = 'black';
  3759. /** Gets or sets the cursor to use when the control is hovered */
  3760. this.hoverCursor = "";
  3761. /** @hidden */
  3762. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3763. /** @hidden */
  3764. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3765. /**
  3766. * An event triggered when pointer wheel is scrolled
  3767. */
  3768. this.onWheelObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3769. /**
  3770. * An event triggered when the pointer move over the control.
  3771. */
  3772. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3773. /**
  3774. * An event triggered when the pointer move out of the control.
  3775. */
  3776. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3777. /**
  3778. * An event triggered when the pointer taps the control
  3779. */
  3780. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3781. /**
  3782. * An event triggered when pointer up
  3783. */
  3784. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3785. /**
  3786. * An event triggered when a control is clicked on
  3787. */
  3788. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3789. /**
  3790. * An event triggered when pointer enters the control
  3791. */
  3792. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3793. /**
  3794. * An event triggered when the control is marked as dirty
  3795. */
  3796. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3797. /**
  3798. * An event triggered before drawing the control
  3799. */
  3800. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3801. /**
  3802. * An event triggered after the control was drawn
  3803. */
  3804. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3805. /**
  3806. * An event triggered when the control has been disposed
  3807. */
  3808. this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3809. /**
  3810. * Gets or sets a fixed ratio for this control.
  3811. * When different from 0, the ratio is used to compute the "second" dimension.
  3812. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  3813. * second dimension is computed as first dimension * fixedRatio
  3814. */
  3815. this.fixedRatio = 0;
  3816. this._fixedRatioMasterIsWidth = true;
  3817. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3818. }
  3819. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3820. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3821. get: function () {
  3822. return this._shadowOffsetX;
  3823. },
  3824. set: function (value) {
  3825. if (this._shadowOffsetX === value) {
  3826. return;
  3827. }
  3828. this._shadowOffsetX = value;
  3829. this._markAsDirty();
  3830. },
  3831. enumerable: false,
  3832. configurable: true
  3833. });
  3834. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3835. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3836. get: function () {
  3837. return this._shadowOffsetY;
  3838. },
  3839. set: function (value) {
  3840. if (this._shadowOffsetY === value) {
  3841. return;
  3842. }
  3843. this._shadowOffsetY = value;
  3844. this._markAsDirty();
  3845. },
  3846. enumerable: false,
  3847. configurable: true
  3848. });
  3849. Object.defineProperty(Control.prototype, "shadowBlur", {
  3850. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3851. get: function () {
  3852. return this._shadowBlur;
  3853. },
  3854. set: function (value) {
  3855. if (this._shadowBlur === value) {
  3856. return;
  3857. }
  3858. this._shadowBlur = value;
  3859. this._markAsDirty();
  3860. },
  3861. enumerable: false,
  3862. configurable: true
  3863. });
  3864. Object.defineProperty(Control.prototype, "shadowColor", {
  3865. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3866. get: function () {
  3867. return this._shadowColor;
  3868. },
  3869. set: function (value) {
  3870. if (this._shadowColor === value) {
  3871. return;
  3872. }
  3873. this._shadowColor = value;
  3874. this._markAsDirty();
  3875. },
  3876. enumerable: false,
  3877. configurable: true
  3878. });
  3879. Object.defineProperty(Control.prototype, "typeName", {
  3880. // Properties
  3881. /** Gets the control type name */
  3882. get: function () {
  3883. return this._getTypeName();
  3884. },
  3885. enumerable: false,
  3886. configurable: true
  3887. });
  3888. /**
  3889. * Get the current class name of the control.
  3890. * @returns current class name
  3891. */
  3892. Control.prototype.getClassName = function () {
  3893. return this._getTypeName();
  3894. };
  3895. Object.defineProperty(Control.prototype, "host", {
  3896. /**
  3897. * Get the hosting AdvancedDynamicTexture
  3898. */
  3899. get: function () {
  3900. return this._host;
  3901. },
  3902. enumerable: false,
  3903. configurable: true
  3904. });
  3905. Object.defineProperty(Control.prototype, "fontOffset", {
  3906. /** Gets or set information about font offsets (used to render and align text) */
  3907. get: function () {
  3908. return this._fontOffset;
  3909. },
  3910. set: function (offset) {
  3911. this._fontOffset = offset;
  3912. },
  3913. enumerable: false,
  3914. configurable: true
  3915. });
  3916. Object.defineProperty(Control.prototype, "alpha", {
  3917. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3918. get: function () {
  3919. return this._alpha;
  3920. },
  3921. set: function (value) {
  3922. if (this._alpha === value) {
  3923. return;
  3924. }
  3925. this._alphaSet = true;
  3926. this._alpha = value;
  3927. this._markAsDirty();
  3928. },
  3929. enumerable: false,
  3930. configurable: true
  3931. });
  3932. Object.defineProperty(Control.prototype, "isHighlighted", {
  3933. /**
  3934. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3935. */
  3936. get: function () {
  3937. return this._isHighlighted;
  3938. },
  3939. set: function (value) {
  3940. if (this._isHighlighted === value) {
  3941. return;
  3942. }
  3943. this._isHighlighted = value;
  3944. this._markAsDirty();
  3945. },
  3946. enumerable: false,
  3947. configurable: true
  3948. });
  3949. Object.defineProperty(Control.prototype, "scaleX", {
  3950. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3951. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3952. */
  3953. get: function () {
  3954. return this._scaleX;
  3955. },
  3956. set: function (value) {
  3957. if (this._scaleX === value) {
  3958. return;
  3959. }
  3960. this._scaleX = value;
  3961. this._markAsDirty();
  3962. this._markMatrixAsDirty();
  3963. },
  3964. enumerable: false,
  3965. configurable: true
  3966. });
  3967. Object.defineProperty(Control.prototype, "scaleY", {
  3968. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3969. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3970. */
  3971. get: function () {
  3972. return this._scaleY;
  3973. },
  3974. set: function (value) {
  3975. if (this._scaleY === value) {
  3976. return;
  3977. }
  3978. this._scaleY = value;
  3979. this._markAsDirty();
  3980. this._markMatrixAsDirty();
  3981. },
  3982. enumerable: false,
  3983. configurable: true
  3984. });
  3985. Object.defineProperty(Control.prototype, "rotation", {
  3986. /** Gets or sets the rotation angle (0 by default)
  3987. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3988. */
  3989. get: function () {
  3990. return this._rotation;
  3991. },
  3992. set: function (value) {
  3993. if (this._rotation === value) {
  3994. return;
  3995. }
  3996. this._rotation = value;
  3997. this._markAsDirty();
  3998. this._markMatrixAsDirty();
  3999. },
  4000. enumerable: false,
  4001. configurable: true
  4002. });
  4003. Object.defineProperty(Control.prototype, "transformCenterY", {
  4004. /** Gets or sets the transformation center on Y axis (0 by default)
  4005. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4006. */
  4007. get: function () {
  4008. return this._transformCenterY;
  4009. },
  4010. set: function (value) {
  4011. if (this._transformCenterY === value) {
  4012. return;
  4013. }
  4014. this._transformCenterY = value;
  4015. this._markAsDirty();
  4016. this._markMatrixAsDirty();
  4017. },
  4018. enumerable: false,
  4019. configurable: true
  4020. });
  4021. Object.defineProperty(Control.prototype, "transformCenterX", {
  4022. /** Gets or sets the transformation center on X axis (0 by default)
  4023. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4024. */
  4025. get: function () {
  4026. return this._transformCenterX;
  4027. },
  4028. set: function (value) {
  4029. if (this._transformCenterX === value) {
  4030. return;
  4031. }
  4032. this._transformCenterX = value;
  4033. this._markAsDirty();
  4034. this._markMatrixAsDirty();
  4035. },
  4036. enumerable: false,
  4037. configurable: true
  4038. });
  4039. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  4040. /**
  4041. * Gets or sets the horizontal alignment
  4042. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4043. */
  4044. get: function () {
  4045. return this._horizontalAlignment;
  4046. },
  4047. set: function (value) {
  4048. if (this._horizontalAlignment === value) {
  4049. return;
  4050. }
  4051. this._horizontalAlignment = value;
  4052. this._markAsDirty();
  4053. },
  4054. enumerable: false,
  4055. configurable: true
  4056. });
  4057. Object.defineProperty(Control.prototype, "verticalAlignment", {
  4058. /**
  4059. * Gets or sets the vertical alignment
  4060. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4061. */
  4062. get: function () {
  4063. return this._verticalAlignment;
  4064. },
  4065. set: function (value) {
  4066. if (this._verticalAlignment === value) {
  4067. return;
  4068. }
  4069. this._verticalAlignment = value;
  4070. this._markAsDirty();
  4071. },
  4072. enumerable: false,
  4073. configurable: true
  4074. });
  4075. Object.defineProperty(Control.prototype, "width", {
  4076. /**
  4077. * Gets or sets control width
  4078. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4079. */
  4080. get: function () {
  4081. return this._width.toString(this._host);
  4082. },
  4083. set: function (value) {
  4084. this._fixedRatioMasterIsWidth = true;
  4085. if (this._width.toString(this._host) === value) {
  4086. return;
  4087. }
  4088. if (this._width.fromString(value)) {
  4089. this._markAsDirty();
  4090. }
  4091. },
  4092. enumerable: false,
  4093. configurable: true
  4094. });
  4095. Object.defineProperty(Control.prototype, "widthInPixels", {
  4096. /**
  4097. * Gets or sets the control width in pixel
  4098. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4099. */
  4100. get: function () {
  4101. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4102. },
  4103. set: function (value) {
  4104. if (isNaN(value)) {
  4105. return;
  4106. }
  4107. this._fixedRatioMasterIsWidth = true;
  4108. this.width = value + "px";
  4109. },
  4110. enumerable: false,
  4111. configurable: true
  4112. });
  4113. Object.defineProperty(Control.prototype, "height", {
  4114. /**
  4115. * Gets or sets control height
  4116. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4117. */
  4118. get: function () {
  4119. return this._height.toString(this._host);
  4120. },
  4121. set: function (value) {
  4122. this._fixedRatioMasterIsWidth = false;
  4123. if (this._height.toString(this._host) === value) {
  4124. return;
  4125. }
  4126. if (this._height.fromString(value)) {
  4127. this._markAsDirty();
  4128. }
  4129. },
  4130. enumerable: false,
  4131. configurable: true
  4132. });
  4133. Object.defineProperty(Control.prototype, "heightInPixels", {
  4134. /**
  4135. * Gets or sets control height in pixel
  4136. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4137. */
  4138. get: function () {
  4139. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4140. },
  4141. set: function (value) {
  4142. if (isNaN(value)) {
  4143. return;
  4144. }
  4145. this._fixedRatioMasterIsWidth = false;
  4146. this.height = value + "px";
  4147. },
  4148. enumerable: false,
  4149. configurable: true
  4150. });
  4151. Object.defineProperty(Control.prototype, "fontFamily", {
  4152. /** Gets or set font family */
  4153. get: function () {
  4154. if (!this._fontSet) {
  4155. return "";
  4156. }
  4157. return this._fontFamily;
  4158. },
  4159. set: function (value) {
  4160. if (this._fontFamily === value) {
  4161. return;
  4162. }
  4163. this._fontFamily = value;
  4164. this._resetFontCache();
  4165. },
  4166. enumerable: false,
  4167. configurable: true
  4168. });
  4169. Object.defineProperty(Control.prototype, "fontStyle", {
  4170. /** Gets or sets font style */
  4171. get: function () {
  4172. return this._fontStyle;
  4173. },
  4174. set: function (value) {
  4175. if (this._fontStyle === value) {
  4176. return;
  4177. }
  4178. this._fontStyle = value;
  4179. this._resetFontCache();
  4180. },
  4181. enumerable: false,
  4182. configurable: true
  4183. });
  4184. Object.defineProperty(Control.prototype, "fontWeight", {
  4185. /** Gets or sets font weight */
  4186. get: function () {
  4187. return this._fontWeight;
  4188. },
  4189. set: function (value) {
  4190. if (this._fontWeight === value) {
  4191. return;
  4192. }
  4193. this._fontWeight = value;
  4194. this._resetFontCache();
  4195. },
  4196. enumerable: false,
  4197. configurable: true
  4198. });
  4199. Object.defineProperty(Control.prototype, "style", {
  4200. /**
  4201. * Gets or sets style
  4202. * @see https://doc.babylonjs.com/how_to/gui#styles
  4203. */
  4204. get: function () {
  4205. return this._style;
  4206. },
  4207. set: function (value) {
  4208. var _this = this;
  4209. if (this._style) {
  4210. this._style.onChangedObservable.remove(this._styleObserver);
  4211. this._styleObserver = null;
  4212. }
  4213. this._style = value;
  4214. if (this._style) {
  4215. this._styleObserver = this._style.onChangedObservable.add(function () {
  4216. _this._markAsDirty();
  4217. _this._resetFontCache();
  4218. });
  4219. }
  4220. this._markAsDirty();
  4221. this._resetFontCache();
  4222. },
  4223. enumerable: false,
  4224. configurable: true
  4225. });
  4226. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4227. /** @hidden */
  4228. get: function () {
  4229. return this._fontSize.isPercentage;
  4230. },
  4231. enumerable: false,
  4232. configurable: true
  4233. });
  4234. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4235. /** Gets or sets font size in pixels */
  4236. get: function () {
  4237. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4238. if (fontSizeToUse.isPixel) {
  4239. return fontSizeToUse.getValue(this._host);
  4240. }
  4241. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4242. },
  4243. set: function (value) {
  4244. if (isNaN(value)) {
  4245. return;
  4246. }
  4247. this.fontSize = value + "px";
  4248. },
  4249. enumerable: false,
  4250. configurable: true
  4251. });
  4252. Object.defineProperty(Control.prototype, "fontSize", {
  4253. /** Gets or sets font size */
  4254. get: function () {
  4255. return this._fontSize.toString(this._host);
  4256. },
  4257. set: function (value) {
  4258. if (this._fontSize.toString(this._host) === value) {
  4259. return;
  4260. }
  4261. if (this._fontSize.fromString(value)) {
  4262. this._markAsDirty();
  4263. this._resetFontCache();
  4264. }
  4265. },
  4266. enumerable: false,
  4267. configurable: true
  4268. });
  4269. Object.defineProperty(Control.prototype, "color", {
  4270. /** Gets or sets foreground color */
  4271. get: function () {
  4272. return this._color;
  4273. },
  4274. set: function (value) {
  4275. if (this._color === value) {
  4276. return;
  4277. }
  4278. this._color = value;
  4279. this._markAsDirty();
  4280. },
  4281. enumerable: false,
  4282. configurable: true
  4283. });
  4284. Object.defineProperty(Control.prototype, "zIndex", {
  4285. /** Gets or sets z index which is used to reorder controls on the z axis */
  4286. get: function () {
  4287. return this._zIndex;
  4288. },
  4289. set: function (value) {
  4290. if (this.zIndex === value) {
  4291. return;
  4292. }
  4293. this._zIndex = value;
  4294. if (this.parent) {
  4295. this.parent._reOrderControl(this);
  4296. }
  4297. },
  4298. enumerable: false,
  4299. configurable: true
  4300. });
  4301. Object.defineProperty(Control.prototype, "notRenderable", {
  4302. /** Gets or sets a boolean indicating if the control can be rendered */
  4303. get: function () {
  4304. return this._doNotRender;
  4305. },
  4306. set: function (value) {
  4307. if (this._doNotRender === value) {
  4308. return;
  4309. }
  4310. this._doNotRender = value;
  4311. this._markAsDirty();
  4312. },
  4313. enumerable: false,
  4314. configurable: true
  4315. });
  4316. Object.defineProperty(Control.prototype, "isVisible", {
  4317. /** Gets or sets a boolean indicating if the control is visible */
  4318. get: function () {
  4319. return this._isVisible;
  4320. },
  4321. set: function (value) {
  4322. if (this._isVisible === value) {
  4323. return;
  4324. }
  4325. this._isVisible = value;
  4326. this._markAsDirty(true);
  4327. },
  4328. enumerable: false,
  4329. configurable: true
  4330. });
  4331. Object.defineProperty(Control.prototype, "isDirty", {
  4332. /** Gets a boolean indicating that the control needs to update its rendering */
  4333. get: function () {
  4334. return this._isDirty;
  4335. },
  4336. enumerable: false,
  4337. configurable: true
  4338. });
  4339. Object.defineProperty(Control.prototype, "linkedMesh", {
  4340. /**
  4341. * Gets the current linked mesh (or null if none)
  4342. */
  4343. get: function () {
  4344. return this._linkedMesh;
  4345. },
  4346. enumerable: false,
  4347. configurable: true
  4348. });
  4349. Object.defineProperty(Control.prototype, "paddingLeft", {
  4350. /**
  4351. * Gets or sets a value indicating the padding to use on the left of the control
  4352. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4353. */
  4354. get: function () {
  4355. return this._paddingLeft.toString(this._host);
  4356. },
  4357. set: function (value) {
  4358. if (this._paddingLeft.fromString(value)) {
  4359. this._markAsDirty();
  4360. }
  4361. },
  4362. enumerable: false,
  4363. configurable: true
  4364. });
  4365. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4366. /**
  4367. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4368. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4369. */
  4370. get: function () {
  4371. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4372. },
  4373. set: function (value) {
  4374. if (isNaN(value)) {
  4375. return;
  4376. }
  4377. this.paddingLeft = value + "px";
  4378. },
  4379. enumerable: false,
  4380. configurable: true
  4381. });
  4382. Object.defineProperty(Control.prototype, "paddingRight", {
  4383. /**
  4384. * Gets or sets a value indicating the padding to use on the right of the control
  4385. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4386. */
  4387. get: function () {
  4388. return this._paddingRight.toString(this._host);
  4389. },
  4390. set: function (value) {
  4391. if (this._paddingRight.fromString(value)) {
  4392. this._markAsDirty();
  4393. }
  4394. },
  4395. enumerable: false,
  4396. configurable: true
  4397. });
  4398. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4399. /**
  4400. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4401. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4402. */
  4403. get: function () {
  4404. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4405. },
  4406. set: function (value) {
  4407. if (isNaN(value)) {
  4408. return;
  4409. }
  4410. this.paddingRight = value + "px";
  4411. },
  4412. enumerable: false,
  4413. configurable: true
  4414. });
  4415. Object.defineProperty(Control.prototype, "paddingTop", {
  4416. /**
  4417. * Gets or sets a value indicating the padding to use on the top of the control
  4418. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4419. */
  4420. get: function () {
  4421. return this._paddingTop.toString(this._host);
  4422. },
  4423. set: function (value) {
  4424. if (this._paddingTop.fromString(value)) {
  4425. this._markAsDirty();
  4426. }
  4427. },
  4428. enumerable: false,
  4429. configurable: true
  4430. });
  4431. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4432. /**
  4433. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4434. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4435. */
  4436. get: function () {
  4437. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4438. },
  4439. set: function (value) {
  4440. if (isNaN(value)) {
  4441. return;
  4442. }
  4443. this.paddingTop = value + "px";
  4444. },
  4445. enumerable: false,
  4446. configurable: true
  4447. });
  4448. Object.defineProperty(Control.prototype, "paddingBottom", {
  4449. /**
  4450. * Gets or sets a value indicating the padding to use on the bottom of the control
  4451. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4452. */
  4453. get: function () {
  4454. return this._paddingBottom.toString(this._host);
  4455. },
  4456. set: function (value) {
  4457. if (this._paddingBottom.fromString(value)) {
  4458. this._markAsDirty();
  4459. }
  4460. },
  4461. enumerable: false,
  4462. configurable: true
  4463. });
  4464. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4465. /**
  4466. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4467. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4468. */
  4469. get: function () {
  4470. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4471. },
  4472. set: function (value) {
  4473. if (isNaN(value)) {
  4474. return;
  4475. }
  4476. this.paddingBottom = value + "px";
  4477. },
  4478. enumerable: false,
  4479. configurable: true
  4480. });
  4481. Object.defineProperty(Control.prototype, "left", {
  4482. /**
  4483. * Gets or sets a value indicating the left coordinate of the control
  4484. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4485. */
  4486. get: function () {
  4487. return this._left.toString(this._host);
  4488. },
  4489. set: function (value) {
  4490. if (this._left.fromString(value)) {
  4491. this._markAsDirty();
  4492. }
  4493. },
  4494. enumerable: false,
  4495. configurable: true
  4496. });
  4497. Object.defineProperty(Control.prototype, "leftInPixels", {
  4498. /**
  4499. * Gets or sets a value indicating the left coordinate in pixels of the control
  4500. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4501. */
  4502. get: function () {
  4503. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4504. },
  4505. set: function (value) {
  4506. if (isNaN(value)) {
  4507. return;
  4508. }
  4509. this.left = value + "px";
  4510. },
  4511. enumerable: false,
  4512. configurable: true
  4513. });
  4514. Object.defineProperty(Control.prototype, "top", {
  4515. /**
  4516. * Gets or sets a value indicating the top coordinate of the control
  4517. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4518. */
  4519. get: function () {
  4520. return this._top.toString(this._host);
  4521. },
  4522. set: function (value) {
  4523. if (this._top.fromString(value)) {
  4524. this._markAsDirty();
  4525. }
  4526. },
  4527. enumerable: false,
  4528. configurable: true
  4529. });
  4530. Object.defineProperty(Control.prototype, "topInPixels", {
  4531. /**
  4532. * Gets or sets a value indicating the top coordinate in pixels of the control
  4533. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4534. */
  4535. get: function () {
  4536. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4537. },
  4538. set: function (value) {
  4539. if (isNaN(value)) {
  4540. return;
  4541. }
  4542. this.top = value + "px";
  4543. },
  4544. enumerable: false,
  4545. configurable: true
  4546. });
  4547. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4548. /**
  4549. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4550. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4551. */
  4552. get: function () {
  4553. return this._linkOffsetX.toString(this._host);
  4554. },
  4555. set: function (value) {
  4556. if (this._linkOffsetX.fromString(value)) {
  4557. this._markAsDirty();
  4558. }
  4559. },
  4560. enumerable: false,
  4561. configurable: true
  4562. });
  4563. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4564. /**
  4565. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4566. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4567. */
  4568. get: function () {
  4569. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4570. },
  4571. set: function (value) {
  4572. if (isNaN(value)) {
  4573. return;
  4574. }
  4575. this.linkOffsetX = value + "px";
  4576. },
  4577. enumerable: false,
  4578. configurable: true
  4579. });
  4580. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4581. /**
  4582. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4583. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4584. */
  4585. get: function () {
  4586. return this._linkOffsetY.toString(this._host);
  4587. },
  4588. set: function (value) {
  4589. if (this._linkOffsetY.fromString(value)) {
  4590. this._markAsDirty();
  4591. }
  4592. },
  4593. enumerable: false,
  4594. configurable: true
  4595. });
  4596. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4597. /**
  4598. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4599. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4600. */
  4601. get: function () {
  4602. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4603. },
  4604. set: function (value) {
  4605. if (isNaN(value)) {
  4606. return;
  4607. }
  4608. this.linkOffsetY = value + "px";
  4609. },
  4610. enumerable: false,
  4611. configurable: true
  4612. });
  4613. Object.defineProperty(Control.prototype, "centerX", {
  4614. /** Gets the center coordinate on X axis */
  4615. get: function () {
  4616. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4617. },
  4618. enumerable: false,
  4619. configurable: true
  4620. });
  4621. Object.defineProperty(Control.prototype, "centerY", {
  4622. /** Gets the center coordinate on Y axis */
  4623. get: function () {
  4624. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4625. },
  4626. enumerable: false,
  4627. configurable: true
  4628. });
  4629. Object.defineProperty(Control.prototype, "isEnabled", {
  4630. /** Gets or sets if control is Enabled*/
  4631. get: function () {
  4632. return this._isEnabled;
  4633. },
  4634. set: function (value) {
  4635. if (this._isEnabled === value) {
  4636. return;
  4637. }
  4638. this._isEnabled = value;
  4639. this._markAsDirty();
  4640. },
  4641. enumerable: false,
  4642. configurable: true
  4643. });
  4644. Object.defineProperty(Control.prototype, "disabledColor", {
  4645. /** Gets or sets background color of control if it's disabled*/
  4646. get: function () {
  4647. return this._disabledColor;
  4648. },
  4649. set: function (value) {
  4650. if (this._disabledColor === value) {
  4651. return;
  4652. }
  4653. this._disabledColor = value;
  4654. this._markAsDirty();
  4655. },
  4656. enumerable: false,
  4657. configurable: true
  4658. });
  4659. Object.defineProperty(Control.prototype, "disabledColorItem", {
  4660. /** Gets or sets front color of control if it's disabled*/
  4661. get: function () {
  4662. return this._disabledColorItem;
  4663. },
  4664. set: function (value) {
  4665. if (this._disabledColorItem === value) {
  4666. return;
  4667. }
  4668. this._disabledColorItem = value;
  4669. this._markAsDirty();
  4670. },
  4671. enumerable: false,
  4672. configurable: true
  4673. });
  4674. /** @hidden */
  4675. Control.prototype._getTypeName = function () {
  4676. return "Control";
  4677. };
  4678. /**
  4679. * Gets the first ascendant in the hierarchy of the given type
  4680. * @param className defines the required type
  4681. * @returns the ascendant or null if not found
  4682. */
  4683. Control.prototype.getAscendantOfClass = function (className) {
  4684. if (!this.parent) {
  4685. return null;
  4686. }
  4687. if (this.parent.getClassName() === className) {
  4688. return this.parent;
  4689. }
  4690. return this.parent.getAscendantOfClass(className);
  4691. };
  4692. /** @hidden */
  4693. Control.prototype._resetFontCache = function () {
  4694. this._fontSet = true;
  4695. this._markAsDirty();
  4696. };
  4697. /**
  4698. * Determines if a container is an ascendant of the current control
  4699. * @param container defines the container to look for
  4700. * @returns true if the container is one of the ascendant of the control
  4701. */
  4702. Control.prototype.isAscendant = function (container) {
  4703. if (!this.parent) {
  4704. return false;
  4705. }
  4706. if (this.parent === container) {
  4707. return true;
  4708. }
  4709. return this.parent.isAscendant(container);
  4710. };
  4711. /**
  4712. * Gets coordinates in local control space
  4713. * @param globalCoordinates defines the coordinates to transform
  4714. * @returns the new coordinates in local space
  4715. */
  4716. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4717. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4718. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4719. return result;
  4720. };
  4721. /**
  4722. * Gets coordinates in local control space
  4723. * @param globalCoordinates defines the coordinates to transform
  4724. * @param result defines the target vector2 where to store the result
  4725. * @returns the current control
  4726. */
  4727. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4728. result.x = globalCoordinates.x - this._currentMeasure.left;
  4729. result.y = globalCoordinates.y - this._currentMeasure.top;
  4730. return this;
  4731. };
  4732. /**
  4733. * Gets coordinates in parent local control space
  4734. * @param globalCoordinates defines the coordinates to transform
  4735. * @returns the new coordinates in parent local space
  4736. */
  4737. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4738. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4739. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4740. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4741. return result;
  4742. };
  4743. /**
  4744. * Move the current control to a vector3 position projected onto the screen.
  4745. * @param position defines the target position
  4746. * @param scene defines the hosting scene
  4747. */
  4748. Control.prototype.moveToVector3 = function (position, scene) {
  4749. if (!this._host || this.parent !== this._host._rootContainer) {
  4750. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4751. return;
  4752. }
  4753. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4754. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4755. var globalViewport = this._host._getGlobalViewport(scene);
  4756. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4757. this._moveToProjectedPosition(projectedPosition);
  4758. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4759. this.notRenderable = true;
  4760. return;
  4761. }
  4762. this.notRenderable = false;
  4763. };
  4764. /**
  4765. * Will store all controls that have this control as ascendant in a given array
  4766. * @param results defines the array where to store the descendants
  4767. * @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
  4768. * @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
  4769. */
  4770. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4771. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4772. // Do nothing by default
  4773. };
  4774. /**
  4775. * Will return all controls that have this control as ascendant
  4776. * @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
  4777. * @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
  4778. * @return all child controls
  4779. */
  4780. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4781. var results = new Array();
  4782. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4783. return results;
  4784. };
  4785. /**
  4786. * Link current control with a target mesh
  4787. * @param mesh defines the mesh to link with
  4788. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4789. */
  4790. Control.prototype.linkWithMesh = function (mesh) {
  4791. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4792. if (mesh) {
  4793. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4794. }
  4795. return;
  4796. }
  4797. var index = this._host._linkedControls.indexOf(this);
  4798. if (index !== -1) {
  4799. this._linkedMesh = mesh;
  4800. if (!mesh) {
  4801. this._host._linkedControls.splice(index, 1);
  4802. }
  4803. return;
  4804. }
  4805. else if (!mesh) {
  4806. return;
  4807. }
  4808. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4809. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4810. this._linkedMesh = mesh;
  4811. this._host._linkedControls.push(this);
  4812. };
  4813. /** @hidden */
  4814. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4815. var oldLeft = this._left.getValue(this._host);
  4816. var oldTop = this._top.getValue(this._host);
  4817. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4818. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4819. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4820. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4821. newLeft = oldLeft;
  4822. }
  4823. if (Math.abs(newTop - oldTop) < 0.5) {
  4824. newTop = oldTop;
  4825. }
  4826. }
  4827. this.left = newLeft + "px";
  4828. this.top = newTop + "px";
  4829. this._left.ignoreAdaptiveScaling = true;
  4830. this._top.ignoreAdaptiveScaling = true;
  4831. this._markAsDirty();
  4832. };
  4833. /** @hidden */
  4834. Control.prototype._offsetLeft = function (offset) {
  4835. this._isDirty = true;
  4836. this._currentMeasure.left += offset;
  4837. };
  4838. /** @hidden */
  4839. Control.prototype._offsetTop = function (offset) {
  4840. this._isDirty = true;
  4841. this._currentMeasure.top += offset;
  4842. };
  4843. /** @hidden */
  4844. Control.prototype._markMatrixAsDirty = function () {
  4845. this._isMatrixDirty = true;
  4846. this._flagDescendantsAsMatrixDirty();
  4847. };
  4848. /** @hidden */
  4849. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4850. // No child
  4851. };
  4852. /** @hidden */
  4853. Control.prototype._intersectsRect = function (rect) {
  4854. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4855. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4856. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4857. return false;
  4858. }
  4859. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4860. return false;
  4861. }
  4862. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4863. return false;
  4864. }
  4865. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4866. return false;
  4867. }
  4868. return true;
  4869. };
  4870. /** @hidden */
  4871. Control.prototype.invalidateRect = function () {
  4872. this._transform();
  4873. if (this.host && this.host.useInvalidateRectOptimization) {
  4874. // Rotate by transform to get the measure transformed to global space
  4875. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4876. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4877. // the previous measure is used to properly clear a control that is scaled down
  4878. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4879. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4880. // Expand rect based on shadows
  4881. var shadowOffsetX = this.shadowOffsetX;
  4882. var shadowOffsetY = this.shadowOffsetY;
  4883. var shadowBlur = this.shadowBlur;
  4884. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4885. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4886. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4887. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4888. 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));
  4889. }
  4890. else {
  4891. 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));
  4892. }
  4893. }
  4894. };
  4895. /** @hidden */
  4896. Control.prototype._markAsDirty = function (force) {
  4897. if (force === void 0) { force = false; }
  4898. if (!this._isVisible && !force) {
  4899. return;
  4900. }
  4901. this._isDirty = true;
  4902. // Redraw only this rectangle
  4903. if (this._host) {
  4904. this._host.markAsDirty();
  4905. }
  4906. };
  4907. /** @hidden */
  4908. Control.prototype._markAllAsDirty = function () {
  4909. this._markAsDirty();
  4910. if (this._font) {
  4911. this._prepareFont();
  4912. }
  4913. };
  4914. /** @hidden */
  4915. Control.prototype._link = function (host) {
  4916. this._host = host;
  4917. if (this._host) {
  4918. this.uniqueId = this._host.getScene().getUniqueId();
  4919. }
  4920. };
  4921. /** @hidden */
  4922. Control.prototype._transform = function (context) {
  4923. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4924. return;
  4925. }
  4926. // postTranslate
  4927. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4928. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4929. if (context) {
  4930. context.translate(offsetX, offsetY);
  4931. // rotate
  4932. context.rotate(this._rotation);
  4933. // scale
  4934. context.scale(this._scaleX, this._scaleY);
  4935. // preTranslate
  4936. context.translate(-offsetX, -offsetY);
  4937. }
  4938. // Need to update matrices?
  4939. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4940. this._cachedOffsetX = offsetX;
  4941. this._cachedOffsetY = offsetY;
  4942. this._isMatrixDirty = false;
  4943. this._flagDescendantsAsMatrixDirty();
  4944. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4945. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4946. }
  4947. };
  4948. /** @hidden */
  4949. Control.prototype._renderHighlight = function (context) {
  4950. if (!this.isHighlighted) {
  4951. return;
  4952. }
  4953. context.save();
  4954. context.strokeStyle = "#4affff";
  4955. context.lineWidth = 2;
  4956. this._renderHighlightSpecific(context);
  4957. context.restore();
  4958. };
  4959. /** @hidden */
  4960. Control.prototype._renderHighlightSpecific = function (context) {
  4961. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4962. };
  4963. /** @hidden */
  4964. Control.prototype._applyStates = function (context) {
  4965. if (this._isFontSizeInPercentage) {
  4966. this._fontSet = true;
  4967. }
  4968. if (this._fontSet) {
  4969. this._prepareFont();
  4970. this._fontSet = false;
  4971. }
  4972. if (this._font) {
  4973. context.font = this._font;
  4974. }
  4975. if (this._color) {
  4976. context.fillStyle = this._color;
  4977. }
  4978. if (Control.AllowAlphaInheritance) {
  4979. context.globalAlpha *= this._alpha;
  4980. }
  4981. else if (this._alphaSet) {
  4982. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4983. }
  4984. };
  4985. /** @hidden */
  4986. Control.prototype._layout = function (parentMeasure, context) {
  4987. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4988. return false;
  4989. }
  4990. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4991. this.host._numLayoutCalls++;
  4992. this._currentMeasure.addAndTransformToRef(this._transformMatrix, -this.paddingLeftInPixels | 0, -this.paddingTopInPixels | 0, this.paddingRightInPixels | 0, this.paddingBottomInPixels | 0, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4993. context.save();
  4994. this._applyStates(context);
  4995. var rebuildCount = 0;
  4996. do {
  4997. this._rebuildLayout = false;
  4998. this._processMeasures(parentMeasure, context);
  4999. rebuildCount++;
  5000. } while (this._rebuildLayout && rebuildCount < 3);
  5001. if (rebuildCount >= 3) {
  5002. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  5003. }
  5004. context.restore();
  5005. this.invalidateRect();
  5006. this._evaluateClippingState(parentMeasure);
  5007. }
  5008. this._wasDirty = this._isDirty;
  5009. this._isDirty = false;
  5010. return true;
  5011. };
  5012. /** @hidden */
  5013. Control.prototype._processMeasures = function (parentMeasure, context) {
  5014. this._currentMeasure.copyFrom(parentMeasure);
  5015. // Let children take some pre-measurement actions
  5016. this._preMeasure(parentMeasure, context);
  5017. this._measure();
  5018. this._computeAlignment(parentMeasure, context);
  5019. // Convert to int values
  5020. this._currentMeasure.left = this._currentMeasure.left | 0;
  5021. this._currentMeasure.top = this._currentMeasure.top | 0;
  5022. this._currentMeasure.width = this._currentMeasure.width | 0;
  5023. this._currentMeasure.height = this._currentMeasure.height | 0;
  5024. // Let children add more features
  5025. this._additionalProcessing(parentMeasure, context);
  5026. this._cachedParentMeasure.copyFrom(parentMeasure);
  5027. if (this.onDirtyObservable.hasObservers()) {
  5028. this.onDirtyObservable.notifyObservers(this);
  5029. }
  5030. };
  5031. Control.prototype._evaluateClippingState = function (parentMeasure) {
  5032. if (this.parent && this.parent.clipChildren) {
  5033. // Early clip
  5034. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  5035. this._isClipped = true;
  5036. return;
  5037. }
  5038. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  5039. this._isClipped = true;
  5040. return;
  5041. }
  5042. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  5043. this._isClipped = true;
  5044. return;
  5045. }
  5046. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  5047. this._isClipped = true;
  5048. return;
  5049. }
  5050. }
  5051. this._isClipped = false;
  5052. };
  5053. /** @hidden */
  5054. Control.prototype._measure = function () {
  5055. // Width / Height
  5056. if (this._width.isPixel) {
  5057. this._currentMeasure.width = this._width.getValue(this._host);
  5058. }
  5059. else {
  5060. this._currentMeasure.width *= this._width.getValue(this._host);
  5061. }
  5062. if (this._height.isPixel) {
  5063. this._currentMeasure.height = this._height.getValue(this._host);
  5064. }
  5065. else {
  5066. this._currentMeasure.height *= this._height.getValue(this._host);
  5067. }
  5068. if (this.fixedRatio !== 0) {
  5069. if (this._fixedRatioMasterIsWidth) {
  5070. this._currentMeasure.height = this._currentMeasure.width * this.fixedRatio;
  5071. }
  5072. else {
  5073. this._currentMeasure.width = this._currentMeasure.height * this.fixedRatio;
  5074. }
  5075. }
  5076. };
  5077. /** @hidden */
  5078. Control.prototype._computeAlignment = function (parentMeasure, context) {
  5079. var width = this._currentMeasure.width;
  5080. var height = this._currentMeasure.height;
  5081. var parentWidth = parentMeasure.width;
  5082. var parentHeight = parentMeasure.height;
  5083. // Left / top
  5084. var x = 0;
  5085. var y = 0;
  5086. switch (this.horizontalAlignment) {
  5087. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  5088. x = 0;
  5089. break;
  5090. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  5091. x = parentWidth - width;
  5092. break;
  5093. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  5094. x = (parentWidth - width) / 2;
  5095. break;
  5096. }
  5097. switch (this.verticalAlignment) {
  5098. case Control.VERTICAL_ALIGNMENT_TOP:
  5099. y = 0;
  5100. break;
  5101. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5102. y = parentHeight - height;
  5103. break;
  5104. case Control.VERTICAL_ALIGNMENT_CENTER:
  5105. y = (parentHeight - height) / 2;
  5106. break;
  5107. }
  5108. if (this._paddingLeft.isPixel) {
  5109. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5110. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5111. }
  5112. else {
  5113. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5114. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5115. }
  5116. if (this._paddingRight.isPixel) {
  5117. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5118. }
  5119. else {
  5120. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5121. }
  5122. if (this._paddingTop.isPixel) {
  5123. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5124. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5125. }
  5126. else {
  5127. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5128. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5129. }
  5130. if (this._paddingBottom.isPixel) {
  5131. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5132. }
  5133. else {
  5134. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5135. }
  5136. if (this._left.isPixel) {
  5137. this._currentMeasure.left += this._left.getValue(this._host);
  5138. }
  5139. else {
  5140. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5141. }
  5142. if (this._top.isPixel) {
  5143. this._currentMeasure.top += this._top.getValue(this._host);
  5144. }
  5145. else {
  5146. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5147. }
  5148. this._currentMeasure.left += x;
  5149. this._currentMeasure.top += y;
  5150. };
  5151. /** @hidden */
  5152. Control.prototype._preMeasure = function (parentMeasure, context) {
  5153. // Do nothing
  5154. };
  5155. /** @hidden */
  5156. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5157. // Do nothing
  5158. };
  5159. /** @hidden */
  5160. Control.prototype._clipForChildren = function (context) {
  5161. // DO nothing
  5162. };
  5163. Control.prototype._clip = function (context, invalidatedRectangle) {
  5164. context.beginPath();
  5165. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5166. if (invalidatedRectangle) {
  5167. // Rotate the invalidated rect into the control's space
  5168. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5169. // Get the intersection of the rect in context space and the current context
  5170. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5171. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5172. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5173. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5174. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5175. Control._ClipMeasure.copyFrom(intersection);
  5176. }
  5177. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5178. var shadowOffsetX = this.shadowOffsetX;
  5179. var shadowOffsetY = this.shadowOffsetY;
  5180. var shadowBlur = this.shadowBlur;
  5181. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5182. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5183. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5184. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5185. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5186. }
  5187. else {
  5188. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5189. }
  5190. context.clip();
  5191. };
  5192. /** @hidden */
  5193. Control.prototype._render = function (context, invalidatedRectangle) {
  5194. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5195. this._isDirty = false;
  5196. return false;
  5197. }
  5198. this.host._numRenderCalls++;
  5199. context.save();
  5200. this._applyStates(context);
  5201. // Transform
  5202. this._transform(context);
  5203. // Clip
  5204. if (this.clipContent) {
  5205. this._clip(context, invalidatedRectangle);
  5206. }
  5207. if (this.onBeforeDrawObservable.hasObservers()) {
  5208. this.onBeforeDrawObservable.notifyObservers(this);
  5209. }
  5210. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5211. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5212. }
  5213. else {
  5214. this._draw(context, invalidatedRectangle);
  5215. }
  5216. if (this.useBitmapCache && this._wasDirty) {
  5217. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5218. }
  5219. this._renderHighlight(context);
  5220. if (this.onAfterDrawObservable.hasObservers()) {
  5221. this.onAfterDrawObservable.notifyObservers(this);
  5222. }
  5223. context.restore();
  5224. return true;
  5225. };
  5226. /** @hidden */
  5227. Control.prototype._draw = function (context, invalidatedRectangle) {
  5228. // Do nothing
  5229. };
  5230. /**
  5231. * Tests if a given coordinates belong to the current control
  5232. * @param x defines x coordinate to test
  5233. * @param y defines y coordinate to test
  5234. * @returns true if the coordinates are inside the control
  5235. */
  5236. Control.prototype.contains = function (x, y) {
  5237. // Invert transform
  5238. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5239. x = this._transformedPosition.x;
  5240. y = this._transformedPosition.y;
  5241. // Check
  5242. if (x < this._currentMeasure.left) {
  5243. return false;
  5244. }
  5245. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5246. return false;
  5247. }
  5248. if (y < this._currentMeasure.top) {
  5249. return false;
  5250. }
  5251. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5252. return false;
  5253. }
  5254. if (this.isPointerBlocker) {
  5255. this._host._shouldBlockPointer = true;
  5256. }
  5257. return true;
  5258. };
  5259. /** @hidden */
  5260. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  5261. if (!this._isEnabled) {
  5262. return false;
  5263. }
  5264. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5265. return false;
  5266. }
  5267. if (!this.contains(x, y)) {
  5268. return false;
  5269. }
  5270. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  5271. return true;
  5272. };
  5273. /** @hidden */
  5274. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5275. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5276. if (canNotify && this.parent != null) {
  5277. this.parent._onPointerMove(target, coordinates, pointerId);
  5278. }
  5279. };
  5280. /** @hidden */
  5281. Control.prototype._onPointerEnter = function (target) {
  5282. if (!this._isEnabled) {
  5283. return false;
  5284. }
  5285. if (this._enterCount > 0) {
  5286. return false;
  5287. }
  5288. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5289. this._enterCount = 0;
  5290. }
  5291. this._enterCount++;
  5292. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5293. if (canNotify && this.parent != null) {
  5294. this.parent._onPointerEnter(target);
  5295. }
  5296. return true;
  5297. };
  5298. /** @hidden */
  5299. Control.prototype._onPointerOut = function (target, force) {
  5300. if (force === void 0) { force = false; }
  5301. if (!force && (!this._isEnabled || target === this)) {
  5302. return;
  5303. }
  5304. this._enterCount = 0;
  5305. var canNotify = true;
  5306. if (!target.isAscendant(this)) {
  5307. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5308. }
  5309. if (canNotify && this.parent != null) {
  5310. this.parent._onPointerOut(target, force);
  5311. }
  5312. };
  5313. /** @hidden */
  5314. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5315. // Prevent pointerout to lose control context.
  5316. // Event redundancy is checked inside the function.
  5317. this._onPointerEnter(this);
  5318. if (this._downCount !== 0) {
  5319. return false;
  5320. }
  5321. this._downCount++;
  5322. this._downPointerIds[pointerId] = true;
  5323. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5324. if (canNotify && this.parent != null) {
  5325. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5326. }
  5327. return true;
  5328. };
  5329. /** @hidden */
  5330. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5331. if (!this._isEnabled) {
  5332. return;
  5333. }
  5334. this._downCount = 0;
  5335. delete this._downPointerIds[pointerId];
  5336. var canNotifyClick = notifyClick;
  5337. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5338. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5339. }
  5340. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5341. if (canNotify && this.parent != null) {
  5342. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5343. }
  5344. };
  5345. /** @hidden */
  5346. Control.prototype._forcePointerUp = function (pointerId) {
  5347. if (pointerId === void 0) { pointerId = null; }
  5348. if (pointerId !== null) {
  5349. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5350. }
  5351. else {
  5352. for (var key in this._downPointerIds) {
  5353. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5354. }
  5355. }
  5356. };
  5357. /** @hidden */
  5358. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5359. if (!this._isEnabled) {
  5360. return;
  5361. }
  5362. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"](deltaX, deltaY));
  5363. if (canNotify && this.parent != null) {
  5364. this.parent._onWheelScroll(deltaX, deltaY);
  5365. }
  5366. };
  5367. /** @hidden */
  5368. Control.prototype._onCanvasBlur = function () { };
  5369. /** @hidden */
  5370. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex, deltaX, deltaY) {
  5371. if (!this._isEnabled) {
  5372. return false;
  5373. }
  5374. this._dummyVector2.copyFromFloats(x, y);
  5375. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5376. this._onPointerMove(this, this._dummyVector2, pointerId);
  5377. var previousControlOver = this._host._lastControlOver[pointerId];
  5378. if (previousControlOver && previousControlOver !== this) {
  5379. previousControlOver._onPointerOut(this);
  5380. }
  5381. if (previousControlOver !== this) {
  5382. this._onPointerEnter(this);
  5383. }
  5384. this._host._lastControlOver[pointerId] = this;
  5385. return true;
  5386. }
  5387. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5388. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5389. this._host._registerLastControlDown(this, pointerId);
  5390. this._host._lastPickedControl = this;
  5391. return true;
  5392. }
  5393. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5394. if (this._host._lastControlDown[pointerId]) {
  5395. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5396. }
  5397. delete this._host._lastControlDown[pointerId];
  5398. return true;
  5399. }
  5400. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL) {
  5401. if (this._host._lastControlOver[pointerId]) {
  5402. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5403. return true;
  5404. }
  5405. }
  5406. return false;
  5407. };
  5408. Control.prototype._prepareFont = function () {
  5409. if (!this._font && !this._fontSet) {
  5410. return;
  5411. }
  5412. if (this._style) {
  5413. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5414. }
  5415. else {
  5416. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5417. }
  5418. this._fontOffset = Control._GetFontOffset(this._font);
  5419. };
  5420. /** Releases associated resources */
  5421. Control.prototype.dispose = function () {
  5422. this.onDirtyObservable.clear();
  5423. this.onBeforeDrawObservable.clear();
  5424. this.onAfterDrawObservable.clear();
  5425. this.onPointerDownObservable.clear();
  5426. this.onPointerEnterObservable.clear();
  5427. this.onPointerMoveObservable.clear();
  5428. this.onPointerOutObservable.clear();
  5429. this.onPointerUpObservable.clear();
  5430. this.onPointerClickObservable.clear();
  5431. this.onWheelObservable.clear();
  5432. if (this._styleObserver && this._style) {
  5433. this._style.onChangedObservable.remove(this._styleObserver);
  5434. this._styleObserver = null;
  5435. }
  5436. if (this.parent) {
  5437. this.parent.removeControl(this);
  5438. this.parent = null;
  5439. }
  5440. if (this._host) {
  5441. var index = this._host._linkedControls.indexOf(this);
  5442. if (index > -1) {
  5443. this.linkWithMesh(null);
  5444. }
  5445. }
  5446. // Callback
  5447. this.onDisposeObservable.notifyObservers(this);
  5448. this.onDisposeObservable.clear();
  5449. };
  5450. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5451. /** HORIZONTAL_ALIGNMENT_LEFT */
  5452. get: function () {
  5453. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5454. },
  5455. enumerable: false,
  5456. configurable: true
  5457. });
  5458. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5459. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5460. get: function () {
  5461. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5462. },
  5463. enumerable: false,
  5464. configurable: true
  5465. });
  5466. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5467. /** HORIZONTAL_ALIGNMENT_CENTER */
  5468. get: function () {
  5469. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5470. },
  5471. enumerable: false,
  5472. configurable: true
  5473. });
  5474. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5475. /** VERTICAL_ALIGNMENT_TOP */
  5476. get: function () {
  5477. return Control._VERTICAL_ALIGNMENT_TOP;
  5478. },
  5479. enumerable: false,
  5480. configurable: true
  5481. });
  5482. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5483. /** VERTICAL_ALIGNMENT_BOTTOM */
  5484. get: function () {
  5485. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5486. },
  5487. enumerable: false,
  5488. configurable: true
  5489. });
  5490. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5491. /** VERTICAL_ALIGNMENT_CENTER */
  5492. get: function () {
  5493. return Control._VERTICAL_ALIGNMENT_CENTER;
  5494. },
  5495. enumerable: false,
  5496. configurable: true
  5497. });
  5498. /** @hidden */
  5499. Control._GetFontOffset = function (font) {
  5500. if (Control._FontHeightSizes[font]) {
  5501. return Control._FontHeightSizes[font];
  5502. }
  5503. var text = document.createElement("span");
  5504. text.innerHTML = "Hg";
  5505. text.style.font = font;
  5506. var block = document.createElement("div");
  5507. block.style.display = "inline-block";
  5508. block.style.width = "1px";
  5509. block.style.height = "0px";
  5510. block.style.verticalAlign = "bottom";
  5511. var div = document.createElement("div");
  5512. div.style.whiteSpace = "nowrap";
  5513. div.appendChild(text);
  5514. div.appendChild(block);
  5515. document.body.appendChild(div);
  5516. var fontAscent = 0;
  5517. var fontHeight = 0;
  5518. try {
  5519. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5520. block.style.verticalAlign = "baseline";
  5521. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5522. }
  5523. finally {
  5524. document.body.removeChild(div);
  5525. }
  5526. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5527. Control._FontHeightSizes[font] = result;
  5528. return result;
  5529. };
  5530. /** @hidden */
  5531. Control.drawEllipse = function (x, y, width, height, context) {
  5532. context.translate(x, y);
  5533. context.scale(width, height);
  5534. context.beginPath();
  5535. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5536. context.closePath();
  5537. context.scale(1 / width, 1 / height);
  5538. context.translate(-x, -y);
  5539. };
  5540. /**
  5541. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5542. */
  5543. Control.AllowAlphaInheritance = false;
  5544. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5545. // Statics
  5546. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5547. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5548. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5549. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5550. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5551. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5552. Control._FontHeightSizes = {};
  5553. /**
  5554. * Creates a stack panel that can be used to render headers
  5555. * @param control defines the control to associate with the header
  5556. * @param text defines the text of the header
  5557. * @param size defines the size of the header
  5558. * @param options defines options used to configure the header
  5559. * @returns a new StackPanel
  5560. * @ignore
  5561. * @hidden
  5562. */
  5563. Control.AddHeader = function () { };
  5564. return Control;
  5565. }());
  5566. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5567. /***/ }),
  5568. /***/ "./2D/controls/displayGrid.ts":
  5569. /*!************************************!*\
  5570. !*** ./2D/controls/displayGrid.ts ***!
  5571. \************************************/
  5572. /*! exports provided: DisplayGrid */
  5573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5574. "use strict";
  5575. __webpack_require__.r(__webpack_exports__);
  5576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5577. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5578. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5579. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  5580. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5581. /** Class used to render a grid */
  5582. var DisplayGrid = /** @class */ (function (_super) {
  5583. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5584. /**
  5585. * Creates a new GridDisplayRectangle
  5586. * @param name defines the control name
  5587. */
  5588. function DisplayGrid(name) {
  5589. var _this = _super.call(this, name) || this;
  5590. _this.name = name;
  5591. _this._cellWidth = 20;
  5592. _this._cellHeight = 20;
  5593. _this._minorLineTickness = 1;
  5594. _this._minorLineColor = "DarkGray";
  5595. _this._majorLineTickness = 2;
  5596. _this._majorLineColor = "White";
  5597. _this._majorLineFrequency = 5;
  5598. _this._background = "Black";
  5599. _this._displayMajorLines = true;
  5600. _this._displayMinorLines = true;
  5601. return _this;
  5602. }
  5603. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5604. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5605. get: function () {
  5606. return this._displayMinorLines;
  5607. },
  5608. set: function (value) {
  5609. if (this._displayMinorLines === value) {
  5610. return;
  5611. }
  5612. this._displayMinorLines = value;
  5613. this._markAsDirty();
  5614. },
  5615. enumerable: false,
  5616. configurable: true
  5617. });
  5618. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5619. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5620. get: function () {
  5621. return this._displayMajorLines;
  5622. },
  5623. set: function (value) {
  5624. if (this._displayMajorLines === value) {
  5625. return;
  5626. }
  5627. this._displayMajorLines = value;
  5628. this._markAsDirty();
  5629. },
  5630. enumerable: false,
  5631. configurable: true
  5632. });
  5633. Object.defineProperty(DisplayGrid.prototype, "background", {
  5634. /** Gets or sets background color (Black by default) */
  5635. get: function () {
  5636. return this._background;
  5637. },
  5638. set: function (value) {
  5639. if (this._background === value) {
  5640. return;
  5641. }
  5642. this._background = value;
  5643. this._markAsDirty();
  5644. },
  5645. enumerable: false,
  5646. configurable: true
  5647. });
  5648. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5649. /** Gets or sets the width of each cell (20 by default) */
  5650. get: function () {
  5651. return this._cellWidth;
  5652. },
  5653. set: function (value) {
  5654. this._cellWidth = value;
  5655. this._markAsDirty();
  5656. },
  5657. enumerable: false,
  5658. configurable: true
  5659. });
  5660. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5661. /** Gets or sets the height of each cell (20 by default) */
  5662. get: function () {
  5663. return this._cellHeight;
  5664. },
  5665. set: function (value) {
  5666. this._cellHeight = value;
  5667. this._markAsDirty();
  5668. },
  5669. enumerable: false,
  5670. configurable: true
  5671. });
  5672. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5673. /** Gets or sets the tickness of minor lines (1 by default) */
  5674. get: function () {
  5675. return this._minorLineTickness;
  5676. },
  5677. set: function (value) {
  5678. this._minorLineTickness = value;
  5679. this._markAsDirty();
  5680. },
  5681. enumerable: false,
  5682. configurable: true
  5683. });
  5684. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5685. /** Gets or sets the color of minor lines (DarkGray by default) */
  5686. get: function () {
  5687. return this._minorLineColor;
  5688. },
  5689. set: function (value) {
  5690. this._minorLineColor = value;
  5691. this._markAsDirty();
  5692. },
  5693. enumerable: false,
  5694. configurable: true
  5695. });
  5696. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5697. /** Gets or sets the tickness of major lines (2 by default) */
  5698. get: function () {
  5699. return this._majorLineTickness;
  5700. },
  5701. set: function (value) {
  5702. this._majorLineTickness = value;
  5703. this._markAsDirty();
  5704. },
  5705. enumerable: false,
  5706. configurable: true
  5707. });
  5708. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5709. /** Gets or sets the color of major lines (White by default) */
  5710. get: function () {
  5711. return this._majorLineColor;
  5712. },
  5713. set: function (value) {
  5714. this._majorLineColor = value;
  5715. this._markAsDirty();
  5716. },
  5717. enumerable: false,
  5718. configurable: true
  5719. });
  5720. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5721. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5722. get: function () {
  5723. return this._majorLineFrequency;
  5724. },
  5725. set: function (value) {
  5726. this._majorLineFrequency = value;
  5727. this._markAsDirty();
  5728. },
  5729. enumerable: false,
  5730. configurable: true
  5731. });
  5732. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5733. context.save();
  5734. this._applyStates(context);
  5735. if (this._isEnabled) {
  5736. if (this._background) {
  5737. context.fillStyle = this._background;
  5738. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5739. }
  5740. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5741. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5742. // Minor lines
  5743. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5744. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5745. if (this._displayMinorLines) {
  5746. context.strokeStyle = this._minorLineColor;
  5747. context.lineWidth = this._minorLineTickness;
  5748. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5749. var cellX = left + x * this.cellWidth;
  5750. context.beginPath();
  5751. context.moveTo(cellX, this._currentMeasure.top);
  5752. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5753. context.stroke();
  5754. }
  5755. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5756. var cellY = top_1 + y * this.cellHeight;
  5757. context.beginPath();
  5758. context.moveTo(this._currentMeasure.left, cellY);
  5759. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5760. context.stroke();
  5761. }
  5762. }
  5763. // Major lines
  5764. if (this._displayMajorLines) {
  5765. context.strokeStyle = this._majorLineColor;
  5766. context.lineWidth = this._majorLineTickness;
  5767. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5768. var cellX = left + x * this.cellWidth;
  5769. context.beginPath();
  5770. context.moveTo(cellX, this._currentMeasure.top);
  5771. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5772. context.stroke();
  5773. }
  5774. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5775. var cellY = top_1 + y * this.cellHeight;
  5776. context.moveTo(this._currentMeasure.left, cellY);
  5777. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5778. context.closePath();
  5779. context.stroke();
  5780. }
  5781. }
  5782. }
  5783. context.restore();
  5784. };
  5785. DisplayGrid.prototype._getTypeName = function () {
  5786. return "DisplayGrid";
  5787. };
  5788. return DisplayGrid;
  5789. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5790. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5791. /***/ }),
  5792. /***/ "./2D/controls/ellipse.ts":
  5793. /*!********************************!*\
  5794. !*** ./2D/controls/ellipse.ts ***!
  5795. \********************************/
  5796. /*! exports provided: Ellipse */
  5797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5798. "use strict";
  5799. __webpack_require__.r(__webpack_exports__);
  5800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5801. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5802. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5803. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5804. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  5805. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5806. /** Class used to create 2D ellipse containers */
  5807. var Ellipse = /** @class */ (function (_super) {
  5808. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5809. /**
  5810. * Creates a new Ellipse
  5811. * @param name defines the control name
  5812. */
  5813. function Ellipse(name) {
  5814. var _this = _super.call(this, name) || this;
  5815. _this.name = name;
  5816. _this._thickness = 1;
  5817. return _this;
  5818. }
  5819. Object.defineProperty(Ellipse.prototype, "thickness", {
  5820. /** Gets or sets border thickness */
  5821. get: function () {
  5822. return this._thickness;
  5823. },
  5824. set: function (value) {
  5825. if (this._thickness === value) {
  5826. return;
  5827. }
  5828. this._thickness = value;
  5829. this._markAsDirty();
  5830. },
  5831. enumerable: false,
  5832. configurable: true
  5833. });
  5834. Ellipse.prototype._getTypeName = function () {
  5835. return "Ellipse";
  5836. };
  5837. Ellipse.prototype._localDraw = function (context) {
  5838. context.save();
  5839. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5840. context.shadowColor = this.shadowColor;
  5841. context.shadowBlur = this.shadowBlur;
  5842. context.shadowOffsetX = this.shadowOffsetX;
  5843. context.shadowOffsetY = this.shadowOffsetY;
  5844. }
  5845. _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);
  5846. if (this._background) {
  5847. context.fillStyle = this._background;
  5848. context.fill();
  5849. }
  5850. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5851. context.shadowBlur = 0;
  5852. context.shadowOffsetX = 0;
  5853. context.shadowOffsetY = 0;
  5854. }
  5855. if (this._thickness) {
  5856. if (this.color) {
  5857. context.strokeStyle = this.color;
  5858. }
  5859. context.lineWidth = this._thickness;
  5860. context.stroke();
  5861. }
  5862. context.restore();
  5863. };
  5864. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5865. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5866. this._measureForChildren.width -= 2 * this._thickness;
  5867. this._measureForChildren.height -= 2 * this._thickness;
  5868. this._measureForChildren.left += this._thickness;
  5869. this._measureForChildren.top += this._thickness;
  5870. };
  5871. Ellipse.prototype._clipForChildren = function (context) {
  5872. _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);
  5873. context.clip();
  5874. };
  5875. return Ellipse;
  5876. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5877. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5878. /***/ }),
  5879. /***/ "./2D/controls/grid.ts":
  5880. /*!*****************************!*\
  5881. !*** ./2D/controls/grid.ts ***!
  5882. \*****************************/
  5883. /*! exports provided: Grid */
  5884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5885. "use strict";
  5886. __webpack_require__.r(__webpack_exports__);
  5887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5888. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5889. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5890. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5891. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5892. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  5893. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5894. /**
  5895. * Class used to create a 2D grid container
  5896. */
  5897. var Grid = /** @class */ (function (_super) {
  5898. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5899. /**
  5900. * Creates a new Grid
  5901. * @param name defines control name
  5902. */
  5903. function Grid(name) {
  5904. var _this = _super.call(this, name) || this;
  5905. _this.name = name;
  5906. _this._rowDefinitions = new Array();
  5907. _this._columnDefinitions = new Array();
  5908. _this._cells = {};
  5909. _this._childControls = new Array();
  5910. return _this;
  5911. }
  5912. Object.defineProperty(Grid.prototype, "columnCount", {
  5913. /**
  5914. * Gets the number of columns
  5915. */
  5916. get: function () {
  5917. return this._columnDefinitions.length;
  5918. },
  5919. enumerable: false,
  5920. configurable: true
  5921. });
  5922. Object.defineProperty(Grid.prototype, "rowCount", {
  5923. /**
  5924. * Gets the number of rows
  5925. */
  5926. get: function () {
  5927. return this._rowDefinitions.length;
  5928. },
  5929. enumerable: false,
  5930. configurable: true
  5931. });
  5932. Object.defineProperty(Grid.prototype, "children", {
  5933. /** Gets the list of children */
  5934. get: function () {
  5935. return this._childControls;
  5936. },
  5937. enumerable: false,
  5938. configurable: true
  5939. });
  5940. Object.defineProperty(Grid.prototype, "cells", {
  5941. /** Gets the list of cells (e.g. the containers) */
  5942. get: function () {
  5943. return this._cells;
  5944. },
  5945. enumerable: false,
  5946. configurable: true
  5947. });
  5948. /**
  5949. * Gets the definition of a specific row
  5950. * @param index defines the index of the row
  5951. * @returns the row definition
  5952. */
  5953. Grid.prototype.getRowDefinition = function (index) {
  5954. if (index < 0 || index >= this._rowDefinitions.length) {
  5955. return null;
  5956. }
  5957. return this._rowDefinitions[index];
  5958. };
  5959. /**
  5960. * Gets the definition of a specific column
  5961. * @param index defines the index of the column
  5962. * @returns the column definition
  5963. */
  5964. Grid.prototype.getColumnDefinition = function (index) {
  5965. if (index < 0 || index >= this._columnDefinitions.length) {
  5966. return null;
  5967. }
  5968. return this._columnDefinitions[index];
  5969. };
  5970. /**
  5971. * Adds a new row to the grid
  5972. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5973. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5974. * @returns the current grid
  5975. */
  5976. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5977. if (isPixel === void 0) { isPixel = false; }
  5978. 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));
  5979. this._markAsDirty();
  5980. return this;
  5981. };
  5982. /**
  5983. * Adds a new column to the grid
  5984. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5985. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5986. * @returns the current grid
  5987. */
  5988. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5989. if (isPixel === void 0) { isPixel = false; }
  5990. 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));
  5991. this._markAsDirty();
  5992. return this;
  5993. };
  5994. /**
  5995. * Update a row definition
  5996. * @param index defines the index of the row to update
  5997. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5998. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5999. * @returns the current grid
  6000. */
  6001. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  6002. if (isPixel === void 0) { isPixel = false; }
  6003. if (index < 0 || index >= this._rowDefinitions.length) {
  6004. return this;
  6005. }
  6006. var current = this._rowDefinitions[index];
  6007. if (current && current.isPixel === isPixel && current.internalValue === height) {
  6008. return this;
  6009. }
  6010. 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);
  6011. this._markAsDirty();
  6012. return this;
  6013. };
  6014. /**
  6015. * Update a column definition
  6016. * @param index defines the index of the column to update
  6017. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6018. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6019. * @returns the current grid
  6020. */
  6021. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  6022. if (isPixel === void 0) { isPixel = false; }
  6023. if (index < 0 || index >= this._columnDefinitions.length) {
  6024. return this;
  6025. }
  6026. var current = this._columnDefinitions[index];
  6027. if (current && current.isPixel === isPixel && current.internalValue === width) {
  6028. return this;
  6029. }
  6030. 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);
  6031. this._markAsDirty();
  6032. return this;
  6033. };
  6034. /**
  6035. * Gets the list of children stored in a specific cell
  6036. * @param row defines the row to check
  6037. * @param column defines the column to check
  6038. * @returns the list of controls
  6039. */
  6040. Grid.prototype.getChildrenAt = function (row, column) {
  6041. var cell = this._cells[row + ":" + column];
  6042. if (!cell) {
  6043. return null;
  6044. }
  6045. return cell.children;
  6046. };
  6047. /**
  6048. * Gets a string representing the child cell info (row x column)
  6049. * @param child defines the control to get info from
  6050. * @returns a string containing the child cell info (row x column)
  6051. */
  6052. Grid.prototype.getChildCellInfo = function (child) {
  6053. return child._tag;
  6054. };
  6055. Grid.prototype._removeCell = function (cell, key) {
  6056. if (!cell) {
  6057. return;
  6058. }
  6059. _super.prototype.removeControl.call(this, cell);
  6060. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  6061. var control = _a[_i];
  6062. var childIndex = this._childControls.indexOf(control);
  6063. if (childIndex !== -1) {
  6064. this._childControls.splice(childIndex, 1);
  6065. }
  6066. }
  6067. delete this._cells[key];
  6068. };
  6069. Grid.prototype._offsetCell = function (previousKey, key) {
  6070. if (!this._cells[key]) {
  6071. return;
  6072. }
  6073. this._cells[previousKey] = this._cells[key];
  6074. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  6075. var control = _a[_i];
  6076. control._tag = previousKey;
  6077. }
  6078. delete this._cells[key];
  6079. };
  6080. /**
  6081. * Remove a column definition at specified index
  6082. * @param index defines the index of the column to remove
  6083. * @returns the current grid
  6084. */
  6085. Grid.prototype.removeColumnDefinition = function (index) {
  6086. if (index < 0 || index >= this._columnDefinitions.length) {
  6087. return this;
  6088. }
  6089. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6090. var key = x + ":" + index;
  6091. var cell = this._cells[key];
  6092. this._removeCell(cell, key);
  6093. }
  6094. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6095. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6096. var previousKey = x + ":" + (y - 1);
  6097. var key = x + ":" + y;
  6098. this._offsetCell(previousKey, key);
  6099. }
  6100. }
  6101. this._columnDefinitions.splice(index, 1);
  6102. this._markAsDirty();
  6103. return this;
  6104. };
  6105. /**
  6106. * Remove a row definition at specified index
  6107. * @param index defines the index of the row to remove
  6108. * @returns the current grid
  6109. */
  6110. Grid.prototype.removeRowDefinition = function (index) {
  6111. if (index < 0 || index >= this._rowDefinitions.length) {
  6112. return this;
  6113. }
  6114. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6115. var key = index + ":" + y;
  6116. var cell = this._cells[key];
  6117. this._removeCell(cell, key);
  6118. }
  6119. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6120. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6121. var previousKey = x - 1 + ":" + y;
  6122. var key = x + ":" + y;
  6123. this._offsetCell(previousKey, key);
  6124. }
  6125. }
  6126. this._rowDefinitions.splice(index, 1);
  6127. this._markAsDirty();
  6128. return this;
  6129. };
  6130. /**
  6131. * Adds a new control to the current grid
  6132. * @param control defines the control to add
  6133. * @param row defines the row where to add the control (0 by default)
  6134. * @param column defines the column where to add the control (0 by default)
  6135. * @returns the current grid
  6136. */
  6137. Grid.prototype.addControl = function (control, row, column) {
  6138. if (row === void 0) { row = 0; }
  6139. if (column === void 0) { column = 0; }
  6140. if (this._rowDefinitions.length === 0) {
  6141. // Add default row definition
  6142. this.addRowDefinition(1, false);
  6143. }
  6144. if (this._columnDefinitions.length === 0) {
  6145. // Add default column definition
  6146. this.addColumnDefinition(1, false);
  6147. }
  6148. if (this._childControls.indexOf(control) !== -1) {
  6149. 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");
  6150. return this;
  6151. }
  6152. var x = Math.min(row, this._rowDefinitions.length - 1);
  6153. var y = Math.min(column, this._columnDefinitions.length - 1);
  6154. var key = x + ":" + y;
  6155. var goodContainer = this._cells[key];
  6156. if (!goodContainer) {
  6157. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6158. this._cells[key] = goodContainer;
  6159. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6160. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6161. _super.prototype.addControl.call(this, goodContainer);
  6162. }
  6163. goodContainer.addControl(control);
  6164. this._childControls.push(control);
  6165. control._tag = key;
  6166. control.parent = this;
  6167. this._markAsDirty();
  6168. return this;
  6169. };
  6170. /**
  6171. * Removes a control from the current container
  6172. * @param control defines the control to remove
  6173. * @returns the current container
  6174. */
  6175. Grid.prototype.removeControl = function (control) {
  6176. var index = this._childControls.indexOf(control);
  6177. if (index !== -1) {
  6178. this._childControls.splice(index, 1);
  6179. }
  6180. var cell = this._cells[control._tag];
  6181. if (cell) {
  6182. cell.removeControl(control);
  6183. control._tag = null;
  6184. }
  6185. this._markAsDirty();
  6186. return this;
  6187. };
  6188. Grid.prototype._getTypeName = function () {
  6189. return "Grid";
  6190. };
  6191. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6192. var widths = [];
  6193. var heights = [];
  6194. var lefts = [];
  6195. var tops = [];
  6196. var availableWidth = this._currentMeasure.width;
  6197. var globalWidthPercentage = 0;
  6198. var availableHeight = this._currentMeasure.height;
  6199. var globalHeightPercentage = 0;
  6200. // Heights
  6201. var index = 0;
  6202. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6203. var value = _a[_i];
  6204. if (value.isPixel) {
  6205. var height = value.getValue(this._host);
  6206. availableHeight -= height;
  6207. heights[index] = height;
  6208. }
  6209. else {
  6210. globalHeightPercentage += value.internalValue;
  6211. }
  6212. index++;
  6213. }
  6214. var top = 0;
  6215. index = 0;
  6216. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6217. var value = _c[_b];
  6218. tops.push(top);
  6219. if (!value.isPixel) {
  6220. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6221. top += height;
  6222. heights[index] = height;
  6223. }
  6224. else {
  6225. top += value.getValue(this._host);
  6226. }
  6227. index++;
  6228. }
  6229. // Widths
  6230. index = 0;
  6231. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6232. var value = _e[_d];
  6233. if (value.isPixel) {
  6234. var width = value.getValue(this._host);
  6235. availableWidth -= width;
  6236. widths[index] = width;
  6237. }
  6238. else {
  6239. globalWidthPercentage += value.internalValue;
  6240. }
  6241. index++;
  6242. }
  6243. var left = 0;
  6244. index = 0;
  6245. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6246. var value = _g[_f];
  6247. lefts.push(left);
  6248. if (!value.isPixel) {
  6249. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6250. left += width;
  6251. widths[index] = width;
  6252. }
  6253. else {
  6254. left += value.getValue(this._host);
  6255. }
  6256. index++;
  6257. }
  6258. definitionCallback(lefts, tops, widths, heights);
  6259. };
  6260. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6261. var _this = this;
  6262. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6263. // Setting child sizes
  6264. for (var key in _this._cells) {
  6265. if (!_this._cells.hasOwnProperty(key)) {
  6266. continue;
  6267. }
  6268. var split = key.split(":");
  6269. var x = parseInt(split[0]);
  6270. var y = parseInt(split[1]);
  6271. var cell = _this._cells[key];
  6272. cell.left = lefts[y] + "px";
  6273. cell.top = tops[x] + "px";
  6274. cell.width = widths[y] + "px";
  6275. cell.height = heights[x] + "px";
  6276. cell._left.ignoreAdaptiveScaling = true;
  6277. cell._top.ignoreAdaptiveScaling = true;
  6278. cell._width.ignoreAdaptiveScaling = true;
  6279. cell._height.ignoreAdaptiveScaling = true;
  6280. }
  6281. });
  6282. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6283. };
  6284. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6285. for (var key in this._cells) {
  6286. if (!this._cells.hasOwnProperty(key)) {
  6287. continue;
  6288. }
  6289. var child = this._cells[key];
  6290. child._markMatrixAsDirty();
  6291. }
  6292. };
  6293. Grid.prototype._renderHighlightSpecific = function (context) {
  6294. var _this = this;
  6295. _super.prototype._renderHighlightSpecific.call(this, context);
  6296. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6297. // Columns
  6298. for (var index = 0; index < lefts.length; index++) {
  6299. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6300. context.beginPath();
  6301. context.moveTo(left, _this._currentMeasure.top);
  6302. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6303. context.stroke();
  6304. }
  6305. // Rows
  6306. for (var index = 0; index < tops.length; index++) {
  6307. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6308. context.beginPath();
  6309. context.moveTo(_this._currentMeasure.left, top_1);
  6310. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6311. context.stroke();
  6312. }
  6313. });
  6314. context.restore();
  6315. };
  6316. /** Releases associated resources */
  6317. Grid.prototype.dispose = function () {
  6318. _super.prototype.dispose.call(this);
  6319. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6320. var control = _a[_i];
  6321. control.dispose();
  6322. }
  6323. this._childControls = [];
  6324. };
  6325. return Grid;
  6326. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6327. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6328. /***/ }),
  6329. /***/ "./2D/controls/image.ts":
  6330. /*!******************************!*\
  6331. !*** ./2D/controls/image.ts ***!
  6332. \******************************/
  6333. /*! exports provided: Image */
  6334. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6335. "use strict";
  6336. __webpack_require__.r(__webpack_exports__);
  6337. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6338. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6339. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  6340. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6341. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6342. /**
  6343. * Class used to create 2D images
  6344. */
  6345. var Image = /** @class */ (function (_super) {
  6346. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6347. /**
  6348. * Creates a new Image
  6349. * @param name defines the control name
  6350. * @param url defines the image url
  6351. */
  6352. function Image(name, url) {
  6353. if (url === void 0) { url = null; }
  6354. var _this = _super.call(this, name) || this;
  6355. _this.name = name;
  6356. _this._workingCanvas = null;
  6357. _this._loaded = false;
  6358. _this._stretch = Image.STRETCH_FILL;
  6359. _this._autoScale = false;
  6360. _this._sourceLeft = 0;
  6361. _this._sourceTop = 0;
  6362. _this._sourceWidth = 0;
  6363. _this._sourceHeight = 0;
  6364. _this._svgAttributesComputationCompleted = false;
  6365. _this._isSVG = false;
  6366. _this._cellWidth = 0;
  6367. _this._cellHeight = 0;
  6368. _this._cellId = -1;
  6369. _this._populateNinePatchSlicesFromImage = false;
  6370. _this._imageDataCache = { data: null, key: "" };
  6371. /**
  6372. * Observable notified when the content is loaded
  6373. */
  6374. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6375. /**
  6376. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6377. */
  6378. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6379. _this.source = url;
  6380. return _this;
  6381. }
  6382. Object.defineProperty(Image.prototype, "isLoaded", {
  6383. /**
  6384. * Gets a boolean indicating that the content is loaded
  6385. */
  6386. get: function () {
  6387. return this._loaded;
  6388. },
  6389. enumerable: false,
  6390. configurable: true
  6391. });
  6392. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6393. /**
  6394. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6395. */
  6396. get: function () {
  6397. return this._populateNinePatchSlicesFromImage;
  6398. },
  6399. set: function (value) {
  6400. if (this._populateNinePatchSlicesFromImage === value) {
  6401. return;
  6402. }
  6403. this._populateNinePatchSlicesFromImage = value;
  6404. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6405. this._extractNinePatchSliceDataFromImage();
  6406. }
  6407. },
  6408. enumerable: false,
  6409. configurable: true
  6410. });
  6411. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6412. /**
  6413. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6414. * Beware using this as this will comsume more memory as the image has to be stored twice
  6415. */
  6416. get: function () {
  6417. return this._detectPointerOnOpaqueOnly;
  6418. },
  6419. set: function (value) {
  6420. if (this._detectPointerOnOpaqueOnly === value) {
  6421. return;
  6422. }
  6423. this._detectPointerOnOpaqueOnly = value;
  6424. },
  6425. enumerable: false,
  6426. configurable: true
  6427. });
  6428. Object.defineProperty(Image.prototype, "sliceLeft", {
  6429. /**
  6430. * Gets or sets the left value for slicing (9-patch)
  6431. */
  6432. get: function () {
  6433. return this._sliceLeft;
  6434. },
  6435. set: function (value) {
  6436. if (this._sliceLeft === value) {
  6437. return;
  6438. }
  6439. this._sliceLeft = value;
  6440. this._markAsDirty();
  6441. },
  6442. enumerable: false,
  6443. configurable: true
  6444. });
  6445. Object.defineProperty(Image.prototype, "sliceRight", {
  6446. /**
  6447. * Gets or sets the right value for slicing (9-patch)
  6448. */
  6449. get: function () {
  6450. return this._sliceRight;
  6451. },
  6452. set: function (value) {
  6453. if (this._sliceRight === value) {
  6454. return;
  6455. }
  6456. this._sliceRight = value;
  6457. this._markAsDirty();
  6458. },
  6459. enumerable: false,
  6460. configurable: true
  6461. });
  6462. Object.defineProperty(Image.prototype, "sliceTop", {
  6463. /**
  6464. * Gets or sets the top value for slicing (9-patch)
  6465. */
  6466. get: function () {
  6467. return this._sliceTop;
  6468. },
  6469. set: function (value) {
  6470. if (this._sliceTop === value) {
  6471. return;
  6472. }
  6473. this._sliceTop = value;
  6474. this._markAsDirty();
  6475. },
  6476. enumerable: false,
  6477. configurable: true
  6478. });
  6479. Object.defineProperty(Image.prototype, "sliceBottom", {
  6480. /**
  6481. * Gets or sets the bottom value for slicing (9-patch)
  6482. */
  6483. get: function () {
  6484. return this._sliceBottom;
  6485. },
  6486. set: function (value) {
  6487. if (this._sliceBottom === value) {
  6488. return;
  6489. }
  6490. this._sliceBottom = value;
  6491. this._markAsDirty();
  6492. },
  6493. enumerable: false,
  6494. configurable: true
  6495. });
  6496. Object.defineProperty(Image.prototype, "sourceLeft", {
  6497. /**
  6498. * Gets or sets the left coordinate in the source image
  6499. */
  6500. get: function () {
  6501. return this._sourceLeft;
  6502. },
  6503. set: function (value) {
  6504. if (this._sourceLeft === value) {
  6505. return;
  6506. }
  6507. this._sourceLeft = value;
  6508. this._markAsDirty();
  6509. },
  6510. enumerable: false,
  6511. configurable: true
  6512. });
  6513. Object.defineProperty(Image.prototype, "sourceTop", {
  6514. /**
  6515. * Gets or sets the top coordinate in the source image
  6516. */
  6517. get: function () {
  6518. return this._sourceTop;
  6519. },
  6520. set: function (value) {
  6521. if (this._sourceTop === value) {
  6522. return;
  6523. }
  6524. this._sourceTop = value;
  6525. this._markAsDirty();
  6526. },
  6527. enumerable: false,
  6528. configurable: true
  6529. });
  6530. Object.defineProperty(Image.prototype, "sourceWidth", {
  6531. /**
  6532. * Gets or sets the width to capture in the source image
  6533. */
  6534. get: function () {
  6535. return this._sourceWidth;
  6536. },
  6537. set: function (value) {
  6538. if (this._sourceWidth === value) {
  6539. return;
  6540. }
  6541. this._sourceWidth = value;
  6542. this._markAsDirty();
  6543. },
  6544. enumerable: false,
  6545. configurable: true
  6546. });
  6547. Object.defineProperty(Image.prototype, "sourceHeight", {
  6548. /**
  6549. * Gets or sets the height to capture in the source image
  6550. */
  6551. get: function () {
  6552. return this._sourceHeight;
  6553. },
  6554. set: function (value) {
  6555. if (this._sourceHeight === value) {
  6556. return;
  6557. }
  6558. this._sourceHeight = value;
  6559. this._markAsDirty();
  6560. },
  6561. enumerable: false,
  6562. configurable: true
  6563. });
  6564. Object.defineProperty(Image.prototype, "isSVG", {
  6565. /** Indicates if the format of the image is SVG */
  6566. get: function () {
  6567. return this._isSVG;
  6568. },
  6569. enumerable: false,
  6570. configurable: true
  6571. });
  6572. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6573. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6574. get: function () {
  6575. return this._svgAttributesComputationCompleted;
  6576. },
  6577. enumerable: false,
  6578. configurable: true
  6579. });
  6580. Object.defineProperty(Image.prototype, "autoScale", {
  6581. /**
  6582. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6583. * @see https://doc.babylonjs.com/how_to/gui#image
  6584. */
  6585. get: function () {
  6586. return this._autoScale;
  6587. },
  6588. set: function (value) {
  6589. if (this._autoScale === value) {
  6590. return;
  6591. }
  6592. this._autoScale = value;
  6593. if (value && this._loaded) {
  6594. this.synchronizeSizeWithContent();
  6595. }
  6596. },
  6597. enumerable: false,
  6598. configurable: true
  6599. });
  6600. Object.defineProperty(Image.prototype, "stretch", {
  6601. /** Gets or sets the streching mode used by the image */
  6602. get: function () {
  6603. return this._stretch;
  6604. },
  6605. set: function (value) {
  6606. if (this._stretch === value) {
  6607. return;
  6608. }
  6609. this._stretch = value;
  6610. this._markAsDirty();
  6611. },
  6612. enumerable: false,
  6613. configurable: true
  6614. });
  6615. /** @hidden */
  6616. Image.prototype._rotate90 = function (n, preserveProperties) {
  6617. if (preserveProperties === void 0) { preserveProperties = false; }
  6618. var canvas = document.createElement('canvas');
  6619. var context = canvas.getContext('2d');
  6620. var width = this._domImage.width;
  6621. var height = this._domImage.height;
  6622. canvas.width = height;
  6623. canvas.height = width;
  6624. context.translate(canvas.width / 2, canvas.height / 2);
  6625. context.rotate(n * Math.PI / 2);
  6626. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6627. var dataUrl = canvas.toDataURL("image/jpg");
  6628. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6629. if (preserveProperties) {
  6630. rotatedImage._stretch = this._stretch;
  6631. rotatedImage._autoScale = this._autoScale;
  6632. rotatedImage._cellId = this._cellId;
  6633. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6634. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6635. }
  6636. this._handleRotationForSVGImage(this, rotatedImage, n);
  6637. this._imageDataCache.data = null;
  6638. return rotatedImage;
  6639. };
  6640. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6641. var _this = this;
  6642. if (!srcImage._isSVG) {
  6643. return;
  6644. }
  6645. if (srcImage._svgAttributesComputationCompleted) {
  6646. this._rotate90SourceProperties(srcImage, dstImage, n);
  6647. this._markAsDirty();
  6648. }
  6649. else {
  6650. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6651. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6652. _this._markAsDirty();
  6653. });
  6654. }
  6655. };
  6656. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6657. var _a, _b;
  6658. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6659. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6660. if (n != 0) {
  6661. var mult = n < 0 ? -1 : 1;
  6662. n = n % 4;
  6663. for (var i = 0; i < Math.abs(n); ++i) {
  6664. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6665. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6666. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6667. if (n < 0) {
  6668. dstTop -= dstHeight;
  6669. }
  6670. else {
  6671. dstLeft -= dstWidth;
  6672. }
  6673. srcLeft = dstLeft;
  6674. srcTop = dstTop;
  6675. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6676. }
  6677. }
  6678. dstImage.sourceLeft = dstLeft;
  6679. dstImage.sourceTop = dstTop;
  6680. dstImage.sourceWidth = dstWidth;
  6681. dstImage.sourceHeight = dstHeight;
  6682. };
  6683. Object.defineProperty(Image.prototype, "domImage", {
  6684. get: function () {
  6685. return this._domImage;
  6686. },
  6687. /**
  6688. * Gets or sets the internal DOM image used to render the control
  6689. */
  6690. set: function (value) {
  6691. var _this = this;
  6692. this._domImage = value;
  6693. this._loaded = false;
  6694. this._imageDataCache.data = null;
  6695. if (this._domImage.width) {
  6696. this._onImageLoaded();
  6697. }
  6698. else {
  6699. this._domImage.onload = function () {
  6700. _this._onImageLoaded();
  6701. };
  6702. }
  6703. },
  6704. enumerable: false,
  6705. configurable: true
  6706. });
  6707. Image.prototype._onImageLoaded = function () {
  6708. this._imageDataCache.data = null;
  6709. this._imageWidth = this._domImage.width;
  6710. this._imageHeight = this._domImage.height;
  6711. this._loaded = true;
  6712. if (this._populateNinePatchSlicesFromImage) {
  6713. this._extractNinePatchSliceDataFromImage();
  6714. }
  6715. if (this._autoScale) {
  6716. this.synchronizeSizeWithContent();
  6717. }
  6718. this.onImageLoadedObservable.notifyObservers(this);
  6719. this._markAsDirty();
  6720. };
  6721. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6722. if (!this._workingCanvas) {
  6723. this._workingCanvas = document.createElement('canvas');
  6724. }
  6725. var canvas = this._workingCanvas;
  6726. var context = canvas.getContext('2d');
  6727. var width = this._domImage.width;
  6728. var height = this._domImage.height;
  6729. canvas.width = width;
  6730. canvas.height = height;
  6731. context.drawImage(this._domImage, 0, 0, width, height);
  6732. var imageData = context.getImageData(0, 0, width, height);
  6733. // Left and right
  6734. this._sliceLeft = -1;
  6735. this._sliceRight = -1;
  6736. for (var x = 0; x < width; x++) {
  6737. var alpha = imageData.data[x * 4 + 3];
  6738. if (alpha > 127 && this._sliceLeft === -1) {
  6739. this._sliceLeft = x;
  6740. continue;
  6741. }
  6742. if (alpha < 127 && this._sliceLeft > -1) {
  6743. this._sliceRight = x;
  6744. break;
  6745. }
  6746. }
  6747. // top and bottom
  6748. this._sliceTop = -1;
  6749. this._sliceBottom = -1;
  6750. for (var y = 0; y < height; y++) {
  6751. var alpha = imageData.data[y * width * 4 + 3];
  6752. if (alpha > 127 && this._sliceTop === -1) {
  6753. this._sliceTop = y;
  6754. continue;
  6755. }
  6756. if (alpha < 127 && this._sliceTop > -1) {
  6757. this._sliceBottom = y;
  6758. break;
  6759. }
  6760. }
  6761. };
  6762. Object.defineProperty(Image.prototype, "source", {
  6763. /**
  6764. * Gets or sets image source url
  6765. */
  6766. set: function (value) {
  6767. var _this = this;
  6768. if (this._source === value) {
  6769. return;
  6770. }
  6771. this._loaded = false;
  6772. this._source = value;
  6773. this._imageDataCache.data = null;
  6774. if (value) {
  6775. value = this._svgCheck(value);
  6776. }
  6777. this._domImage = document.createElement("img");
  6778. this._domImage.onload = function () {
  6779. _this._onImageLoaded();
  6780. };
  6781. if (value) {
  6782. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6783. this._domImage.src = value;
  6784. }
  6785. },
  6786. enumerable: false,
  6787. configurable: true
  6788. });
  6789. /**
  6790. * Checks for svg document with icon id present
  6791. */
  6792. Image.prototype._svgCheck = function (value) {
  6793. var _this = this;
  6794. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6795. this._isSVG = true;
  6796. var svgsrc = value.split('#')[0];
  6797. var elemid = value.split('#')[1];
  6798. // check if object alr exist in document
  6799. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6800. if (svgExist) {
  6801. var svgDoc = svgExist.contentDocument;
  6802. // get viewbox width and height, get svg document width and height in px
  6803. if (svgDoc && svgDoc.documentElement) {
  6804. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6805. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6806. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6807. var elem = svgDoc.getElementById(elemid);
  6808. if (elem && vb && docwidth && docheight) {
  6809. this._getSVGAttribs(svgExist, elemid);
  6810. return value;
  6811. }
  6812. }
  6813. // wait for object to load
  6814. svgExist.addEventListener("load", function () {
  6815. _this._getSVGAttribs(svgExist, elemid);
  6816. });
  6817. }
  6818. else {
  6819. // create document object
  6820. var svgImage = document.createElement("object");
  6821. svgImage.data = svgsrc;
  6822. svgImage.type = "image/svg+xml";
  6823. svgImage.width = "0%";
  6824. svgImage.height = "0%";
  6825. document.body.appendChild(svgImage);
  6826. // when the object has loaded, get the element attribs
  6827. svgImage.onload = function () {
  6828. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6829. if (svgobj) {
  6830. _this._getSVGAttribs(svgobj, elemid);
  6831. }
  6832. };
  6833. }
  6834. return svgsrc;
  6835. }
  6836. else {
  6837. return value;
  6838. }
  6839. };
  6840. /**
  6841. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6842. * given external svg file and icon id
  6843. */
  6844. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6845. var svgDoc = svgsrc.contentDocument;
  6846. // get viewbox width and height, get svg document width and height in px
  6847. if (svgDoc && svgDoc.documentElement) {
  6848. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6849. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6850. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6851. // get element bbox and matrix transform
  6852. var elem = svgDoc.getElementById(elemid);
  6853. if (vb && docwidth && docheight && elem) {
  6854. var vb_width = Number(vb.split(" ")[2]);
  6855. var vb_height = Number(vb.split(" ")[3]);
  6856. var elem_bbox = elem.getBBox();
  6857. var elem_matrix_a = 1;
  6858. var elem_matrix_d = 1;
  6859. var elem_matrix_e = 0;
  6860. var elem_matrix_f = 0;
  6861. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6862. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6863. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6864. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6865. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6866. }
  6867. // compute source coordinates and dimensions
  6868. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6869. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6870. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6871. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6872. this._svgAttributesComputationCompleted = true;
  6873. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6874. }
  6875. }
  6876. };
  6877. Object.defineProperty(Image.prototype, "cellWidth", {
  6878. /**
  6879. * Gets or sets the cell width to use when animation sheet is enabled
  6880. * @see https://doc.babylonjs.com/how_to/gui#image
  6881. */
  6882. get: function () {
  6883. return this._cellWidth;
  6884. },
  6885. set: function (value) {
  6886. if (this._cellWidth === value) {
  6887. return;
  6888. }
  6889. this._cellWidth = value;
  6890. this._markAsDirty();
  6891. },
  6892. enumerable: false,
  6893. configurable: true
  6894. });
  6895. Object.defineProperty(Image.prototype, "cellHeight", {
  6896. /**
  6897. * Gets or sets the cell height to use when animation sheet is enabled
  6898. * @see https://doc.babylonjs.com/how_to/gui#image
  6899. */
  6900. get: function () {
  6901. return this._cellHeight;
  6902. },
  6903. set: function (value) {
  6904. if (this._cellHeight === value) {
  6905. return;
  6906. }
  6907. this._cellHeight = value;
  6908. this._markAsDirty();
  6909. },
  6910. enumerable: false,
  6911. configurable: true
  6912. });
  6913. Object.defineProperty(Image.prototype, "cellId", {
  6914. /**
  6915. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6916. * @see https://doc.babylonjs.com/how_to/gui#image
  6917. */
  6918. get: function () {
  6919. return this._cellId;
  6920. },
  6921. set: function (value) {
  6922. if (this._cellId === value) {
  6923. return;
  6924. }
  6925. this._cellId = value;
  6926. this._markAsDirty();
  6927. },
  6928. enumerable: false,
  6929. configurable: true
  6930. });
  6931. /**
  6932. * Tests if a given coordinates belong to the current control
  6933. * @param x defines x coordinate to test
  6934. * @param y defines y coordinate to test
  6935. * @returns true if the coordinates are inside the control
  6936. */
  6937. Image.prototype.contains = function (x, y) {
  6938. if (!_super.prototype.contains.call(this, x, y)) {
  6939. return false;
  6940. }
  6941. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6942. return true;
  6943. }
  6944. var width = this._currentMeasure.width | 0;
  6945. var height = this._currentMeasure.height | 0;
  6946. var key = width + "_" + height;
  6947. var imageData = this._imageDataCache.data;
  6948. if (!imageData || this._imageDataCache.key !== key) {
  6949. var canvas = this._workingCanvas;
  6950. var context_1 = canvas.getContext("2d");
  6951. this._imageDataCache.data = imageData = context_1.getImageData(0, 0, width, height).data;
  6952. this._imageDataCache.key = key;
  6953. }
  6954. x = (x - this._currentMeasure.left) | 0;
  6955. y = (y - this._currentMeasure.top) | 0;
  6956. var pickedPixel = imageData[(x + y * width) * 4 + 3];
  6957. return pickedPixel > 0;
  6958. };
  6959. Image.prototype._getTypeName = function () {
  6960. return "Image";
  6961. };
  6962. /** Force the control to synchronize with its content */
  6963. Image.prototype.synchronizeSizeWithContent = function () {
  6964. if (!this._loaded) {
  6965. return;
  6966. }
  6967. this.width = this._domImage.width + "px";
  6968. this.height = this._domImage.height + "px";
  6969. };
  6970. Image.prototype._processMeasures = function (parentMeasure, context) {
  6971. if (this._loaded) {
  6972. switch (this._stretch) {
  6973. case Image.STRETCH_NONE:
  6974. break;
  6975. case Image.STRETCH_FILL:
  6976. break;
  6977. case Image.STRETCH_UNIFORM:
  6978. break;
  6979. case Image.STRETCH_NINE_PATCH:
  6980. break;
  6981. case Image.STRETCH_EXTEND:
  6982. if (this._autoScale) {
  6983. this.synchronizeSizeWithContent();
  6984. }
  6985. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6986. this.parent.adaptWidthToChildren = true;
  6987. this.parent.adaptHeightToChildren = true;
  6988. }
  6989. break;
  6990. }
  6991. }
  6992. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6993. };
  6994. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6995. if (!this._detectPointerOnOpaqueOnly) {
  6996. return;
  6997. }
  6998. if (!this._workingCanvas) {
  6999. this._workingCanvas = document.createElement('canvas');
  7000. }
  7001. var canvas = this._workingCanvas;
  7002. var width = this._currentMeasure.width;
  7003. var height = this._currentMeasure.height;
  7004. var context = canvas.getContext("2d");
  7005. canvas.width = width;
  7006. canvas.height = height;
  7007. context.clearRect(0, 0, width, height);
  7008. };
  7009. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  7010. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  7011. if (!this._detectPointerOnOpaqueOnly) {
  7012. return;
  7013. }
  7014. var canvas = this._workingCanvas;
  7015. context = canvas.getContext("2d");
  7016. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  7017. };
  7018. Image.prototype._draw = function (context) {
  7019. context.save();
  7020. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7021. context.shadowColor = this.shadowColor;
  7022. context.shadowBlur = this.shadowBlur;
  7023. context.shadowOffsetX = this.shadowOffsetX;
  7024. context.shadowOffsetY = this.shadowOffsetY;
  7025. }
  7026. var x, y, width, height;
  7027. if (this.cellId == -1) {
  7028. x = this._sourceLeft;
  7029. y = this._sourceTop;
  7030. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  7031. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  7032. }
  7033. else {
  7034. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  7035. var column = (this.cellId / rowCount) >> 0;
  7036. var row = this.cellId % rowCount;
  7037. x = this.cellWidth * row;
  7038. y = this.cellHeight * column;
  7039. width = this.cellWidth;
  7040. height = this.cellHeight;
  7041. }
  7042. this._prepareWorkingCanvasForOpaqueDetection();
  7043. this._applyStates(context);
  7044. if (this._loaded) {
  7045. switch (this._stretch) {
  7046. case Image.STRETCH_NONE:
  7047. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7048. break;
  7049. case Image.STRETCH_FILL:
  7050. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7051. break;
  7052. case Image.STRETCH_UNIFORM:
  7053. var hRatio = this._currentMeasure.width / width;
  7054. var vRatio = this._currentMeasure.height / height;
  7055. var ratio = Math.min(hRatio, vRatio);
  7056. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  7057. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  7058. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  7059. break;
  7060. case Image.STRETCH_EXTEND:
  7061. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7062. break;
  7063. case Image.STRETCH_NINE_PATCH:
  7064. this._renderNinePatch(context);
  7065. break;
  7066. }
  7067. }
  7068. context.restore();
  7069. };
  7070. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  7071. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  7072. };
  7073. Image.prototype._renderNinePatch = function (context) {
  7074. var height = this._imageHeight;
  7075. var leftWidth = this._sliceLeft;
  7076. var topHeight = this._sliceTop;
  7077. var bottomHeight = this._imageHeight - this._sliceBottom;
  7078. var rightWidth = this._imageWidth - this._sliceRight;
  7079. var left = 0;
  7080. var top = 0;
  7081. if (this._populateNinePatchSlicesFromImage) {
  7082. left = 1;
  7083. top = 1;
  7084. height -= 2;
  7085. leftWidth -= 1;
  7086. topHeight -= 1;
  7087. bottomHeight -= 1;
  7088. rightWidth -= 1;
  7089. }
  7090. var centerWidth = this._sliceRight - this._sliceLeft;
  7091. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  7092. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  7093. // Corners
  7094. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  7095. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  7096. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  7097. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  7098. // Center
  7099. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  7100. // Borders
  7101. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7102. 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);
  7103. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  7104. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  7105. };
  7106. Image.prototype.dispose = function () {
  7107. _super.prototype.dispose.call(this);
  7108. this.onImageLoadedObservable.clear();
  7109. this.onSVGAttributesComputedObservable.clear();
  7110. };
  7111. // Static
  7112. /** STRETCH_NONE */
  7113. Image.STRETCH_NONE = 0;
  7114. /** STRETCH_FILL */
  7115. Image.STRETCH_FILL = 1;
  7116. /** STRETCH_UNIFORM */
  7117. Image.STRETCH_UNIFORM = 2;
  7118. /** STRETCH_EXTEND */
  7119. Image.STRETCH_EXTEND = 3;
  7120. /** NINE_PATCH */
  7121. Image.STRETCH_NINE_PATCH = 4;
  7122. return Image;
  7123. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7124. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7125. /***/ }),
  7126. /***/ "./2D/controls/index.ts":
  7127. /*!******************************!*\
  7128. !*** ./2D/controls/index.ts ***!
  7129. \******************************/
  7130. /*! 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 */
  7131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7132. "use strict";
  7133. __webpack_require__.r(__webpack_exports__);
  7134. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7136. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7138. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7140. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7142. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7144. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7146. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  7148. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  7150. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  7152. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  7154. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  7156. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  7158. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  7160. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  7162. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  7164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  7165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  7166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  7167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  7168. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  7170. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  7172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  7173. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  7175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  7176. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  7178. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  7180. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  7182. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  7184. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  7186. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  7188. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  7190. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  7192. /***/ }),
  7193. /***/ "./2D/controls/inputPassword.ts":
  7194. /*!**************************************!*\
  7195. !*** ./2D/controls/inputPassword.ts ***!
  7196. \**************************************/
  7197. /*! exports provided: InputPassword */
  7198. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7199. "use strict";
  7200. __webpack_require__.r(__webpack_exports__);
  7201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7202. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7203. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7204. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  7205. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7206. /**
  7207. * Class used to create a password control
  7208. */
  7209. var InputPassword = /** @class */ (function (_super) {
  7210. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7211. function InputPassword() {
  7212. return _super !== null && _super.apply(this, arguments) || this;
  7213. }
  7214. InputPassword.prototype._beforeRenderText = function (text) {
  7215. var txt = "";
  7216. for (var i = 0; i < text.length; i++) {
  7217. txt += "\u2022";
  7218. }
  7219. return txt;
  7220. };
  7221. return InputPassword;
  7222. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7223. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7224. /***/ }),
  7225. /***/ "./2D/controls/inputText.ts":
  7226. /*!**********************************!*\
  7227. !*** ./2D/controls/inputText.ts ***!
  7228. \**********************************/
  7229. /*! exports provided: InputText */
  7230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7231. "use strict";
  7232. __webpack_require__.r(__webpack_exports__);
  7233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7234. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7235. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  7236. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7237. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7238. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7239. /**
  7240. * Class used to create input text control
  7241. */
  7242. var InputText = /** @class */ (function (_super) {
  7243. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7244. /**
  7245. * Creates a new InputText
  7246. * @param name defines the control name
  7247. * @param text defines the text of the control
  7248. */
  7249. function InputText(name, text) {
  7250. if (text === void 0) { text = ""; }
  7251. var _this = _super.call(this, name) || this;
  7252. _this.name = name;
  7253. _this._text = "";
  7254. _this._placeholderText = "";
  7255. _this._background = "#222222";
  7256. _this._focusedBackground = "#000000";
  7257. _this._focusedColor = "white";
  7258. _this._placeholderColor = "gray";
  7259. _this._thickness = 1;
  7260. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7261. _this._autoStretchWidth = true;
  7262. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7263. _this._isFocused = false;
  7264. _this._blinkIsEven = false;
  7265. _this._cursorOffset = 0;
  7266. _this._deadKey = false;
  7267. _this._addKey = true;
  7268. _this._currentKey = "";
  7269. _this._isTextHighlightOn = false;
  7270. _this._textHighlightColor = "#d5e0ff";
  7271. _this._highligherOpacity = 0.4;
  7272. _this._highlightedText = "";
  7273. _this._startHighlightIndex = 0;
  7274. _this._endHighlightIndex = 0;
  7275. _this._cursorIndex = -1;
  7276. _this._onFocusSelectAll = false;
  7277. _this._isPointerDown = false;
  7278. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7279. _this.promptMessage = "Please enter text:";
  7280. /** Force disable prompt on mobile device */
  7281. _this.disableMobilePrompt = false;
  7282. /** Observable raised when the text changes */
  7283. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7284. /** Observable raised just before an entered character is to be added */
  7285. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7286. /** Observable raised when the control gets the focus */
  7287. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7288. /** Observable raised when the control loses the focus */
  7289. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7290. /**Observable raised when the text is highlighted */
  7291. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7292. /**Observable raised when copy event is triggered */
  7293. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7294. /** Observable raised when cut event is triggered */
  7295. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7296. /** Observable raised when paste event is triggered */
  7297. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7298. /** Observable raised when a key event was processed */
  7299. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7300. _this.text = text;
  7301. _this.isPointerBlocker = true;
  7302. return _this;
  7303. }
  7304. Object.defineProperty(InputText.prototype, "maxWidth", {
  7305. /** Gets or sets the maximum width allowed by the control */
  7306. get: function () {
  7307. return this._maxWidth.toString(this._host);
  7308. },
  7309. set: function (value) {
  7310. if (this._maxWidth.toString(this._host) === value) {
  7311. return;
  7312. }
  7313. if (this._maxWidth.fromString(value)) {
  7314. this._markAsDirty();
  7315. }
  7316. },
  7317. enumerable: false,
  7318. configurable: true
  7319. });
  7320. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7321. /** Gets the maximum width allowed by the control in pixels */
  7322. get: function () {
  7323. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7324. },
  7325. enumerable: false,
  7326. configurable: true
  7327. });
  7328. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7329. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7330. get: function () {
  7331. return this._highligherOpacity;
  7332. },
  7333. set: function (value) {
  7334. if (this._highligherOpacity === value) {
  7335. return;
  7336. }
  7337. this._highligherOpacity = value;
  7338. this._markAsDirty();
  7339. },
  7340. enumerable: false,
  7341. configurable: true
  7342. });
  7343. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7344. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7345. get: function () {
  7346. return this._onFocusSelectAll;
  7347. },
  7348. set: function (value) {
  7349. if (this._onFocusSelectAll === value) {
  7350. return;
  7351. }
  7352. this._onFocusSelectAll = value;
  7353. this._markAsDirty();
  7354. },
  7355. enumerable: false,
  7356. configurable: true
  7357. });
  7358. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7359. /** Gets or sets the text hightlight color */
  7360. get: function () {
  7361. return this._textHighlightColor;
  7362. },
  7363. set: function (value) {
  7364. if (this._textHighlightColor === value) {
  7365. return;
  7366. }
  7367. this._textHighlightColor = value;
  7368. this._markAsDirty();
  7369. },
  7370. enumerable: false,
  7371. configurable: true
  7372. });
  7373. Object.defineProperty(InputText.prototype, "margin", {
  7374. /** Gets or sets control margin */
  7375. get: function () {
  7376. return this._margin.toString(this._host);
  7377. },
  7378. set: function (value) {
  7379. if (this._margin.toString(this._host) === value) {
  7380. return;
  7381. }
  7382. if (this._margin.fromString(value)) {
  7383. this._markAsDirty();
  7384. }
  7385. },
  7386. enumerable: false,
  7387. configurable: true
  7388. });
  7389. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7390. /** Gets control margin in pixels */
  7391. get: function () {
  7392. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7393. },
  7394. enumerable: false,
  7395. configurable: true
  7396. });
  7397. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7398. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7399. get: function () {
  7400. return this._autoStretchWidth;
  7401. },
  7402. set: function (value) {
  7403. if (this._autoStretchWidth === value) {
  7404. return;
  7405. }
  7406. this._autoStretchWidth = value;
  7407. this._markAsDirty();
  7408. },
  7409. enumerable: false,
  7410. configurable: true
  7411. });
  7412. Object.defineProperty(InputText.prototype, "thickness", {
  7413. /** Gets or sets border thickness */
  7414. get: function () {
  7415. return this._thickness;
  7416. },
  7417. set: function (value) {
  7418. if (this._thickness === value) {
  7419. return;
  7420. }
  7421. this._thickness = value;
  7422. this._markAsDirty();
  7423. },
  7424. enumerable: false,
  7425. configurable: true
  7426. });
  7427. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7428. /** Gets or sets the background color when focused */
  7429. get: function () {
  7430. return this._focusedBackground;
  7431. },
  7432. set: function (value) {
  7433. if (this._focusedBackground === value) {
  7434. return;
  7435. }
  7436. this._focusedBackground = value;
  7437. this._markAsDirty();
  7438. },
  7439. enumerable: false,
  7440. configurable: true
  7441. });
  7442. Object.defineProperty(InputText.prototype, "focusedColor", {
  7443. /** Gets or sets the background color when focused */
  7444. get: function () {
  7445. return this._focusedColor;
  7446. },
  7447. set: function (value) {
  7448. if (this._focusedColor === value) {
  7449. return;
  7450. }
  7451. this._focusedColor = value;
  7452. this._markAsDirty();
  7453. },
  7454. enumerable: false,
  7455. configurable: true
  7456. });
  7457. Object.defineProperty(InputText.prototype, "background", {
  7458. /** Gets or sets the background color */
  7459. get: function () {
  7460. return this._background;
  7461. },
  7462. set: function (value) {
  7463. if (this._background === value) {
  7464. return;
  7465. }
  7466. this._background = value;
  7467. this._markAsDirty();
  7468. },
  7469. enumerable: false,
  7470. configurable: true
  7471. });
  7472. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7473. /** Gets or sets the placeholder color */
  7474. get: function () {
  7475. return this._placeholderColor;
  7476. },
  7477. set: function (value) {
  7478. if (this._placeholderColor === value) {
  7479. return;
  7480. }
  7481. this._placeholderColor = value;
  7482. this._markAsDirty();
  7483. },
  7484. enumerable: false,
  7485. configurable: true
  7486. });
  7487. Object.defineProperty(InputText.prototype, "placeholderText", {
  7488. /** Gets or sets the text displayed when the control is empty */
  7489. get: function () {
  7490. return this._placeholderText;
  7491. },
  7492. set: function (value) {
  7493. if (this._placeholderText === value) {
  7494. return;
  7495. }
  7496. this._placeholderText = value;
  7497. this._markAsDirty();
  7498. },
  7499. enumerable: false,
  7500. configurable: true
  7501. });
  7502. Object.defineProperty(InputText.prototype, "deadKey", {
  7503. /** Gets or sets the dead key flag */
  7504. get: function () {
  7505. return this._deadKey;
  7506. },
  7507. set: function (flag) {
  7508. this._deadKey = flag;
  7509. },
  7510. enumerable: false,
  7511. configurable: true
  7512. });
  7513. Object.defineProperty(InputText.prototype, "highlightedText", {
  7514. /** Gets or sets the highlight text */
  7515. get: function () {
  7516. return this._highlightedText;
  7517. },
  7518. set: function (text) {
  7519. if (this._highlightedText === text) {
  7520. return;
  7521. }
  7522. this._highlightedText = text;
  7523. this._markAsDirty();
  7524. },
  7525. enumerable: false,
  7526. configurable: true
  7527. });
  7528. Object.defineProperty(InputText.prototype, "addKey", {
  7529. /** Gets or sets if the current key should be added */
  7530. get: function () {
  7531. return this._addKey;
  7532. },
  7533. set: function (flag) {
  7534. this._addKey = flag;
  7535. },
  7536. enumerable: false,
  7537. configurable: true
  7538. });
  7539. Object.defineProperty(InputText.prototype, "currentKey", {
  7540. /** Gets or sets the value of the current key being entered */
  7541. get: function () {
  7542. return this._currentKey;
  7543. },
  7544. set: function (key) {
  7545. this._currentKey = key;
  7546. },
  7547. enumerable: false,
  7548. configurable: true
  7549. });
  7550. Object.defineProperty(InputText.prototype, "text", {
  7551. /** Gets or sets the text displayed in the control */
  7552. get: function () {
  7553. return this._text;
  7554. },
  7555. set: function (value) {
  7556. var valueAsString = value.toString(); // Forcing convertion
  7557. if (this._text === valueAsString) {
  7558. return;
  7559. }
  7560. this._text = valueAsString;
  7561. this._markAsDirty();
  7562. this.onTextChangedObservable.notifyObservers(this);
  7563. },
  7564. enumerable: false,
  7565. configurable: true
  7566. });
  7567. Object.defineProperty(InputText.prototype, "width", {
  7568. /** Gets or sets control width */
  7569. get: function () {
  7570. return this._width.toString(this._host);
  7571. },
  7572. set: function (value) {
  7573. if (this._width.toString(this._host) === value) {
  7574. return;
  7575. }
  7576. if (this._width.fromString(value)) {
  7577. this._markAsDirty();
  7578. }
  7579. this.autoStretchWidth = false;
  7580. },
  7581. enumerable: false,
  7582. configurable: true
  7583. });
  7584. /** @hidden */
  7585. InputText.prototype.onBlur = function () {
  7586. this._isFocused = false;
  7587. this._scrollLeft = null;
  7588. this._cursorOffset = 0;
  7589. clearTimeout(this._blinkTimeout);
  7590. this._markAsDirty();
  7591. this.onBlurObservable.notifyObservers(this);
  7592. this._host.unRegisterClipboardEvents();
  7593. if (this._onClipboardObserver) {
  7594. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7595. }
  7596. var scene = this._host.getScene();
  7597. if (this._onPointerDblTapObserver && scene) {
  7598. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7599. }
  7600. };
  7601. /** @hidden */
  7602. InputText.prototype.onFocus = function () {
  7603. var _this = this;
  7604. if (!this._isEnabled) {
  7605. return;
  7606. }
  7607. this._scrollLeft = null;
  7608. this._isFocused = true;
  7609. this._blinkIsEven = false;
  7610. this._cursorOffset = 0;
  7611. this._markAsDirty();
  7612. this.onFocusObservable.notifyObservers(this);
  7613. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7614. var value = prompt(this.promptMessage);
  7615. if (value !== null) {
  7616. this.text = value;
  7617. }
  7618. this._host.focusedControl = null;
  7619. return;
  7620. }
  7621. this._host.registerClipboardEvents();
  7622. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7623. // process clipboard event, can be configured.
  7624. switch (clipboardInfo.type) {
  7625. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7626. _this._onCopyText(clipboardInfo.event);
  7627. _this.onTextCopyObservable.notifyObservers(_this);
  7628. break;
  7629. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7630. _this._onCutText(clipboardInfo.event);
  7631. _this.onTextCutObservable.notifyObservers(_this);
  7632. break;
  7633. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7634. _this._onPasteText(clipboardInfo.event);
  7635. _this.onTextPasteObservable.notifyObservers(_this);
  7636. break;
  7637. default: return;
  7638. }
  7639. });
  7640. var scene = this._host.getScene();
  7641. if (scene) {
  7642. //register the pointer double tap event
  7643. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7644. if (!_this._isFocused) {
  7645. return;
  7646. }
  7647. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7648. _this._processDblClick(pointerInfo);
  7649. }
  7650. });
  7651. }
  7652. if (this._onFocusSelectAll) {
  7653. this._selectAllText();
  7654. }
  7655. };
  7656. InputText.prototype._getTypeName = function () {
  7657. return "InputText";
  7658. };
  7659. /**
  7660. * Function called to get the list of controls that should not steal the focus from this control
  7661. * @returns an array of controls
  7662. */
  7663. InputText.prototype.keepsFocusWith = function () {
  7664. if (!this._connectedVirtualKeyboard) {
  7665. return null;
  7666. }
  7667. return [this._connectedVirtualKeyboard];
  7668. };
  7669. /** @hidden */
  7670. InputText.prototype.processKey = function (keyCode, key, evt) {
  7671. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7672. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7673. return;
  7674. }
  7675. //select all
  7676. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7677. this._selectAllText();
  7678. evt.preventDefault();
  7679. return;
  7680. }
  7681. // Specific cases
  7682. switch (keyCode) {
  7683. case 32: //SPACE
  7684. key = " "; //ie11 key for space is "Spacebar"
  7685. break;
  7686. case 191: //SLASH
  7687. if (evt) {
  7688. evt.preventDefault();
  7689. }
  7690. break;
  7691. case 8: // BACKSPACE
  7692. if (this._text && this._text.length > 0) {
  7693. //delete the highlighted text
  7694. if (this._isTextHighlightOn) {
  7695. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7696. this._isTextHighlightOn = false;
  7697. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7698. this._blinkIsEven = false;
  7699. if (evt) {
  7700. evt.preventDefault();
  7701. }
  7702. return;
  7703. }
  7704. //delete single character
  7705. if (this._cursorOffset === 0) {
  7706. this.text = this._text.substr(0, this._text.length - 1);
  7707. }
  7708. else {
  7709. var deletePosition = this._text.length - this._cursorOffset;
  7710. if (deletePosition > 0) {
  7711. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7712. }
  7713. }
  7714. }
  7715. if (evt) {
  7716. evt.preventDefault();
  7717. }
  7718. return;
  7719. case 46: // DELETE
  7720. if (this._isTextHighlightOn) {
  7721. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7722. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7723. while (decrementor > 0 && this._cursorOffset > 0) {
  7724. this._cursorOffset--;
  7725. }
  7726. this._isTextHighlightOn = false;
  7727. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7728. if (evt) {
  7729. evt.preventDefault();
  7730. }
  7731. return;
  7732. }
  7733. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7734. var deletePosition = this._text.length - this._cursorOffset;
  7735. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7736. this._cursorOffset--;
  7737. }
  7738. if (evt) {
  7739. evt.preventDefault();
  7740. }
  7741. return;
  7742. case 13: // RETURN
  7743. this._host.focusedControl = null;
  7744. this._isTextHighlightOn = false;
  7745. return;
  7746. case 35: // END
  7747. this._cursorOffset = 0;
  7748. this._blinkIsEven = false;
  7749. this._isTextHighlightOn = false;
  7750. this._markAsDirty();
  7751. return;
  7752. case 36: // HOME
  7753. this._cursorOffset = this._text.length;
  7754. this._blinkIsEven = false;
  7755. this._isTextHighlightOn = false;
  7756. this._markAsDirty();
  7757. return;
  7758. case 37: // LEFT
  7759. this._cursorOffset++;
  7760. if (this._cursorOffset > this._text.length) {
  7761. this._cursorOffset = this._text.length;
  7762. }
  7763. if (evt && evt.shiftKey) {
  7764. // update the cursor
  7765. this._blinkIsEven = false;
  7766. // shift + ctrl/cmd + <-
  7767. if (evt.ctrlKey || evt.metaKey) {
  7768. if (!this._isTextHighlightOn) {
  7769. if (this._text.length === this._cursorOffset) {
  7770. return;
  7771. }
  7772. else {
  7773. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7774. }
  7775. }
  7776. this._startHighlightIndex = 0;
  7777. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7778. this._cursorOffset = this._text.length;
  7779. this._isTextHighlightOn = true;
  7780. this._markAsDirty();
  7781. return;
  7782. }
  7783. //store the starting point
  7784. if (!this._isTextHighlightOn) {
  7785. this._isTextHighlightOn = true;
  7786. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7787. }
  7788. //if text is already highlighted
  7789. else if (this._cursorIndex === -1) {
  7790. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7791. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7792. }
  7793. //set the highlight indexes
  7794. if (this._cursorIndex < this._cursorOffset) {
  7795. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7796. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7797. }
  7798. else if (this._cursorIndex > this._cursorOffset) {
  7799. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7800. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7801. }
  7802. else {
  7803. this._isTextHighlightOn = false;
  7804. }
  7805. this._markAsDirty();
  7806. return;
  7807. }
  7808. if (this._isTextHighlightOn) {
  7809. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7810. this._isTextHighlightOn = false;
  7811. }
  7812. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7813. this._cursorOffset = this.text.length;
  7814. evt.preventDefault();
  7815. }
  7816. this._blinkIsEven = false;
  7817. this._isTextHighlightOn = false;
  7818. this._cursorIndex = -1;
  7819. this._markAsDirty();
  7820. return;
  7821. case 39: // RIGHT
  7822. this._cursorOffset--;
  7823. if (this._cursorOffset < 0) {
  7824. this._cursorOffset = 0;
  7825. }
  7826. if (evt && evt.shiftKey) {
  7827. //update the cursor
  7828. this._blinkIsEven = false;
  7829. //shift + ctrl/cmd + ->
  7830. if (evt.ctrlKey || evt.metaKey) {
  7831. if (!this._isTextHighlightOn) {
  7832. if (this._cursorOffset === 0) {
  7833. return;
  7834. }
  7835. else {
  7836. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7837. }
  7838. }
  7839. this._endHighlightIndex = this._text.length;
  7840. this._isTextHighlightOn = true;
  7841. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7842. this._cursorOffset = 0;
  7843. this._markAsDirty();
  7844. return;
  7845. }
  7846. if (!this._isTextHighlightOn) {
  7847. this._isTextHighlightOn = true;
  7848. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7849. }
  7850. //if text is already highlighted
  7851. else if (this._cursorIndex === -1) {
  7852. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7853. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7854. }
  7855. //set the highlight indexes
  7856. if (this._cursorIndex < this._cursorOffset) {
  7857. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7858. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7859. }
  7860. else if (this._cursorIndex > this._cursorOffset) {
  7861. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7862. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7863. }
  7864. else {
  7865. this._isTextHighlightOn = false;
  7866. }
  7867. this._markAsDirty();
  7868. return;
  7869. }
  7870. if (this._isTextHighlightOn) {
  7871. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7872. this._isTextHighlightOn = false;
  7873. }
  7874. //ctr + ->
  7875. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7876. this._cursorOffset = 0;
  7877. evt.preventDefault();
  7878. }
  7879. this._blinkIsEven = false;
  7880. this._isTextHighlightOn = false;
  7881. this._cursorIndex = -1;
  7882. this._markAsDirty();
  7883. return;
  7884. case 222: // Dead
  7885. if (evt) {
  7886. evt.preventDefault();
  7887. }
  7888. this._cursorIndex = -1;
  7889. this.deadKey = true;
  7890. break;
  7891. }
  7892. // Printable characters
  7893. if (key &&
  7894. ((keyCode === -1) || // Direct access
  7895. (keyCode === 32) || // Space
  7896. (keyCode > 47 && keyCode < 64) || // Numbers
  7897. (keyCode > 64 && keyCode < 91) || // Letters
  7898. (keyCode > 159 && keyCode < 193) || // Special characters
  7899. (keyCode > 218 && keyCode < 223) || // Special characters
  7900. (keyCode > 95 && keyCode < 112))) { // Numpad
  7901. this._currentKey = key;
  7902. this.onBeforeKeyAddObservable.notifyObservers(this);
  7903. key = this._currentKey;
  7904. if (this._addKey) {
  7905. if (this._isTextHighlightOn) {
  7906. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7907. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7908. this._isTextHighlightOn = false;
  7909. this._blinkIsEven = false;
  7910. this._markAsDirty();
  7911. }
  7912. else if (this._cursorOffset === 0) {
  7913. this.text += key;
  7914. }
  7915. else {
  7916. var insertPosition = this._text.length - this._cursorOffset;
  7917. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7918. }
  7919. }
  7920. }
  7921. };
  7922. /** @hidden */
  7923. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7924. //update the cursor
  7925. this._blinkIsEven = false;
  7926. if (this._cursorIndex === -1) {
  7927. this._cursorIndex = offset;
  7928. }
  7929. else {
  7930. if (this._cursorIndex < this._cursorOffset) {
  7931. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7932. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7933. }
  7934. else if (this._cursorIndex > this._cursorOffset) {
  7935. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7936. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7937. }
  7938. else {
  7939. this._isTextHighlightOn = false;
  7940. this._markAsDirty();
  7941. return;
  7942. }
  7943. }
  7944. this._isTextHighlightOn = true;
  7945. this._markAsDirty();
  7946. };
  7947. /** @hidden */
  7948. InputText.prototype._processDblClick = function (evt) {
  7949. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7950. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7951. this._endHighlightIndex = this._startHighlightIndex;
  7952. var rWord = /\w+/g, moveLeft, moveRight;
  7953. do {
  7954. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7955. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7956. } while (moveLeft || moveRight);
  7957. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7958. this.onTextHighlightObservable.notifyObservers(this);
  7959. this._isTextHighlightOn = true;
  7960. this._clickedCoordinate = null;
  7961. this._blinkIsEven = true;
  7962. this._cursorIndex = -1;
  7963. this._markAsDirty();
  7964. };
  7965. /** @hidden */
  7966. InputText.prototype._selectAllText = function () {
  7967. this._blinkIsEven = true;
  7968. this._isTextHighlightOn = true;
  7969. this._startHighlightIndex = 0;
  7970. this._endHighlightIndex = this._text.length;
  7971. this._cursorOffset = this._text.length;
  7972. this._cursorIndex = -1;
  7973. this._markAsDirty();
  7974. };
  7975. /**
  7976. * Handles the keyboard event
  7977. * @param evt Defines the KeyboardEvent
  7978. */
  7979. InputText.prototype.processKeyboard = function (evt) {
  7980. // process pressed key
  7981. this.processKey(evt.keyCode, evt.key, evt);
  7982. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7983. };
  7984. /** @hidden */
  7985. InputText.prototype._onCopyText = function (ev) {
  7986. this._isTextHighlightOn = false;
  7987. //when write permission to clipbaord data is denied
  7988. try {
  7989. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7990. }
  7991. catch (_a) { } //pass
  7992. this._host.clipboardData = this._highlightedText;
  7993. };
  7994. /** @hidden */
  7995. InputText.prototype._onCutText = function (ev) {
  7996. if (!this._highlightedText) {
  7997. return;
  7998. }
  7999. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  8000. this._isTextHighlightOn = false;
  8001. this._cursorOffset = this.text.length - this._startHighlightIndex;
  8002. //when write permission to clipbaord data is denied
  8003. try {
  8004. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8005. }
  8006. catch (_a) { } //pass
  8007. this._host.clipboardData = this._highlightedText;
  8008. this._highlightedText = "";
  8009. };
  8010. /** @hidden */
  8011. InputText.prototype._onPasteText = function (ev) {
  8012. var data = "";
  8013. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  8014. data = ev.clipboardData.getData("text/plain");
  8015. }
  8016. else {
  8017. //get the cached data; returns blank string by default
  8018. data = this._host.clipboardData;
  8019. }
  8020. var insertPosition = this._text.length - this._cursorOffset;
  8021. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  8022. };
  8023. InputText.prototype._draw = function (context, invalidatedRectangle) {
  8024. var _this = this;
  8025. context.save();
  8026. this._applyStates(context);
  8027. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8028. context.shadowColor = this.shadowColor;
  8029. context.shadowBlur = this.shadowBlur;
  8030. context.shadowOffsetX = this.shadowOffsetX;
  8031. context.shadowOffsetY = this.shadowOffsetY;
  8032. }
  8033. // Background
  8034. if (this._isFocused) {
  8035. if (this._focusedBackground) {
  8036. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  8037. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8038. }
  8039. }
  8040. else if (this._background) {
  8041. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8042. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8043. }
  8044. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8045. context.shadowBlur = 0;
  8046. context.shadowOffsetX = 0;
  8047. context.shadowOffsetY = 0;
  8048. }
  8049. if (!this._fontOffset) {
  8050. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  8051. }
  8052. // Text
  8053. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  8054. if (this.color) {
  8055. context.fillStyle = this.color;
  8056. }
  8057. var text = this._beforeRenderText(this._text);
  8058. if (!this._isFocused && !this._text && this._placeholderText) {
  8059. text = this._placeholderText;
  8060. if (this._placeholderColor) {
  8061. context.fillStyle = this._placeholderColor;
  8062. }
  8063. }
  8064. this._textWidth = context.measureText(text).width;
  8065. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  8066. if (this._autoStretchWidth) {
  8067. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  8068. }
  8069. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  8070. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  8071. context.save();
  8072. context.beginPath();
  8073. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  8074. context.clip();
  8075. if (this._isFocused && this._textWidth > availableWidth) {
  8076. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  8077. if (!this._scrollLeft) {
  8078. this._scrollLeft = textLeft;
  8079. }
  8080. }
  8081. else {
  8082. this._scrollLeft = clipTextLeft;
  8083. }
  8084. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  8085. // Cursor
  8086. if (this._isFocused) {
  8087. // Need to move cursor
  8088. if (this._clickedCoordinate) {
  8089. var rightPosition = this._scrollLeft + this._textWidth;
  8090. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  8091. var currentSize = 0;
  8092. this._cursorOffset = 0;
  8093. var previousDist = 0;
  8094. do {
  8095. if (this._cursorOffset) {
  8096. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  8097. }
  8098. this._cursorOffset++;
  8099. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  8100. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  8101. // Find closest move
  8102. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8103. this._cursorOffset--;
  8104. }
  8105. this._blinkIsEven = false;
  8106. this._clickedCoordinate = null;
  8107. }
  8108. // Render cursor
  8109. if (!this._blinkIsEven) {
  8110. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  8111. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8112. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8113. if (cursorLeft < clipTextLeft) {
  8114. this._scrollLeft += (clipTextLeft - cursorLeft);
  8115. cursorLeft = clipTextLeft;
  8116. this._markAsDirty();
  8117. }
  8118. else if (cursorLeft > clipTextLeft + availableWidth) {
  8119. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8120. cursorLeft = clipTextLeft + availableWidth;
  8121. this._markAsDirty();
  8122. }
  8123. if (!this._isTextHighlightOn) {
  8124. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8125. }
  8126. }
  8127. clearTimeout(this._blinkTimeout);
  8128. this._blinkTimeout = setTimeout(function () {
  8129. _this._blinkIsEven = !_this._blinkIsEven;
  8130. _this._markAsDirty();
  8131. }, 500);
  8132. //show the highlighted text
  8133. if (this._isTextHighlightOn) {
  8134. clearTimeout(this._blinkTimeout);
  8135. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  8136. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8137. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8138. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8139. if (highlightCursorLeft < clipTextLeft) {
  8140. width = width - (clipTextLeft - highlightCursorLeft);
  8141. if (!width) {
  8142. // when using left arrow on text.length > availableWidth;
  8143. // assigns the width of the first letter after clipTextLeft
  8144. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  8145. }
  8146. highlightCursorLeft = clipTextLeft;
  8147. }
  8148. //for transparancy
  8149. context.globalAlpha = this._highligherOpacity;
  8150. context.fillStyle = this._textHighlightColor;
  8151. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8152. context.globalAlpha = 1.0;
  8153. }
  8154. }
  8155. context.restore();
  8156. // Border
  8157. if (this._thickness) {
  8158. if (this._isFocused) {
  8159. if (this.focusedColor) {
  8160. context.strokeStyle = this.focusedColor;
  8161. }
  8162. }
  8163. else {
  8164. if (this.color) {
  8165. context.strokeStyle = this.color;
  8166. }
  8167. }
  8168. context.lineWidth = this._thickness;
  8169. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8170. }
  8171. context.restore();
  8172. };
  8173. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8174. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8175. return false;
  8176. }
  8177. this._clickedCoordinate = coordinates.x;
  8178. this._isTextHighlightOn = false;
  8179. this._highlightedText = "";
  8180. this._cursorIndex = -1;
  8181. this._isPointerDown = true;
  8182. this._host._capturingControl[pointerId] = this;
  8183. if (this._host.focusedControl === this) {
  8184. // Move cursor
  8185. clearTimeout(this._blinkTimeout);
  8186. this._markAsDirty();
  8187. return true;
  8188. }
  8189. if (!this._isEnabled) {
  8190. return false;
  8191. }
  8192. this._host.focusedControl = this;
  8193. return true;
  8194. };
  8195. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  8196. if (this._host.focusedControl === this && this._isPointerDown) {
  8197. this._clickedCoordinate = coordinates.x;
  8198. this._markAsDirty();
  8199. this._updateValueFromCursorIndex(this._cursorOffset);
  8200. }
  8201. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  8202. };
  8203. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8204. this._isPointerDown = false;
  8205. delete this._host._capturingControl[pointerId];
  8206. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8207. };
  8208. InputText.prototype._beforeRenderText = function (text) {
  8209. return text;
  8210. };
  8211. InputText.prototype.dispose = function () {
  8212. _super.prototype.dispose.call(this);
  8213. this.onBlurObservable.clear();
  8214. this.onFocusObservable.clear();
  8215. this.onTextChangedObservable.clear();
  8216. this.onTextCopyObservable.clear();
  8217. this.onTextCutObservable.clear();
  8218. this.onTextPasteObservable.clear();
  8219. this.onTextHighlightObservable.clear();
  8220. this.onKeyboardEventProcessedObservable.clear();
  8221. };
  8222. return InputText;
  8223. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8224. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8225. /***/ }),
  8226. /***/ "./2D/controls/line.ts":
  8227. /*!*****************************!*\
  8228. !*** ./2D/controls/line.ts ***!
  8229. \*****************************/
  8230. /*! exports provided: Line */
  8231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8232. "use strict";
  8233. __webpack_require__.r(__webpack_exports__);
  8234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8235. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8236. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  8237. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8238. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8239. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8240. /** Class used to render 2D lines */
  8241. var Line = /** @class */ (function (_super) {
  8242. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8243. /**
  8244. * Creates a new Line
  8245. * @param name defines the control name
  8246. */
  8247. function Line(name) {
  8248. var _this = _super.call(this, name) || this;
  8249. _this.name = name;
  8250. _this._lineWidth = 1;
  8251. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8252. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8253. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8254. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8255. _this._dash = new Array();
  8256. _this._automaticSize = true;
  8257. _this.isHitTestVisible = false;
  8258. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8259. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8260. return _this;
  8261. }
  8262. Object.defineProperty(Line.prototype, "dash", {
  8263. /** Gets or sets the dash pattern */
  8264. get: function () {
  8265. return this._dash;
  8266. },
  8267. set: function (value) {
  8268. if (this._dash === value) {
  8269. return;
  8270. }
  8271. this._dash = value;
  8272. this._markAsDirty();
  8273. },
  8274. enumerable: false,
  8275. configurable: true
  8276. });
  8277. Object.defineProperty(Line.prototype, "connectedControl", {
  8278. /** Gets or sets the control connected with the line end */
  8279. get: function () {
  8280. return this._connectedControl;
  8281. },
  8282. set: function (value) {
  8283. var _this = this;
  8284. if (this._connectedControl === value) {
  8285. return;
  8286. }
  8287. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8288. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8289. this._connectedControlDirtyObserver = null;
  8290. }
  8291. if (value) {
  8292. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8293. }
  8294. this._connectedControl = value;
  8295. this._markAsDirty();
  8296. },
  8297. enumerable: false,
  8298. configurable: true
  8299. });
  8300. Object.defineProperty(Line.prototype, "x1", {
  8301. /** Gets or sets start coordinates on X axis */
  8302. get: function () {
  8303. return this._x1.toString(this._host);
  8304. },
  8305. set: function (value) {
  8306. if (this._x1.toString(this._host) === value) {
  8307. return;
  8308. }
  8309. if (this._x1.fromString(value)) {
  8310. this._markAsDirty();
  8311. }
  8312. },
  8313. enumerable: false,
  8314. configurable: true
  8315. });
  8316. Object.defineProperty(Line.prototype, "y1", {
  8317. /** Gets or sets start coordinates on Y axis */
  8318. get: function () {
  8319. return this._y1.toString(this._host);
  8320. },
  8321. set: function (value) {
  8322. if (this._y1.toString(this._host) === value) {
  8323. return;
  8324. }
  8325. if (this._y1.fromString(value)) {
  8326. this._markAsDirty();
  8327. }
  8328. },
  8329. enumerable: false,
  8330. configurable: true
  8331. });
  8332. Object.defineProperty(Line.prototype, "x2", {
  8333. /** Gets or sets end coordinates on X axis */
  8334. get: function () {
  8335. return this._x2.toString(this._host);
  8336. },
  8337. set: function (value) {
  8338. if (this._x2.toString(this._host) === value) {
  8339. return;
  8340. }
  8341. if (this._x2.fromString(value)) {
  8342. this._markAsDirty();
  8343. }
  8344. },
  8345. enumerable: false,
  8346. configurable: true
  8347. });
  8348. Object.defineProperty(Line.prototype, "y2", {
  8349. /** Gets or sets end coordinates on Y axis */
  8350. get: function () {
  8351. return this._y2.toString(this._host);
  8352. },
  8353. set: function (value) {
  8354. if (this._y2.toString(this._host) === value) {
  8355. return;
  8356. }
  8357. if (this._y2.fromString(value)) {
  8358. this._markAsDirty();
  8359. }
  8360. },
  8361. enumerable: false,
  8362. configurable: true
  8363. });
  8364. Object.defineProperty(Line.prototype, "lineWidth", {
  8365. /** Gets or sets line width */
  8366. get: function () {
  8367. return this._lineWidth;
  8368. },
  8369. set: function (value) {
  8370. if (this._lineWidth === value) {
  8371. return;
  8372. }
  8373. this._lineWidth = value;
  8374. this._markAsDirty();
  8375. },
  8376. enumerable: false,
  8377. configurable: true
  8378. });
  8379. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8380. /** Gets or sets horizontal alignment */
  8381. set: function (value) {
  8382. return;
  8383. },
  8384. enumerable: false,
  8385. configurable: true
  8386. });
  8387. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8388. /** Gets or sets vertical alignment */
  8389. set: function (value) {
  8390. return;
  8391. },
  8392. enumerable: false,
  8393. configurable: true
  8394. });
  8395. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8396. get: function () {
  8397. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8398. },
  8399. enumerable: false,
  8400. configurable: true
  8401. });
  8402. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8403. get: function () {
  8404. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8405. },
  8406. enumerable: false,
  8407. configurable: true
  8408. });
  8409. Line.prototype._getTypeName = function () {
  8410. return "Line";
  8411. };
  8412. Line.prototype._draw = function (context) {
  8413. context.save();
  8414. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8415. context.shadowColor = this.shadowColor;
  8416. context.shadowBlur = this.shadowBlur;
  8417. context.shadowOffsetX = this.shadowOffsetX;
  8418. context.shadowOffsetY = this.shadowOffsetY;
  8419. }
  8420. this._applyStates(context);
  8421. context.strokeStyle = this.color;
  8422. context.lineWidth = this._lineWidth;
  8423. context.setLineDash(this._dash);
  8424. context.beginPath();
  8425. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8426. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8427. context.stroke();
  8428. context.restore();
  8429. };
  8430. Line.prototype._measure = function () {
  8431. // Width / Height
  8432. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8433. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8434. };
  8435. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8436. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8437. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8438. };
  8439. /**
  8440. * Move one end of the line given 3D cartesian coordinates.
  8441. * @param position Targeted world position
  8442. * @param scene Scene
  8443. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8444. */
  8445. Line.prototype.moveToVector3 = function (position, scene, end) {
  8446. if (end === void 0) { end = false; }
  8447. if (!this._host || this.parent !== this._host._rootContainer) {
  8448. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8449. return;
  8450. }
  8451. var globalViewport = this._host._getGlobalViewport(scene);
  8452. var projectedPosition = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8453. this._moveToProjectedPosition(projectedPosition, end);
  8454. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8455. this.notRenderable = true;
  8456. return;
  8457. }
  8458. this.notRenderable = false;
  8459. };
  8460. /**
  8461. * Move one end of the line to a position in screen absolute space.
  8462. * @param projectedPosition Position in screen absolute space (X, Y)
  8463. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8464. */
  8465. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8466. if (end === void 0) { end = false; }
  8467. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8468. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8469. if (end) {
  8470. this.x2 = x;
  8471. this.y2 = y;
  8472. this._x2.ignoreAdaptiveScaling = true;
  8473. this._y2.ignoreAdaptiveScaling = true;
  8474. }
  8475. else {
  8476. this.x1 = x;
  8477. this.y1 = y;
  8478. this._x1.ignoreAdaptiveScaling = true;
  8479. this._y1.ignoreAdaptiveScaling = true;
  8480. }
  8481. };
  8482. return Line;
  8483. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8484. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8485. /***/ }),
  8486. /***/ "./2D/controls/multiLine.ts":
  8487. /*!**********************************!*\
  8488. !*** ./2D/controls/multiLine.ts ***!
  8489. \**********************************/
  8490. /*! exports provided: MultiLine */
  8491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8492. "use strict";
  8493. __webpack_require__.r(__webpack_exports__);
  8494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8495. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8496. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Maths/math.vector");
  8497. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8498. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8499. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8500. /**
  8501. * Class used to create multi line control
  8502. */
  8503. var MultiLine = /** @class */ (function (_super) {
  8504. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8505. /**
  8506. * Creates a new MultiLine
  8507. * @param name defines the control name
  8508. */
  8509. function MultiLine(name) {
  8510. var _this = _super.call(this, name) || this;
  8511. _this.name = name;
  8512. _this._lineWidth = 1;
  8513. /** Function called when a point is updated */
  8514. _this.onPointUpdate = function () {
  8515. _this._markAsDirty();
  8516. };
  8517. _this._automaticSize = true;
  8518. _this.isHitTestVisible = false;
  8519. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8520. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8521. _this._dash = [];
  8522. _this._points = [];
  8523. return _this;
  8524. }
  8525. Object.defineProperty(MultiLine.prototype, "dash", {
  8526. /** Gets or sets dash pattern */
  8527. get: function () {
  8528. return this._dash;
  8529. },
  8530. set: function (value) {
  8531. if (this._dash === value) {
  8532. return;
  8533. }
  8534. this._dash = value;
  8535. this._markAsDirty();
  8536. },
  8537. enumerable: false,
  8538. configurable: true
  8539. });
  8540. /**
  8541. * Gets point stored at specified index
  8542. * @param index defines the index to look for
  8543. * @returns the requested point if found
  8544. */
  8545. MultiLine.prototype.getAt = function (index) {
  8546. if (!this._points[index]) {
  8547. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8548. }
  8549. return this._points[index];
  8550. };
  8551. /**
  8552. * Adds new points to the point collection
  8553. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8554. * @returns the list of created MultiLinePoint
  8555. */
  8556. MultiLine.prototype.add = function () {
  8557. var _this = this;
  8558. var items = [];
  8559. for (var _i = 0; _i < arguments.length; _i++) {
  8560. items[_i] = arguments[_i];
  8561. }
  8562. return items.map(function (item) { return _this.push(item); });
  8563. };
  8564. /**
  8565. * Adds a new point to the point collection
  8566. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8567. * @returns the created MultiLinePoint
  8568. */
  8569. MultiLine.prototype.push = function (item) {
  8570. var point = this.getAt(this._points.length);
  8571. if (item == null) {
  8572. return point;
  8573. }
  8574. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8575. point.mesh = item;
  8576. }
  8577. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8578. point.control = item;
  8579. }
  8580. else if (item.x != null && item.y != null) {
  8581. point.x = item.x;
  8582. point.y = item.y;
  8583. }
  8584. return point;
  8585. };
  8586. /**
  8587. * Remove a specific value or point from the active point collection
  8588. * @param value defines the value or point to remove
  8589. */
  8590. MultiLine.prototype.remove = function (value) {
  8591. var index;
  8592. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8593. index = this._points.indexOf(value);
  8594. if (index === -1) {
  8595. return;
  8596. }
  8597. }
  8598. else {
  8599. index = value;
  8600. }
  8601. var point = this._points[index];
  8602. if (!point) {
  8603. return;
  8604. }
  8605. point.dispose();
  8606. this._points.splice(index, 1);
  8607. };
  8608. /**
  8609. * Resets this object to initial state (no point)
  8610. */
  8611. MultiLine.prototype.reset = function () {
  8612. while (this._points.length > 0) {
  8613. this.remove(this._points.length - 1);
  8614. }
  8615. };
  8616. /**
  8617. * Resets all links
  8618. */
  8619. MultiLine.prototype.resetLinks = function () {
  8620. this._points.forEach(function (point) {
  8621. if (point != null) {
  8622. point.resetLinks();
  8623. }
  8624. });
  8625. };
  8626. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8627. /** Gets or sets line width */
  8628. get: function () {
  8629. return this._lineWidth;
  8630. },
  8631. set: function (value) {
  8632. if (this._lineWidth === value) {
  8633. return;
  8634. }
  8635. this._lineWidth = value;
  8636. this._markAsDirty();
  8637. },
  8638. enumerable: false,
  8639. configurable: true
  8640. });
  8641. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8642. set: function (value) {
  8643. return;
  8644. },
  8645. enumerable: false,
  8646. configurable: true
  8647. });
  8648. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8649. set: function (value) {
  8650. return;
  8651. },
  8652. enumerable: false,
  8653. configurable: true
  8654. });
  8655. MultiLine.prototype._getTypeName = function () {
  8656. return "MultiLine";
  8657. };
  8658. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8659. context.save();
  8660. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8661. context.shadowColor = this.shadowColor;
  8662. context.shadowBlur = this.shadowBlur;
  8663. context.shadowOffsetX = this.shadowOffsetX;
  8664. context.shadowOffsetY = this.shadowOffsetY;
  8665. }
  8666. this._applyStates(context);
  8667. context.strokeStyle = this.color;
  8668. context.lineWidth = this._lineWidth;
  8669. context.setLineDash(this._dash);
  8670. context.beginPath();
  8671. var first = true; //first index is not necessarily 0
  8672. this._points.forEach(function (point) {
  8673. if (!point) {
  8674. return;
  8675. }
  8676. if (first) {
  8677. context.moveTo(point._point.x, point._point.y);
  8678. first = false;
  8679. }
  8680. else {
  8681. context.lineTo(point._point.x, point._point.y);
  8682. }
  8683. });
  8684. context.stroke();
  8685. context.restore();
  8686. };
  8687. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8688. var _this = this;
  8689. this._minX = null;
  8690. this._minY = null;
  8691. this._maxX = null;
  8692. this._maxY = null;
  8693. this._points.forEach(function (point, index) {
  8694. if (!point) {
  8695. return;
  8696. }
  8697. point.translate();
  8698. if (_this._minX == null || point._point.x < _this._minX) {
  8699. _this._minX = point._point.x;
  8700. }
  8701. if (_this._minY == null || point._point.y < _this._minY) {
  8702. _this._minY = point._point.y;
  8703. }
  8704. if (_this._maxX == null || point._point.x > _this._maxX) {
  8705. _this._maxX = point._point.x;
  8706. }
  8707. if (_this._maxY == null || point._point.y > _this._maxY) {
  8708. _this._maxY = point._point.y;
  8709. }
  8710. });
  8711. if (this._minX == null) {
  8712. this._minX = 0;
  8713. }
  8714. if (this._minY == null) {
  8715. this._minY = 0;
  8716. }
  8717. if (this._maxX == null) {
  8718. this._maxX = 0;
  8719. }
  8720. if (this._maxY == null) {
  8721. this._maxY = 0;
  8722. }
  8723. };
  8724. MultiLine.prototype._measure = function () {
  8725. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8726. return;
  8727. }
  8728. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8729. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8730. };
  8731. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8732. if (this._minX == null || this._minY == null) {
  8733. return;
  8734. }
  8735. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8736. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8737. };
  8738. MultiLine.prototype.dispose = function () {
  8739. this.reset();
  8740. _super.prototype.dispose.call(this);
  8741. };
  8742. return MultiLine;
  8743. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8744. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8745. /***/ }),
  8746. /***/ "./2D/controls/radioButton.ts":
  8747. /*!************************************!*\
  8748. !*** ./2D/controls/radioButton.ts ***!
  8749. \************************************/
  8750. /*! exports provided: RadioButton */
  8751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8752. "use strict";
  8753. __webpack_require__.r(__webpack_exports__);
  8754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8755. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8756. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  8757. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8758. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8759. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8760. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8761. /**
  8762. * Class used to create radio button controls
  8763. */
  8764. var RadioButton = /** @class */ (function (_super) {
  8765. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8766. /**
  8767. * Creates a new RadioButton
  8768. * @param name defines the control name
  8769. */
  8770. function RadioButton(name) {
  8771. var _this = _super.call(this, name) || this;
  8772. _this.name = name;
  8773. _this._isChecked = false;
  8774. _this._background = "black";
  8775. _this._checkSizeRatio = 0.8;
  8776. _this._thickness = 1;
  8777. /** Gets or sets group name */
  8778. _this.group = "";
  8779. /** Observable raised when isChecked is changed */
  8780. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8781. _this.isPointerBlocker = true;
  8782. return _this;
  8783. }
  8784. Object.defineProperty(RadioButton.prototype, "thickness", {
  8785. /** Gets or sets border thickness */
  8786. get: function () {
  8787. return this._thickness;
  8788. },
  8789. set: function (value) {
  8790. if (this._thickness === value) {
  8791. return;
  8792. }
  8793. this._thickness = value;
  8794. this._markAsDirty();
  8795. },
  8796. enumerable: false,
  8797. configurable: true
  8798. });
  8799. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8800. /** Gets or sets a value indicating the ratio between overall size and check size */
  8801. get: function () {
  8802. return this._checkSizeRatio;
  8803. },
  8804. set: function (value) {
  8805. value = Math.max(Math.min(1, value), 0);
  8806. if (this._checkSizeRatio === value) {
  8807. return;
  8808. }
  8809. this._checkSizeRatio = value;
  8810. this._markAsDirty();
  8811. },
  8812. enumerable: false,
  8813. configurable: true
  8814. });
  8815. Object.defineProperty(RadioButton.prototype, "background", {
  8816. /** Gets or sets background color */
  8817. get: function () {
  8818. return this._background;
  8819. },
  8820. set: function (value) {
  8821. if (this._background === value) {
  8822. return;
  8823. }
  8824. this._background = value;
  8825. this._markAsDirty();
  8826. },
  8827. enumerable: false,
  8828. configurable: true
  8829. });
  8830. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8831. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8832. get: function () {
  8833. return this._isChecked;
  8834. },
  8835. set: function (value) {
  8836. var _this = this;
  8837. if (this._isChecked === value) {
  8838. return;
  8839. }
  8840. this._isChecked = value;
  8841. this._markAsDirty();
  8842. this.onIsCheckedChangedObservable.notifyObservers(value);
  8843. if (this._isChecked && this._host) {
  8844. // Update all controls from same group
  8845. this._host.executeOnAllControls(function (control) {
  8846. if (control === _this) {
  8847. return;
  8848. }
  8849. if (control.group === undefined) {
  8850. return;
  8851. }
  8852. var childRadio = control;
  8853. if (childRadio.group === _this.group) {
  8854. childRadio.isChecked = false;
  8855. }
  8856. });
  8857. }
  8858. },
  8859. enumerable: false,
  8860. configurable: true
  8861. });
  8862. RadioButton.prototype._getTypeName = function () {
  8863. return "RadioButton";
  8864. };
  8865. RadioButton.prototype._draw = function (context) {
  8866. context.save();
  8867. this._applyStates(context);
  8868. var actualWidth = this._currentMeasure.width - this._thickness;
  8869. var actualHeight = this._currentMeasure.height - this._thickness;
  8870. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8871. context.shadowColor = this.shadowColor;
  8872. context.shadowBlur = this.shadowBlur;
  8873. context.shadowOffsetX = this.shadowOffsetX;
  8874. context.shadowOffsetY = this.shadowOffsetY;
  8875. }
  8876. // Outer
  8877. _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);
  8878. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8879. context.fill();
  8880. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8881. context.shadowBlur = 0;
  8882. context.shadowOffsetX = 0;
  8883. context.shadowOffsetY = 0;
  8884. }
  8885. context.strokeStyle = this.color;
  8886. context.lineWidth = this._thickness;
  8887. context.stroke();
  8888. // Inner
  8889. if (this._isChecked) {
  8890. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8891. var offsetWidth = actualWidth * this._checkSizeRatio;
  8892. var offseHeight = actualHeight * this._checkSizeRatio;
  8893. _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);
  8894. context.fill();
  8895. }
  8896. context.restore();
  8897. };
  8898. // Events
  8899. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8900. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8901. return false;
  8902. }
  8903. if (!this.isChecked) {
  8904. this.isChecked = true;
  8905. }
  8906. return true;
  8907. };
  8908. /**
  8909. * Utility function to easily create a radio button with a header
  8910. * @param title defines the label to use for the header
  8911. * @param group defines the group to use for the radio button
  8912. * @param isChecked defines the initial state of the radio button
  8913. * @param onValueChanged defines the callback to call when value changes
  8914. * @returns a StackPanel containing the radio button and a textBlock
  8915. */
  8916. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8917. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8918. panel.isVertical = false;
  8919. panel.height = "30px";
  8920. var radio = new RadioButton();
  8921. radio.width = "20px";
  8922. radio.height = "20px";
  8923. radio.isChecked = isChecked;
  8924. radio.color = "green";
  8925. radio.group = group;
  8926. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8927. panel.addControl(radio);
  8928. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8929. header.text = title;
  8930. header.width = "180px";
  8931. header.paddingLeft = "5px";
  8932. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8933. header.color = "white";
  8934. panel.addControl(header);
  8935. return panel;
  8936. };
  8937. return RadioButton;
  8938. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8939. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8940. /***/ }),
  8941. /***/ "./2D/controls/rectangle.ts":
  8942. /*!**********************************!*\
  8943. !*** ./2D/controls/rectangle.ts ***!
  8944. \**********************************/
  8945. /*! exports provided: Rectangle */
  8946. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8947. "use strict";
  8948. __webpack_require__.r(__webpack_exports__);
  8949. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8950. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8951. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8952. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  8953. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8954. /** Class used to create rectangle container */
  8955. var Rectangle = /** @class */ (function (_super) {
  8956. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8957. /**
  8958. * Creates a new Rectangle
  8959. * @param name defines the control name
  8960. */
  8961. function Rectangle(name) {
  8962. var _this = _super.call(this, name) || this;
  8963. _this.name = name;
  8964. _this._thickness = 1;
  8965. _this._cornerRadius = 0;
  8966. return _this;
  8967. }
  8968. Object.defineProperty(Rectangle.prototype, "thickness", {
  8969. /** Gets or sets border thickness */
  8970. get: function () {
  8971. return this._thickness;
  8972. },
  8973. set: function (value) {
  8974. if (this._thickness === value) {
  8975. return;
  8976. }
  8977. this._thickness = value;
  8978. this._markAsDirty();
  8979. },
  8980. enumerable: false,
  8981. configurable: true
  8982. });
  8983. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8984. /** Gets or sets the corner radius angle */
  8985. get: function () {
  8986. return this._cornerRadius;
  8987. },
  8988. set: function (value) {
  8989. if (value < 0) {
  8990. value = 0;
  8991. }
  8992. if (this._cornerRadius === value) {
  8993. return;
  8994. }
  8995. this._cornerRadius = value;
  8996. this._markAsDirty();
  8997. },
  8998. enumerable: false,
  8999. configurable: true
  9000. });
  9001. Rectangle.prototype._getTypeName = function () {
  9002. return "Rectangle";
  9003. };
  9004. Rectangle.prototype._localDraw = function (context) {
  9005. context.save();
  9006. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9007. context.shadowColor = this.shadowColor;
  9008. context.shadowBlur = this.shadowBlur;
  9009. context.shadowOffsetX = this.shadowOffsetX;
  9010. context.shadowOffsetY = this.shadowOffsetY;
  9011. }
  9012. if (this._background) {
  9013. context.fillStyle = this._background;
  9014. if (this._cornerRadius) {
  9015. this._drawRoundedRect(context, this._thickness / 2);
  9016. context.fill();
  9017. }
  9018. else {
  9019. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  9020. }
  9021. }
  9022. if (this._thickness) {
  9023. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9024. context.shadowBlur = 0;
  9025. context.shadowOffsetX = 0;
  9026. context.shadowOffsetY = 0;
  9027. }
  9028. if (this.color) {
  9029. context.strokeStyle = this.color;
  9030. }
  9031. context.lineWidth = this._thickness;
  9032. if (this._cornerRadius) {
  9033. this._drawRoundedRect(context, this._thickness / 2);
  9034. context.stroke();
  9035. }
  9036. else {
  9037. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  9038. }
  9039. }
  9040. context.restore();
  9041. };
  9042. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  9043. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9044. this._measureForChildren.width -= 2 * this._thickness;
  9045. this._measureForChildren.height -= 2 * this._thickness;
  9046. this._measureForChildren.left += this._thickness;
  9047. this._measureForChildren.top += this._thickness;
  9048. };
  9049. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  9050. if (offset === void 0) { offset = 0; }
  9051. var x = this._currentMeasure.left + offset;
  9052. var y = this._currentMeasure.top + offset;
  9053. var width = this._currentMeasure.width - offset * 2;
  9054. var height = this._currentMeasure.height - offset * 2;
  9055. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  9056. context.beginPath();
  9057. context.moveTo(x + radius, y);
  9058. context.lineTo(x + width - radius, y);
  9059. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  9060. context.lineTo(x + width, y + height - radius);
  9061. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  9062. context.lineTo(x + radius, y + height);
  9063. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  9064. context.lineTo(x, y + radius);
  9065. context.quadraticCurveTo(x, y, x + radius, y);
  9066. context.closePath();
  9067. };
  9068. Rectangle.prototype._clipForChildren = function (context) {
  9069. if (this._cornerRadius) {
  9070. this._drawRoundedRect(context, this._thickness);
  9071. context.clip();
  9072. }
  9073. };
  9074. return Rectangle;
  9075. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9076. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  9077. /***/ }),
  9078. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  9079. /*!***************************************************!*\
  9080. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  9081. \***************************************************/
  9082. /*! exports provided: ScrollViewer */
  9083. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9084. "use strict";
  9085. __webpack_require__.r(__webpack_exports__);
  9086. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  9087. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9088. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  9089. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  9090. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9091. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  9092. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  9093. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  9094. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  9095. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  9096. /**
  9097. * Class used to hold a viewer window and sliders in a grid
  9098. */
  9099. var ScrollViewer = /** @class */ (function (_super) {
  9100. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  9101. /**
  9102. * Creates a new ScrollViewer
  9103. * @param name of ScrollViewer
  9104. */
  9105. function ScrollViewer(name, isImageBased) {
  9106. var _this = _super.call(this, name) || this;
  9107. _this._barSize = 20;
  9108. _this._pointerIsOver = false;
  9109. _this._wheelPrecision = 0.05;
  9110. _this._thumbLength = 0.5;
  9111. _this._thumbHeight = 1;
  9112. _this._barImageHeight = 1;
  9113. _this._horizontalBarImageHeight = 1;
  9114. _this._verticalBarImageHeight = 1;
  9115. _this._oldWindowContentsWidth = 0;
  9116. _this._oldWindowContentsHeight = 0;
  9117. _this._forceHorizontalBar = false;
  9118. _this._forceVerticalBar = false;
  9119. _this._useImageBar = isImageBased ? isImageBased : false;
  9120. _this.onDirtyObservable.add(function () {
  9121. _this._horizontalBarSpace.color = _this.color;
  9122. _this._verticalBarSpace.color = _this.color;
  9123. _this._dragSpace.color = _this.color;
  9124. });
  9125. _this.onPointerEnterObservable.add(function () {
  9126. _this._pointerIsOver = true;
  9127. });
  9128. _this.onPointerOutObservable.add(function () {
  9129. _this._pointerIsOver = false;
  9130. });
  9131. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9132. if (_this._useImageBar) {
  9133. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9134. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9135. }
  9136. else {
  9137. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9138. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9139. }
  9140. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9141. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9142. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9143. _this._grid.addColumnDefinition(1);
  9144. _this._grid.addColumnDefinition(0, true);
  9145. _this._grid.addRowDefinition(1);
  9146. _this._grid.addRowDefinition(0, true);
  9147. _super.prototype.addControl.call(_this, _this._grid);
  9148. _this._grid.addControl(_this._window, 0, 0);
  9149. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9150. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9151. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9152. _this._verticalBarSpace.thickness = 1;
  9153. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9154. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9155. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9156. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9157. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9158. _this._horizontalBarSpace.thickness = 1;
  9159. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9160. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9161. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9162. _this._dragSpace.thickness = 1;
  9163. _this._grid.addControl(_this._dragSpace, 1, 1);
  9164. // Colors
  9165. if (!_this._useImageBar) {
  9166. _this.barColor = "grey";
  9167. _this.barBackground = "transparent";
  9168. }
  9169. return _this;
  9170. }
  9171. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9172. /**
  9173. * Gets the horizontal scrollbar
  9174. */
  9175. get: function () {
  9176. return this._horizontalBar;
  9177. },
  9178. enumerable: false,
  9179. configurable: true
  9180. });
  9181. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9182. /**
  9183. * Gets the vertical scrollbar
  9184. */
  9185. get: function () {
  9186. return this._verticalBar;
  9187. },
  9188. enumerable: false,
  9189. configurable: true
  9190. });
  9191. /**
  9192. * Adds a new control to the current container
  9193. * @param control defines the control to add
  9194. * @returns the current container
  9195. */
  9196. ScrollViewer.prototype.addControl = function (control) {
  9197. if (!control) {
  9198. return this;
  9199. }
  9200. this._window.addControl(control);
  9201. return this;
  9202. };
  9203. /**
  9204. * Removes a control from the current container
  9205. * @param control defines the control to remove
  9206. * @returns the current container
  9207. */
  9208. ScrollViewer.prototype.removeControl = function (control) {
  9209. this._window.removeControl(control);
  9210. return this;
  9211. };
  9212. Object.defineProperty(ScrollViewer.prototype, "children", {
  9213. /** Gets the list of children */
  9214. get: function () {
  9215. return this._window.children;
  9216. },
  9217. enumerable: false,
  9218. configurable: true
  9219. });
  9220. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9221. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9222. var child = _a[_i];
  9223. child._markMatrixAsDirty();
  9224. }
  9225. };
  9226. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9227. /**
  9228. * Freezes or unfreezes the controls in the window.
  9229. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9230. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9231. */
  9232. get: function () {
  9233. return this._window.freezeControls;
  9234. },
  9235. set: function (value) {
  9236. this._window.freezeControls = value;
  9237. },
  9238. enumerable: false,
  9239. configurable: true
  9240. });
  9241. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9242. /** Gets the bucket width */
  9243. get: function () {
  9244. return this._window.bucketWidth;
  9245. },
  9246. enumerable: false,
  9247. configurable: true
  9248. });
  9249. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9250. /** Gets the bucket height */
  9251. get: function () {
  9252. return this._window.bucketHeight;
  9253. },
  9254. enumerable: false,
  9255. configurable: true
  9256. });
  9257. /**
  9258. * Sets the bucket sizes.
  9259. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9260. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9261. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9262. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9263. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9264. * used), that's why it is not enabled by default.
  9265. * @param width width of the bucket
  9266. * @param height height of the bucket
  9267. */
  9268. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9269. this._window.setBucketSizes(width, height);
  9270. };
  9271. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9272. /**
  9273. * Forces the horizontal scroll bar to be displayed
  9274. */
  9275. get: function () {
  9276. return this._forceHorizontalBar;
  9277. },
  9278. set: function (value) {
  9279. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9280. this._horizontalBar.isVisible = value;
  9281. this._forceHorizontalBar = value;
  9282. },
  9283. enumerable: false,
  9284. configurable: true
  9285. });
  9286. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9287. /**
  9288. * Forces the vertical scroll bar to be displayed
  9289. */
  9290. get: function () {
  9291. return this._forceVerticalBar;
  9292. },
  9293. set: function (value) {
  9294. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9295. this._verticalBar.isVisible = value;
  9296. this._forceVerticalBar = value;
  9297. },
  9298. enumerable: false,
  9299. configurable: true
  9300. });
  9301. /** Reset the scroll viewer window to initial size */
  9302. ScrollViewer.prototype.resetWindow = function () {
  9303. this._window.width = "100%";
  9304. this._window.height = "100%";
  9305. };
  9306. ScrollViewer.prototype._getTypeName = function () {
  9307. return "ScrollViewer";
  9308. };
  9309. ScrollViewer.prototype._buildClientSizes = function () {
  9310. var ratio = this.host.idealRatio;
  9311. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9312. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9313. this._clientWidth = this._window.parentClientWidth;
  9314. this._clientHeight = this._window.parentClientHeight;
  9315. };
  9316. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9317. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9318. this._buildClientSizes();
  9319. };
  9320. ScrollViewer.prototype._postMeasure = function () {
  9321. _super.prototype._postMeasure.call(this);
  9322. this._updateScroller();
  9323. this._setWindowPosition(false);
  9324. };
  9325. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9326. /**
  9327. * Gets or sets the mouse wheel precision
  9328. * from 0 to 1 with a default value of 0.05
  9329. * */
  9330. get: function () {
  9331. return this._wheelPrecision;
  9332. },
  9333. set: function (value) {
  9334. if (this._wheelPrecision === value) {
  9335. return;
  9336. }
  9337. if (value < 0) {
  9338. value = 0;
  9339. }
  9340. if (value > 1) {
  9341. value = 1;
  9342. }
  9343. this._wheelPrecision = value;
  9344. },
  9345. enumerable: false,
  9346. configurable: true
  9347. });
  9348. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9349. /** Gets or sets the scroll bar container background color */
  9350. get: function () {
  9351. return this._horizontalBarSpace.background;
  9352. },
  9353. set: function (color) {
  9354. if (this._horizontalBarSpace.background === color) {
  9355. return;
  9356. }
  9357. this._horizontalBarSpace.background = color;
  9358. this._verticalBarSpace.background = color;
  9359. },
  9360. enumerable: false,
  9361. configurable: true
  9362. });
  9363. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9364. /** Gets or sets the bar color */
  9365. get: function () {
  9366. return this._barColor;
  9367. },
  9368. set: function (color) {
  9369. if (this._barColor === color) {
  9370. return;
  9371. }
  9372. this._barColor = color;
  9373. this._horizontalBar.color = color;
  9374. this._verticalBar.color = color;
  9375. },
  9376. enumerable: false,
  9377. configurable: true
  9378. });
  9379. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9380. /** Gets or sets the bar image */
  9381. get: function () {
  9382. return this._barImage;
  9383. },
  9384. set: function (value) {
  9385. if (this._barImage === value) {
  9386. return;
  9387. }
  9388. this._barImage = value;
  9389. var hb = this._horizontalBar;
  9390. var vb = this._verticalBar;
  9391. hb.thumbImage = value;
  9392. vb.thumbImage = value;
  9393. },
  9394. enumerable: false,
  9395. configurable: true
  9396. });
  9397. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9398. /** Gets or sets the horizontal bar image */
  9399. get: function () {
  9400. return this._horizontalBarImage;
  9401. },
  9402. set: function (value) {
  9403. if (this._horizontalBarImage === value) {
  9404. return;
  9405. }
  9406. this._horizontalBarImage = value;
  9407. var hb = this._horizontalBar;
  9408. hb.thumbImage = value;
  9409. },
  9410. enumerable: false,
  9411. configurable: true
  9412. });
  9413. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9414. /** Gets or sets the vertical bar image */
  9415. get: function () {
  9416. return this._verticalBarImage;
  9417. },
  9418. set: function (value) {
  9419. if (this._verticalBarImage === value) {
  9420. return;
  9421. }
  9422. this._verticalBarImage = value;
  9423. var vb = this._verticalBar;
  9424. vb.thumbImage = value;
  9425. },
  9426. enumerable: false,
  9427. configurable: true
  9428. });
  9429. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9430. /** Gets or sets the size of the bar */
  9431. get: function () {
  9432. return this._barSize;
  9433. },
  9434. set: function (value) {
  9435. if (this._barSize === value) {
  9436. return;
  9437. }
  9438. this._barSize = value;
  9439. this._markAsDirty();
  9440. if (this._horizontalBar.isVisible) {
  9441. this._grid.setRowDefinition(1, this._barSize, true);
  9442. }
  9443. if (this._verticalBar.isVisible) {
  9444. this._grid.setColumnDefinition(1, this._barSize, true);
  9445. }
  9446. },
  9447. enumerable: false,
  9448. configurable: true
  9449. });
  9450. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9451. /** Gets or sets the length of the thumb */
  9452. get: function () {
  9453. return this._thumbLength;
  9454. },
  9455. set: function (value) {
  9456. if (this._thumbLength === value) {
  9457. return;
  9458. }
  9459. if (value <= 0) {
  9460. value = 0.1;
  9461. }
  9462. if (value > 1) {
  9463. value = 1;
  9464. }
  9465. this._thumbLength = value;
  9466. var hb = this._horizontalBar;
  9467. var vb = this._verticalBar;
  9468. hb.thumbLength = value;
  9469. vb.thumbLength = value;
  9470. this._markAsDirty();
  9471. },
  9472. enumerable: false,
  9473. configurable: true
  9474. });
  9475. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9476. /** Gets or sets the height of the thumb */
  9477. get: function () {
  9478. return this._thumbHeight;
  9479. },
  9480. set: function (value) {
  9481. if (this._thumbHeight === value) {
  9482. return;
  9483. }
  9484. if (value <= 0) {
  9485. value = 0.1;
  9486. }
  9487. if (value > 1) {
  9488. value = 1;
  9489. }
  9490. this._thumbHeight = value;
  9491. var hb = this._horizontalBar;
  9492. var vb = this._verticalBar;
  9493. hb.thumbHeight = value;
  9494. vb.thumbHeight = value;
  9495. this._markAsDirty();
  9496. },
  9497. enumerable: false,
  9498. configurable: true
  9499. });
  9500. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9501. /** Gets or sets the height of the bar image */
  9502. get: function () {
  9503. return this._barImageHeight;
  9504. },
  9505. set: function (value) {
  9506. if (this._barImageHeight === value) {
  9507. return;
  9508. }
  9509. if (value <= 0) {
  9510. value = 0.1;
  9511. }
  9512. if (value > 1) {
  9513. value = 1;
  9514. }
  9515. this._barImageHeight = value;
  9516. var hb = this._horizontalBar;
  9517. var vb = this._verticalBar;
  9518. hb.barImageHeight = value;
  9519. vb.barImageHeight = value;
  9520. this._markAsDirty();
  9521. },
  9522. enumerable: false,
  9523. configurable: true
  9524. });
  9525. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9526. /** Gets or sets the height of the horizontal bar image */
  9527. get: function () {
  9528. return this._horizontalBarImageHeight;
  9529. },
  9530. set: function (value) {
  9531. if (this._horizontalBarImageHeight === value) {
  9532. return;
  9533. }
  9534. if (value <= 0) {
  9535. value = 0.1;
  9536. }
  9537. if (value > 1) {
  9538. value = 1;
  9539. }
  9540. this._horizontalBarImageHeight = value;
  9541. var hb = this._horizontalBar;
  9542. hb.barImageHeight = value;
  9543. this._markAsDirty();
  9544. },
  9545. enumerable: false,
  9546. configurable: true
  9547. });
  9548. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9549. /** Gets or sets the height of the vertical bar image */
  9550. get: function () {
  9551. return this._verticalBarImageHeight;
  9552. },
  9553. set: function (value) {
  9554. if (this._verticalBarImageHeight === value) {
  9555. return;
  9556. }
  9557. if (value <= 0) {
  9558. value = 0.1;
  9559. }
  9560. if (value > 1) {
  9561. value = 1;
  9562. }
  9563. this._verticalBarImageHeight = value;
  9564. var vb = this._verticalBar;
  9565. vb.barImageHeight = value;
  9566. this._markAsDirty();
  9567. },
  9568. enumerable: false,
  9569. configurable: true
  9570. });
  9571. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9572. /** Gets or sets the bar background */
  9573. get: function () {
  9574. return this._barBackground;
  9575. },
  9576. set: function (color) {
  9577. if (this._barBackground === color) {
  9578. return;
  9579. }
  9580. this._barBackground = color;
  9581. var hb = this._horizontalBar;
  9582. var vb = this._verticalBar;
  9583. hb.background = color;
  9584. vb.background = color;
  9585. this._dragSpace.background = color;
  9586. },
  9587. enumerable: false,
  9588. configurable: true
  9589. });
  9590. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9591. /** Gets or sets the bar background image */
  9592. get: function () {
  9593. return this._barBackgroundImage;
  9594. },
  9595. set: function (value) {
  9596. if (this._barBackgroundImage === value) {
  9597. }
  9598. this._barBackgroundImage = value;
  9599. var hb = this._horizontalBar;
  9600. var vb = this._verticalBar;
  9601. hb.backgroundImage = value;
  9602. vb.backgroundImage = value;
  9603. },
  9604. enumerable: false,
  9605. configurable: true
  9606. });
  9607. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9608. /** Gets or sets the horizontal bar background image */
  9609. get: function () {
  9610. return this._horizontalBarBackgroundImage;
  9611. },
  9612. set: function (value) {
  9613. if (this._horizontalBarBackgroundImage === value) {
  9614. }
  9615. this._horizontalBarBackgroundImage = value;
  9616. var hb = this._horizontalBar;
  9617. hb.backgroundImage = value;
  9618. },
  9619. enumerable: false,
  9620. configurable: true
  9621. });
  9622. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9623. /** Gets or sets the vertical bar background image */
  9624. get: function () {
  9625. return this._verticalBarBackgroundImage;
  9626. },
  9627. set: function (value) {
  9628. if (this._verticalBarBackgroundImage === value) {
  9629. }
  9630. this._verticalBarBackgroundImage = value;
  9631. var vb = this._verticalBar;
  9632. vb.backgroundImage = value;
  9633. },
  9634. enumerable: false,
  9635. configurable: true
  9636. });
  9637. ScrollViewer.prototype._setWindowPosition = function (force) {
  9638. if (force === void 0) { force = true; }
  9639. var ratio = this.host.idealRatio;
  9640. var windowContentsWidth = this._window._currentMeasure.width;
  9641. var windowContentsHeight = this._window._currentMeasure.height;
  9642. if (!force && this._oldWindowContentsWidth === windowContentsWidth && this._oldWindowContentsHeight === windowContentsHeight) {
  9643. return;
  9644. }
  9645. this._oldWindowContentsWidth = windowContentsWidth;
  9646. this._oldWindowContentsHeight = windowContentsHeight;
  9647. var _endLeft = this._clientWidth - windowContentsWidth;
  9648. var _endTop = this._clientHeight - windowContentsHeight;
  9649. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9650. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9651. if (newLeft !== this._window.left) {
  9652. this._window.left = newLeft;
  9653. if (!this.freezeControls) {
  9654. this._rebuildLayout = true;
  9655. }
  9656. }
  9657. if (newTop !== this._window.top) {
  9658. this._window.top = newTop;
  9659. if (!this.freezeControls) {
  9660. this._rebuildLayout = true;
  9661. }
  9662. }
  9663. };
  9664. /** @hidden */
  9665. ScrollViewer.prototype._updateScroller = function () {
  9666. var windowContentsWidth = this._window._currentMeasure.width;
  9667. var windowContentsHeight = this._window._currentMeasure.height;
  9668. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9669. this._grid.setRowDefinition(1, 0, true);
  9670. this._horizontalBar.isVisible = false;
  9671. this._horizontalBar.value = 0;
  9672. this._rebuildLayout = true;
  9673. }
  9674. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9675. this._grid.setRowDefinition(1, this._barSize, true);
  9676. this._horizontalBar.isVisible = true;
  9677. this._rebuildLayout = true;
  9678. }
  9679. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9680. this._grid.setColumnDefinition(1, 0, true);
  9681. this._verticalBar.isVisible = false;
  9682. this._verticalBar.value = 0;
  9683. this._rebuildLayout = true;
  9684. }
  9685. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9686. this._grid.setColumnDefinition(1, this._barSize, true);
  9687. this._verticalBar.isVisible = true;
  9688. this._rebuildLayout = true;
  9689. }
  9690. this._buildClientSizes();
  9691. var ratio = this.host.idealRatio;
  9692. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9693. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9694. };
  9695. ScrollViewer.prototype._link = function (host) {
  9696. _super.prototype._link.call(this, host);
  9697. this._attachWheel();
  9698. };
  9699. /** @hidden */
  9700. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9701. var _this = this;
  9702. barControl.paddingLeft = 0;
  9703. barControl.width = "100%";
  9704. barControl.height = "100%";
  9705. barControl.barOffset = 0;
  9706. barControl.value = 0;
  9707. barControl.maximum = 1;
  9708. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9709. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9710. barControl.isVertical = isVertical;
  9711. barControl.rotation = rotation;
  9712. barControl.isVisible = false;
  9713. barContainer.addControl(barControl);
  9714. barControl.onValueChangedObservable.add(function (value) {
  9715. _this._setWindowPosition();
  9716. });
  9717. };
  9718. /** @hidden */
  9719. ScrollViewer.prototype._attachWheel = function () {
  9720. var _this = this;
  9721. if (!this._host || this._onWheelObserver) {
  9722. return;
  9723. }
  9724. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  9725. if (!_this._pointerIsOver) {
  9726. return;
  9727. }
  9728. if (_this._verticalBar.isVisible == true) {
  9729. if (pi.y < 0 && _this._verticalBar.value > 0) {
  9730. _this._verticalBar.value -= _this._wheelPrecision;
  9731. }
  9732. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9733. _this._verticalBar.value += _this._wheelPrecision;
  9734. }
  9735. }
  9736. if (_this._horizontalBar.isVisible == true) {
  9737. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9738. _this._horizontalBar.value += _this._wheelPrecision;
  9739. }
  9740. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  9741. _this._horizontalBar.value -= _this._wheelPrecision;
  9742. }
  9743. }
  9744. });
  9745. };
  9746. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9747. if (!this.isHighlighted) {
  9748. return;
  9749. }
  9750. _super.prototype._renderHighlightSpecific.call(this, context);
  9751. this._grid._renderHighlightSpecific(context);
  9752. context.restore();
  9753. };
  9754. /** Releases associated resources */
  9755. ScrollViewer.prototype.dispose = function () {
  9756. this.onWheelObservable.remove(this._onWheelObserver);
  9757. this._onWheelObserver = null;
  9758. _super.prototype.dispose.call(this);
  9759. };
  9760. return ScrollViewer;
  9761. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9762. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9763. /***/ }),
  9764. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9765. /*!*********************************************************!*\
  9766. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9767. \*********************************************************/
  9768. /*! exports provided: _ScrollViewerWindow */
  9769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9770. "use strict";
  9771. __webpack_require__.r(__webpack_exports__);
  9772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9773. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9774. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9775. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9776. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9777. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9778. /**
  9779. * Class used to hold a the container for ScrollViewer
  9780. * @hidden
  9781. */
  9782. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9783. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9784. /**
  9785. * Creates a new ScrollViewerWindow
  9786. * @param name of ScrollViewerWindow
  9787. */
  9788. function _ScrollViewerWindow(name) {
  9789. var _this = _super.call(this, name) || this;
  9790. _this._freezeControls = false;
  9791. _this._bucketWidth = 0;
  9792. _this._bucketHeight = 0;
  9793. _this._buckets = {};
  9794. return _this;
  9795. }
  9796. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9797. get: function () {
  9798. return this._freezeControls;
  9799. },
  9800. set: function (value) {
  9801. if (this._freezeControls === value) {
  9802. return;
  9803. }
  9804. if (!value) {
  9805. this._restoreMeasures();
  9806. }
  9807. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9808. this._freezeControls = false;
  9809. var textureSize = this.host.getSize();
  9810. var renderWidth = textureSize.width;
  9811. var renderHeight = textureSize.height;
  9812. var context = this.host.getContext();
  9813. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9814. this.host._numLayoutCalls = 0;
  9815. this.host._rootContainer._layout(measure, context);
  9816. // in freeze mode, prepare children measures accordingly
  9817. if (value) {
  9818. this._updateMeasures();
  9819. if (this._useBuckets()) {
  9820. this._makeBuckets();
  9821. }
  9822. }
  9823. this._freezeControls = value;
  9824. this.host.markAsDirty(); // redraw with the (new) current settings
  9825. },
  9826. enumerable: false,
  9827. configurable: true
  9828. });
  9829. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9830. get: function () {
  9831. return this._bucketWidth;
  9832. },
  9833. enumerable: false,
  9834. configurable: true
  9835. });
  9836. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9837. get: function () {
  9838. return this._bucketHeight;
  9839. },
  9840. enumerable: false,
  9841. configurable: true
  9842. });
  9843. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9844. this._bucketWidth = width;
  9845. this._bucketHeight = height;
  9846. if (this._useBuckets()) {
  9847. if (this._freezeControls) {
  9848. this._makeBuckets();
  9849. }
  9850. }
  9851. else {
  9852. this._buckets = {};
  9853. }
  9854. };
  9855. _ScrollViewerWindow.prototype._useBuckets = function () {
  9856. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9857. };
  9858. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9859. this._buckets = {};
  9860. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9861. this._dispatchInBuckets(this._children);
  9862. this._oldLeft = null;
  9863. this._oldTop = null;
  9864. };
  9865. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9866. for (var i = 0; i < children.length; ++i) {
  9867. var child = children[i];
  9868. var bStartX = Math.max(0, Math.floor((child._customData._origLeft - this._customData.origLeft) / this._bucketWidth)), bEndX = Math.floor((child._customData._origLeft - this._customData.origLeft + child._currentMeasure.width - 1) / this._bucketWidth), bStartY = Math.max(0, Math.floor((child._customData._origTop - this._customData.origTop) / this._bucketHeight)), bEndY = Math.floor((child._customData._origTop - this._customData.origTop + child._currentMeasure.height - 1) / this._bucketHeight);
  9869. while (bStartY <= bEndY) {
  9870. for (var x = bStartX; x <= bEndX; ++x) {
  9871. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9872. if (!lstc) {
  9873. lstc = [];
  9874. this._buckets[bucket] = lstc;
  9875. }
  9876. lstc.push(child);
  9877. }
  9878. bStartY++;
  9879. }
  9880. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9881. this._dispatchInBuckets(child._children);
  9882. }
  9883. }
  9884. };
  9885. // reset left and top measures for the window and all its children
  9886. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9887. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9888. this._measureForChildren.left -= left;
  9889. this._measureForChildren.top -= top;
  9890. this._currentMeasure.left -= left;
  9891. this._currentMeasure.top -= top;
  9892. this._customData.origLeftForChildren = this._measureForChildren.left;
  9893. this._customData.origTopForChildren = this._measureForChildren.top;
  9894. this._customData.origLeft = this._currentMeasure.left;
  9895. this._customData.origTop = this._currentMeasure.top;
  9896. this._updateChildrenMeasures(this._children, left, top);
  9897. };
  9898. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9899. for (var i = 0; i < children.length; ++i) {
  9900. var child = children[i];
  9901. child._currentMeasure.left -= left;
  9902. child._currentMeasure.top -= top;
  9903. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9904. child._customData._origTop = child._currentMeasure.top;
  9905. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9906. this._updateChildrenMeasures(child._children, left, top);
  9907. }
  9908. }
  9909. };
  9910. _ScrollViewerWindow.prototype._restoreMeasures = function () {
  9911. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9912. this._measureForChildren.left = this._customData.origLeftForChildren + left;
  9913. this._measureForChildren.top = this._customData.origTopForChildren + top;
  9914. this._currentMeasure.left = this._customData.origLeft + left;
  9915. this._currentMeasure.top = this._customData.origTop + top;
  9916. };
  9917. _ScrollViewerWindow.prototype._getTypeName = function () {
  9918. return "ScrollViewerWindow";
  9919. };
  9920. /** @hidden */
  9921. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9922. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9923. this._parentMeasure = parentMeasure;
  9924. this._measureForChildren.left = this._currentMeasure.left;
  9925. this._measureForChildren.top = this._currentMeasure.top;
  9926. this._measureForChildren.width = parentMeasure.width;
  9927. this._measureForChildren.height = parentMeasure.height;
  9928. };
  9929. /** @hidden */
  9930. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9931. if (this._freezeControls) {
  9932. this.invalidateRect(); // will trigger a redraw of the window
  9933. return false;
  9934. }
  9935. return _super.prototype._layout.call(this, parentMeasure, context);
  9936. };
  9937. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9938. for (var i = 0; i < children.length; ++i) {
  9939. var child = children[i];
  9940. child._currentMeasure.left = child._customData._origLeft + left;
  9941. child._currentMeasure.top = child._customData._origTop + top;
  9942. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9943. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9944. this._scrollChildren(child._children, left, top);
  9945. }
  9946. }
  9947. };
  9948. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9949. 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);
  9950. while (bStartY <= bEndY) {
  9951. for (var x = bStartX; x <= bEndX; ++x) {
  9952. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9953. if (lstc) {
  9954. for (var i = 0; i < lstc.length; ++i) {
  9955. var child = lstc[i];
  9956. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9957. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9958. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9959. }
  9960. }
  9961. }
  9962. bStartY++;
  9963. }
  9964. };
  9965. /** @hidden */
  9966. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9967. if (!this._freezeControls) {
  9968. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9969. return;
  9970. }
  9971. this._localDraw(context);
  9972. if (this.clipChildren) {
  9973. this._clipForChildren(context);
  9974. }
  9975. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9976. if (this._useBuckets()) {
  9977. if (this._oldLeft !== null && this._oldTop !== null) {
  9978. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  9979. this._scrollChildrenWithBuckets(left, top, left, top);
  9980. }
  9981. else {
  9982. this._scrollChildren(this._children, left, top);
  9983. }
  9984. }
  9985. else {
  9986. this._scrollChildren(this._children, left, top);
  9987. }
  9988. this._oldLeft = left;
  9989. this._oldTop = top;
  9990. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9991. var child = _a[_i];
  9992. if (!child._intersectsRect(this._parentMeasure)) {
  9993. continue;
  9994. }
  9995. child._render(context, this._parentMeasure);
  9996. }
  9997. };
  9998. _ScrollViewerWindow.prototype._postMeasure = function () {
  9999. if (this._freezeControls) {
  10000. _super.prototype._postMeasure.call(this);
  10001. return;
  10002. }
  10003. var maxWidth = this.parentClientWidth;
  10004. var maxHeight = this.parentClientHeight;
  10005. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10006. var child = _a[_i];
  10007. if (!child.isVisible || child.notRenderable) {
  10008. continue;
  10009. }
  10010. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  10011. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  10012. }
  10013. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  10014. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  10015. }
  10016. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width + child.paddingRightInPixels);
  10017. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height + child.paddingBottomInPixels);
  10018. }
  10019. if (this._currentMeasure.width !== maxWidth) {
  10020. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10021. this._currentMeasure.width = maxWidth;
  10022. this._rebuildLayout = true;
  10023. this._isDirty = true;
  10024. }
  10025. if (this._currentMeasure.height !== maxHeight) {
  10026. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10027. this._currentMeasure.height = maxHeight;
  10028. this._rebuildLayout = true;
  10029. this._isDirty = true;
  10030. }
  10031. _super.prototype._postMeasure.call(this);
  10032. };
  10033. return _ScrollViewerWindow;
  10034. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10035. /***/ }),
  10036. /***/ "./2D/controls/selector.ts":
  10037. /*!*********************************!*\
  10038. !*** ./2D/controls/selector.ts ***!
  10039. \*********************************/
  10040. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  10041. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10042. "use strict";
  10043. __webpack_require__.r(__webpack_exports__);
  10044. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  10045. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  10046. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  10047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  10048. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  10049. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10050. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  10051. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10052. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10053. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10054. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  10055. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  10056. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  10057. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10058. /** Class used to create a RadioGroup
  10059. * which contains groups of radio buttons
  10060. */
  10061. var SelectorGroup = /** @class */ (function () {
  10062. /**
  10063. * Creates a new SelectorGroup
  10064. * @param name of group, used as a group heading
  10065. */
  10066. function SelectorGroup(
  10067. /** name of SelectorGroup */
  10068. name) {
  10069. this.name = name;
  10070. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10071. this._selectors = new Array();
  10072. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10073. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10074. this._groupHeader = this._addGroupHeader(name);
  10075. }
  10076. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  10077. /** Gets the groupPanel of the SelectorGroup */
  10078. get: function () {
  10079. return this._groupPanel;
  10080. },
  10081. enumerable: false,
  10082. configurable: true
  10083. });
  10084. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  10085. /** Gets the selectors array */
  10086. get: function () {
  10087. return this._selectors;
  10088. },
  10089. enumerable: false,
  10090. configurable: true
  10091. });
  10092. Object.defineProperty(SelectorGroup.prototype, "header", {
  10093. /** Gets and sets the group header */
  10094. get: function () {
  10095. return this._groupHeader.text;
  10096. },
  10097. set: function (label) {
  10098. if (this._groupHeader.text === "label") {
  10099. return;
  10100. }
  10101. this._groupHeader.text = label;
  10102. },
  10103. enumerable: false,
  10104. configurable: true
  10105. });
  10106. /** @hidden */
  10107. SelectorGroup.prototype._addGroupHeader = function (text) {
  10108. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  10109. groupHeading.width = 0.9;
  10110. groupHeading.height = "30px";
  10111. groupHeading.textWrapping = true;
  10112. groupHeading.color = "black";
  10113. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10114. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10115. groupHeading.left = "2px";
  10116. this._groupPanel.addControl(groupHeading);
  10117. return groupHeading;
  10118. };
  10119. /** @hidden*/
  10120. SelectorGroup.prototype._getSelector = function (selectorNb) {
  10121. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10122. return;
  10123. }
  10124. return this._selectors[selectorNb];
  10125. };
  10126. /** Removes the selector at the given position
  10127. * @param selectorNb the position of the selector within the group
  10128. */
  10129. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  10130. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10131. return;
  10132. }
  10133. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10134. this._selectors.splice(selectorNb, 1);
  10135. };
  10136. return SelectorGroup;
  10137. }());
  10138. /** Class used to create a CheckboxGroup
  10139. * which contains groups of checkbox buttons
  10140. */
  10141. var CheckboxGroup = /** @class */ (function (_super) {
  10142. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10143. function CheckboxGroup() {
  10144. return _super !== null && _super.apply(this, arguments) || this;
  10145. }
  10146. /** Adds a checkbox as a control
  10147. * @param text is the label for the selector
  10148. * @param func is the function called when the Selector is checked
  10149. * @param checked is true when Selector is checked
  10150. */
  10151. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10152. if (func === void 0) { func = function (s) { }; }
  10153. if (checked === void 0) { checked = false; }
  10154. var checked = checked || false;
  10155. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10156. button.width = "20px";
  10157. button.height = "20px";
  10158. button.color = "#364249";
  10159. button.background = "#CCCCCC";
  10160. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10161. button.onIsCheckedChangedObservable.add(function (state) {
  10162. func(state);
  10163. });
  10164. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10165. _selector.height = "30px";
  10166. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10167. _selector.left = "4px";
  10168. this.groupPanel.addControl(_selector);
  10169. this.selectors.push(_selector);
  10170. button.isChecked = checked;
  10171. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10172. button.color = this.groupPanel.parent.parent.buttonColor;
  10173. button.background = this.groupPanel.parent.parent.buttonBackground;
  10174. }
  10175. };
  10176. /** @hidden */
  10177. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10178. this.selectors[selectorNb].children[1].text = label;
  10179. };
  10180. /** @hidden */
  10181. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10182. this.selectors[selectorNb].children[1].color = color;
  10183. };
  10184. /** @hidden */
  10185. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10186. this.selectors[selectorNb].children[0].color = color;
  10187. };
  10188. /** @hidden */
  10189. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10190. this.selectors[selectorNb].children[0].background = color;
  10191. };
  10192. return CheckboxGroup;
  10193. }(SelectorGroup));
  10194. /** Class used to create a RadioGroup
  10195. * which contains groups of radio buttons
  10196. */
  10197. var RadioGroup = /** @class */ (function (_super) {
  10198. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10199. function RadioGroup() {
  10200. var _this = _super !== null && _super.apply(this, arguments) || this;
  10201. _this._selectNb = 0;
  10202. return _this;
  10203. }
  10204. /** Adds a radio button as a control
  10205. * @param label is the label for the selector
  10206. * @param func is the function called when the Selector is checked
  10207. * @param checked is true when Selector is checked
  10208. */
  10209. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10210. if (func === void 0) { func = function (n) { }; }
  10211. if (checked === void 0) { checked = false; }
  10212. var nb = this._selectNb++;
  10213. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10214. button.name = label;
  10215. button.width = "20px";
  10216. button.height = "20px";
  10217. button.color = "#364249";
  10218. button.background = "#CCCCCC";
  10219. button.group = this.name;
  10220. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10221. button.onIsCheckedChangedObservable.add(function (state) {
  10222. if (state) {
  10223. func(nb);
  10224. }
  10225. });
  10226. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10227. _selector.height = "30px";
  10228. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10229. _selector.left = "4px";
  10230. this.groupPanel.addControl(_selector);
  10231. this.selectors.push(_selector);
  10232. button.isChecked = checked;
  10233. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10234. button.color = this.groupPanel.parent.parent.buttonColor;
  10235. button.background = this.groupPanel.parent.parent.buttonBackground;
  10236. }
  10237. };
  10238. /** @hidden */
  10239. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10240. this.selectors[selectorNb].children[1].text = label;
  10241. };
  10242. /** @hidden */
  10243. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10244. this.selectors[selectorNb].children[1].color = color;
  10245. };
  10246. /** @hidden */
  10247. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10248. this.selectors[selectorNb].children[0].color = color;
  10249. };
  10250. /** @hidden */
  10251. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10252. this.selectors[selectorNb].children[0].background = color;
  10253. };
  10254. return RadioGroup;
  10255. }(SelectorGroup));
  10256. /** Class used to create a SliderGroup
  10257. * which contains groups of slider buttons
  10258. */
  10259. var SliderGroup = /** @class */ (function (_super) {
  10260. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10261. function SliderGroup() {
  10262. return _super !== null && _super.apply(this, arguments) || this;
  10263. }
  10264. /**
  10265. * Adds a slider to the SelectorGroup
  10266. * @param label is the label for the SliderBar
  10267. * @param func is the function called when the Slider moves
  10268. * @param unit is a string describing the units used, eg degrees or metres
  10269. * @param min is the minimum value for the Slider
  10270. * @param max is the maximum value for the Slider
  10271. * @param value is the start value for the Slider between min and max
  10272. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10273. */
  10274. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10275. if (func === void 0) { func = function (v) { }; }
  10276. if (unit === void 0) { unit = "Units"; }
  10277. if (min === void 0) { min = 0; }
  10278. if (max === void 0) { max = 0; }
  10279. if (value === void 0) { value = 0; }
  10280. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10281. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10282. button.name = unit;
  10283. button.value = value;
  10284. button.minimum = min;
  10285. button.maximum = max;
  10286. button.width = 0.9;
  10287. button.height = "20px";
  10288. button.color = "#364249";
  10289. button.background = "#CCCCCC";
  10290. button.borderColor = "black";
  10291. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10292. button.left = "4px";
  10293. button.paddingBottom = "4px";
  10294. button.onValueChangedObservable.add(function (value) {
  10295. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10296. func(value);
  10297. });
  10298. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10299. _selector.height = "60px";
  10300. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10301. _selector.left = "4px";
  10302. _selector.children[0].name = label;
  10303. this.groupPanel.addControl(_selector);
  10304. this.selectors.push(_selector);
  10305. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10306. button.color = this.groupPanel.parent.parent.buttonColor;
  10307. button.background = this.groupPanel.parent.parent.buttonBackground;
  10308. }
  10309. };
  10310. /** @hidden */
  10311. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10312. this.selectors[selectorNb].children[0].name = label;
  10313. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10314. };
  10315. /** @hidden */
  10316. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10317. this.selectors[selectorNb].children[0].color = color;
  10318. };
  10319. /** @hidden */
  10320. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10321. this.selectors[selectorNb].children[1].color = color;
  10322. };
  10323. /** @hidden */
  10324. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10325. this.selectors[selectorNb].children[1].background = color;
  10326. };
  10327. return SliderGroup;
  10328. }(SelectorGroup));
  10329. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10330. * @see https://doc.babylonjs.com/how_to/selector
  10331. */
  10332. var SelectionPanel = /** @class */ (function (_super) {
  10333. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10334. /**
  10335. * Creates a new SelectionPanel
  10336. * @param name of SelectionPanel
  10337. * @param groups is an array of SelectionGroups
  10338. */
  10339. function SelectionPanel(
  10340. /** name of SelectionPanel */
  10341. name,
  10342. /** an array of SelectionGroups */
  10343. groups) {
  10344. if (groups === void 0) { groups = []; }
  10345. var _this = _super.call(this, name) || this;
  10346. _this.name = name;
  10347. _this.groups = groups;
  10348. _this._buttonColor = "#364249";
  10349. _this._buttonBackground = "#CCCCCC";
  10350. _this._headerColor = "black";
  10351. _this._barColor = "white";
  10352. _this._barHeight = "2px";
  10353. _this._spacerHeight = "20px";
  10354. _this._bars = new Array();
  10355. _this._groups = groups;
  10356. _this.thickness = 2;
  10357. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10358. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10359. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10360. _this._panel.top = 5;
  10361. _this._panel.left = 5;
  10362. _this._panel.width = 0.95;
  10363. if (groups.length > 0) {
  10364. for (var i = 0; i < groups.length - 1; i++) {
  10365. _this._panel.addControl(groups[i].groupPanel);
  10366. _this._addSpacer();
  10367. }
  10368. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10369. }
  10370. _this.addControl(_this._panel);
  10371. return _this;
  10372. }
  10373. SelectionPanel.prototype._getTypeName = function () {
  10374. return "SelectionPanel";
  10375. };
  10376. Object.defineProperty(SelectionPanel.prototype, "panel", {
  10377. /** Gets the (stack) panel of the SelectionPanel */
  10378. get: function () {
  10379. return this._panel;
  10380. },
  10381. enumerable: false,
  10382. configurable: true
  10383. });
  10384. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10385. /** Gets or sets the headerColor */
  10386. get: function () {
  10387. return this._headerColor;
  10388. },
  10389. set: function (color) {
  10390. if (this._headerColor === color) {
  10391. return;
  10392. }
  10393. this._headerColor = color;
  10394. this._setHeaderColor();
  10395. },
  10396. enumerable: false,
  10397. configurable: true
  10398. });
  10399. SelectionPanel.prototype._setHeaderColor = function () {
  10400. for (var i = 0; i < this._groups.length; i++) {
  10401. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10402. }
  10403. };
  10404. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10405. /** Gets or sets the button color */
  10406. get: function () {
  10407. return this._buttonColor;
  10408. },
  10409. set: function (color) {
  10410. if (this._buttonColor === color) {
  10411. return;
  10412. }
  10413. this._buttonColor = color;
  10414. this._setbuttonColor();
  10415. },
  10416. enumerable: false,
  10417. configurable: true
  10418. });
  10419. SelectionPanel.prototype._setbuttonColor = function () {
  10420. for (var i = 0; i < this._groups.length; i++) {
  10421. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10422. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10423. }
  10424. }
  10425. };
  10426. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10427. /** Gets or sets the label color */
  10428. get: function () {
  10429. return this._labelColor;
  10430. },
  10431. set: function (color) {
  10432. if (this._labelColor === color) {
  10433. return;
  10434. }
  10435. this._labelColor = color;
  10436. this._setLabelColor();
  10437. },
  10438. enumerable: false,
  10439. configurable: true
  10440. });
  10441. SelectionPanel.prototype._setLabelColor = function () {
  10442. for (var i = 0; i < this._groups.length; i++) {
  10443. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10444. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10445. }
  10446. }
  10447. };
  10448. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10449. /** Gets or sets the button background */
  10450. get: function () {
  10451. return this._buttonBackground;
  10452. },
  10453. set: function (color) {
  10454. if (this._buttonBackground === color) {
  10455. return;
  10456. }
  10457. this._buttonBackground = color;
  10458. this._setButtonBackground();
  10459. },
  10460. enumerable: false,
  10461. configurable: true
  10462. });
  10463. SelectionPanel.prototype._setButtonBackground = function () {
  10464. for (var i = 0; i < this._groups.length; i++) {
  10465. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10466. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10467. }
  10468. }
  10469. };
  10470. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10471. /** Gets or sets the color of separator bar */
  10472. get: function () {
  10473. return this._barColor;
  10474. },
  10475. set: function (color) {
  10476. if (this._barColor === color) {
  10477. return;
  10478. }
  10479. this._barColor = color;
  10480. this._setBarColor();
  10481. },
  10482. enumerable: false,
  10483. configurable: true
  10484. });
  10485. SelectionPanel.prototype._setBarColor = function () {
  10486. for (var i = 0; i < this._bars.length; i++) {
  10487. this._bars[i].children[0].background = this._barColor;
  10488. }
  10489. };
  10490. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10491. /** Gets or sets the height of separator bar */
  10492. get: function () {
  10493. return this._barHeight;
  10494. },
  10495. set: function (value) {
  10496. if (this._barHeight === value) {
  10497. return;
  10498. }
  10499. this._barHeight = value;
  10500. this._setBarHeight();
  10501. },
  10502. enumerable: false,
  10503. configurable: true
  10504. });
  10505. SelectionPanel.prototype._setBarHeight = function () {
  10506. for (var i = 0; i < this._bars.length; i++) {
  10507. this._bars[i].children[0].height = this._barHeight;
  10508. }
  10509. };
  10510. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10511. /** Gets or sets the height of spacers*/
  10512. get: function () {
  10513. return this._spacerHeight;
  10514. },
  10515. set: function (value) {
  10516. if (this._spacerHeight === value) {
  10517. return;
  10518. }
  10519. this._spacerHeight = value;
  10520. this._setSpacerHeight();
  10521. },
  10522. enumerable: false,
  10523. configurable: true
  10524. });
  10525. SelectionPanel.prototype._setSpacerHeight = function () {
  10526. for (var i = 0; i < this._bars.length; i++) {
  10527. this._bars[i].height = this._spacerHeight;
  10528. }
  10529. };
  10530. /** Adds a bar between groups */
  10531. SelectionPanel.prototype._addSpacer = function () {
  10532. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10533. separator.width = 1;
  10534. separator.height = this._spacerHeight;
  10535. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10536. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10537. bar.width = 1;
  10538. bar.height = this._barHeight;
  10539. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10540. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10541. bar.background = this._barColor;
  10542. bar.color = "transparent";
  10543. separator.addControl(bar);
  10544. this._panel.addControl(separator);
  10545. this._bars.push(separator);
  10546. };
  10547. /** Add a group to the selection panel
  10548. * @param group is the selector group to add
  10549. */
  10550. SelectionPanel.prototype.addGroup = function (group) {
  10551. if (this._groups.length > 0) {
  10552. this._addSpacer();
  10553. }
  10554. this._panel.addControl(group.groupPanel);
  10555. this._groups.push(group);
  10556. group.groupPanel.children[0].color = this._headerColor;
  10557. for (var j = 0; j < group.selectors.length; j++) {
  10558. group._setSelectorButtonColor(j, this._buttonColor);
  10559. group._setSelectorButtonBackground(j, this._buttonBackground);
  10560. }
  10561. };
  10562. /** Remove the group from the given position
  10563. * @param groupNb is the position of the group in the list
  10564. */
  10565. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10566. if (groupNb < 0 || groupNb >= this._groups.length) {
  10567. return;
  10568. }
  10569. var group = this._groups[groupNb];
  10570. this._panel.removeControl(group.groupPanel);
  10571. this._groups.splice(groupNb, 1);
  10572. if (groupNb < this._bars.length) {
  10573. this._panel.removeControl(this._bars[groupNb]);
  10574. this._bars.splice(groupNb, 1);
  10575. }
  10576. };
  10577. /** Change a group header label
  10578. * @param label is the new group header label
  10579. * @param groupNb is the number of the group to relabel
  10580. * */
  10581. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10582. if (groupNb < 0 || groupNb >= this._groups.length) {
  10583. return;
  10584. }
  10585. var group = this._groups[groupNb];
  10586. group.groupPanel.children[0].text = label;
  10587. };
  10588. /** Change selector label to the one given
  10589. * @param label is the new selector label
  10590. * @param groupNb is the number of the groupcontaining the selector
  10591. * @param selectorNb is the number of the selector within a group to relabel
  10592. * */
  10593. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10594. if (groupNb < 0 || groupNb >= this._groups.length) {
  10595. return;
  10596. }
  10597. var group = this._groups[groupNb];
  10598. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10599. return;
  10600. }
  10601. group._setSelectorLabel(selectorNb, label);
  10602. };
  10603. /** For a given group position remove the selector at the given position
  10604. * @param groupNb is the number of the group to remove the selector from
  10605. * @param selectorNb is the number of the selector within the group
  10606. */
  10607. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10608. if (groupNb < 0 || groupNb >= this._groups.length) {
  10609. return;
  10610. }
  10611. var group = this._groups[groupNb];
  10612. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10613. return;
  10614. }
  10615. group.removeSelector(selectorNb);
  10616. };
  10617. /** For a given group position of correct type add a checkbox button
  10618. * @param groupNb is the number of the group to remove the selector from
  10619. * @param label is the label for the selector
  10620. * @param func is the function called when the Selector is checked
  10621. * @param checked is true when Selector is checked
  10622. */
  10623. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10624. if (func === void 0) { func = function () { }; }
  10625. if (checked === void 0) { checked = false; }
  10626. if (groupNb < 0 || groupNb >= this._groups.length) {
  10627. return;
  10628. }
  10629. var group = this._groups[groupNb];
  10630. group.addCheckbox(label, func, checked);
  10631. };
  10632. /** For a given group position of correct type add a radio button
  10633. * @param groupNb is the number of the group to remove the selector from
  10634. * @param label is the label for the selector
  10635. * @param func is the function called when the Selector is checked
  10636. * @param checked is true when Selector is checked
  10637. */
  10638. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10639. if (func === void 0) { func = function () { }; }
  10640. if (checked === void 0) { checked = false; }
  10641. if (groupNb < 0 || groupNb >= this._groups.length) {
  10642. return;
  10643. }
  10644. var group = this._groups[groupNb];
  10645. group.addRadio(label, func, checked);
  10646. };
  10647. /**
  10648. * For a given slider group add a slider
  10649. * @param groupNb is the number of the group to add the slider to
  10650. * @param label is the label for the Slider
  10651. * @param func is the function called when the Slider moves
  10652. * @param unit is a string describing the units used, eg degrees or metres
  10653. * @param min is the minimum value for the Slider
  10654. * @param max is the maximum value for the Slider
  10655. * @param value is the start value for the Slider between min and max
  10656. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10657. */
  10658. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10659. if (func === void 0) { func = function () { }; }
  10660. if (unit === void 0) { unit = "Units"; }
  10661. if (min === void 0) { min = 0; }
  10662. if (max === void 0) { max = 0; }
  10663. if (value === void 0) { value = 0; }
  10664. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10665. if (groupNb < 0 || groupNb >= this._groups.length) {
  10666. return;
  10667. }
  10668. var group = this._groups[groupNb];
  10669. group.addSlider(label, func, unit, min, max, value, onVal);
  10670. };
  10671. return SelectionPanel;
  10672. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10673. /***/ }),
  10674. /***/ "./2D/controls/sliders/baseSlider.ts":
  10675. /*!*******************************************!*\
  10676. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10677. \*******************************************/
  10678. /*! exports provided: BaseSlider */
  10679. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10680. "use strict";
  10681. __webpack_require__.r(__webpack_exports__);
  10682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10683. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10684. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  10685. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10686. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10687. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10688. /**
  10689. * Class used to create slider controls
  10690. */
  10691. var BaseSlider = /** @class */ (function (_super) {
  10692. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10693. /**
  10694. * Creates a new BaseSlider
  10695. * @param name defines the control name
  10696. */
  10697. function BaseSlider(name) {
  10698. var _this = _super.call(this, name) || this;
  10699. _this.name = name;
  10700. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10701. _this._minimum = 0;
  10702. _this._maximum = 100;
  10703. _this._value = 50;
  10704. _this._isVertical = false;
  10705. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10706. _this._isThumbClamped = false;
  10707. _this._displayThumb = true;
  10708. _this._step = 0;
  10709. _this._lastPointerDownID = -1;
  10710. // Shared rendering info
  10711. _this._effectiveBarOffset = 0;
  10712. /** Observable raised when the sldier value changes */
  10713. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10714. // Events
  10715. _this._pointerIsDown = false;
  10716. _this.isPointerBlocker = true;
  10717. return _this;
  10718. }
  10719. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10720. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10721. get: function () {
  10722. return this._displayThumb;
  10723. },
  10724. set: function (value) {
  10725. if (this._displayThumb === value) {
  10726. return;
  10727. }
  10728. this._displayThumb = value;
  10729. this._markAsDirty();
  10730. },
  10731. enumerable: false,
  10732. configurable: true
  10733. });
  10734. Object.defineProperty(BaseSlider.prototype, "step", {
  10735. /** Gets or sets a step to apply to values (0 by default) */
  10736. get: function () {
  10737. return this._step;
  10738. },
  10739. set: function (value) {
  10740. if (this._step === value) {
  10741. return;
  10742. }
  10743. this._step = value;
  10744. this._markAsDirty();
  10745. },
  10746. enumerable: false,
  10747. configurable: true
  10748. });
  10749. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10750. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10751. get: function () {
  10752. return this._barOffset.toString(this._host);
  10753. },
  10754. set: function (value) {
  10755. if (this._barOffset.toString(this._host) === value) {
  10756. return;
  10757. }
  10758. if (this._barOffset.fromString(value)) {
  10759. this._markAsDirty();
  10760. }
  10761. },
  10762. enumerable: false,
  10763. configurable: true
  10764. });
  10765. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10766. /** Gets main bar offset in pixels*/
  10767. get: function () {
  10768. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10769. },
  10770. enumerable: false,
  10771. configurable: true
  10772. });
  10773. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10774. /** Gets or sets thumb width */
  10775. get: function () {
  10776. return this._thumbWidth.toString(this._host);
  10777. },
  10778. set: function (value) {
  10779. if (this._thumbWidth.toString(this._host) === value) {
  10780. return;
  10781. }
  10782. if (this._thumbWidth.fromString(value)) {
  10783. this._markAsDirty();
  10784. }
  10785. },
  10786. enumerable: false,
  10787. configurable: true
  10788. });
  10789. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10790. /** Gets thumb width in pixels */
  10791. get: function () {
  10792. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10793. },
  10794. enumerable: false,
  10795. configurable: true
  10796. });
  10797. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10798. /** Gets or sets minimum value */
  10799. get: function () {
  10800. return this._minimum;
  10801. },
  10802. set: function (value) {
  10803. if (this._minimum === value) {
  10804. return;
  10805. }
  10806. this._minimum = value;
  10807. this._markAsDirty();
  10808. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10809. },
  10810. enumerable: false,
  10811. configurable: true
  10812. });
  10813. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10814. /** Gets or sets maximum value */
  10815. get: function () {
  10816. return this._maximum;
  10817. },
  10818. set: function (value) {
  10819. if (this._maximum === value) {
  10820. return;
  10821. }
  10822. this._maximum = value;
  10823. this._markAsDirty();
  10824. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10825. },
  10826. enumerable: false,
  10827. configurable: true
  10828. });
  10829. Object.defineProperty(BaseSlider.prototype, "value", {
  10830. /** Gets or sets current value */
  10831. get: function () {
  10832. return this._value;
  10833. },
  10834. set: function (value) {
  10835. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10836. if (this._value === value) {
  10837. return;
  10838. }
  10839. this._value = value;
  10840. this._markAsDirty();
  10841. this.onValueChangedObservable.notifyObservers(this._value);
  10842. },
  10843. enumerable: false,
  10844. configurable: true
  10845. });
  10846. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10847. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10848. get: function () {
  10849. return this._isVertical;
  10850. },
  10851. set: function (value) {
  10852. if (this._isVertical === value) {
  10853. return;
  10854. }
  10855. this._isVertical = value;
  10856. this._markAsDirty();
  10857. },
  10858. enumerable: false,
  10859. configurable: true
  10860. });
  10861. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10862. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10863. get: function () {
  10864. return this._isThumbClamped;
  10865. },
  10866. set: function (value) {
  10867. if (this._isThumbClamped === value) {
  10868. return;
  10869. }
  10870. this._isThumbClamped = value;
  10871. this._markAsDirty();
  10872. },
  10873. enumerable: false,
  10874. configurable: true
  10875. });
  10876. BaseSlider.prototype._getTypeName = function () {
  10877. return "BaseSlider";
  10878. };
  10879. BaseSlider.prototype._getThumbPosition = function () {
  10880. if (this.isVertical) {
  10881. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10882. }
  10883. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10884. };
  10885. BaseSlider.prototype._getThumbThickness = function (type) {
  10886. var thumbThickness = 0;
  10887. switch (type) {
  10888. case "circle":
  10889. if (this._thumbWidth.isPixel) {
  10890. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10891. }
  10892. else {
  10893. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10894. }
  10895. break;
  10896. case "rectangle":
  10897. if (this._thumbWidth.isPixel) {
  10898. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10899. }
  10900. else {
  10901. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10902. }
  10903. }
  10904. return thumbThickness;
  10905. };
  10906. BaseSlider.prototype._prepareRenderingData = function (type) {
  10907. // Main bar
  10908. this._effectiveBarOffset = 0;
  10909. this._renderLeft = this._currentMeasure.left;
  10910. this._renderTop = this._currentMeasure.top;
  10911. this._renderWidth = this._currentMeasure.width;
  10912. this._renderHeight = this._currentMeasure.height;
  10913. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10914. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10915. this._effectiveThumbThickness = this._getThumbThickness(type);
  10916. if (this.displayThumb) {
  10917. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10918. }
  10919. //throw error when height is less than width for vertical slider
  10920. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10921. console.error("Height should be greater than width");
  10922. return;
  10923. }
  10924. if (this._barOffset.isPixel) {
  10925. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10926. }
  10927. else {
  10928. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10929. }
  10930. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10931. if (this.isVertical) {
  10932. this._renderLeft += this._effectiveBarOffset;
  10933. if (!this.isThumbClamped && this.displayThumb) {
  10934. this._renderTop += (this._effectiveThumbThickness / 2);
  10935. }
  10936. this._renderHeight = this._backgroundBoxLength;
  10937. this._renderWidth = this._backgroundBoxThickness;
  10938. }
  10939. else {
  10940. this._renderTop += this._effectiveBarOffset;
  10941. if (!this.isThumbClamped && this.displayThumb) {
  10942. this._renderLeft += (this._effectiveThumbThickness / 2);
  10943. }
  10944. this._renderHeight = this._backgroundBoxThickness;
  10945. this._renderWidth = this._backgroundBoxLength;
  10946. }
  10947. };
  10948. /** @hidden */
  10949. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10950. if (this.rotation != 0) {
  10951. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10952. x = this._transformedPosition.x;
  10953. y = this._transformedPosition.y;
  10954. }
  10955. var value;
  10956. if (this._isVertical) {
  10957. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10958. }
  10959. else {
  10960. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10961. }
  10962. var mult = (1 / this._step) | 0;
  10963. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10964. };
  10965. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10966. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10967. return false;
  10968. }
  10969. this._pointerIsDown = true;
  10970. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10971. this._host._capturingControl[pointerId] = this;
  10972. this._lastPointerDownID = pointerId;
  10973. return true;
  10974. };
  10975. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10976. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10977. if (pointerId != this._lastPointerDownID) {
  10978. return;
  10979. }
  10980. if (this._pointerIsDown) {
  10981. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10982. }
  10983. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10984. };
  10985. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10986. this._pointerIsDown = false;
  10987. delete this._host._capturingControl[pointerId];
  10988. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10989. };
  10990. BaseSlider.prototype._onCanvasBlur = function () {
  10991. this._forcePointerUp();
  10992. _super.prototype._onCanvasBlur.call(this);
  10993. };
  10994. return BaseSlider;
  10995. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10996. /***/ }),
  10997. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10998. /*!*************************************************!*\
  10999. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  11000. \*************************************************/
  11001. /*! exports provided: ImageBasedSlider */
  11002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11003. "use strict";
  11004. __webpack_require__.r(__webpack_exports__);
  11005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  11006. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11007. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11008. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11009. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  11010. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  11011. /**
  11012. * Class used to create slider controls based on images
  11013. */
  11014. var ImageBasedSlider = /** @class */ (function (_super) {
  11015. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  11016. /**
  11017. * Creates a new ImageBasedSlider
  11018. * @param name defines the control name
  11019. */
  11020. function ImageBasedSlider(name) {
  11021. var _this = _super.call(this, name) || this;
  11022. _this.name = name;
  11023. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11024. return _this;
  11025. }
  11026. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  11027. get: function () {
  11028. return this._displayThumb && this.thumbImage != null;
  11029. },
  11030. set: function (value) {
  11031. if (this._displayThumb === value) {
  11032. return;
  11033. }
  11034. this._displayThumb = value;
  11035. this._markAsDirty();
  11036. },
  11037. enumerable: false,
  11038. configurable: true
  11039. });
  11040. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  11041. /**
  11042. * Gets or sets the image used to render the background
  11043. */
  11044. get: function () {
  11045. return this._backgroundImage;
  11046. },
  11047. set: function (value) {
  11048. var _this = this;
  11049. if (this._backgroundImage === value) {
  11050. return;
  11051. }
  11052. this._backgroundImage = value;
  11053. if (value && !value.isLoaded) {
  11054. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11055. }
  11056. this._markAsDirty();
  11057. },
  11058. enumerable: false,
  11059. configurable: true
  11060. });
  11061. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  11062. /**
  11063. * Gets or sets the image used to render the value bar
  11064. */
  11065. get: function () {
  11066. return this._valueBarImage;
  11067. },
  11068. set: function (value) {
  11069. var _this = this;
  11070. if (this._valueBarImage === value) {
  11071. return;
  11072. }
  11073. this._valueBarImage = value;
  11074. if (value && !value.isLoaded) {
  11075. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11076. }
  11077. this._markAsDirty();
  11078. },
  11079. enumerable: false,
  11080. configurable: true
  11081. });
  11082. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  11083. /**
  11084. * Gets or sets the image used to render the thumb
  11085. */
  11086. get: function () {
  11087. return this._thumbImage;
  11088. },
  11089. set: function (value) {
  11090. var _this = this;
  11091. if (this._thumbImage === value) {
  11092. return;
  11093. }
  11094. this._thumbImage = value;
  11095. if (value && !value.isLoaded) {
  11096. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11097. }
  11098. this._markAsDirty();
  11099. },
  11100. enumerable: false,
  11101. configurable: true
  11102. });
  11103. ImageBasedSlider.prototype._getTypeName = function () {
  11104. return "ImageBasedSlider";
  11105. };
  11106. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  11107. context.save();
  11108. this._applyStates(context);
  11109. this._prepareRenderingData("rectangle");
  11110. var thumbPosition = this._getThumbPosition();
  11111. var left = this._renderLeft;
  11112. var top = this._renderTop;
  11113. var width = this._renderWidth;
  11114. var height = this._renderHeight;
  11115. // Background
  11116. if (this._backgroundImage) {
  11117. this._tempMeasure.copyFromFloats(left, top, width, height);
  11118. if (this.isThumbClamped && this.displayThumb) {
  11119. if (this.isVertical) {
  11120. this._tempMeasure.height += this._effectiveThumbThickness;
  11121. }
  11122. else {
  11123. this._tempMeasure.width += this._effectiveThumbThickness;
  11124. }
  11125. }
  11126. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11127. this._backgroundImage._draw(context);
  11128. }
  11129. // Bar
  11130. if (this._valueBarImage) {
  11131. if (this.isVertical) {
  11132. if (this.isThumbClamped && this.displayThumb) {
  11133. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11134. }
  11135. else {
  11136. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  11137. }
  11138. }
  11139. else {
  11140. if (this.isThumbClamped && this.displayThumb) {
  11141. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  11142. }
  11143. else {
  11144. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11145. }
  11146. }
  11147. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11148. this._valueBarImage._draw(context);
  11149. }
  11150. // Thumb
  11151. if (this.displayThumb) {
  11152. if (this.isVertical) {
  11153. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11154. }
  11155. else {
  11156. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11157. }
  11158. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11159. this._thumbImage._draw(context);
  11160. }
  11161. context.restore();
  11162. };
  11163. return ImageBasedSlider;
  11164. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11165. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11166. /***/ }),
  11167. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11168. /*!***********************************************!*\
  11169. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11170. \***********************************************/
  11171. /*! exports provided: ImageScrollBar */
  11172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11173. "use strict";
  11174. __webpack_require__.r(__webpack_exports__);
  11175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11176. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11177. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11178. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11179. /**
  11180. * Class used to create slider controls
  11181. */
  11182. var ImageScrollBar = /** @class */ (function (_super) {
  11183. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11184. /**
  11185. * Creates a new ImageScrollBar
  11186. * @param name defines the control name
  11187. */
  11188. function ImageScrollBar(name) {
  11189. var _this = _super.call(this, name) || this;
  11190. _this.name = name;
  11191. _this._thumbLength = 0.5;
  11192. _this._thumbHeight = 1;
  11193. _this._barImageHeight = 1;
  11194. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11195. /** Number of 90° rotation to apply on the images when in vertical mode */
  11196. _this.num90RotationInVerticalMode = 1;
  11197. return _this;
  11198. }
  11199. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11200. /**
  11201. * Gets or sets the image used to render the background for horizontal bar
  11202. */
  11203. get: function () {
  11204. return this._backgroundBaseImage;
  11205. },
  11206. set: function (value) {
  11207. var _this = this;
  11208. if (this._backgroundBaseImage === value) {
  11209. return;
  11210. }
  11211. this._backgroundBaseImage = value;
  11212. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11213. if (!value.isLoaded) {
  11214. value.onImageLoadedObservable.addOnce(function () {
  11215. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11216. _this._backgroundImage = rotatedValue;
  11217. if (!rotatedValue.isLoaded) {
  11218. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11219. _this._markAsDirty();
  11220. });
  11221. }
  11222. _this._markAsDirty();
  11223. });
  11224. }
  11225. else {
  11226. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11227. this._markAsDirty();
  11228. }
  11229. }
  11230. else {
  11231. this._backgroundImage = value;
  11232. if (value && !value.isLoaded) {
  11233. value.onImageLoadedObservable.addOnce(function () {
  11234. _this._markAsDirty();
  11235. });
  11236. }
  11237. this._markAsDirty();
  11238. }
  11239. },
  11240. enumerable: false,
  11241. configurable: true
  11242. });
  11243. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11244. /**
  11245. * Gets or sets the image used to render the thumb
  11246. */
  11247. get: function () {
  11248. return this._thumbBaseImage;
  11249. },
  11250. set: function (value) {
  11251. var _this = this;
  11252. if (this._thumbBaseImage === value) {
  11253. return;
  11254. }
  11255. this._thumbBaseImage = value;
  11256. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11257. if (!value.isLoaded) {
  11258. value.onImageLoadedObservable.addOnce(function () {
  11259. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11260. _this._thumbImage = rotatedValue;
  11261. if (!rotatedValue.isLoaded) {
  11262. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11263. _this._markAsDirty();
  11264. });
  11265. }
  11266. _this._markAsDirty();
  11267. });
  11268. }
  11269. else {
  11270. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11271. this._markAsDirty();
  11272. }
  11273. }
  11274. else {
  11275. this._thumbImage = value;
  11276. if (value && !value.isLoaded) {
  11277. value.onImageLoadedObservable.addOnce(function () {
  11278. _this._markAsDirty();
  11279. });
  11280. }
  11281. this._markAsDirty();
  11282. }
  11283. },
  11284. enumerable: false,
  11285. configurable: true
  11286. });
  11287. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11288. /**
  11289. * Gets or sets the length of the thumb
  11290. */
  11291. get: function () {
  11292. return this._thumbLength;
  11293. },
  11294. set: function (value) {
  11295. if (this._thumbLength === value) {
  11296. return;
  11297. }
  11298. this._thumbLength = value;
  11299. this._markAsDirty();
  11300. },
  11301. enumerable: false,
  11302. configurable: true
  11303. });
  11304. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11305. /**
  11306. * Gets or sets the height of the thumb
  11307. */
  11308. get: function () {
  11309. return this._thumbHeight;
  11310. },
  11311. set: function (value) {
  11312. if (this._thumbLength === value) {
  11313. return;
  11314. }
  11315. this._thumbHeight = value;
  11316. this._markAsDirty();
  11317. },
  11318. enumerable: false,
  11319. configurable: true
  11320. });
  11321. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11322. /**
  11323. * Gets or sets the height of the bar image
  11324. */
  11325. get: function () {
  11326. return this._barImageHeight;
  11327. },
  11328. set: function (value) {
  11329. if (this._barImageHeight === value) {
  11330. return;
  11331. }
  11332. this._barImageHeight = value;
  11333. this._markAsDirty();
  11334. },
  11335. enumerable: false,
  11336. configurable: true
  11337. });
  11338. ImageScrollBar.prototype._getTypeName = function () {
  11339. return "ImageScrollBar";
  11340. };
  11341. ImageScrollBar.prototype._getThumbThickness = function () {
  11342. var thumbThickness = 0;
  11343. if (this._thumbWidth.isPixel) {
  11344. thumbThickness = this._thumbWidth.getValue(this._host);
  11345. }
  11346. else {
  11347. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11348. }
  11349. return thumbThickness;
  11350. };
  11351. ImageScrollBar.prototype._draw = function (context) {
  11352. context.save();
  11353. this._applyStates(context);
  11354. this._prepareRenderingData("rectangle");
  11355. var thumbPosition = this._getThumbPosition();
  11356. var left = this._renderLeft;
  11357. var top = this._renderTop;
  11358. var width = this._renderWidth;
  11359. var height = this._renderHeight;
  11360. // Background
  11361. if (this._backgroundImage) {
  11362. this._tempMeasure.copyFromFloats(left, top, width, height);
  11363. if (this.isVertical) {
  11364. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11365. this._tempMeasure.height += this._effectiveThumbThickness;
  11366. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11367. }
  11368. else {
  11369. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11370. this._tempMeasure.width += this._effectiveThumbThickness;
  11371. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11372. }
  11373. this._backgroundImage._draw(context);
  11374. }
  11375. // Thumb
  11376. if (this.isVertical) {
  11377. 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);
  11378. }
  11379. else {
  11380. 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);
  11381. }
  11382. if (this._thumbImage) {
  11383. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11384. this._thumbImage._draw(context);
  11385. }
  11386. context.restore();
  11387. };
  11388. /** @hidden */
  11389. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11390. if (this.rotation != 0) {
  11391. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11392. x = this._transformedPosition.x;
  11393. y = this._transformedPosition.y;
  11394. }
  11395. if (this._first) {
  11396. this._first = false;
  11397. this._originX = x;
  11398. this._originY = y;
  11399. // Check if move is required
  11400. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11401. if (this.isVertical) {
  11402. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11403. }
  11404. else {
  11405. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11406. }
  11407. }
  11408. }
  11409. // Delta mode
  11410. var delta = 0;
  11411. if (this.isVertical) {
  11412. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11413. }
  11414. else {
  11415. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11416. }
  11417. this.value += delta * (this.maximum - this.minimum);
  11418. this._originX = x;
  11419. this._originY = y;
  11420. };
  11421. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11422. this._first = true;
  11423. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11424. };
  11425. return ImageScrollBar;
  11426. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11427. /***/ }),
  11428. /***/ "./2D/controls/sliders/scrollBar.ts":
  11429. /*!******************************************!*\
  11430. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11431. \******************************************/
  11432. /*! exports provided: ScrollBar */
  11433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11434. "use strict";
  11435. __webpack_require__.r(__webpack_exports__);
  11436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11437. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11438. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11439. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11440. /**
  11441. * Class used to create slider controls
  11442. */
  11443. var ScrollBar = /** @class */ (function (_super) {
  11444. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11445. /**
  11446. * Creates a new Slider
  11447. * @param name defines the control name
  11448. */
  11449. function ScrollBar(name) {
  11450. var _this = _super.call(this, name) || this;
  11451. _this.name = name;
  11452. _this._background = "black";
  11453. _this._borderColor = "white";
  11454. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11455. return _this;
  11456. }
  11457. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11458. /** Gets or sets border color */
  11459. get: function () {
  11460. return this._borderColor;
  11461. },
  11462. set: function (value) {
  11463. if (this._borderColor === value) {
  11464. return;
  11465. }
  11466. this._borderColor = value;
  11467. this._markAsDirty();
  11468. },
  11469. enumerable: false,
  11470. configurable: true
  11471. });
  11472. Object.defineProperty(ScrollBar.prototype, "background", {
  11473. /** Gets or sets background color */
  11474. get: function () {
  11475. return this._background;
  11476. },
  11477. set: function (value) {
  11478. if (this._background === value) {
  11479. return;
  11480. }
  11481. this._background = value;
  11482. this._markAsDirty();
  11483. },
  11484. enumerable: false,
  11485. configurable: true
  11486. });
  11487. ScrollBar.prototype._getTypeName = function () {
  11488. return "Scrollbar";
  11489. };
  11490. ScrollBar.prototype._getThumbThickness = function () {
  11491. var thumbThickness = 0;
  11492. if (this._thumbWidth.isPixel) {
  11493. thumbThickness = this._thumbWidth.getValue(this._host);
  11494. }
  11495. else {
  11496. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11497. }
  11498. return thumbThickness;
  11499. };
  11500. ScrollBar.prototype._draw = function (context) {
  11501. context.save();
  11502. this._applyStates(context);
  11503. this._prepareRenderingData("rectangle");
  11504. var left = this._renderLeft;
  11505. var thumbPosition = this._getThumbPosition();
  11506. context.fillStyle = this._background;
  11507. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11508. // Value bar
  11509. context.fillStyle = this.color;
  11510. // Thumb
  11511. if (this.isVertical) {
  11512. this._tempMeasure.left = left - this._effectiveBarOffset;
  11513. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11514. this._tempMeasure.width = this._currentMeasure.width;
  11515. this._tempMeasure.height = this._effectiveThumbThickness;
  11516. }
  11517. else {
  11518. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11519. this._tempMeasure.top = this._currentMeasure.top;
  11520. this._tempMeasure.width = this._effectiveThumbThickness;
  11521. this._tempMeasure.height = this._currentMeasure.height;
  11522. }
  11523. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11524. context.restore();
  11525. };
  11526. /** @hidden */
  11527. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11528. if (this.rotation != 0) {
  11529. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11530. x = this._transformedPosition.x;
  11531. y = this._transformedPosition.y;
  11532. }
  11533. if (this._first) {
  11534. this._first = false;
  11535. this._originX = x;
  11536. this._originY = y;
  11537. // Check if move is required
  11538. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11539. if (this.isVertical) {
  11540. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11541. }
  11542. else {
  11543. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11544. }
  11545. }
  11546. }
  11547. // Delta mode
  11548. var delta = 0;
  11549. if (this.isVertical) {
  11550. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11551. }
  11552. else {
  11553. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11554. }
  11555. this.value += delta * (this.maximum - this.minimum);
  11556. this._originX = x;
  11557. this._originY = y;
  11558. };
  11559. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11560. this._first = true;
  11561. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11562. };
  11563. return ScrollBar;
  11564. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11565. /***/ }),
  11566. /***/ "./2D/controls/sliders/slider.ts":
  11567. /*!***************************************!*\
  11568. !*** ./2D/controls/sliders/slider.ts ***!
  11569. \***************************************/
  11570. /*! exports provided: Slider */
  11571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11572. "use strict";
  11573. __webpack_require__.r(__webpack_exports__);
  11574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11575. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11576. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11577. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  11578. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11579. /**
  11580. * Class used to create slider controls
  11581. */
  11582. var Slider = /** @class */ (function (_super) {
  11583. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11584. /**
  11585. * Creates a new Slider
  11586. * @param name defines the control name
  11587. */
  11588. function Slider(name) {
  11589. var _this = _super.call(this, name) || this;
  11590. _this.name = name;
  11591. _this._background = "black";
  11592. _this._borderColor = "white";
  11593. _this._thumbColor = "";
  11594. _this._isThumbCircle = false;
  11595. _this._displayValueBar = true;
  11596. return _this;
  11597. }
  11598. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11599. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11600. get: function () {
  11601. return this._displayValueBar;
  11602. },
  11603. set: function (value) {
  11604. if (this._displayValueBar === value) {
  11605. return;
  11606. }
  11607. this._displayValueBar = value;
  11608. this._markAsDirty();
  11609. },
  11610. enumerable: false,
  11611. configurable: true
  11612. });
  11613. Object.defineProperty(Slider.prototype, "borderColor", {
  11614. /** Gets or sets border color */
  11615. get: function () {
  11616. return this._borderColor;
  11617. },
  11618. set: function (value) {
  11619. if (this._borderColor === value) {
  11620. return;
  11621. }
  11622. this._borderColor = value;
  11623. this._markAsDirty();
  11624. },
  11625. enumerable: false,
  11626. configurable: true
  11627. });
  11628. Object.defineProperty(Slider.prototype, "background", {
  11629. /** Gets or sets background color */
  11630. get: function () {
  11631. return this._background;
  11632. },
  11633. set: function (value) {
  11634. if (this._background === value) {
  11635. return;
  11636. }
  11637. this._background = value;
  11638. this._markAsDirty();
  11639. },
  11640. enumerable: false,
  11641. configurable: true
  11642. });
  11643. Object.defineProperty(Slider.prototype, "thumbColor", {
  11644. /** Gets or sets thumb's color */
  11645. get: function () {
  11646. return this._thumbColor;
  11647. },
  11648. set: function (value) {
  11649. if (this._thumbColor === value) {
  11650. return;
  11651. }
  11652. this._thumbColor = value;
  11653. this._markAsDirty();
  11654. },
  11655. enumerable: false,
  11656. configurable: true
  11657. });
  11658. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11659. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11660. get: function () {
  11661. return this._isThumbCircle;
  11662. },
  11663. set: function (value) {
  11664. if (this._isThumbCircle === value) {
  11665. return;
  11666. }
  11667. this._isThumbCircle = value;
  11668. this._markAsDirty();
  11669. },
  11670. enumerable: false,
  11671. configurable: true
  11672. });
  11673. Slider.prototype._getTypeName = function () {
  11674. return "Slider";
  11675. };
  11676. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11677. context.save();
  11678. this._applyStates(context);
  11679. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11680. var left = this._renderLeft;
  11681. var top = this._renderTop;
  11682. var width = this._renderWidth;
  11683. var height = this._renderHeight;
  11684. var radius = 0;
  11685. if (this.isThumbClamped && this.isThumbCircle) {
  11686. if (this.isVertical) {
  11687. top += (this._effectiveThumbThickness / 2);
  11688. }
  11689. else {
  11690. left += (this._effectiveThumbThickness / 2);
  11691. }
  11692. radius = this._backgroundBoxThickness / 2;
  11693. }
  11694. else {
  11695. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11696. }
  11697. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11698. context.shadowColor = this.shadowColor;
  11699. context.shadowBlur = this.shadowBlur;
  11700. context.shadowOffsetX = this.shadowOffsetX;
  11701. context.shadowOffsetY = this.shadowOffsetY;
  11702. }
  11703. var thumbPosition = this._getThumbPosition();
  11704. context.fillStyle = this._background;
  11705. if (this.isVertical) {
  11706. if (this.isThumbClamped) {
  11707. if (this.isThumbCircle) {
  11708. context.beginPath();
  11709. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11710. context.fill();
  11711. context.fillRect(left, top, width, height);
  11712. }
  11713. else {
  11714. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11715. }
  11716. }
  11717. else {
  11718. context.fillRect(left, top, width, height);
  11719. }
  11720. }
  11721. else {
  11722. if (this.isThumbClamped) {
  11723. if (this.isThumbCircle) {
  11724. context.beginPath();
  11725. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11726. context.fill();
  11727. context.fillRect(left, top, width, height);
  11728. }
  11729. else {
  11730. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11731. }
  11732. }
  11733. else {
  11734. context.fillRect(left, top, width, height);
  11735. }
  11736. }
  11737. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11738. context.shadowBlur = 0;
  11739. context.shadowOffsetX = 0;
  11740. context.shadowOffsetY = 0;
  11741. }
  11742. // Value bar
  11743. context.fillStyle = this.color;
  11744. if (this._displayValueBar) {
  11745. if (this.isVertical) {
  11746. if (this.isThumbClamped) {
  11747. if (this.isThumbCircle) {
  11748. context.beginPath();
  11749. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11750. context.fill();
  11751. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11752. }
  11753. else {
  11754. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11755. }
  11756. }
  11757. else {
  11758. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11759. }
  11760. }
  11761. else {
  11762. if (this.isThumbClamped) {
  11763. if (this.isThumbCircle) {
  11764. context.beginPath();
  11765. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11766. context.fill();
  11767. context.fillRect(left, top, thumbPosition, height);
  11768. }
  11769. else {
  11770. context.fillRect(left, top, thumbPosition, height);
  11771. }
  11772. }
  11773. else {
  11774. context.fillRect(left, top, thumbPosition, height);
  11775. }
  11776. }
  11777. }
  11778. // Thumb
  11779. context.fillStyle = this._thumbColor || this.color;
  11780. if (this.displayThumb) {
  11781. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11782. context.shadowColor = this.shadowColor;
  11783. context.shadowBlur = this.shadowBlur;
  11784. context.shadowOffsetX = this.shadowOffsetX;
  11785. context.shadowOffsetY = this.shadowOffsetY;
  11786. }
  11787. if (this._isThumbCircle) {
  11788. context.beginPath();
  11789. if (this.isVertical) {
  11790. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11791. }
  11792. else {
  11793. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11794. }
  11795. context.fill();
  11796. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11797. context.shadowBlur = 0;
  11798. context.shadowOffsetX = 0;
  11799. context.shadowOffsetY = 0;
  11800. }
  11801. context.strokeStyle = this._borderColor;
  11802. context.stroke();
  11803. }
  11804. else {
  11805. if (this.isVertical) {
  11806. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11807. }
  11808. else {
  11809. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11810. }
  11811. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11812. context.shadowBlur = 0;
  11813. context.shadowOffsetX = 0;
  11814. context.shadowOffsetY = 0;
  11815. }
  11816. context.strokeStyle = this._borderColor;
  11817. if (this.isVertical) {
  11818. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11819. }
  11820. else {
  11821. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11822. }
  11823. }
  11824. }
  11825. context.restore();
  11826. };
  11827. return Slider;
  11828. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11829. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11830. /***/ }),
  11831. /***/ "./2D/controls/stackPanel.ts":
  11832. /*!***********************************!*\
  11833. !*** ./2D/controls/stackPanel.ts ***!
  11834. \***********************************/
  11835. /*! exports provided: StackPanel */
  11836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11837. "use strict";
  11838. __webpack_require__.r(__webpack_exports__);
  11839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11840. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11841. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  11842. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11843. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11844. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11845. /**
  11846. * Class used to create a 2D stack panel container
  11847. */
  11848. var StackPanel = /** @class */ (function (_super) {
  11849. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11850. /**
  11851. * Creates a new StackPanel
  11852. * @param name defines control name
  11853. */
  11854. function StackPanel(name) {
  11855. var _this = _super.call(this, name) || this;
  11856. _this.name = name;
  11857. _this._isVertical = true;
  11858. _this._manualWidth = false;
  11859. _this._manualHeight = false;
  11860. _this._doNotTrackManualChanges = false;
  11861. /**
  11862. * Gets or sets a boolean indicating that layou warnings should be ignored
  11863. */
  11864. _this.ignoreLayoutWarnings = false;
  11865. return _this;
  11866. }
  11867. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11868. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11869. get: function () {
  11870. return this._isVertical;
  11871. },
  11872. set: function (value) {
  11873. if (this._isVertical === value) {
  11874. return;
  11875. }
  11876. this._isVertical = value;
  11877. this._markAsDirty();
  11878. },
  11879. enumerable: false,
  11880. configurable: true
  11881. });
  11882. Object.defineProperty(StackPanel.prototype, "width", {
  11883. get: function () {
  11884. return this._width.toString(this._host);
  11885. },
  11886. /**
  11887. * Gets or sets panel width.
  11888. * This value should not be set when in horizontal mode as it will be computed automatically
  11889. */
  11890. set: function (value) {
  11891. if (!this._doNotTrackManualChanges) {
  11892. this._manualWidth = true;
  11893. }
  11894. if (this._width.toString(this._host) === value) {
  11895. return;
  11896. }
  11897. if (this._width.fromString(value)) {
  11898. this._markAsDirty();
  11899. }
  11900. },
  11901. enumerable: false,
  11902. configurable: true
  11903. });
  11904. Object.defineProperty(StackPanel.prototype, "height", {
  11905. get: function () {
  11906. return this._height.toString(this._host);
  11907. },
  11908. /**
  11909. * Gets or sets panel height.
  11910. * This value should not be set when in vertical mode as it will be computed automatically
  11911. */
  11912. set: function (value) {
  11913. if (!this._doNotTrackManualChanges) {
  11914. this._manualHeight = true;
  11915. }
  11916. if (this._height.toString(this._host) === value) {
  11917. return;
  11918. }
  11919. if (this._height.fromString(value)) {
  11920. this._markAsDirty();
  11921. }
  11922. },
  11923. enumerable: false,
  11924. configurable: true
  11925. });
  11926. StackPanel.prototype._getTypeName = function () {
  11927. return "StackPanel";
  11928. };
  11929. /** @hidden */
  11930. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11931. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11932. var child = _a[_i];
  11933. if (this._isVertical) {
  11934. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11935. }
  11936. else {
  11937. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11938. }
  11939. }
  11940. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11941. };
  11942. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11943. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11944. this._measureForChildren.copyFrom(parentMeasure);
  11945. this._measureForChildren.left = this._currentMeasure.left;
  11946. this._measureForChildren.top = this._currentMeasure.top;
  11947. if (!this.isVertical || this._manualWidth) {
  11948. this._measureForChildren.width = this._currentMeasure.width;
  11949. }
  11950. if (this.isVertical || this._manualHeight) {
  11951. this._measureForChildren.height = this._currentMeasure.height;
  11952. }
  11953. };
  11954. StackPanel.prototype._postMeasure = function () {
  11955. var stackWidth = 0;
  11956. var stackHeight = 0;
  11957. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11958. var child = _a[_i];
  11959. if (!child.isVisible || child.notRenderable) {
  11960. continue;
  11961. }
  11962. if (this._isVertical) {
  11963. if (child.top !== stackHeight + "px") {
  11964. child.top = stackHeight + "px";
  11965. this._rebuildLayout = true;
  11966. child._top.ignoreAdaptiveScaling = true;
  11967. }
  11968. if (child._height.isPercentage && !child._automaticSize) {
  11969. if (!this.ignoreLayoutWarnings) {
  11970. 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");
  11971. }
  11972. }
  11973. else {
  11974. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11975. }
  11976. }
  11977. else {
  11978. if (child.left !== stackWidth + "px") {
  11979. child.left = stackWidth + "px";
  11980. this._rebuildLayout = true;
  11981. child._left.ignoreAdaptiveScaling = true;
  11982. }
  11983. if (child._width.isPercentage && !child._automaticSize) {
  11984. if (!this.ignoreLayoutWarnings) {
  11985. 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");
  11986. }
  11987. }
  11988. else {
  11989. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11990. }
  11991. }
  11992. }
  11993. stackWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  11994. stackHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  11995. this._doNotTrackManualChanges = true;
  11996. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11997. // User can now define their own height and width for stack panel.
  11998. var panelWidthChanged = false;
  11999. var panelHeightChanged = false;
  12000. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  12001. var previousHeight = this.height;
  12002. this.height = stackHeight + "px";
  12003. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  12004. }
  12005. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  12006. var previousWidth = this.width;
  12007. this.width = stackWidth + "px";
  12008. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  12009. }
  12010. if (panelHeightChanged) {
  12011. this._height.ignoreAdaptiveScaling = true;
  12012. }
  12013. if (panelWidthChanged) {
  12014. this._width.ignoreAdaptiveScaling = true;
  12015. }
  12016. this._doNotTrackManualChanges = false;
  12017. if (panelWidthChanged || panelHeightChanged) {
  12018. this._rebuildLayout = true;
  12019. }
  12020. _super.prototype._postMeasure.call(this);
  12021. };
  12022. return StackPanel;
  12023. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  12024. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  12025. /***/ }),
  12026. /***/ "./2D/controls/statics.ts":
  12027. /*!********************************!*\
  12028. !*** ./2D/controls/statics.ts ***!
  12029. \********************************/
  12030. /*! exports provided: name */
  12031. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12032. "use strict";
  12033. __webpack_require__.r(__webpack_exports__);
  12034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  12035. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12036. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12037. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  12038. /**
  12039. * Forcing an export so that this code will execute
  12040. * @hidden
  12041. */
  12042. var name = "Statics";
  12043. /**
  12044. * Creates a stack panel that can be used to render headers
  12045. * @param control defines the control to associate with the header
  12046. * @param text defines the text of the header
  12047. * @param size defines the size of the header
  12048. * @param options defines options used to configure the header
  12049. * @returns a new StackPanel
  12050. */
  12051. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  12052. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  12053. var isHorizontal = options ? options.isHorizontal : true;
  12054. var controlFirst = options ? options.controlFirst : true;
  12055. panel.isVertical = !isHorizontal;
  12056. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  12057. header.text = text;
  12058. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12059. if (isHorizontal) {
  12060. header.width = size;
  12061. }
  12062. else {
  12063. header.height = size;
  12064. }
  12065. if (controlFirst) {
  12066. panel.addControl(control);
  12067. panel.addControl(header);
  12068. header.paddingLeft = "5px";
  12069. }
  12070. else {
  12071. panel.addControl(header);
  12072. panel.addControl(control);
  12073. header.paddingRight = "5px";
  12074. }
  12075. header.shadowBlur = control.shadowBlur;
  12076. header.shadowColor = control.shadowColor;
  12077. header.shadowOffsetX = control.shadowOffsetX;
  12078. header.shadowOffsetY = control.shadowOffsetY;
  12079. return panel;
  12080. };
  12081. /***/ }),
  12082. /***/ "./2D/controls/textBlock.ts":
  12083. /*!**********************************!*\
  12084. !*** ./2D/controls/textBlock.ts ***!
  12085. \**********************************/
  12086. /*! exports provided: TextWrapping, TextBlock */
  12087. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12088. "use strict";
  12089. __webpack_require__.r(__webpack_exports__);
  12090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  12091. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  12092. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12093. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  12094. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12095. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  12096. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12097. /**
  12098. * Enum that determines the text-wrapping mode to use.
  12099. */
  12100. var TextWrapping;
  12101. (function (TextWrapping) {
  12102. /**
  12103. * Clip the text when it's larger than Control.width; this is the default mode.
  12104. */
  12105. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  12106. /**
  12107. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  12108. */
  12109. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  12110. /**
  12111. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  12112. */
  12113. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  12114. })(TextWrapping || (TextWrapping = {}));
  12115. /**
  12116. * Class used to create text block control
  12117. */
  12118. var TextBlock = /** @class */ (function (_super) {
  12119. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  12120. /**
  12121. * Creates a new TextBlock object
  12122. * @param name defines the name of the control
  12123. * @param text defines the text to display (emptry string by default)
  12124. */
  12125. function TextBlock(
  12126. /**
  12127. * Defines the name of the control
  12128. */
  12129. name, text) {
  12130. if (text === void 0) { text = ""; }
  12131. var _this = _super.call(this, name) || this;
  12132. _this.name = name;
  12133. _this._text = "";
  12134. _this._textWrapping = TextWrapping.Clip;
  12135. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  12136. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  12137. _this._resizeToFit = false;
  12138. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  12139. _this._outlineWidth = 0;
  12140. _this._outlineColor = "white";
  12141. _this._underline = false;
  12142. _this._lineThrough = false;
  12143. /**
  12144. * An event triggered after the text is changed
  12145. */
  12146. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12147. /**
  12148. * An event triggered after the text was broken up into lines
  12149. */
  12150. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12151. _this.text = text;
  12152. return _this;
  12153. }
  12154. Object.defineProperty(TextBlock.prototype, "lines", {
  12155. /**
  12156. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  12157. */
  12158. get: function () {
  12159. return this._lines;
  12160. },
  12161. enumerable: false,
  12162. configurable: true
  12163. });
  12164. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12165. /**
  12166. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12167. */
  12168. get: function () {
  12169. return this._resizeToFit;
  12170. },
  12171. /**
  12172. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12173. */
  12174. set: function (value) {
  12175. if (this._resizeToFit === value) {
  12176. return;
  12177. }
  12178. this._resizeToFit = value;
  12179. if (this._resizeToFit) {
  12180. this._width.ignoreAdaptiveScaling = true;
  12181. this._height.ignoreAdaptiveScaling = true;
  12182. }
  12183. this._markAsDirty();
  12184. },
  12185. enumerable: false,
  12186. configurable: true
  12187. });
  12188. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12189. /**
  12190. * Gets or sets a boolean indicating if text must be wrapped
  12191. */
  12192. get: function () {
  12193. return this._textWrapping;
  12194. },
  12195. /**
  12196. * Gets or sets a boolean indicating if text must be wrapped
  12197. */
  12198. set: function (value) {
  12199. if (this._textWrapping === value) {
  12200. return;
  12201. }
  12202. this._textWrapping = +value;
  12203. this._markAsDirty();
  12204. },
  12205. enumerable: false,
  12206. configurable: true
  12207. });
  12208. Object.defineProperty(TextBlock.prototype, "text", {
  12209. /**
  12210. * Gets or sets text to display
  12211. */
  12212. get: function () {
  12213. return this._text;
  12214. },
  12215. /**
  12216. * Gets or sets text to display
  12217. */
  12218. set: function (value) {
  12219. if (this._text === value) {
  12220. return;
  12221. }
  12222. this._text = value;
  12223. this._markAsDirty();
  12224. this.onTextChangedObservable.notifyObservers(this);
  12225. },
  12226. enumerable: false,
  12227. configurable: true
  12228. });
  12229. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12230. /**
  12231. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12232. */
  12233. get: function () {
  12234. return this._textHorizontalAlignment;
  12235. },
  12236. /**
  12237. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12238. */
  12239. set: function (value) {
  12240. if (this._textHorizontalAlignment === value) {
  12241. return;
  12242. }
  12243. this._textHorizontalAlignment = value;
  12244. this._markAsDirty();
  12245. },
  12246. enumerable: false,
  12247. configurable: true
  12248. });
  12249. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12250. /**
  12251. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12252. */
  12253. get: function () {
  12254. return this._textVerticalAlignment;
  12255. },
  12256. /**
  12257. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12258. */
  12259. set: function (value) {
  12260. if (this._textVerticalAlignment === value) {
  12261. return;
  12262. }
  12263. this._textVerticalAlignment = value;
  12264. this._markAsDirty();
  12265. },
  12266. enumerable: false,
  12267. configurable: true
  12268. });
  12269. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12270. /**
  12271. * Gets or sets line spacing value
  12272. */
  12273. get: function () {
  12274. return this._lineSpacing.toString(this._host);
  12275. },
  12276. /**
  12277. * Gets or sets line spacing value
  12278. */
  12279. set: function (value) {
  12280. if (this._lineSpacing.fromString(value)) {
  12281. this._markAsDirty();
  12282. }
  12283. },
  12284. enumerable: false,
  12285. configurable: true
  12286. });
  12287. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12288. /**
  12289. * Gets or sets outlineWidth of the text to display
  12290. */
  12291. get: function () {
  12292. return this._outlineWidth;
  12293. },
  12294. /**
  12295. * Gets or sets outlineWidth of the text to display
  12296. */
  12297. set: function (value) {
  12298. if (this._outlineWidth === value) {
  12299. return;
  12300. }
  12301. this._outlineWidth = value;
  12302. this._markAsDirty();
  12303. },
  12304. enumerable: false,
  12305. configurable: true
  12306. });
  12307. Object.defineProperty(TextBlock.prototype, "underline", {
  12308. /**
  12309. * Gets or sets a boolean indicating that text must have underline
  12310. */
  12311. get: function () {
  12312. return this._underline;
  12313. },
  12314. /**
  12315. * Gets or sets a boolean indicating that text must have underline
  12316. */
  12317. set: function (value) {
  12318. if (this._underline === value) {
  12319. return;
  12320. }
  12321. this._underline = value;
  12322. this._markAsDirty();
  12323. },
  12324. enumerable: false,
  12325. configurable: true
  12326. });
  12327. Object.defineProperty(TextBlock.prototype, "lineThrough", {
  12328. /**
  12329. * Gets or sets an boolean indicating that text must be crossed out
  12330. */
  12331. get: function () {
  12332. return this._lineThrough;
  12333. },
  12334. /**
  12335. * Gets or sets an boolean indicating that text must be crossed out
  12336. */
  12337. set: function (value) {
  12338. if (this._lineThrough === value) {
  12339. return;
  12340. }
  12341. this._lineThrough = value;
  12342. this._markAsDirty();
  12343. },
  12344. enumerable: false,
  12345. configurable: true
  12346. });
  12347. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12348. /**
  12349. * Gets or sets outlineColor of the text to display
  12350. */
  12351. get: function () {
  12352. return this._outlineColor;
  12353. },
  12354. /**
  12355. * Gets or sets outlineColor of the text to display
  12356. */
  12357. set: function (value) {
  12358. if (this._outlineColor === value) {
  12359. return;
  12360. }
  12361. this._outlineColor = value;
  12362. this._markAsDirty();
  12363. },
  12364. enumerable: false,
  12365. configurable: true
  12366. });
  12367. TextBlock.prototype._getTypeName = function () {
  12368. return "TextBlock";
  12369. };
  12370. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12371. if (!this._fontOffset) {
  12372. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12373. }
  12374. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12375. // Prepare lines
  12376. this._lines = this._breakLines(this._currentMeasure.width, context);
  12377. this.onLinesReadyObservable.notifyObservers(this);
  12378. var maxLineWidth = 0;
  12379. for (var i = 0; i < this._lines.length; i++) {
  12380. var line = this._lines[i];
  12381. if (line.width > maxLineWidth) {
  12382. maxLineWidth = line.width;
  12383. }
  12384. }
  12385. if (this._resizeToFit) {
  12386. if (this._textWrapping === TextWrapping.Clip) {
  12387. var newWidth = (this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth) | 0;
  12388. if (newWidth !== this._width.internalValue) {
  12389. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12390. this._rebuildLayout = true;
  12391. }
  12392. }
  12393. var newHeight = (this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;
  12394. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12395. var lineSpacing = 0;
  12396. if (this._lineSpacing.isPixel) {
  12397. lineSpacing = this._lineSpacing.getValue(this._host);
  12398. }
  12399. else {
  12400. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12401. }
  12402. newHeight += (this._lines.length - 1) * lineSpacing;
  12403. }
  12404. if (newHeight !== this._height.internalValue) {
  12405. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12406. this._rebuildLayout = true;
  12407. }
  12408. }
  12409. };
  12410. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12411. var width = this._currentMeasure.width;
  12412. var x = 0;
  12413. switch (this._textHorizontalAlignment) {
  12414. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12415. x = 0;
  12416. break;
  12417. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12418. x = width - textWidth;
  12419. break;
  12420. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12421. x = (width - textWidth) / 2;
  12422. break;
  12423. }
  12424. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12425. context.shadowColor = this.shadowColor;
  12426. context.shadowBlur = this.shadowBlur;
  12427. context.shadowOffsetX = this.shadowOffsetX;
  12428. context.shadowOffsetY = this.shadowOffsetY;
  12429. }
  12430. if (this.outlineWidth) {
  12431. context.strokeText(text, this._currentMeasure.left + x, y);
  12432. }
  12433. context.fillText(text, this._currentMeasure.left + x, y);
  12434. if (this._underline) {
  12435. context.beginPath();
  12436. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  12437. context.moveTo(this._currentMeasure.left + x, y + 3);
  12438. context.lineTo(this._currentMeasure.left + x + textWidth, y + 3);
  12439. context.stroke();
  12440. context.closePath();
  12441. }
  12442. if (this._lineThrough) {
  12443. context.beginPath();
  12444. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  12445. context.moveTo(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3);
  12446. context.lineTo(this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3);
  12447. context.stroke();
  12448. context.closePath();
  12449. }
  12450. };
  12451. /** @hidden */
  12452. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12453. context.save();
  12454. this._applyStates(context);
  12455. // Render lines
  12456. this._renderLines(context);
  12457. context.restore();
  12458. };
  12459. TextBlock.prototype._applyStates = function (context) {
  12460. _super.prototype._applyStates.call(this, context);
  12461. if (this.outlineWidth) {
  12462. context.lineWidth = this.outlineWidth;
  12463. context.strokeStyle = this.outlineColor;
  12464. }
  12465. };
  12466. TextBlock.prototype._breakLines = function (refWidth, context) {
  12467. var lines = [];
  12468. var _lines = this.text.split("\n");
  12469. if (this._textWrapping === TextWrapping.Ellipsis) {
  12470. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12471. var _line = _lines_1[_i];
  12472. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12473. }
  12474. }
  12475. else if (this._textWrapping === TextWrapping.WordWrap) {
  12476. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12477. var _line = _lines_2[_a];
  12478. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12479. }
  12480. }
  12481. else {
  12482. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12483. var _line = _lines_3[_b];
  12484. lines.push(this._parseLine(_line, context));
  12485. }
  12486. }
  12487. return lines;
  12488. };
  12489. TextBlock.prototype._parseLine = function (line, context) {
  12490. if (line === void 0) { line = ""; }
  12491. return { text: line, width: context.measureText(line).width };
  12492. };
  12493. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12494. if (line === void 0) { line = ""; }
  12495. var lineWidth = context.measureText(line).width;
  12496. if (lineWidth > width) {
  12497. line += "…";
  12498. }
  12499. // unicode support. split('') does not work with unicode!
  12500. // make sure Array.from is available
  12501. var characters = Array.from && Array.from(line);
  12502. if (!characters) {
  12503. // no array.from, use the old method
  12504. while (line.length > 2 && lineWidth > width) {
  12505. line = line.slice(0, -2) + "…";
  12506. lineWidth = context.measureText(line).width;
  12507. }
  12508. }
  12509. else {
  12510. while (characters.length && lineWidth > width) {
  12511. characters.pop();
  12512. line = characters.join("") + "...";
  12513. lineWidth = context.measureText(line).width;
  12514. }
  12515. }
  12516. return { text: line, width: lineWidth };
  12517. };
  12518. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12519. if (line === void 0) { line = ""; }
  12520. var lines = [];
  12521. var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(" ");
  12522. var lineWidth = 0;
  12523. for (var n = 0; n < words.length; n++) {
  12524. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12525. var metrics = context.measureText(testLine);
  12526. var testWidth = metrics.width;
  12527. if (testWidth > width && n > 0) {
  12528. lines.push({ text: line, width: lineWidth });
  12529. line = words[n];
  12530. lineWidth = context.measureText(line).width;
  12531. }
  12532. else {
  12533. lineWidth = testWidth;
  12534. line = testLine;
  12535. }
  12536. }
  12537. lines.push({ text: line, width: lineWidth });
  12538. return lines;
  12539. };
  12540. TextBlock.prototype._renderLines = function (context) {
  12541. var height = this._currentMeasure.height;
  12542. var rootY = 0;
  12543. switch (this._textVerticalAlignment) {
  12544. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12545. rootY = this._fontOffset.ascent;
  12546. break;
  12547. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12548. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12549. break;
  12550. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12551. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12552. break;
  12553. }
  12554. rootY += this._currentMeasure.top;
  12555. for (var i = 0; i < this._lines.length; i++) {
  12556. var line = this._lines[i];
  12557. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12558. if (this._lineSpacing.isPixel) {
  12559. rootY += this._lineSpacing.getValue(this._host);
  12560. }
  12561. else {
  12562. rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12563. }
  12564. }
  12565. this._drawText(line.text, line.width, rootY, context);
  12566. rootY += this._fontOffset.height;
  12567. }
  12568. };
  12569. /**
  12570. * Given a width constraint applied on the text block, find the expected height
  12571. * @returns expected height
  12572. */
  12573. TextBlock.prototype.computeExpectedHeight = function () {
  12574. if (this.text && this.widthInPixels) {
  12575. var context_1 = document.createElement("canvas").getContext("2d");
  12576. if (context_1) {
  12577. this._applyStates(context_1);
  12578. if (!this._fontOffset) {
  12579. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12580. }
  12581. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12582. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12583. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12584. var lineSpacing = 0;
  12585. if (this._lineSpacing.isPixel) {
  12586. lineSpacing = this._lineSpacing.getValue(this._host);
  12587. }
  12588. else {
  12589. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12590. }
  12591. newHeight += (lines.length - 1) * lineSpacing;
  12592. }
  12593. return newHeight;
  12594. }
  12595. }
  12596. return 0;
  12597. };
  12598. TextBlock.prototype.dispose = function () {
  12599. _super.prototype.dispose.call(this);
  12600. this.onTextChangedObservable.clear();
  12601. };
  12602. return TextBlock;
  12603. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12604. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12605. /***/ }),
  12606. /***/ "./2D/controls/virtualKeyboard.ts":
  12607. /*!****************************************!*\
  12608. !*** ./2D/controls/virtualKeyboard.ts ***!
  12609. \****************************************/
  12610. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12611. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12612. "use strict";
  12613. __webpack_require__.r(__webpack_exports__);
  12614. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12616. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12617. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  12618. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12619. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12620. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12621. /**
  12622. * Class used to store key control properties
  12623. */
  12624. var KeyPropertySet = /** @class */ (function () {
  12625. function KeyPropertySet() {
  12626. }
  12627. return KeyPropertySet;
  12628. }());
  12629. /**
  12630. * Class used to create virtual keyboard
  12631. */
  12632. var VirtualKeyboard = /** @class */ (function (_super) {
  12633. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12634. function VirtualKeyboard() {
  12635. var _this = _super !== null && _super.apply(this, arguments) || this;
  12636. /** Observable raised when a key is pressed */
  12637. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12638. /** Gets or sets default key button width */
  12639. _this.defaultButtonWidth = "40px";
  12640. /** Gets or sets default key button height */
  12641. _this.defaultButtonHeight = "40px";
  12642. /** Gets or sets default key button left padding */
  12643. _this.defaultButtonPaddingLeft = "2px";
  12644. /** Gets or sets default key button right padding */
  12645. _this.defaultButtonPaddingRight = "2px";
  12646. /** Gets or sets default key button top padding */
  12647. _this.defaultButtonPaddingTop = "2px";
  12648. /** Gets or sets default key button bottom padding */
  12649. _this.defaultButtonPaddingBottom = "2px";
  12650. /** Gets or sets default key button foreground color */
  12651. _this.defaultButtonColor = "#DDD";
  12652. /** Gets or sets default key button background color */
  12653. _this.defaultButtonBackground = "#070707";
  12654. /** Gets or sets shift button foreground color */
  12655. _this.shiftButtonColor = "#7799FF";
  12656. /** Gets or sets shift button thickness*/
  12657. _this.selectedShiftThickness = 1;
  12658. /** Gets shift key state */
  12659. _this.shiftState = 0;
  12660. _this._currentlyConnectedInputText = null;
  12661. _this._connectedInputTexts = [];
  12662. _this._onKeyPressObserver = null;
  12663. return _this;
  12664. }
  12665. VirtualKeyboard.prototype._getTypeName = function () {
  12666. return "VirtualKeyboard";
  12667. };
  12668. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12669. var _this = this;
  12670. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12671. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12672. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12673. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12674. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12675. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12676. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12677. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12678. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12679. button.thickness = 0;
  12680. button.isFocusInvisible = true;
  12681. button.shadowColor = this.shadowColor;
  12682. button.shadowBlur = this.shadowBlur;
  12683. button.shadowOffsetX = this.shadowOffsetX;
  12684. button.shadowOffsetY = this.shadowOffsetY;
  12685. button.onPointerUpObservable.add(function () {
  12686. _this.onKeyPressObservable.notifyObservers(key);
  12687. });
  12688. return button;
  12689. };
  12690. /**
  12691. * Adds a new row of keys
  12692. * @param keys defines the list of keys to add
  12693. * @param propertySets defines the associated property sets
  12694. */
  12695. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12696. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12697. panel.isVertical = false;
  12698. panel.isFocusInvisible = true;
  12699. var maxKey = null;
  12700. for (var i = 0; i < keys.length; i++) {
  12701. var properties = null;
  12702. if (propertySets && propertySets.length === keys.length) {
  12703. properties = propertySets[i];
  12704. }
  12705. var key = this._createKey(keys[i], properties);
  12706. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12707. maxKey = key;
  12708. }
  12709. panel.addControl(key);
  12710. }
  12711. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12712. this.addControl(panel);
  12713. };
  12714. /**
  12715. * Set the shift key to a specific state
  12716. * @param shiftState defines the new shift state
  12717. */
  12718. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12719. if (!this.children) {
  12720. return;
  12721. }
  12722. for (var i = 0; i < this.children.length; i++) {
  12723. var row = this.children[i];
  12724. if (!row || !row.children) {
  12725. continue;
  12726. }
  12727. var rowContainer = row;
  12728. for (var j = 0; j < rowContainer.children.length; j++) {
  12729. var button = rowContainer.children[j];
  12730. if (!button || !button.children[0]) {
  12731. continue;
  12732. }
  12733. var button_tblock = button.children[0];
  12734. if (button_tblock.text === "\u21E7") {
  12735. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12736. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12737. }
  12738. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12739. }
  12740. }
  12741. };
  12742. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12743. /** Gets the input text control currently attached to the keyboard */
  12744. get: function () {
  12745. return this._currentlyConnectedInputText;
  12746. },
  12747. enumerable: false,
  12748. configurable: true
  12749. });
  12750. /**
  12751. * Connects the keyboard with an input text control
  12752. *
  12753. * @param input defines the target control
  12754. */
  12755. VirtualKeyboard.prototype.connect = function (input) {
  12756. var _this = this;
  12757. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12758. if (inputTextAlreadyConnected) {
  12759. return;
  12760. }
  12761. if (this._onKeyPressObserver === null) {
  12762. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12763. if (!_this._currentlyConnectedInputText) {
  12764. return;
  12765. }
  12766. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12767. switch (key) {
  12768. case "\u21E7":
  12769. _this.shiftState++;
  12770. if (_this.shiftState > 2) {
  12771. _this.shiftState = 0;
  12772. }
  12773. _this.applyShiftState(_this.shiftState);
  12774. return;
  12775. case "\u2190":
  12776. _this._currentlyConnectedInputText.processKey(8);
  12777. return;
  12778. case "\u21B5":
  12779. _this._currentlyConnectedInputText.processKey(13);
  12780. return;
  12781. }
  12782. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12783. if (_this.shiftState === 1) {
  12784. _this.shiftState = 0;
  12785. _this.applyShiftState(_this.shiftState);
  12786. }
  12787. });
  12788. }
  12789. this.isVisible = false;
  12790. this._currentlyConnectedInputText = input;
  12791. input._connectedVirtualKeyboard = this;
  12792. // Events hooking
  12793. var onFocusObserver = input.onFocusObservable.add(function () {
  12794. _this._currentlyConnectedInputText = input;
  12795. input._connectedVirtualKeyboard = _this;
  12796. _this.isVisible = true;
  12797. });
  12798. var onBlurObserver = input.onBlurObservable.add(function () {
  12799. input._connectedVirtualKeyboard = null;
  12800. _this._currentlyConnectedInputText = null;
  12801. _this.isVisible = false;
  12802. });
  12803. this._connectedInputTexts.push({
  12804. input: input,
  12805. onBlurObserver: onBlurObserver,
  12806. onFocusObserver: onFocusObserver
  12807. });
  12808. };
  12809. /**
  12810. * Disconnects the keyboard from connected InputText controls
  12811. *
  12812. * @param input optionally defines a target control, otherwise all are disconnected
  12813. */
  12814. VirtualKeyboard.prototype.disconnect = function (input) {
  12815. var _this = this;
  12816. if (input) {
  12817. // .find not available on IE
  12818. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12819. if (filtered.length === 1) {
  12820. this._removeConnectedInputObservables(filtered[0]);
  12821. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12822. if (this._currentlyConnectedInputText === input) {
  12823. this._currentlyConnectedInputText = null;
  12824. }
  12825. }
  12826. }
  12827. else {
  12828. this._connectedInputTexts.forEach(function (connectedInputText) {
  12829. _this._removeConnectedInputObservables(connectedInputText);
  12830. });
  12831. this._connectedInputTexts = [];
  12832. }
  12833. if (this._connectedInputTexts.length === 0) {
  12834. this._currentlyConnectedInputText = null;
  12835. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12836. this._onKeyPressObserver = null;
  12837. }
  12838. };
  12839. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12840. connectedInputText.input._connectedVirtualKeyboard = null;
  12841. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12842. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12843. };
  12844. /**
  12845. * Release all resources
  12846. */
  12847. VirtualKeyboard.prototype.dispose = function () {
  12848. _super.prototype.dispose.call(this);
  12849. this.disconnect();
  12850. };
  12851. // Statics
  12852. /**
  12853. * Creates a new keyboard using a default layout
  12854. *
  12855. * @param name defines control name
  12856. * @returns a new VirtualKeyboard
  12857. */
  12858. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12859. var returnValue = new VirtualKeyboard(name);
  12860. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12861. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12862. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12863. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12864. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12865. return returnValue;
  12866. };
  12867. return VirtualKeyboard;
  12868. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12869. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12870. /***/ }),
  12871. /***/ "./2D/index.ts":
  12872. /*!*********************!*\
  12873. !*** ./2D/index.ts ***!
  12874. \*********************/
  12875. /*! 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, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader */
  12876. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12877. "use strict";
  12878. __webpack_require__.r(__webpack_exports__);
  12879. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12890. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12912. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12914. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12916. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12919. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12921. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12923. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12925. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12927. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12929. /***/ }),
  12930. /***/ "./2D/math2D.ts":
  12931. /*!**********************!*\
  12932. !*** ./2D/math2D.ts ***!
  12933. \**********************/
  12934. /*! exports provided: Vector2WithInfo, Matrix2D */
  12935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12936. "use strict";
  12937. __webpack_require__.r(__webpack_exports__);
  12938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12940. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12941. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  12942. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  12943. /**
  12944. * Class used to transport Vector2 information for pointer events
  12945. */
  12946. var Vector2WithInfo = /** @class */ (function (_super) {
  12947. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12948. /**
  12949. * Creates a new Vector2WithInfo
  12950. * @param source defines the vector2 data to transport
  12951. * @param buttonIndex defines the current mouse button index
  12952. */
  12953. function Vector2WithInfo(source,
  12954. /** defines the current mouse button index */
  12955. buttonIndex) {
  12956. if (buttonIndex === void 0) { buttonIndex = 0; }
  12957. var _this = _super.call(this, source.x, source.y) || this;
  12958. _this.buttonIndex = buttonIndex;
  12959. return _this;
  12960. }
  12961. return Vector2WithInfo;
  12962. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12963. /** Class used to provide 2D matrix features */
  12964. var Matrix2D = /** @class */ (function () {
  12965. /**
  12966. * Creates a new matrix
  12967. * @param m00 defines value for (0, 0)
  12968. * @param m01 defines value for (0, 1)
  12969. * @param m10 defines value for (1, 0)
  12970. * @param m11 defines value for (1, 1)
  12971. * @param m20 defines value for (2, 0)
  12972. * @param m21 defines value for (2, 1)
  12973. */
  12974. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12975. /** Gets the internal array of 6 floats used to store matrix data */
  12976. this.m = new Float32Array(6);
  12977. this.fromValues(m00, m01, m10, m11, m20, m21);
  12978. }
  12979. /**
  12980. * Fills the matrix from direct values
  12981. * @param m00 defines value for (0, 0)
  12982. * @param m01 defines value for (0, 1)
  12983. * @param m10 defines value for (1, 0)
  12984. * @param m11 defines value for (1, 1)
  12985. * @param m20 defines value for (2, 0)
  12986. * @param m21 defines value for (2, 1)
  12987. * @returns the current modified matrix
  12988. */
  12989. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12990. this.m[0] = m00;
  12991. this.m[1] = m01;
  12992. this.m[2] = m10;
  12993. this.m[3] = m11;
  12994. this.m[4] = m20;
  12995. this.m[5] = m21;
  12996. return this;
  12997. };
  12998. /**
  12999. * Gets matrix determinant
  13000. * @returns the determinant
  13001. */
  13002. Matrix2D.prototype.determinant = function () {
  13003. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  13004. };
  13005. /**
  13006. * Inverses the matrix and stores it in a target matrix
  13007. * @param result defines the target matrix
  13008. * @returns the current matrix
  13009. */
  13010. Matrix2D.prototype.invertToRef = function (result) {
  13011. var l0 = this.m[0];
  13012. var l1 = this.m[1];
  13013. var l2 = this.m[2];
  13014. var l3 = this.m[3];
  13015. var l4 = this.m[4];
  13016. var l5 = this.m[5];
  13017. var det = this.determinant();
  13018. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  13019. result.m[0] = 0;
  13020. result.m[1] = 0;
  13021. result.m[2] = 0;
  13022. result.m[3] = 0;
  13023. result.m[4] = 0;
  13024. result.m[5] = 0;
  13025. return this;
  13026. }
  13027. var detDiv = 1 / det;
  13028. var det4 = l2 * l5 - l3 * l4;
  13029. var det5 = l1 * l4 - l0 * l5;
  13030. result.m[0] = l3 * detDiv;
  13031. result.m[1] = -l1 * detDiv;
  13032. result.m[2] = -l2 * detDiv;
  13033. result.m[3] = l0 * detDiv;
  13034. result.m[4] = det4 * detDiv;
  13035. result.m[5] = det5 * detDiv;
  13036. return this;
  13037. };
  13038. /**
  13039. * Multiplies the current matrix with another one
  13040. * @param other defines the second operand
  13041. * @param result defines the target matrix
  13042. * @returns the current matrix
  13043. */
  13044. Matrix2D.prototype.multiplyToRef = function (other, result) {
  13045. var l0 = this.m[0];
  13046. var l1 = this.m[1];
  13047. var l2 = this.m[2];
  13048. var l3 = this.m[3];
  13049. var l4 = this.m[4];
  13050. var l5 = this.m[5];
  13051. var r0 = other.m[0];
  13052. var r1 = other.m[1];
  13053. var r2 = other.m[2];
  13054. var r3 = other.m[3];
  13055. var r4 = other.m[4];
  13056. var r5 = other.m[5];
  13057. result.m[0] = l0 * r0 + l1 * r2;
  13058. result.m[1] = l0 * r1 + l1 * r3;
  13059. result.m[2] = l2 * r0 + l3 * r2;
  13060. result.m[3] = l2 * r1 + l3 * r3;
  13061. result.m[4] = l4 * r0 + l5 * r2 + r4;
  13062. result.m[5] = l4 * r1 + l5 * r3 + r5;
  13063. return this;
  13064. };
  13065. /**
  13066. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  13067. * @param x defines the x coordinate to transform
  13068. * @param y defines the x coordinate to transform
  13069. * @param result defines the target vector2
  13070. * @returns the current matrix
  13071. */
  13072. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  13073. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  13074. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  13075. return this;
  13076. };
  13077. // Statics
  13078. /**
  13079. * Creates an identity matrix
  13080. * @returns a new matrix
  13081. */
  13082. Matrix2D.Identity = function () {
  13083. return new Matrix2D(1, 0, 0, 1, 0, 0);
  13084. };
  13085. /**
  13086. * Creates a translation matrix and stores it in a target matrix
  13087. * @param x defines the x coordinate of the translation
  13088. * @param y defines the y coordinate of the translation
  13089. * @param result defines the target matrix
  13090. */
  13091. Matrix2D.TranslationToRef = function (x, y, result) {
  13092. result.fromValues(1, 0, 0, 1, x, y);
  13093. };
  13094. /**
  13095. * Creates a scaling matrix and stores it in a target matrix
  13096. * @param x defines the x coordinate of the scaling
  13097. * @param y defines the y coordinate of the scaling
  13098. * @param result defines the target matrix
  13099. */
  13100. Matrix2D.ScalingToRef = function (x, y, result) {
  13101. result.fromValues(x, 0, 0, y, 0, 0);
  13102. };
  13103. /**
  13104. * Creates a rotation matrix and stores it in a target matrix
  13105. * @param angle defines the rotation angle
  13106. * @param result defines the target matrix
  13107. */
  13108. Matrix2D.RotationToRef = function (angle, result) {
  13109. var s = Math.sin(angle);
  13110. var c = Math.cos(angle);
  13111. result.fromValues(c, s, -s, c, 0, 0);
  13112. };
  13113. /**
  13114. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  13115. * @param tx defines the x coordinate of the translation
  13116. * @param ty defines the y coordinate of the translation
  13117. * @param angle defines the rotation angle
  13118. * @param scaleX defines the x coordinate of the scaling
  13119. * @param scaleY defines the y coordinate of the scaling
  13120. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  13121. * @param result defines the target matrix
  13122. */
  13123. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  13124. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  13125. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  13126. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  13127. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  13128. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  13129. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  13130. if (parentMatrix) {
  13131. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  13132. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  13133. }
  13134. else {
  13135. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  13136. }
  13137. };
  13138. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  13139. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  13140. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  13141. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  13142. Matrix2D._TempCompose0 = Matrix2D.Identity();
  13143. Matrix2D._TempCompose1 = Matrix2D.Identity();
  13144. Matrix2D._TempCompose2 = Matrix2D.Identity();
  13145. return Matrix2D;
  13146. }());
  13147. /***/ }),
  13148. /***/ "./2D/measure.ts":
  13149. /*!***********************!*\
  13150. !*** ./2D/measure.ts ***!
  13151. \***********************/
  13152. /*! exports provided: Measure */
  13153. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13154. "use strict";
  13155. __webpack_require__.r(__webpack_exports__);
  13156. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  13157. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  13158. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13159. var tmpRect = [
  13160. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13161. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13162. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13163. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13164. ];
  13165. var tmpRect2 = [
  13166. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13167. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13168. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13169. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13170. ];
  13171. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13172. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13173. /**
  13174. * Class used to store 2D control sizes
  13175. */
  13176. var Measure = /** @class */ (function () {
  13177. /**
  13178. * Creates a new measure
  13179. * @param left defines left coordinate
  13180. * @param top defines top coordinate
  13181. * @param width defines width dimension
  13182. * @param height defines height dimension
  13183. */
  13184. function Measure(
  13185. /** defines left coordinate */
  13186. left,
  13187. /** defines top coordinate */
  13188. top,
  13189. /** defines width dimension */
  13190. width,
  13191. /** defines height dimension */
  13192. height) {
  13193. this.left = left;
  13194. this.top = top;
  13195. this.width = width;
  13196. this.height = height;
  13197. }
  13198. /**
  13199. * Copy from another measure
  13200. * @param other defines the other measure to copy from
  13201. */
  13202. Measure.prototype.copyFrom = function (other) {
  13203. this.left = other.left;
  13204. this.top = other.top;
  13205. this.width = other.width;
  13206. this.height = other.height;
  13207. };
  13208. /**
  13209. * Copy from a group of 4 floats
  13210. * @param left defines left coordinate
  13211. * @param top defines top coordinate
  13212. * @param width defines width dimension
  13213. * @param height defines height dimension
  13214. */
  13215. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  13216. this.left = left;
  13217. this.top = top;
  13218. this.width = width;
  13219. this.height = height;
  13220. };
  13221. /**
  13222. * Computes the axis aligned bounding box measure for two given measures
  13223. * @param a Input measure
  13224. * @param b Input measure
  13225. * @param result the resulting bounding measure
  13226. */
  13227. Measure.CombineToRef = function (a, b, result) {
  13228. var left = Math.min(a.left, b.left);
  13229. var top = Math.min(a.top, b.top);
  13230. var right = Math.max(a.left + a.width, b.left + b.width);
  13231. var bottom = Math.max(a.top + a.height, b.top + b.height);
  13232. result.left = left;
  13233. result.top = top;
  13234. result.width = right - left;
  13235. result.height = bottom - top;
  13236. };
  13237. /**
  13238. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13239. * @param transform the matrix to transform the measure before computing the AABB
  13240. * @param addX number to add to left
  13241. * @param addY number to add to top
  13242. * @param addWidth number to add to width
  13243. * @param addHeight number to add to height
  13244. * @param result the resulting AABB
  13245. */
  13246. Measure.prototype.addAndTransformToRef = function (transform, addX, addY, addWidth, addHeight, result) {
  13247. var left = this.left + addX;
  13248. var top = this.top + addY;
  13249. var width = this.width + addWidth;
  13250. var height = this.height + addHeight;
  13251. tmpRect[0].copyFromFloats(left, top);
  13252. tmpRect[1].copyFromFloats(left + width, top);
  13253. tmpRect[2].copyFromFloats(left + width, top + height);
  13254. tmpRect[3].copyFromFloats(left, top + height);
  13255. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  13256. tmpV2.copyFromFloats(0, 0);
  13257. for (var i = 0; i < 4; i++) {
  13258. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  13259. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  13260. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  13261. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  13262. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  13263. }
  13264. result.left = tmpV1.x;
  13265. result.top = tmpV1.y;
  13266. result.width = tmpV2.x - tmpV1.x;
  13267. result.height = tmpV2.y - tmpV1.y;
  13268. };
  13269. /**
  13270. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13271. * @param transform the matrix to transform the measure before computing the AABB
  13272. * @param result the resulting AABB
  13273. */
  13274. Measure.prototype.transformToRef = function (transform, result) {
  13275. this.addAndTransformToRef(transform, 0, 0, 0, 0, result);
  13276. };
  13277. /**
  13278. * Check equality between this measure and another one
  13279. * @param other defines the other measures
  13280. * @returns true if both measures are equals
  13281. */
  13282. Measure.prototype.isEqualsTo = function (other) {
  13283. if (this.left !== other.left) {
  13284. return false;
  13285. }
  13286. if (this.top !== other.top) {
  13287. return false;
  13288. }
  13289. if (this.width !== other.width) {
  13290. return false;
  13291. }
  13292. if (this.height !== other.height) {
  13293. return false;
  13294. }
  13295. return true;
  13296. };
  13297. /**
  13298. * Creates an empty measure
  13299. * @returns a new measure
  13300. */
  13301. Measure.Empty = function () {
  13302. return new Measure(0, 0, 0, 0);
  13303. };
  13304. return Measure;
  13305. }());
  13306. /***/ }),
  13307. /***/ "./2D/multiLinePoint.ts":
  13308. /*!******************************!*\
  13309. !*** ./2D/multiLinePoint.ts ***!
  13310. \******************************/
  13311. /*! exports provided: MultiLinePoint */
  13312. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13313. "use strict";
  13314. __webpack_require__.r(__webpack_exports__);
  13315. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13316. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  13317. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13318. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13319. /**
  13320. * Class used to store a point for a MultiLine object.
  13321. * The point can be pure 2D coordinates, a mesh or a control
  13322. */
  13323. var MultiLinePoint = /** @class */ (function () {
  13324. /**
  13325. * Creates a new MultiLinePoint
  13326. * @param multiLine defines the source MultiLine object
  13327. */
  13328. function MultiLinePoint(multiLine) {
  13329. this._multiLine = multiLine;
  13330. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13331. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13332. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13333. }
  13334. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13335. /** Gets or sets x coordinate */
  13336. get: function () {
  13337. return this._x.toString(this._multiLine._host);
  13338. },
  13339. set: function (value) {
  13340. if (this._x.toString(this._multiLine._host) === value) {
  13341. return;
  13342. }
  13343. if (this._x.fromString(value)) {
  13344. this._multiLine._markAsDirty();
  13345. }
  13346. },
  13347. enumerable: false,
  13348. configurable: true
  13349. });
  13350. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13351. /** Gets or sets y coordinate */
  13352. get: function () {
  13353. return this._y.toString(this._multiLine._host);
  13354. },
  13355. set: function (value) {
  13356. if (this._y.toString(this._multiLine._host) === value) {
  13357. return;
  13358. }
  13359. if (this._y.fromString(value)) {
  13360. this._multiLine._markAsDirty();
  13361. }
  13362. },
  13363. enumerable: false,
  13364. configurable: true
  13365. });
  13366. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13367. /** Gets or sets the control associated with this point */
  13368. get: function () {
  13369. return this._control;
  13370. },
  13371. set: function (value) {
  13372. if (this._control === value) {
  13373. return;
  13374. }
  13375. if (this._control && this._controlObserver) {
  13376. this._control.onDirtyObservable.remove(this._controlObserver);
  13377. this._controlObserver = null;
  13378. }
  13379. this._control = value;
  13380. if (this._control) {
  13381. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13382. }
  13383. this._multiLine._markAsDirty();
  13384. },
  13385. enumerable: false,
  13386. configurable: true
  13387. });
  13388. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13389. /** Gets or sets the mesh associated with this point */
  13390. get: function () {
  13391. return this._mesh;
  13392. },
  13393. set: function (value) {
  13394. if (this._mesh === value) {
  13395. return;
  13396. }
  13397. if (this._mesh && this._meshObserver) {
  13398. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13399. }
  13400. this._mesh = value;
  13401. if (this._mesh) {
  13402. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13403. }
  13404. this._multiLine._markAsDirty();
  13405. },
  13406. enumerable: false,
  13407. configurable: true
  13408. });
  13409. /** Resets links */
  13410. MultiLinePoint.prototype.resetLinks = function () {
  13411. this.control = null;
  13412. this.mesh = null;
  13413. };
  13414. /**
  13415. * Gets a translation vector
  13416. * @returns the translation vector
  13417. */
  13418. MultiLinePoint.prototype.translate = function () {
  13419. this._point = this._translatePoint();
  13420. return this._point;
  13421. };
  13422. MultiLinePoint.prototype._translatePoint = function () {
  13423. if (this._mesh != null) {
  13424. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13425. }
  13426. else if (this._control != null) {
  13427. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  13428. }
  13429. else {
  13430. var host = this._multiLine._host;
  13431. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13432. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13433. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  13434. }
  13435. };
  13436. /** Release associated resources */
  13437. MultiLinePoint.prototype.dispose = function () {
  13438. this.resetLinks();
  13439. };
  13440. return MultiLinePoint;
  13441. }());
  13442. /***/ }),
  13443. /***/ "./2D/style.ts":
  13444. /*!*********************!*\
  13445. !*** ./2D/style.ts ***!
  13446. \*********************/
  13447. /*! exports provided: Style */
  13448. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13449. "use strict";
  13450. __webpack_require__.r(__webpack_exports__);
  13451. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13452. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  13453. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13454. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13455. /**
  13456. * Define a style used by control to automatically setup properties based on a template.
  13457. * Only support font related properties so far
  13458. */
  13459. var Style = /** @class */ (function () {
  13460. /**
  13461. * Creates a new style object
  13462. * @param host defines the AdvancedDynamicTexture which hosts this style
  13463. */
  13464. function Style(host) {
  13465. this._fontFamily = "Arial";
  13466. this._fontStyle = "";
  13467. this._fontWeight = "";
  13468. /** @hidden */
  13469. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13470. /**
  13471. * Observable raised when the style values are changed
  13472. */
  13473. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13474. this._host = host;
  13475. }
  13476. Object.defineProperty(Style.prototype, "fontSize", {
  13477. /**
  13478. * Gets or sets the font size
  13479. */
  13480. get: function () {
  13481. return this._fontSize.toString(this._host);
  13482. },
  13483. set: function (value) {
  13484. if (this._fontSize.toString(this._host) === value) {
  13485. return;
  13486. }
  13487. if (this._fontSize.fromString(value)) {
  13488. this.onChangedObservable.notifyObservers(this);
  13489. }
  13490. },
  13491. enumerable: false,
  13492. configurable: true
  13493. });
  13494. Object.defineProperty(Style.prototype, "fontFamily", {
  13495. /**
  13496. * Gets or sets the font family
  13497. */
  13498. get: function () {
  13499. return this._fontFamily;
  13500. },
  13501. set: function (value) {
  13502. if (this._fontFamily === value) {
  13503. return;
  13504. }
  13505. this._fontFamily = value;
  13506. this.onChangedObservable.notifyObservers(this);
  13507. },
  13508. enumerable: false,
  13509. configurable: true
  13510. });
  13511. Object.defineProperty(Style.prototype, "fontStyle", {
  13512. /**
  13513. * Gets or sets the font style
  13514. */
  13515. get: function () {
  13516. return this._fontStyle;
  13517. },
  13518. set: function (value) {
  13519. if (this._fontStyle === value) {
  13520. return;
  13521. }
  13522. this._fontStyle = value;
  13523. this.onChangedObservable.notifyObservers(this);
  13524. },
  13525. enumerable: false,
  13526. configurable: true
  13527. });
  13528. Object.defineProperty(Style.prototype, "fontWeight", {
  13529. /** Gets or sets font weight */
  13530. get: function () {
  13531. return this._fontWeight;
  13532. },
  13533. set: function (value) {
  13534. if (this._fontWeight === value) {
  13535. return;
  13536. }
  13537. this._fontWeight = value;
  13538. this.onChangedObservable.notifyObservers(this);
  13539. },
  13540. enumerable: false,
  13541. configurable: true
  13542. });
  13543. /** Dispose all associated resources */
  13544. Style.prototype.dispose = function () {
  13545. this.onChangedObservable.clear();
  13546. };
  13547. return Style;
  13548. }());
  13549. /***/ }),
  13550. /***/ "./2D/valueAndUnit.ts":
  13551. /*!****************************!*\
  13552. !*** ./2D/valueAndUnit.ts ***!
  13553. \****************************/
  13554. /*! exports provided: ValueAndUnit */
  13555. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13556. "use strict";
  13557. __webpack_require__.r(__webpack_exports__);
  13558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13559. /**
  13560. * Class used to specific a value and its associated unit
  13561. */
  13562. var ValueAndUnit = /** @class */ (function () {
  13563. /**
  13564. * Creates a new ValueAndUnit
  13565. * @param value defines the value to store
  13566. * @param unit defines the unit to store
  13567. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13568. */
  13569. function ValueAndUnit(value,
  13570. /** defines the unit to store */
  13571. unit,
  13572. /** defines a boolean indicating if the value can be negative */
  13573. negativeValueAllowed) {
  13574. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13575. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13576. this.unit = unit;
  13577. this.negativeValueAllowed = negativeValueAllowed;
  13578. this._value = 1;
  13579. /**
  13580. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13581. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13582. */
  13583. this.ignoreAdaptiveScaling = false;
  13584. this._value = value;
  13585. this._originalUnit = unit;
  13586. }
  13587. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13588. /** Gets a boolean indicating if the value is a percentage */
  13589. get: function () {
  13590. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13591. },
  13592. enumerable: false,
  13593. configurable: true
  13594. });
  13595. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13596. /** Gets a boolean indicating if the value is store as pixel */
  13597. get: function () {
  13598. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13599. },
  13600. enumerable: false,
  13601. configurable: true
  13602. });
  13603. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13604. /** Gets direct internal value */
  13605. get: function () {
  13606. return this._value;
  13607. },
  13608. enumerable: false,
  13609. configurable: true
  13610. });
  13611. /**
  13612. * Gets value as pixel
  13613. * @param host defines the root host
  13614. * @param refValue defines the reference value for percentages
  13615. * @returns the value as pixel
  13616. */
  13617. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13618. if (this.isPixel) {
  13619. return this.getValue(host);
  13620. }
  13621. return this.getValue(host) * refValue;
  13622. };
  13623. /**
  13624. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13625. * @param value defines the value to store
  13626. * @param unit defines the unit to store
  13627. * @returns the current ValueAndUnit
  13628. */
  13629. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13630. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13631. this._value = value;
  13632. this.unit = unit;
  13633. return this;
  13634. };
  13635. /**
  13636. * Gets the value accordingly to its unit
  13637. * @param host defines the root host
  13638. * @returns the value
  13639. */
  13640. ValueAndUnit.prototype.getValue = function (host) {
  13641. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13642. var width = 0;
  13643. var height = 0;
  13644. if (host.idealWidth) {
  13645. width = (this._value * host.getSize().width) / host.idealWidth;
  13646. }
  13647. if (host.idealHeight) {
  13648. height = (this._value * host.getSize().height) / host.idealHeight;
  13649. }
  13650. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13651. return window.innerWidth < window.innerHeight ? width : height;
  13652. }
  13653. if (host.idealWidth) { // horizontal
  13654. return width;
  13655. }
  13656. if (host.idealHeight) { // vertical
  13657. return height;
  13658. }
  13659. }
  13660. return this._value;
  13661. };
  13662. /**
  13663. * Gets a string representation of the value
  13664. * @param host defines the root host
  13665. * @param decimals defines an optional number of decimals to display
  13666. * @returns a string
  13667. */
  13668. ValueAndUnit.prototype.toString = function (host, decimals) {
  13669. switch (this.unit) {
  13670. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13671. var percentage = this.getValue(host) * 100;
  13672. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13673. case ValueAndUnit.UNITMODE_PIXEL:
  13674. var pixels = this.getValue(host);
  13675. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13676. }
  13677. return this.unit.toString();
  13678. };
  13679. /**
  13680. * Store a value parsed from a string
  13681. * @param source defines the source string
  13682. * @returns true if the value was successfully parsed
  13683. */
  13684. ValueAndUnit.prototype.fromString = function (source) {
  13685. var match = ValueAndUnit._Regex.exec(source.toString());
  13686. if (!match || match.length === 0) {
  13687. return false;
  13688. }
  13689. var sourceValue = parseFloat(match[1]);
  13690. var sourceUnit = this._originalUnit;
  13691. if (!this.negativeValueAllowed) {
  13692. if (sourceValue < 0) {
  13693. sourceValue = 0;
  13694. }
  13695. }
  13696. if (match.length === 4) {
  13697. switch (match[3]) {
  13698. case "px":
  13699. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13700. break;
  13701. case "%":
  13702. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13703. sourceValue /= 100.0;
  13704. break;
  13705. }
  13706. }
  13707. if (sourceValue === this._value && sourceUnit === this.unit) {
  13708. return false;
  13709. }
  13710. this._value = sourceValue;
  13711. this.unit = sourceUnit;
  13712. return true;
  13713. };
  13714. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13715. /** UNITMODE_PERCENTAGE */
  13716. get: function () {
  13717. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13718. },
  13719. enumerable: false,
  13720. configurable: true
  13721. });
  13722. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13723. /** UNITMODE_PIXEL */
  13724. get: function () {
  13725. return ValueAndUnit._UNITMODE_PIXEL;
  13726. },
  13727. enumerable: false,
  13728. configurable: true
  13729. });
  13730. // Static
  13731. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13732. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13733. ValueAndUnit._UNITMODE_PIXEL = 1;
  13734. return ValueAndUnit;
  13735. }());
  13736. /***/ }),
  13737. /***/ "./2D/xmlLoader.ts":
  13738. /*!*************************!*\
  13739. !*** ./2D/xmlLoader.ts ***!
  13740. \*************************/
  13741. /*! exports provided: XmlLoader */
  13742. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13743. "use strict";
  13744. __webpack_require__.r(__webpack_exports__);
  13745. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13746. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  13747. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13748. /**
  13749. * Class used to load GUI via XML.
  13750. */
  13751. var XmlLoader = /** @class */ (function () {
  13752. /**
  13753. * Create a new xml loader
  13754. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13755. */
  13756. function XmlLoader(parentClass) {
  13757. if (parentClass === void 0) { parentClass = null; }
  13758. this._nodes = {};
  13759. this._nodeTypes = {
  13760. element: 1,
  13761. attribute: 2,
  13762. text: 3
  13763. };
  13764. this._isLoaded = false;
  13765. this._objectAttributes = {
  13766. "textHorizontalAlignment": 1,
  13767. "textVerticalAlignment": 2,
  13768. "horizontalAlignment": 3,
  13769. "verticalAlignment": 4,
  13770. "stretch": 5,
  13771. };
  13772. if (parentClass) {
  13773. this._parentClass = parentClass;
  13774. }
  13775. }
  13776. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13777. var element = window;
  13778. if (this._parentClass) {
  13779. element = this._parentClass;
  13780. }
  13781. var value = attributeValue;
  13782. value = value.split(".");
  13783. for (var i = 0; i < value.length; i++) {
  13784. element = element[value[i]];
  13785. }
  13786. return element;
  13787. };
  13788. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13789. var attribute = attributeName.split(".");
  13790. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13791. return className[attribute[1]];
  13792. };
  13793. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13794. if (linkParent === void 0) { linkParent = true; }
  13795. try {
  13796. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13797. var guiNode = new className();
  13798. if (parent && linkParent) {
  13799. parent.addControl(guiNode);
  13800. }
  13801. for (var i = 0; i < node.attributes.length; i++) {
  13802. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13803. continue;
  13804. }
  13805. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13806. var element = this._getChainElement(node.attributes[i].value);
  13807. guiNode[node.attributes[i].name].add(element);
  13808. continue;
  13809. }
  13810. else if (node.attributes[i].name == "linkWithMesh") {
  13811. if (this._parentClass) {
  13812. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13813. }
  13814. else {
  13815. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13816. }
  13817. }
  13818. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13819. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13820. guiNode[node.attributes[i].name] = element;
  13821. }
  13822. else if (!this._objectAttributes[node.attributes[i].name]) {
  13823. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13824. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13825. }
  13826. else {
  13827. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13828. }
  13829. }
  13830. else {
  13831. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13832. }
  13833. }
  13834. if (!node.attributes.getNamedItem("id")) {
  13835. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13836. return guiNode;
  13837. }
  13838. var id = node.attributes.getNamedItem("id").value;
  13839. if (id.startsWith("{{") && id.endsWith("}}")) {
  13840. id = this._getChainElement(id.substring(2, id.length - 2));
  13841. }
  13842. if (!this._nodes[id]) {
  13843. this._nodes[id] = guiNode;
  13844. }
  13845. else {
  13846. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13847. }
  13848. return guiNode;
  13849. }
  13850. catch (e) {
  13851. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13852. }
  13853. };
  13854. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13855. var width;
  13856. var height;
  13857. var columns;
  13858. var rows = node.children;
  13859. var cells;
  13860. var isPixel = false;
  13861. var cellNode;
  13862. var rowNumber = -1;
  13863. var columnNumber = -1;
  13864. var totalColumnsNumber = 0;
  13865. for (var i = 0; i < rows.length; i++) {
  13866. if (rows[i].nodeType != this._nodeTypes.element) {
  13867. continue;
  13868. }
  13869. if (rows[i].nodeName != "Row") {
  13870. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13871. }
  13872. rowNumber += 1;
  13873. columns = rows[i].children;
  13874. if (!rows[i].attributes.getNamedItem("height")) {
  13875. throw "XmlLoader Exception : Height must be defined for grid rows";
  13876. }
  13877. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13878. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13879. guiNode.addRowDefinition(height, isPixel);
  13880. for (var j = 0; j < columns.length; j++) {
  13881. if (columns[j].nodeType != this._nodeTypes.element) {
  13882. continue;
  13883. }
  13884. if (columns[j].nodeName != "Column") {
  13885. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13886. }
  13887. columnNumber += 1;
  13888. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13889. 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.";
  13890. }
  13891. if (rowNumber == 0) {
  13892. if (!columns[j].attributes.getNamedItem("width")) {
  13893. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13894. }
  13895. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13896. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13897. guiNode.addColumnDefinition(width, isPixel);
  13898. }
  13899. cells = columns[j].children;
  13900. for (var k = 0; k < cells.length; k++) {
  13901. if (cells[k].nodeType != this._nodeTypes.element) {
  13902. continue;
  13903. }
  13904. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13905. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13906. if (cells[k].firstChild) {
  13907. this._parseXml(cells[k].firstChild, cellNode);
  13908. }
  13909. }
  13910. }
  13911. if (rowNumber == 0) {
  13912. totalColumnsNumber = columnNumber;
  13913. }
  13914. columnNumber = -1;
  13915. }
  13916. if (node.nextSibling) {
  13917. this._parseXml(node.nextSibling, parent);
  13918. }
  13919. };
  13920. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13921. if (node.firstChild) {
  13922. this._parseXml(node.firstChild, guiNode);
  13923. }
  13924. if (node.nextSibling) {
  13925. this._parseXml(node.nextSibling, parent);
  13926. }
  13927. };
  13928. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13929. if (this._parentClass) {
  13930. this._parentClass[variable] = source[iterator];
  13931. }
  13932. else {
  13933. window[variable] = source[iterator];
  13934. }
  13935. if (node.firstChild) {
  13936. this._parseXml(node.firstChild, guiNode, true);
  13937. }
  13938. };
  13939. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13940. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13941. if (!dataSource.includes(" in ")) {
  13942. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13943. }
  13944. else {
  13945. var isArray = true;
  13946. var splittedSource = dataSource.split(" in ");
  13947. if (splittedSource.length < 2) {
  13948. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13949. }
  13950. var source = splittedSource[1];
  13951. if (source.startsWith("{") && source.endsWith("}")) {
  13952. isArray = false;
  13953. }
  13954. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13955. source = source.substring(1, source.length - 1);
  13956. }
  13957. if (this._parentClass) {
  13958. source = this._parentClass[source];
  13959. }
  13960. else {
  13961. source = window[source];
  13962. }
  13963. if (isArray) {
  13964. for (var i = 0; i < source.length; i++) {
  13965. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13966. }
  13967. }
  13968. else {
  13969. for (var i in source) {
  13970. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13971. }
  13972. }
  13973. if (node.nextSibling) {
  13974. this._parseXml(node.nextSibling, parent);
  13975. }
  13976. }
  13977. };
  13978. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13979. if (generated === void 0) { generated = false; }
  13980. if (node.nodeType != this._nodeTypes.element) {
  13981. if (node.nextSibling) {
  13982. this._parseXml(node.nextSibling, parent, generated);
  13983. }
  13984. return;
  13985. }
  13986. if (generated) {
  13987. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13988. }
  13989. var guiNode = this._createGuiElement(node, parent);
  13990. if (node.nodeName == "Grid") {
  13991. this._parseGrid(node, guiNode, parent);
  13992. }
  13993. else if (!node.attributes.getNamedItem("dataSource")) {
  13994. this._parseElement(node, guiNode, parent);
  13995. }
  13996. else {
  13997. this._parseElementsFromSource(node, guiNode, parent);
  13998. }
  13999. };
  14000. /**
  14001. * Gets if the loading has finished.
  14002. * @returns whether the loading has finished or not
  14003. */
  14004. XmlLoader.prototype.isLoaded = function () {
  14005. return this._isLoaded;
  14006. };
  14007. /**
  14008. * Gets a loaded node / control by id.
  14009. * @param id the Controls id set in the xml
  14010. * @returns element of type Control
  14011. */
  14012. XmlLoader.prototype.getNodeById = function (id) {
  14013. return this._nodes[id];
  14014. };
  14015. /**
  14016. * Gets all loaded nodes / controls
  14017. * @returns Array of controls
  14018. */
  14019. XmlLoader.prototype.getNodes = function () {
  14020. return this._nodes;
  14021. };
  14022. /**
  14023. * Initiates the xml layout loading
  14024. * @param xmlFile defines the xml layout to load
  14025. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  14026. * @param callback defines the callback called on layout load.
  14027. */
  14028. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  14029. var xhttp = new XMLHttpRequest();
  14030. xhttp.onreadystatechange = function () {
  14031. if (xhttp.readyState == 4 && xhttp.status == 200) {
  14032. if (!xhttp.responseXML) {
  14033. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  14034. }
  14035. var xmlDoc = xhttp.responseXML.documentElement;
  14036. this._parseXml(xmlDoc.firstChild, rootNode);
  14037. this._isLoaded = true;
  14038. if (callback) {
  14039. callback();
  14040. }
  14041. }
  14042. }.bind(this);
  14043. xhttp.open("GET", xmlFile, true);
  14044. xhttp.send();
  14045. };
  14046. return XmlLoader;
  14047. }());
  14048. /***/ }),
  14049. /***/ "./3D/controls/abstractButton3D.ts":
  14050. /*!*****************************************!*\
  14051. !*** ./3D/controls/abstractButton3D.ts ***!
  14052. \*****************************************/
  14053. /*! exports provided: AbstractButton3D */
  14054. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14055. "use strict";
  14056. __webpack_require__.r(__webpack_exports__);
  14057. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  14058. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14059. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math.vector");
  14060. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14061. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14062. /**
  14063. * Class used as a root to all buttons
  14064. */
  14065. var AbstractButton3D = /** @class */ (function (_super) {
  14066. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  14067. /**
  14068. * Creates a new button
  14069. * @param name defines the control name
  14070. */
  14071. function AbstractButton3D(name) {
  14072. return _super.call(this, name) || this;
  14073. }
  14074. AbstractButton3D.prototype._getTypeName = function () {
  14075. return "AbstractButton3D";
  14076. };
  14077. // Mesh association
  14078. AbstractButton3D.prototype._createNode = function (scene) {
  14079. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  14080. };
  14081. return AbstractButton3D;
  14082. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14083. /***/ }),
  14084. /***/ "./3D/controls/button3D.ts":
  14085. /*!*********************************!*\
  14086. !*** ./3D/controls/button3D.ts ***!
  14087. \*********************************/
  14088. /*! exports provided: Button3D */
  14089. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14090. "use strict";
  14091. __webpack_require__.r(__webpack_exports__);
  14092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  14093. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14094. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  14095. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  14096. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14097. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14098. /**
  14099. * Class used to create a button in 3D
  14100. */
  14101. var Button3D = /** @class */ (function (_super) {
  14102. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  14103. /**
  14104. * Creates a new button
  14105. * @param name defines the control name
  14106. */
  14107. function Button3D(name) {
  14108. var _this = _super.call(this, name) || this;
  14109. _this._contentResolution = 512;
  14110. _this._contentScaleRatio = 2;
  14111. // Default animations
  14112. _this.pointerEnterAnimation = function () {
  14113. if (!_this.mesh) {
  14114. return;
  14115. }
  14116. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  14117. };
  14118. _this.pointerOutAnimation = function () {
  14119. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14120. };
  14121. _this.pointerDownAnimation = function () {
  14122. if (!_this.mesh) {
  14123. return;
  14124. }
  14125. _this.mesh.scaling.scaleInPlace(0.95);
  14126. };
  14127. _this.pointerUpAnimation = function () {
  14128. if (!_this.mesh) {
  14129. return;
  14130. }
  14131. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14132. };
  14133. return _this;
  14134. }
  14135. Object.defineProperty(Button3D.prototype, "contentResolution", {
  14136. /**
  14137. * Gets or sets the texture resolution used to render content (512 by default)
  14138. */
  14139. get: function () {
  14140. return this._contentResolution;
  14141. },
  14142. set: function (value) {
  14143. if (this._contentResolution === value) {
  14144. return;
  14145. }
  14146. this._contentResolution = value;
  14147. this._resetContent();
  14148. },
  14149. enumerable: false,
  14150. configurable: true
  14151. });
  14152. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  14153. /**
  14154. * Gets or sets the texture scale ratio used to render content (2 by default)
  14155. */
  14156. get: function () {
  14157. return this._contentScaleRatio;
  14158. },
  14159. set: function (value) {
  14160. if (this._contentScaleRatio === value) {
  14161. return;
  14162. }
  14163. this._contentScaleRatio = value;
  14164. this._resetContent();
  14165. },
  14166. enumerable: false,
  14167. configurable: true
  14168. });
  14169. Button3D.prototype._disposeFacadeTexture = function () {
  14170. if (this._facadeTexture) {
  14171. this._facadeTexture.dispose();
  14172. this._facadeTexture = null;
  14173. }
  14174. };
  14175. Button3D.prototype._resetContent = function () {
  14176. this._disposeFacadeTexture();
  14177. this.content = this._content;
  14178. };
  14179. Object.defineProperty(Button3D.prototype, "content", {
  14180. /**
  14181. * Gets or sets the GUI 2D content used to display the button's facade
  14182. */
  14183. get: function () {
  14184. return this._content;
  14185. },
  14186. set: function (value) {
  14187. this._content = value;
  14188. if (!this._host || !this._host.utilityLayer) {
  14189. return;
  14190. }
  14191. if (!this._facadeTexture) {
  14192. this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__["AdvancedDynamicTexture"]("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  14193. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  14194. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  14195. this._facadeTexture.premulAlpha = true;
  14196. }
  14197. else {
  14198. this._facadeTexture.rootContainer.clearControls();
  14199. }
  14200. this._facadeTexture.addControl(value);
  14201. this._applyFacade(this._facadeTexture);
  14202. },
  14203. enumerable: false,
  14204. configurable: true
  14205. });
  14206. /**
  14207. * Apply the facade texture (created from the content property).
  14208. * This function can be overloaded by child classes
  14209. * @param facadeTexture defines the AdvancedDynamicTexture to use
  14210. */
  14211. Button3D.prototype._applyFacade = function (facadeTexture) {
  14212. this._currentMaterial.emissiveTexture = facadeTexture;
  14213. };
  14214. Button3D.prototype._getTypeName = function () {
  14215. return "Button3D";
  14216. };
  14217. // Mesh association
  14218. Button3D.prototype._createNode = function (scene) {
  14219. var faceUV = new Array(6);
  14220. for (var i = 0; i < 6; i++) {
  14221. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  14222. }
  14223. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  14224. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  14225. width: 1.0,
  14226. height: 1.0,
  14227. depth: 0.08,
  14228. faceUV: faceUV
  14229. }, scene);
  14230. return mesh;
  14231. };
  14232. Button3D.prototype._affectMaterial = function (mesh) {
  14233. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  14234. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14235. mesh.material = material;
  14236. this._currentMaterial = material;
  14237. this._resetContent();
  14238. };
  14239. /**
  14240. * Releases all associated resources
  14241. */
  14242. Button3D.prototype.dispose = function () {
  14243. _super.prototype.dispose.call(this);
  14244. this._disposeFacadeTexture();
  14245. if (this._currentMaterial) {
  14246. this._currentMaterial.dispose();
  14247. }
  14248. };
  14249. return Button3D;
  14250. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  14251. /***/ }),
  14252. /***/ "./3D/controls/container3D.ts":
  14253. /*!************************************!*\
  14254. !*** ./3D/controls/container3D.ts ***!
  14255. \************************************/
  14256. /*! exports provided: Container3D */
  14257. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14258. "use strict";
  14259. __webpack_require__.r(__webpack_exports__);
  14260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  14261. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14262. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math.vector");
  14263. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14264. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14265. /**
  14266. * Class used to create containers for controls
  14267. */
  14268. var Container3D = /** @class */ (function (_super) {
  14269. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  14270. /**
  14271. * Creates a new container
  14272. * @param name defines the container name
  14273. */
  14274. function Container3D(name) {
  14275. var _this = _super.call(this, name) || this;
  14276. _this._blockLayout = false;
  14277. /**
  14278. * Gets the list of child controls
  14279. */
  14280. _this._children = new Array();
  14281. return _this;
  14282. }
  14283. Object.defineProperty(Container3D.prototype, "children", {
  14284. /**
  14285. * Gets the list of child controls
  14286. */
  14287. get: function () {
  14288. return this._children;
  14289. },
  14290. enumerable: false,
  14291. configurable: true
  14292. });
  14293. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14294. /**
  14295. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14296. * This is helpful to optimize layout operation when adding multiple children in a row
  14297. */
  14298. get: function () {
  14299. return this._blockLayout;
  14300. },
  14301. set: function (value) {
  14302. if (this._blockLayout === value) {
  14303. return;
  14304. }
  14305. this._blockLayout = value;
  14306. if (!this._blockLayout) {
  14307. this._arrangeChildren();
  14308. }
  14309. },
  14310. enumerable: false,
  14311. configurable: true
  14312. });
  14313. /**
  14314. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14315. * @returns the current container
  14316. */
  14317. Container3D.prototype.updateLayout = function () {
  14318. this._arrangeChildren();
  14319. return this;
  14320. };
  14321. /**
  14322. * Gets a boolean indicating if the given control is in the children of this control
  14323. * @param control defines the control to check
  14324. * @returns true if the control is in the child list
  14325. */
  14326. Container3D.prototype.containsControl = function (control) {
  14327. return this._children.indexOf(control) !== -1;
  14328. };
  14329. /**
  14330. * Adds a control to the children of this control
  14331. * @param control defines the control to add
  14332. * @returns the current container
  14333. */
  14334. Container3D.prototype.addControl = function (control) {
  14335. var index = this._children.indexOf(control);
  14336. if (index !== -1) {
  14337. return this;
  14338. }
  14339. control.parent = this;
  14340. control._host = this._host;
  14341. this._children.push(control);
  14342. if (this._host.utilityLayer) {
  14343. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14344. if (control.node) {
  14345. control.node.parent = this.node;
  14346. }
  14347. if (!this.blockLayout) {
  14348. this._arrangeChildren();
  14349. }
  14350. }
  14351. return this;
  14352. };
  14353. /**
  14354. * This function will be called everytime a new control is added
  14355. */
  14356. Container3D.prototype._arrangeChildren = function () {
  14357. };
  14358. Container3D.prototype._createNode = function (scene) {
  14359. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14360. };
  14361. /**
  14362. * Removes a control from the children of this control
  14363. * @param control defines the control to remove
  14364. * @returns the current container
  14365. */
  14366. Container3D.prototype.removeControl = function (control) {
  14367. var index = this._children.indexOf(control);
  14368. if (index !== -1) {
  14369. this._children.splice(index, 1);
  14370. control.parent = null;
  14371. control._disposeNode();
  14372. }
  14373. return this;
  14374. };
  14375. Container3D.prototype._getTypeName = function () {
  14376. return "Container3D";
  14377. };
  14378. /**
  14379. * Releases all associated resources
  14380. */
  14381. Container3D.prototype.dispose = function () {
  14382. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14383. var control = _a[_i];
  14384. control.dispose();
  14385. }
  14386. this._children = [];
  14387. _super.prototype.dispose.call(this);
  14388. };
  14389. /** Control rotation will remain unchanged */
  14390. Container3D.UNSET_ORIENTATION = 0;
  14391. /** Control will rotate to make it look at sphere central axis */
  14392. Container3D.FACEORIGIN_ORIENTATION = 1;
  14393. /** Control will rotate to make it look back at sphere central axis */
  14394. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14395. /** Control will rotate to look at z axis (0, 0, 1) */
  14396. Container3D.FACEFORWARD_ORIENTATION = 3;
  14397. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14398. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14399. return Container3D;
  14400. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14401. /***/ }),
  14402. /***/ "./3D/controls/control3D.ts":
  14403. /*!**********************************!*\
  14404. !*** ./3D/controls/control3D.ts ***!
  14405. \**********************************/
  14406. /*! exports provided: Control3D */
  14407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14408. "use strict";
  14409. __webpack_require__.r(__webpack_exports__);
  14410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14411. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  14412. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14413. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14414. /**
  14415. * Class used as base class for controls
  14416. */
  14417. var Control3D = /** @class */ (function () {
  14418. /**
  14419. * Creates a new control
  14420. * @param name defines the control name
  14421. */
  14422. function Control3D(
  14423. /** Defines the control name */
  14424. name) {
  14425. this.name = name;
  14426. this._downCount = 0;
  14427. this._enterCount = -1;
  14428. this._downPointerIds = {};
  14429. this._isVisible = true;
  14430. /**
  14431. * An event triggered when the pointer move over the control
  14432. */
  14433. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14434. /**
  14435. * An event triggered when the pointer move out of the control
  14436. */
  14437. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14438. /**
  14439. * An event triggered when the pointer taps the control
  14440. */
  14441. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14442. /**
  14443. * An event triggered when pointer is up
  14444. */
  14445. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14446. /**
  14447. * An event triggered when a control is clicked on (with a mouse)
  14448. */
  14449. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14450. /**
  14451. * An event triggered when pointer enters the control
  14452. */
  14453. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14454. // Behaviors
  14455. this._behaviors = new Array();
  14456. }
  14457. Object.defineProperty(Control3D.prototype, "position", {
  14458. /** Gets or sets the control position in world space */
  14459. get: function () {
  14460. if (!this._node) {
  14461. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14462. }
  14463. return this._node.position;
  14464. },
  14465. set: function (value) {
  14466. if (!this._node) {
  14467. return;
  14468. }
  14469. this._node.position = value;
  14470. },
  14471. enumerable: false,
  14472. configurable: true
  14473. });
  14474. Object.defineProperty(Control3D.prototype, "scaling", {
  14475. /** Gets or sets the control scaling in world space */
  14476. get: function () {
  14477. if (!this._node) {
  14478. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14479. }
  14480. return this._node.scaling;
  14481. },
  14482. set: function (value) {
  14483. if (!this._node) {
  14484. return;
  14485. }
  14486. this._node.scaling = value;
  14487. },
  14488. enumerable: false,
  14489. configurable: true
  14490. });
  14491. Object.defineProperty(Control3D.prototype, "behaviors", {
  14492. /**
  14493. * Gets the list of attached behaviors
  14494. * @see https://doc.babylonjs.com/features/behaviour
  14495. */
  14496. get: function () {
  14497. return this._behaviors;
  14498. },
  14499. enumerable: false,
  14500. configurable: true
  14501. });
  14502. /**
  14503. * Attach a behavior to the control
  14504. * @see https://doc.babylonjs.com/features/behaviour
  14505. * @param behavior defines the behavior to attach
  14506. * @returns the current control
  14507. */
  14508. Control3D.prototype.addBehavior = function (behavior) {
  14509. var _this = this;
  14510. var index = this._behaviors.indexOf(behavior);
  14511. if (index !== -1) {
  14512. return this;
  14513. }
  14514. behavior.init();
  14515. var scene = this._host.scene;
  14516. if (scene.isLoading) {
  14517. // We defer the attach when the scene will be loaded
  14518. scene.onDataLoadedObservable.addOnce(function () {
  14519. behavior.attach(_this);
  14520. });
  14521. }
  14522. else {
  14523. behavior.attach(this);
  14524. }
  14525. this._behaviors.push(behavior);
  14526. return this;
  14527. };
  14528. /**
  14529. * Remove an attached behavior
  14530. * @see https://doc.babylonjs.com/features/behaviour
  14531. * @param behavior defines the behavior to attach
  14532. * @returns the current control
  14533. */
  14534. Control3D.prototype.removeBehavior = function (behavior) {
  14535. var index = this._behaviors.indexOf(behavior);
  14536. if (index === -1) {
  14537. return this;
  14538. }
  14539. this._behaviors[index].detach();
  14540. this._behaviors.splice(index, 1);
  14541. return this;
  14542. };
  14543. /**
  14544. * Gets an attached behavior by name
  14545. * @param name defines the name of the behavior to look for
  14546. * @see https://doc.babylonjs.com/features/behaviour
  14547. * @returns null if behavior was not found else the requested behavior
  14548. */
  14549. Control3D.prototype.getBehaviorByName = function (name) {
  14550. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14551. var behavior = _a[_i];
  14552. if (behavior.name === name) {
  14553. return behavior;
  14554. }
  14555. }
  14556. return null;
  14557. };
  14558. Object.defineProperty(Control3D.prototype, "isVisible", {
  14559. /** Gets or sets a boolean indicating if the control is visible */
  14560. get: function () {
  14561. return this._isVisible;
  14562. },
  14563. set: function (value) {
  14564. if (this._isVisible === value) {
  14565. return;
  14566. }
  14567. this._isVisible = value;
  14568. var mesh = this.mesh;
  14569. if (mesh) {
  14570. mesh.setEnabled(value);
  14571. }
  14572. },
  14573. enumerable: false,
  14574. configurable: true
  14575. });
  14576. Object.defineProperty(Control3D.prototype, "typeName", {
  14577. /**
  14578. * Gets a string representing the class name
  14579. */
  14580. get: function () {
  14581. return this._getTypeName();
  14582. },
  14583. enumerable: false,
  14584. configurable: true
  14585. });
  14586. /**
  14587. * Get the current class name of the control.
  14588. * @returns current class name
  14589. */
  14590. Control3D.prototype.getClassName = function () {
  14591. return this._getTypeName();
  14592. };
  14593. Control3D.prototype._getTypeName = function () {
  14594. return "Control3D";
  14595. };
  14596. Object.defineProperty(Control3D.prototype, "node", {
  14597. /**
  14598. * Gets the transform node used by this control
  14599. */
  14600. get: function () {
  14601. return this._node;
  14602. },
  14603. enumerable: false,
  14604. configurable: true
  14605. });
  14606. Object.defineProperty(Control3D.prototype, "mesh", {
  14607. /**
  14608. * Gets the mesh used to render this control
  14609. */
  14610. get: function () {
  14611. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14612. return this._node;
  14613. }
  14614. return null;
  14615. },
  14616. enumerable: false,
  14617. configurable: true
  14618. });
  14619. /**
  14620. * Link the control as child of the given node
  14621. * @param node defines the node to link to. Use null to unlink the control
  14622. * @returns the current control
  14623. */
  14624. Control3D.prototype.linkToTransformNode = function (node) {
  14625. if (this._node) {
  14626. this._node.parent = node;
  14627. }
  14628. return this;
  14629. };
  14630. /** @hidden **/
  14631. Control3D.prototype._prepareNode = function (scene) {
  14632. if (!this._node) {
  14633. this._node = this._createNode(scene);
  14634. if (!this.node) {
  14635. return;
  14636. }
  14637. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14638. this._node.position = this.position;
  14639. this._node.scaling = this.scaling;
  14640. var mesh = this.mesh;
  14641. if (mesh) {
  14642. mesh.isPickable = true;
  14643. this._affectMaterial(mesh);
  14644. }
  14645. }
  14646. };
  14647. /**
  14648. * Node creation.
  14649. * Can be overriden by children
  14650. * @param scene defines the scene where the node must be attached
  14651. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14652. */
  14653. Control3D.prototype._createNode = function (scene) {
  14654. // Do nothing by default
  14655. return null;
  14656. };
  14657. /**
  14658. * Affect a material to the given mesh
  14659. * @param mesh defines the mesh which will represent the control
  14660. */
  14661. Control3D.prototype._affectMaterial = function (mesh) {
  14662. mesh.material = null;
  14663. };
  14664. // Pointers
  14665. /** @hidden */
  14666. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14667. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14668. };
  14669. /** @hidden */
  14670. Control3D.prototype._onPointerEnter = function (target) {
  14671. if (this._enterCount > 0) {
  14672. return false;
  14673. }
  14674. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14675. this._enterCount = 0;
  14676. }
  14677. this._enterCount++;
  14678. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14679. if (this.pointerEnterAnimation) {
  14680. this.pointerEnterAnimation();
  14681. }
  14682. return true;
  14683. };
  14684. /** @hidden */
  14685. Control3D.prototype._onPointerOut = function (target) {
  14686. this._enterCount = 0;
  14687. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14688. if (this.pointerOutAnimation) {
  14689. this.pointerOutAnimation();
  14690. }
  14691. };
  14692. /** @hidden */
  14693. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14694. if (this._downCount !== 0) {
  14695. this._downCount++;
  14696. return false;
  14697. }
  14698. this._downCount++;
  14699. this._downPointerIds[pointerId] = true;
  14700. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14701. if (this.pointerDownAnimation) {
  14702. this.pointerDownAnimation();
  14703. }
  14704. return true;
  14705. };
  14706. /** @hidden */
  14707. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14708. this._downCount--;
  14709. delete this._downPointerIds[pointerId];
  14710. if (this._downCount < 0) {
  14711. // Handle if forcePointerUp was called prior to this
  14712. this._downCount = 0;
  14713. return;
  14714. }
  14715. if (this._downCount == 0) {
  14716. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14717. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14718. }
  14719. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14720. if (this.pointerUpAnimation) {
  14721. this.pointerUpAnimation();
  14722. }
  14723. }
  14724. };
  14725. /** @hidden */
  14726. Control3D.prototype.forcePointerUp = function (pointerId) {
  14727. if (pointerId === void 0) { pointerId = null; }
  14728. if (pointerId !== null) {
  14729. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14730. }
  14731. else {
  14732. for (var key in this._downPointerIds) {
  14733. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14734. }
  14735. if (this._downCount > 0) {
  14736. this._downCount = 1;
  14737. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14738. }
  14739. }
  14740. };
  14741. /** @hidden */
  14742. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14743. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14744. this._onPointerMove(this, pickedPoint);
  14745. var previousControlOver = this._host._lastControlOver[pointerId];
  14746. if (previousControlOver && previousControlOver !== this) {
  14747. previousControlOver._onPointerOut(this);
  14748. }
  14749. if (previousControlOver !== this) {
  14750. this._onPointerEnter(this);
  14751. }
  14752. this._host._lastControlOver[pointerId] = this;
  14753. return true;
  14754. }
  14755. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14756. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14757. this._host._lastControlDown[pointerId] = this;
  14758. this._host._lastPickedControl = this;
  14759. return true;
  14760. }
  14761. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP || type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) {
  14762. if (this._host._lastControlDown[pointerId]) {
  14763. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14764. }
  14765. delete this._host._lastControlDown[pointerId];
  14766. return true;
  14767. }
  14768. return false;
  14769. };
  14770. /** @hidden */
  14771. Control3D.prototype._disposeNode = function () {
  14772. if (this._node) {
  14773. this._node.dispose();
  14774. this._node = null;
  14775. }
  14776. };
  14777. /**
  14778. * Releases all associated resources
  14779. */
  14780. Control3D.prototype.dispose = function () {
  14781. this.onPointerDownObservable.clear();
  14782. this.onPointerEnterObservable.clear();
  14783. this.onPointerMoveObservable.clear();
  14784. this.onPointerOutObservable.clear();
  14785. this.onPointerUpObservable.clear();
  14786. this.onPointerClickObservable.clear();
  14787. this._disposeNode();
  14788. // Behaviors
  14789. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14790. var behavior = _a[_i];
  14791. behavior.detach();
  14792. }
  14793. };
  14794. return Control3D;
  14795. }());
  14796. /***/ }),
  14797. /***/ "./3D/controls/cylinderPanel.ts":
  14798. /*!**************************************!*\
  14799. !*** ./3D/controls/cylinderPanel.ts ***!
  14800. \**************************************/
  14801. /*! exports provided: CylinderPanel */
  14802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14803. "use strict";
  14804. __webpack_require__.r(__webpack_exports__);
  14805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14806. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14807. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  14808. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14809. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14810. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14811. /**
  14812. * Class used to create a container panel deployed on the surface of a cylinder
  14813. */
  14814. var CylinderPanel = /** @class */ (function (_super) {
  14815. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14816. function CylinderPanel() {
  14817. var _this = _super !== null && _super.apply(this, arguments) || this;
  14818. _this._radius = 5.0;
  14819. return _this;
  14820. }
  14821. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14822. /**
  14823. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14824. */
  14825. get: function () {
  14826. return this._radius;
  14827. },
  14828. set: function (value) {
  14829. var _this = this;
  14830. if (this._radius === value) {
  14831. return;
  14832. }
  14833. this._radius = value;
  14834. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14835. _this._arrangeChildren();
  14836. });
  14837. },
  14838. enumerable: false,
  14839. configurable: true
  14840. });
  14841. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14842. var mesh = control.mesh;
  14843. if (!mesh) {
  14844. return;
  14845. }
  14846. var newPos = this._cylindricalMapping(nodePosition);
  14847. control.position = newPos;
  14848. switch (this.orientation) {
  14849. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14850. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14851. break;
  14852. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14853. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14854. break;
  14855. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14856. break;
  14857. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14858. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14859. break;
  14860. }
  14861. };
  14862. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14863. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14864. var yAngle = (source.x / this._radius);
  14865. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14866. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14867. };
  14868. return CylinderPanel;
  14869. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14870. /***/ }),
  14871. /***/ "./3D/controls/holographicButton.ts":
  14872. /*!******************************************!*\
  14873. !*** ./3D/controls/holographicButton.ts ***!
  14874. \******************************************/
  14875. /*! exports provided: HolographicButton */
  14876. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14877. "use strict";
  14878. __webpack_require__.r(__webpack_exports__);
  14879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14880. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14881. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14882. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Maths/math.vector");
  14883. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  14884. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14885. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14886. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14887. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14888. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14889. /**
  14890. * Class used to create a holographic button in 3D
  14891. */
  14892. var HolographicButton = /** @class */ (function (_super) {
  14893. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14894. /**
  14895. * Creates a new button
  14896. * @param name defines the control name
  14897. */
  14898. function HolographicButton(name, shareMaterials) {
  14899. if (shareMaterials === void 0) { shareMaterials = true; }
  14900. var _this = _super.call(this, name) || this;
  14901. _this._shareMaterials = true;
  14902. _this._shareMaterials = shareMaterials;
  14903. // Default animations
  14904. _this.pointerEnterAnimation = function () {
  14905. if (!_this.mesh) {
  14906. return;
  14907. }
  14908. _this._frontPlate.setEnabled(true);
  14909. };
  14910. _this.pointerOutAnimation = function () {
  14911. if (!_this.mesh) {
  14912. return;
  14913. }
  14914. _this._frontPlate.setEnabled(false);
  14915. };
  14916. return _this;
  14917. }
  14918. HolographicButton.prototype._disposeTooltip = function () {
  14919. this._tooltipFade = null;
  14920. if (this._tooltipTextBlock) {
  14921. this._tooltipTextBlock.dispose();
  14922. }
  14923. if (this._tooltipTexture) {
  14924. this._tooltipTexture.dispose();
  14925. }
  14926. if (this._tooltipMesh) {
  14927. this._tooltipMesh.dispose();
  14928. }
  14929. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14930. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14931. };
  14932. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14933. get: function () {
  14934. return this._backPlate.renderingGroupId;
  14935. },
  14936. /**
  14937. * Rendering ground id of all the mesh in the button
  14938. */
  14939. set: function (id) {
  14940. this._backPlate.renderingGroupId = id;
  14941. this._textPlate.renderingGroupId = id;
  14942. this._frontPlate.renderingGroupId = id;
  14943. if (this._tooltipMesh) {
  14944. this._tooltipMesh.renderingGroupId = id;
  14945. }
  14946. },
  14947. enumerable: false,
  14948. configurable: true
  14949. });
  14950. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14951. get: function () {
  14952. if (this._tooltipTextBlock) {
  14953. return this._tooltipTextBlock.text;
  14954. }
  14955. return null;
  14956. },
  14957. /**
  14958. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14959. */
  14960. set: function (text) {
  14961. var _this = this;
  14962. if (!text) {
  14963. this._disposeTooltip();
  14964. return;
  14965. }
  14966. if (!this._tooltipFade) {
  14967. // Create tooltip with mesh and text
  14968. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14969. var tooltipBackground = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  14970. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14971. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14972. tooltipBackground.material = mat;
  14973. tooltipBackground.isPickable = false;
  14974. this._tooltipMesh.addChild(tooltipBackground);
  14975. tooltipBackground.position.z = 0.05;
  14976. this._tooltipMesh.scaling.y = 1 / 3;
  14977. this._tooltipMesh.position.y = 0.7;
  14978. this._tooltipMesh.position.z = -0.15;
  14979. this._tooltipMesh.isPickable = false;
  14980. this._tooltipMesh.parent = this._backPlate;
  14981. // Create text texture for the tooltip
  14982. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14983. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14984. this._tooltipTextBlock.scaleY = 3;
  14985. this._tooltipTextBlock.color = "white";
  14986. this._tooltipTextBlock.fontSize = 130;
  14987. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14988. // Add hover action to tooltip
  14989. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14990. this._tooltipFade.delay = 500;
  14991. this._tooltipMesh.addBehavior(this._tooltipFade);
  14992. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14993. if (_this._tooltipFade) {
  14994. _this._tooltipFade.fadeIn(true);
  14995. }
  14996. });
  14997. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14998. if (_this._tooltipFade) {
  14999. _this._tooltipFade.fadeIn(false);
  15000. }
  15001. });
  15002. }
  15003. if (this._tooltipTextBlock) {
  15004. this._tooltipTextBlock.text = text;
  15005. }
  15006. },
  15007. enumerable: false,
  15008. configurable: true
  15009. });
  15010. Object.defineProperty(HolographicButton.prototype, "text", {
  15011. /**
  15012. * Gets or sets text for the button
  15013. */
  15014. get: function () {
  15015. return this._text;
  15016. },
  15017. set: function (value) {
  15018. if (this._text === value) {
  15019. return;
  15020. }
  15021. this._text = value;
  15022. this._rebuildContent();
  15023. },
  15024. enumerable: false,
  15025. configurable: true
  15026. });
  15027. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  15028. /**
  15029. * Gets or sets the image url for the button
  15030. */
  15031. get: function () {
  15032. return this._imageUrl;
  15033. },
  15034. set: function (value) {
  15035. if (this._imageUrl === value) {
  15036. return;
  15037. }
  15038. this._imageUrl = value;
  15039. this._rebuildContent();
  15040. },
  15041. enumerable: false,
  15042. configurable: true
  15043. });
  15044. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  15045. /**
  15046. * Gets the back material used by this button
  15047. */
  15048. get: function () {
  15049. return this._backMaterial;
  15050. },
  15051. enumerable: false,
  15052. configurable: true
  15053. });
  15054. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  15055. /**
  15056. * Gets the front material used by this button
  15057. */
  15058. get: function () {
  15059. return this._frontMaterial;
  15060. },
  15061. enumerable: false,
  15062. configurable: true
  15063. });
  15064. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  15065. /**
  15066. * Gets the plate material used by this button
  15067. */
  15068. get: function () {
  15069. return this._plateMaterial;
  15070. },
  15071. enumerable: false,
  15072. configurable: true
  15073. });
  15074. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  15075. /**
  15076. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  15077. */
  15078. get: function () {
  15079. return this._shareMaterials;
  15080. },
  15081. enumerable: false,
  15082. configurable: true
  15083. });
  15084. HolographicButton.prototype._getTypeName = function () {
  15085. return "HolographicButton";
  15086. };
  15087. HolographicButton.prototype._rebuildContent = function () {
  15088. this._disposeFacadeTexture();
  15089. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  15090. panel.isVertical = true;
  15091. if (this._imageUrl) {
  15092. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  15093. image.source = this._imageUrl;
  15094. image.paddingTop = "40px";
  15095. image.height = "180px";
  15096. image.width = "100px";
  15097. image.paddingBottom = "40px";
  15098. panel.addControl(image);
  15099. }
  15100. if (this._text) {
  15101. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  15102. text.text = this._text;
  15103. text.color = "white";
  15104. text.height = "30px";
  15105. text.fontSize = 24;
  15106. panel.addControl(text);
  15107. }
  15108. if (this._frontPlate) {
  15109. this.content = panel;
  15110. }
  15111. };
  15112. // Mesh association
  15113. HolographicButton.prototype._createNode = function (scene) {
  15114. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  15115. width: 1.0,
  15116. height: 1.0,
  15117. depth: 0.08
  15118. }, scene);
  15119. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  15120. width: 1.0,
  15121. height: 1.0,
  15122. depth: 0.08
  15123. }, scene);
  15124. this._frontPlate.parent = this._backPlate;
  15125. this._frontPlate.position.z = -0.08;
  15126. this._frontPlate.isPickable = false;
  15127. this._frontPlate.setEnabled(false);
  15128. this._textPlate = _super.prototype._createNode.call(this, scene);
  15129. this._textPlate.parent = this._backPlate;
  15130. this._textPlate.position.z = -0.08;
  15131. this._textPlate.isPickable = false;
  15132. return this._backPlate;
  15133. };
  15134. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  15135. this._plateMaterial.emissiveTexture = facadeTexture;
  15136. this._plateMaterial.opacityTexture = facadeTexture;
  15137. };
  15138. HolographicButton.prototype._createBackMaterial = function (mesh) {
  15139. var _this = this;
  15140. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  15141. this._backMaterial.renderHoverLight = true;
  15142. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  15143. if (pickedPoint) {
  15144. _this._backMaterial.hoverPosition = pickedPoint;
  15145. _this._backMaterial.hoverColor.a = 1.0;
  15146. }
  15147. else {
  15148. _this._backMaterial.hoverColor.a = 0;
  15149. }
  15150. });
  15151. };
  15152. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  15153. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  15154. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  15155. this._frontMaterial.alpha = 0.5; // Additive
  15156. this._frontMaterial.renderBorders = true;
  15157. };
  15158. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  15159. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  15160. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  15161. };
  15162. HolographicButton.prototype._affectMaterial = function (mesh) {
  15163. // Back
  15164. if (this._shareMaterials) {
  15165. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  15166. this._createBackMaterial(mesh);
  15167. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  15168. }
  15169. else {
  15170. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  15171. }
  15172. // Front
  15173. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  15174. this._createFrontMaterial(mesh);
  15175. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  15176. }
  15177. else {
  15178. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  15179. }
  15180. }
  15181. else {
  15182. this._createBackMaterial(mesh);
  15183. this._createFrontMaterial(mesh);
  15184. }
  15185. this._createPlateMaterial(mesh);
  15186. this._backPlate.material = this._backMaterial;
  15187. this._frontPlate.material = this._frontMaterial;
  15188. this._textPlate.material = this._plateMaterial;
  15189. this._rebuildContent();
  15190. };
  15191. /**
  15192. * Releases all associated resources
  15193. */
  15194. HolographicButton.prototype.dispose = function () {
  15195. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  15196. this._disposeTooltip();
  15197. if (!this.shareMaterials) {
  15198. this._backMaterial.dispose();
  15199. this._frontMaterial.dispose();
  15200. this._plateMaterial.dispose();
  15201. if (this._pickedPointObserver) {
  15202. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  15203. this._pickedPointObserver = null;
  15204. }
  15205. }
  15206. };
  15207. return HolographicButton;
  15208. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15209. /***/ }),
  15210. /***/ "./3D/controls/index.ts":
  15211. /*!******************************!*\
  15212. !*** ./3D/controls/index.ts ***!
  15213. \******************************/
  15214. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  15215. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15216. "use strict";
  15217. __webpack_require__.r(__webpack_exports__);
  15218. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  15219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15220. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15222. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  15224. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  15226. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  15227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  15228. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  15229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  15230. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  15231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  15232. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  15233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  15234. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  15235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  15236. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  15237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  15238. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  15239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  15240. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  15242. /***/ }),
  15243. /***/ "./3D/controls/meshButton3D.ts":
  15244. /*!*************************************!*\
  15245. !*** ./3D/controls/meshButton3D.ts ***!
  15246. \*************************************/
  15247. /*! exports provided: MeshButton3D */
  15248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15249. "use strict";
  15250. __webpack_require__.r(__webpack_exports__);
  15251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  15252. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15253. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15254. /**
  15255. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  15256. */
  15257. var MeshButton3D = /** @class */ (function (_super) {
  15258. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  15259. /**
  15260. * Creates a new 3D button based on a mesh
  15261. * @param mesh mesh to become a 3D button
  15262. * @param name defines the control name
  15263. */
  15264. function MeshButton3D(mesh, name) {
  15265. var _this = _super.call(this, name) || this;
  15266. _this._currentMesh = mesh;
  15267. /**
  15268. * Provides a default behavior on hover/out & up/down
  15269. * Override those function to create your own desired behavior specific to your mesh
  15270. */
  15271. _this.pointerEnterAnimation = function () {
  15272. if (!_this.mesh) {
  15273. return;
  15274. }
  15275. _this.mesh.scaling.scaleInPlace(1.1);
  15276. };
  15277. _this.pointerOutAnimation = function () {
  15278. if (!_this.mesh) {
  15279. return;
  15280. }
  15281. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  15282. };
  15283. _this.pointerDownAnimation = function () {
  15284. if (!_this.mesh) {
  15285. return;
  15286. }
  15287. _this.mesh.scaling.scaleInPlace(0.95);
  15288. };
  15289. _this.pointerUpAnimation = function () {
  15290. if (!_this.mesh) {
  15291. return;
  15292. }
  15293. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15294. };
  15295. return _this;
  15296. }
  15297. MeshButton3D.prototype._getTypeName = function () {
  15298. return "MeshButton3D";
  15299. };
  15300. // Mesh association
  15301. MeshButton3D.prototype._createNode = function (scene) {
  15302. var _this = this;
  15303. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15304. mesh.metadata = _this;
  15305. });
  15306. return this._currentMesh;
  15307. };
  15308. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15309. };
  15310. return MeshButton3D;
  15311. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15312. /***/ }),
  15313. /***/ "./3D/controls/planePanel.ts":
  15314. /*!***********************************!*\
  15315. !*** ./3D/controls/planePanel.ts ***!
  15316. \***********************************/
  15317. /*! exports provided: PlanePanel */
  15318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15319. "use strict";
  15320. __webpack_require__.r(__webpack_exports__);
  15321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15322. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15323. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  15324. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15325. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15326. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15327. /**
  15328. * Class used to create a container panel deployed on the surface of a plane
  15329. */
  15330. var PlanePanel = /** @class */ (function (_super) {
  15331. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15332. function PlanePanel() {
  15333. return _super !== null && _super.apply(this, arguments) || this;
  15334. }
  15335. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15336. var mesh = control.mesh;
  15337. if (!mesh) {
  15338. return;
  15339. }
  15340. control.position = nodePosition.clone();
  15341. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15342. target.copyFrom(nodePosition);
  15343. switch (this.orientation) {
  15344. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15345. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15346. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15347. mesh.lookAt(target);
  15348. break;
  15349. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15350. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15351. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15352. mesh.lookAt(target);
  15353. break;
  15354. }
  15355. };
  15356. return PlanePanel;
  15357. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15358. /***/ }),
  15359. /***/ "./3D/controls/scatterPanel.ts":
  15360. /*!*************************************!*\
  15361. !*** ./3D/controls/scatterPanel.ts ***!
  15362. \*************************************/
  15363. /*! exports provided: ScatterPanel */
  15364. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15365. "use strict";
  15366. __webpack_require__.r(__webpack_exports__);
  15367. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15368. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15369. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15370. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15371. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15372. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15373. /**
  15374. * Class used to create a container panel where items get randomized planar mapping
  15375. */
  15376. var ScatterPanel = /** @class */ (function (_super) {
  15377. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15378. function ScatterPanel() {
  15379. var _this = _super !== null && _super.apply(this, arguments) || this;
  15380. _this._iteration = 100.0;
  15381. return _this;
  15382. }
  15383. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15384. /**
  15385. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15386. */
  15387. get: function () {
  15388. return this._iteration;
  15389. },
  15390. set: function (value) {
  15391. var _this = this;
  15392. if (this._iteration === value) {
  15393. return;
  15394. }
  15395. this._iteration = value;
  15396. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15397. _this._arrangeChildren();
  15398. });
  15399. },
  15400. enumerable: false,
  15401. configurable: true
  15402. });
  15403. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15404. var mesh = control.mesh;
  15405. var newPos = this._scatterMapping(nodePosition);
  15406. if (!mesh) {
  15407. return;
  15408. }
  15409. switch (this.orientation) {
  15410. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15411. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15412. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15413. break;
  15414. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15415. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15416. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15417. break;
  15418. }
  15419. control.position = newPos;
  15420. };
  15421. ScatterPanel.prototype._scatterMapping = function (source) {
  15422. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15423. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15424. return source;
  15425. };
  15426. ScatterPanel.prototype._finalProcessing = function () {
  15427. var meshes = [];
  15428. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15429. var child = _a[_i];
  15430. if (!child.mesh) {
  15431. continue;
  15432. }
  15433. meshes.push(child.mesh);
  15434. }
  15435. for (var count = 0; count < this._iteration; count++) {
  15436. meshes.sort(function (a, b) {
  15437. var distance1 = a.position.lengthSquared();
  15438. var distance2 = b.position.lengthSquared();
  15439. if (distance1 < distance2) {
  15440. return 1;
  15441. }
  15442. else if (distance1 > distance2) {
  15443. return -1;
  15444. }
  15445. return 0;
  15446. });
  15447. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15448. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15449. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15450. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15451. for (var i = 0; i < meshes.length - 1; i++) {
  15452. for (var j = i + 1; j < meshes.length; j++) {
  15453. if (i != j) {
  15454. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15455. // Ignore Z axis
  15456. difference2D.x = difference.x;
  15457. difference2D.y = difference.y;
  15458. var combinedRadius = cellSize;
  15459. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15460. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15461. distance -= minSeparation;
  15462. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15463. difference2D.normalize();
  15464. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15465. meshes[j].position.addInPlace(difference);
  15466. meshes[i].position.subtractInPlace(difference);
  15467. }
  15468. }
  15469. }
  15470. }
  15471. }
  15472. };
  15473. return ScatterPanel;
  15474. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15475. /***/ }),
  15476. /***/ "./3D/controls/spherePanel.ts":
  15477. /*!************************************!*\
  15478. !*** ./3D/controls/spherePanel.ts ***!
  15479. \************************************/
  15480. /*! exports provided: SpherePanel */
  15481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15482. "use strict";
  15483. __webpack_require__.r(__webpack_exports__);
  15484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15485. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15486. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15487. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15488. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15489. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15490. /**
  15491. * Class used to create a container panel deployed on the surface of a sphere
  15492. */
  15493. var SpherePanel = /** @class */ (function (_super) {
  15494. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15495. function SpherePanel() {
  15496. var _this = _super !== null && _super.apply(this, arguments) || this;
  15497. _this._radius = 5.0;
  15498. return _this;
  15499. }
  15500. Object.defineProperty(SpherePanel.prototype, "radius", {
  15501. /**
  15502. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15503. */
  15504. get: function () {
  15505. return this._radius;
  15506. },
  15507. set: function (value) {
  15508. var _this = this;
  15509. if (this._radius === value) {
  15510. return;
  15511. }
  15512. this._radius = value;
  15513. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15514. _this._arrangeChildren();
  15515. });
  15516. },
  15517. enumerable: false,
  15518. configurable: true
  15519. });
  15520. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15521. var mesh = control.mesh;
  15522. if (!mesh) {
  15523. return;
  15524. }
  15525. var newPos = this._sphericalMapping(nodePosition);
  15526. control.position = newPos;
  15527. switch (this.orientation) {
  15528. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15529. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15530. break;
  15531. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15532. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15533. break;
  15534. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15535. break;
  15536. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15537. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15538. break;
  15539. }
  15540. };
  15541. SpherePanel.prototype._sphericalMapping = function (source) {
  15542. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15543. var xAngle = (source.y / this._radius);
  15544. var yAngle = -(source.x / this._radius);
  15545. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15546. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15547. };
  15548. return SpherePanel;
  15549. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15550. /***/ }),
  15551. /***/ "./3D/controls/stackPanel3D.ts":
  15552. /*!*************************************!*\
  15553. !*** ./3D/controls/stackPanel3D.ts ***!
  15554. \*************************************/
  15555. /*! exports provided: StackPanel3D */
  15556. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15557. "use strict";
  15558. __webpack_require__.r(__webpack_exports__);
  15559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15560. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15561. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15562. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15563. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15564. /**
  15565. * Class used to create a stack panel in 3D on XY plane
  15566. */
  15567. var StackPanel3D = /** @class */ (function (_super) {
  15568. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15569. /**
  15570. * Creates new StackPanel
  15571. * @param isVertical
  15572. */
  15573. function StackPanel3D(isVertical) {
  15574. if (isVertical === void 0) { isVertical = false; }
  15575. var _this = _super.call(this) || this;
  15576. _this._isVertical = false;
  15577. /**
  15578. * Gets or sets the distance between elements
  15579. */
  15580. _this.margin = 0.1;
  15581. _this._isVertical = isVertical;
  15582. return _this;
  15583. }
  15584. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15585. /**
  15586. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15587. */
  15588. get: function () {
  15589. return this._isVertical;
  15590. },
  15591. set: function (value) {
  15592. var _this = this;
  15593. if (this._isVertical === value) {
  15594. return;
  15595. }
  15596. this._isVertical = value;
  15597. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15598. _this._arrangeChildren();
  15599. });
  15600. },
  15601. enumerable: false,
  15602. configurable: true
  15603. });
  15604. StackPanel3D.prototype._arrangeChildren = function () {
  15605. var width = 0;
  15606. var height = 0;
  15607. var controlCount = 0;
  15608. var extendSizes = [];
  15609. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15610. // Measure
  15611. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15612. var child = _a[_i];
  15613. if (!child.mesh) {
  15614. continue;
  15615. }
  15616. controlCount++;
  15617. child.mesh.computeWorldMatrix(true);
  15618. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15619. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15620. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15621. extendSizes.push(extendSize);
  15622. if (this._isVertical) {
  15623. height += extendSize.y;
  15624. }
  15625. else {
  15626. width += extendSize.x;
  15627. }
  15628. }
  15629. if (this._isVertical) {
  15630. height += (controlCount - 1) * this.margin / 2;
  15631. }
  15632. else {
  15633. width += (controlCount - 1) * this.margin / 2;
  15634. }
  15635. // Arrange
  15636. var offset;
  15637. if (this._isVertical) {
  15638. offset = -height;
  15639. }
  15640. else {
  15641. offset = -width;
  15642. }
  15643. var index = 0;
  15644. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15645. var child = _c[_b];
  15646. if (!child.mesh) {
  15647. continue;
  15648. }
  15649. controlCount--;
  15650. var extendSize = extendSizes[index++];
  15651. if (this._isVertical) {
  15652. child.position.y = offset + extendSize.y;
  15653. child.position.x = 0;
  15654. offset += extendSize.y * 2;
  15655. }
  15656. else {
  15657. child.position.x = offset + extendSize.x;
  15658. child.position.y = 0;
  15659. offset += extendSize.x * 2;
  15660. }
  15661. offset += (controlCount > 0 ? this.margin : 0);
  15662. }
  15663. };
  15664. return StackPanel3D;
  15665. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15666. /***/ }),
  15667. /***/ "./3D/controls/volumeBasedPanel.ts":
  15668. /*!*****************************************!*\
  15669. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15670. \*****************************************/
  15671. /*! exports provided: VolumeBasedPanel */
  15672. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15673. "use strict";
  15674. __webpack_require__.r(__webpack_exports__);
  15675. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15676. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15677. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15678. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15679. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15680. /**
  15681. * Abstract class used to create a container panel deployed on the surface of a volume
  15682. */
  15683. var VolumeBasedPanel = /** @class */ (function (_super) {
  15684. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15685. /**
  15686. * Creates new VolumeBasedPanel
  15687. */
  15688. function VolumeBasedPanel() {
  15689. var _this = _super.call(this) || this;
  15690. _this._columns = 10;
  15691. _this._rows = 0;
  15692. _this._rowThenColum = true;
  15693. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15694. /**
  15695. * Gets or sets the distance between elements
  15696. */
  15697. _this.margin = 0;
  15698. return _this;
  15699. }
  15700. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15701. /**
  15702. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15703. * | Value | Type | Description |
  15704. * | ----- | ----------------------------------- | ----------- |
  15705. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15706. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15707. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15708. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15709. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15710. */
  15711. get: function () {
  15712. return this._orientation;
  15713. },
  15714. set: function (value) {
  15715. var _this = this;
  15716. if (this._orientation === value) {
  15717. return;
  15718. }
  15719. this._orientation = value;
  15720. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15721. _this._arrangeChildren();
  15722. });
  15723. },
  15724. enumerable: false,
  15725. configurable: true
  15726. });
  15727. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15728. /**
  15729. * Gets or sets the number of columns requested (10 by default).
  15730. * The panel will automatically compute the number of rows based on number of child controls.
  15731. */
  15732. get: function () {
  15733. return this._columns;
  15734. },
  15735. set: function (value) {
  15736. var _this = this;
  15737. if (this._columns === value) {
  15738. return;
  15739. }
  15740. this._columns = value;
  15741. this._rowThenColum = true;
  15742. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15743. _this._arrangeChildren();
  15744. });
  15745. },
  15746. enumerable: false,
  15747. configurable: true
  15748. });
  15749. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15750. /**
  15751. * Gets or sets a the number of rows requested.
  15752. * The panel will automatically compute the number of columns based on number of child controls.
  15753. */
  15754. get: function () {
  15755. return this._rows;
  15756. },
  15757. set: function (value) {
  15758. var _this = this;
  15759. if (this._rows === value) {
  15760. return;
  15761. }
  15762. this._rows = value;
  15763. this._rowThenColum = false;
  15764. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15765. _this._arrangeChildren();
  15766. });
  15767. },
  15768. enumerable: false,
  15769. configurable: true
  15770. });
  15771. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15772. this._cellWidth = 0;
  15773. this._cellHeight = 0;
  15774. var rows = 0;
  15775. var columns = 0;
  15776. var controlCount = 0;
  15777. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15778. // Measure
  15779. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15780. var child = _a[_i];
  15781. if (!child.mesh) {
  15782. continue;
  15783. }
  15784. controlCount++;
  15785. child.mesh.computeWorldMatrix(true);
  15786. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15787. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15788. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15789. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15790. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15791. diff.scaleInPlace(0.5);
  15792. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15793. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15794. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15795. }
  15796. this._cellWidth += this.margin * 2;
  15797. this._cellHeight += this.margin * 2;
  15798. // Arrange
  15799. if (this._rowThenColum) {
  15800. columns = this._columns;
  15801. rows = Math.ceil(controlCount / this._columns);
  15802. }
  15803. else {
  15804. rows = this._rows;
  15805. columns = Math.ceil(controlCount / this._rows);
  15806. }
  15807. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15808. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15809. var nodeGrid = [];
  15810. var cellCounter = 0;
  15811. if (this._rowThenColum) {
  15812. for (var r = 0; r < rows; r++) {
  15813. for (var c = 0; c < columns; c++) {
  15814. 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));
  15815. cellCounter++;
  15816. if (cellCounter > controlCount) {
  15817. break;
  15818. }
  15819. }
  15820. }
  15821. }
  15822. else {
  15823. for (var c = 0; c < columns; c++) {
  15824. for (var r = 0; r < rows; r++) {
  15825. 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));
  15826. cellCounter++;
  15827. if (cellCounter > controlCount) {
  15828. break;
  15829. }
  15830. }
  15831. }
  15832. }
  15833. cellCounter = 0;
  15834. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15835. var child = _c[_b];
  15836. if (!child.mesh) {
  15837. continue;
  15838. }
  15839. this._mapGridNode(child, nodeGrid[cellCounter]);
  15840. cellCounter++;
  15841. }
  15842. this._finalProcessing();
  15843. };
  15844. /** Child classes can implement this function to provide additional processing */
  15845. VolumeBasedPanel.prototype._finalProcessing = function () {
  15846. };
  15847. return VolumeBasedPanel;
  15848. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15849. /***/ }),
  15850. /***/ "./3D/gui3DManager.ts":
  15851. /*!****************************!*\
  15852. !*** ./3D/gui3DManager.ts ***!
  15853. \****************************/
  15854. /*! exports provided: GUI3DManager */
  15855. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15856. "use strict";
  15857. __webpack_require__.r(__webpack_exports__);
  15858. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15859. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  15860. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15861. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15862. /**
  15863. * Class used to manage 3D user interface
  15864. * @see https://doc.babylonjs.com/how_to/gui3d
  15865. */
  15866. var GUI3DManager = /** @class */ (function () {
  15867. /**
  15868. * Creates a new GUI3DManager
  15869. * @param scene
  15870. */
  15871. function GUI3DManager(scene) {
  15872. var _this = this;
  15873. /** @hidden */
  15874. this._lastControlOver = {};
  15875. /** @hidden */
  15876. this._lastControlDown = {};
  15877. /**
  15878. * Observable raised when the point picked by the pointer events changed
  15879. */
  15880. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15881. // Shared resources
  15882. /** @hidden */
  15883. this._sharedMaterials = {};
  15884. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15885. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15886. _this._sceneDisposeObserver = null;
  15887. _this._utilityLayer = null;
  15888. _this.dispose();
  15889. });
  15890. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15891. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15892. this._utilityLayer.pickUtilitySceneFirst = false;
  15893. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15894. return mesh && mesh.metadata && mesh.metadata._node;
  15895. };
  15896. // Root
  15897. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15898. this._rootContainer._host = this;
  15899. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15900. // Events
  15901. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15902. _this._handlePointerOut(pointerId, true);
  15903. });
  15904. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15905. _this._doPicking(pi);
  15906. });
  15907. // Scene
  15908. this._utilityLayer.utilityLayerScene.autoClear = false;
  15909. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15910. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15911. }
  15912. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15913. /** Gets the hosting scene */
  15914. get: function () {
  15915. return this._scene;
  15916. },
  15917. enumerable: false,
  15918. configurable: true
  15919. });
  15920. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15921. /** Gets associated utility layer */
  15922. get: function () {
  15923. return this._utilityLayer;
  15924. },
  15925. enumerable: false,
  15926. configurable: true
  15927. });
  15928. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15929. var previousControlOver = this._lastControlOver[pointerId];
  15930. if (previousControlOver) {
  15931. previousControlOver._onPointerOut(previousControlOver);
  15932. delete this._lastControlOver[pointerId];
  15933. }
  15934. if (isPointerUp) {
  15935. if (this._lastControlDown[pointerId]) {
  15936. this._lastControlDown[pointerId].forcePointerUp();
  15937. delete this._lastControlDown[pointerId];
  15938. }
  15939. }
  15940. this.onPickedPointChangedObservable.notifyObservers(null);
  15941. };
  15942. GUI3DManager.prototype._doPicking = function (pi) {
  15943. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15944. return false;
  15945. }
  15946. var pointerEvent = (pi.event);
  15947. var pointerId = pointerEvent.pointerId || 0;
  15948. var buttonIndex = pointerEvent.button;
  15949. var pickingInfo = pi.pickInfo;
  15950. if (!pickingInfo || !pickingInfo.hit) {
  15951. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15952. return false;
  15953. }
  15954. var control = (pickingInfo.pickedMesh.metadata);
  15955. if (pickingInfo.pickedPoint) {
  15956. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15957. }
  15958. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15959. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15960. if (this._lastControlOver[pointerId]) {
  15961. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15962. }
  15963. delete this._lastControlOver[pointerId];
  15964. }
  15965. }
  15966. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15967. if (this._lastControlDown[pointerEvent.pointerId]) {
  15968. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15969. delete this._lastControlDown[pointerEvent.pointerId];
  15970. }
  15971. if (pointerEvent.pointerType === "touch") {
  15972. this._handlePointerOut(pointerId, false);
  15973. }
  15974. }
  15975. return true;
  15976. };
  15977. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15978. /**
  15979. * Gets the root container
  15980. */
  15981. get: function () {
  15982. return this._rootContainer;
  15983. },
  15984. enumerable: false,
  15985. configurable: true
  15986. });
  15987. /**
  15988. * Gets a boolean indicating if the given control is in the root child list
  15989. * @param control defines the control to check
  15990. * @returns true if the control is in the root child list
  15991. */
  15992. GUI3DManager.prototype.containsControl = function (control) {
  15993. return this._rootContainer.containsControl(control);
  15994. };
  15995. /**
  15996. * Adds a control to the root child list
  15997. * @param control defines the control to add
  15998. * @returns the current manager
  15999. */
  16000. GUI3DManager.prototype.addControl = function (control) {
  16001. this._rootContainer.addControl(control);
  16002. return this;
  16003. };
  16004. /**
  16005. * Removes a control from the root child list
  16006. * @param control defines the control to remove
  16007. * @returns the current container
  16008. */
  16009. GUI3DManager.prototype.removeControl = function (control) {
  16010. this._rootContainer.removeControl(control);
  16011. return this;
  16012. };
  16013. /**
  16014. * Releases all associated resources
  16015. */
  16016. GUI3DManager.prototype.dispose = function () {
  16017. this._rootContainer.dispose();
  16018. for (var materialName in this._sharedMaterials) {
  16019. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  16020. continue;
  16021. }
  16022. this._sharedMaterials[materialName].dispose();
  16023. }
  16024. this._sharedMaterials = {};
  16025. if (this._pointerOutObserver && this._utilityLayer) {
  16026. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  16027. this._pointerOutObserver = null;
  16028. }
  16029. this.onPickedPointChangedObservable.clear();
  16030. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  16031. if (utilityLayerScene) {
  16032. if (this._pointerObserver) {
  16033. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  16034. this._pointerObserver = null;
  16035. }
  16036. }
  16037. if (this._scene) {
  16038. if (this._sceneDisposeObserver) {
  16039. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  16040. this._sceneDisposeObserver = null;
  16041. }
  16042. }
  16043. if (this._utilityLayer) {
  16044. this._utilityLayer.dispose();
  16045. }
  16046. };
  16047. return GUI3DManager;
  16048. }());
  16049. /***/ }),
  16050. /***/ "./3D/index.ts":
  16051. /*!*********************!*\
  16052. !*** ./3D/index.ts ***!
  16053. \*********************/
  16054. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16056. "use strict";
  16057. __webpack_require__.r(__webpack_exports__);
  16058. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  16059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16071. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  16072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16074. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  16075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  16076. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  16077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  16078. /***/ }),
  16079. /***/ "./3D/materials/fluentMaterial.ts":
  16080. /*!****************************************!*\
  16081. !*** ./3D/materials/fluentMaterial.ts ***!
  16082. \****************************************/
  16083. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16084. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16085. "use strict";
  16086. __webpack_require__.r(__webpack_exports__);
  16087. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  16088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  16089. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16090. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Maths/math.vector");
  16091. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  16092. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  16093. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  16094. /** @hidden */
  16095. var FluentMaterialDefines = /** @class */ (function (_super) {
  16096. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  16097. function FluentMaterialDefines() {
  16098. var _this = _super.call(this) || this;
  16099. _this.INNERGLOW = false;
  16100. _this.BORDER = false;
  16101. _this.HOVERLIGHT = false;
  16102. _this.TEXTURE = false;
  16103. _this.rebuild();
  16104. return _this;
  16105. }
  16106. return FluentMaterialDefines;
  16107. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  16108. /**
  16109. * Class used to render controls with fluent desgin
  16110. */
  16111. var FluentMaterial = /** @class */ (function (_super) {
  16112. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  16113. /**
  16114. * Creates a new Fluent material
  16115. * @param name defines the name of the material
  16116. * @param scene defines the hosting scene
  16117. */
  16118. function FluentMaterial(name, scene) {
  16119. var _this = _super.call(this, name, scene) || this;
  16120. /**
  16121. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  16122. */
  16123. _this.innerGlowColorIntensity = 0.5;
  16124. /**
  16125. * Gets or sets the inner glow color (white by default)
  16126. */
  16127. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  16128. /**
  16129. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  16130. */
  16131. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  16132. /**
  16133. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  16134. */
  16135. _this.renderBorders = false;
  16136. /**
  16137. * Gets or sets border width (default is 0.5)
  16138. */
  16139. _this.borderWidth = 0.5;
  16140. /**
  16141. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  16142. */
  16143. _this.edgeSmoothingValue = 0.02;
  16144. /**
  16145. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  16146. */
  16147. _this.borderMinValue = 0.1;
  16148. /**
  16149. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  16150. */
  16151. _this.renderHoverLight = false;
  16152. /**
  16153. * Gets or sets the radius used to render the hover light (default is 1.0)
  16154. */
  16155. _this.hoverRadius = 1.0;
  16156. /**
  16157. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  16158. */
  16159. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  16160. /**
  16161. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  16162. */
  16163. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  16164. return _this;
  16165. }
  16166. FluentMaterial.prototype.needAlphaBlending = function () {
  16167. return this.alpha !== 1.0;
  16168. };
  16169. FluentMaterial.prototype.needAlphaTesting = function () {
  16170. return false;
  16171. };
  16172. FluentMaterial.prototype.getAlphaTestTexture = function () {
  16173. return null;
  16174. };
  16175. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  16176. if (this.isFrozen) {
  16177. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  16178. return true;
  16179. }
  16180. }
  16181. if (!subMesh._materialDefines) {
  16182. subMesh._materialDefines = new FluentMaterialDefines();
  16183. }
  16184. var scene = this.getScene();
  16185. var defines = subMesh._materialDefines;
  16186. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  16187. if (defines._renderId === scene.getRenderId()) {
  16188. return true;
  16189. }
  16190. }
  16191. if (defines._areTexturesDirty) {
  16192. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  16193. defines.BORDER = this.renderBorders;
  16194. defines.HOVERLIGHT = this.renderHoverLight;
  16195. if (this._albedoTexture) {
  16196. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  16197. return false;
  16198. }
  16199. else {
  16200. defines.TEXTURE = true;
  16201. }
  16202. }
  16203. else {
  16204. defines.TEXTURE = false;
  16205. }
  16206. }
  16207. var engine = scene.getEngine();
  16208. // Get correct effect
  16209. if (defines.isDirty) {
  16210. defines.markAsProcessed();
  16211. scene.resetCachedMaterial();
  16212. //Attributes
  16213. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  16214. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  16215. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  16216. var shaderName = "fluent";
  16217. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  16218. "hoverColor", "hoverPosition", "hoverRadius"
  16219. ];
  16220. var samplers = ["albedoSampler"];
  16221. var uniformBuffers = new Array();
  16222. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  16223. uniformsNames: uniforms,
  16224. uniformBuffersNames: uniformBuffers,
  16225. samplers: samplers,
  16226. defines: defines,
  16227. maxSimultaneousLights: 4
  16228. });
  16229. var join = defines.toString();
  16230. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  16231. attributes: attribs,
  16232. uniformsNames: uniforms,
  16233. uniformBuffersNames: uniformBuffers,
  16234. samplers: samplers,
  16235. defines: join,
  16236. fallbacks: null,
  16237. onCompiled: this.onCompiled,
  16238. onError: this.onError,
  16239. indexParameters: { maxSimultaneousLights: 4 }
  16240. }, engine));
  16241. }
  16242. if (!subMesh.effect || !subMesh.effect.isReady()) {
  16243. return false;
  16244. }
  16245. defines._renderId = scene.getRenderId();
  16246. subMesh.effect._wasPreviouslyReady = true;
  16247. return true;
  16248. };
  16249. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  16250. var scene = this.getScene();
  16251. var defines = subMesh._materialDefines;
  16252. if (!defines) {
  16253. return;
  16254. }
  16255. var effect = subMesh.effect;
  16256. if (!effect) {
  16257. return;
  16258. }
  16259. this._activeEffect = effect;
  16260. // Matrices
  16261. this.bindOnlyWorldMatrix(world);
  16262. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  16263. if (this._mustRebind(scene, effect)) {
  16264. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  16265. if (defines.INNERGLOW) {
  16266. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  16267. }
  16268. if (defines.BORDER) {
  16269. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  16270. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  16271. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  16272. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16273. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16274. }
  16275. if (defines.HOVERLIGHT) {
  16276. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  16277. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  16278. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  16279. }
  16280. if (defines.TEXTURE) {
  16281. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  16282. }
  16283. }
  16284. this._afterBind(mesh, this._activeEffect);
  16285. };
  16286. FluentMaterial.prototype.getActiveTextures = function () {
  16287. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16288. return activeTextures;
  16289. };
  16290. FluentMaterial.prototype.hasTexture = function (texture) {
  16291. if (_super.prototype.hasTexture.call(this, texture)) {
  16292. return true;
  16293. }
  16294. return false;
  16295. };
  16296. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16297. _super.prototype.dispose.call(this, forceDisposeEffect);
  16298. };
  16299. FluentMaterial.prototype.clone = function (name) {
  16300. var _this = this;
  16301. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16302. };
  16303. FluentMaterial.prototype.serialize = function () {
  16304. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16305. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16306. return serializationObject;
  16307. };
  16308. FluentMaterial.prototype.getClassName = function () {
  16309. return "FluentMaterial";
  16310. };
  16311. // Statics
  16312. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16313. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16314. };
  16315. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16316. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16317. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16318. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16319. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16320. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16321. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16322. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16323. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16324. ], FluentMaterial.prototype, "albedoColor", void 0);
  16325. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16326. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16327. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16328. ], FluentMaterial.prototype, "renderBorders", void 0);
  16329. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16330. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16331. ], FluentMaterial.prototype, "borderWidth", void 0);
  16332. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16333. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16334. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16335. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16336. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16337. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16338. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16339. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16340. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16341. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16342. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16343. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16344. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16345. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16346. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16347. ], FluentMaterial.prototype, "hoverColor", void 0);
  16348. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16349. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16350. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16351. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16352. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16353. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16354. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16355. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16356. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16357. return FluentMaterial;
  16358. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16359. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16360. /***/ }),
  16361. /***/ "./3D/materials/index.ts":
  16362. /*!*******************************!*\
  16363. !*** ./3D/materials/index.ts ***!
  16364. \*******************************/
  16365. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16366. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16367. "use strict";
  16368. __webpack_require__.r(__webpack_exports__);
  16369. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16372. /***/ }),
  16373. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16374. /*!*************************************************!*\
  16375. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16376. \*************************************************/
  16377. /*! exports provided: fluentPixelShader */
  16378. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16379. "use strict";
  16380. __webpack_require__.r(__webpack_exports__);
  16381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16382. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math.vector");
  16383. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16384. var name = 'fluentPixelShader';
  16385. 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}";
  16386. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16387. /** @hidden */
  16388. var fluentPixelShader = { name: name, shader: shader };
  16389. /***/ }),
  16390. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16391. /*!***********************************************!*\
  16392. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16393. \***********************************************/
  16394. /*! exports provided: fluentVertexShader */
  16395. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16396. "use strict";
  16397. __webpack_require__.r(__webpack_exports__);
  16398. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16399. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math.vector");
  16400. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16401. var name = 'fluentVertexShader';
  16402. 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";
  16403. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16404. /** @hidden */
  16405. var fluentVertexShader = { name: name, shader: shader };
  16406. /***/ }),
  16407. /***/ "./3D/vector3WithInfo.ts":
  16408. /*!*******************************!*\
  16409. !*** ./3D/vector3WithInfo.ts ***!
  16410. \*******************************/
  16411. /*! exports provided: Vector3WithInfo */
  16412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16413. "use strict";
  16414. __webpack_require__.r(__webpack_exports__);
  16415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16416. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16417. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  16418. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16419. /**
  16420. * Class used to transport Vector3 information for pointer events
  16421. */
  16422. var Vector3WithInfo = /** @class */ (function (_super) {
  16423. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16424. /**
  16425. * Creates a new Vector3WithInfo
  16426. * @param source defines the vector3 data to transport
  16427. * @param buttonIndex defines the current mouse button index
  16428. */
  16429. function Vector3WithInfo(source,
  16430. /** defines the current mouse button index */
  16431. buttonIndex) {
  16432. if (buttonIndex === void 0) { buttonIndex = 0; }
  16433. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16434. _this.buttonIndex = buttonIndex;
  16435. return _this;
  16436. }
  16437. return Vector3WithInfo;
  16438. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16439. /***/ }),
  16440. /***/ "./index.ts":
  16441. /*!******************!*\
  16442. !*** ./index.ts ***!
  16443. \******************/
  16444. /*! 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, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16446. "use strict";
  16447. __webpack_require__.r(__webpack_exports__);
  16448. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16490. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16507. /***/ }),
  16508. /***/ "./legacy/legacy.ts":
  16509. /*!**************************!*\
  16510. !*** ./legacy/legacy.ts ***!
  16511. \**************************/
  16512. /*! 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, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16513. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16514. "use strict";
  16515. __webpack_require__.r(__webpack_exports__);
  16516. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16574. /**
  16575. * Legacy support, defining window.BABYLON.GUI (global variable).
  16576. *
  16577. * This is the entry point for the UMD module.
  16578. * The entry point for a future ESM package should be index.ts
  16579. */
  16580. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16581. if (typeof globalObject !== "undefined") {
  16582. globalObject.BABYLON = globalObject.BABYLON || {};
  16583. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16584. }
  16585. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16586. /***/ }),
  16587. /***/ "babylonjs/Maths/math.vector":
  16588. /*!****************************************************************************************************!*\
  16589. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16590. \****************************************************************************************************/
  16591. /*! no static exports found */
  16592. /***/ (function(module, exports) {
  16593. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__;
  16594. /***/ })
  16595. /******/ });
  16596. });
  16597. //# sourceMappingURL=babylon.gui.js.map