babylon.gui.js 748 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212
  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. !*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Maths/math.vector");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /** @hidden */
  516. _this._numLayoutCalls = 0;
  517. /** @hidden */
  518. _this._numRenderCalls = 0;
  519. /**
  520. * Define type to string to ensure compatibility across browsers
  521. * Safari doesn't support DataTransfer constructor
  522. */
  523. _this._clipboardData = "";
  524. /**
  525. * Observable event triggered each time an clipboard event is received from the rendering canvas
  526. */
  527. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered each time a pointer down is intercepted by a control
  530. */
  531. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered before layout is evaluated
  534. */
  535. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered after the layout was evaluated
  538. */
  539. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered before the texture is rendered
  542. */
  543. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Observable event triggered after the texture was rendered
  546. */
  547. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  548. /**
  549. * Gets or sets a boolean defining if alpha is stored as premultiplied
  550. */
  551. _this.premulAlpha = false;
  552. _this._useInvalidateRectOptimization = true;
  553. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  554. _this._invalidatedRectangle = null;
  555. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  556. /** @hidden */
  557. _this.onClipboardCopy = function (rawEvt) {
  558. var evt = rawEvt;
  559. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  560. _this.onClipboardObservable.notifyObservers(ev);
  561. evt.preventDefault();
  562. };
  563. /** @hidden */
  564. _this.onClipboardCut = function (rawEvt) {
  565. var evt = rawEvt;
  566. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  567. _this.onClipboardObservable.notifyObservers(ev);
  568. evt.preventDefault();
  569. };
  570. /** @hidden */
  571. _this.onClipboardPaste = function (rawEvt) {
  572. var evt = rawEvt;
  573. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  574. _this.onClipboardObservable.notifyObservers(ev);
  575. evt.preventDefault();
  576. };
  577. scene = _this.getScene();
  578. if (!scene || !_this._texture) {
  579. return _this;
  580. }
  581. _this._rootElement = scene.getEngine().getInputElement();
  582. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  583. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  584. if (!_this._focusedControl) {
  585. return;
  586. }
  587. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  588. _this._focusedControl.processKeyboard(info.event);
  589. }
  590. info.skipOnPointerObservable = true;
  591. });
  592. _this._rootContainer._link(_this);
  593. _this.hasAlpha = true;
  594. if (!width || !height) {
  595. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  596. _this._onResize();
  597. }
  598. _this._texture.isReady = true;
  599. return _this;
  600. }
  601. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  602. /** Gets the number of layout calls made the last time the ADT has been rendered */
  603. get: function () {
  604. return this._numLayoutCalls;
  605. },
  606. enumerable: true,
  607. configurable: true
  608. });
  609. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  610. /** Gets the number of render calls made the last time the ADT has been rendered */
  611. get: function () {
  612. return this._numRenderCalls;
  613. },
  614. enumerable: true,
  615. configurable: true
  616. });
  617. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  618. /**
  619. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  620. * Useful when you want more antialiasing
  621. */
  622. get: function () {
  623. return this._renderScale;
  624. },
  625. set: function (value) {
  626. if (value === this._renderScale) {
  627. return;
  628. }
  629. this._renderScale = value;
  630. this._onResize();
  631. },
  632. enumerable: true,
  633. configurable: true
  634. });
  635. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  636. /** Gets or sets the background color */
  637. get: function () {
  638. return this._background;
  639. },
  640. set: function (value) {
  641. if (this._background === value) {
  642. return;
  643. }
  644. this._background = value;
  645. this.markAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  651. /**
  652. * Gets or sets the ideal width used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealWidth;
  658. },
  659. set: function (value) {
  660. if (this._idealWidth === value) {
  661. return;
  662. }
  663. this._idealWidth = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  671. /**
  672. * Gets or sets the ideal height used to design controls.
  673. * The GUI will then rescale everything accordingly
  674. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  675. */
  676. get: function () {
  677. return this._idealHeight;
  678. },
  679. set: function (value) {
  680. if (this._idealHeight === value) {
  681. return;
  682. }
  683. this._idealHeight = value;
  684. this.markAsDirty();
  685. this._rootContainer._markAllAsDirty();
  686. },
  687. enumerable: true,
  688. configurable: true
  689. });
  690. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  691. /**
  692. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  693. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  694. */
  695. get: function () {
  696. return this._useSmallestIdeal;
  697. },
  698. set: function (value) {
  699. if (this._useSmallestIdeal === value) {
  700. return;
  701. }
  702. this._useSmallestIdeal = value;
  703. this.markAsDirty();
  704. this._rootContainer._markAllAsDirty();
  705. },
  706. enumerable: true,
  707. configurable: true
  708. });
  709. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  710. /**
  711. * Gets or sets a boolean indicating if adaptive scaling must be used
  712. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  713. */
  714. get: function () {
  715. return this._renderAtIdealSize;
  716. },
  717. set: function (value) {
  718. if (this._renderAtIdealSize === value) {
  719. return;
  720. }
  721. this._renderAtIdealSize = value;
  722. this._onResize();
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  728. /**
  729. * Gets the ratio used when in "ideal mode"
  730. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  731. * */
  732. get: function () {
  733. var rwidth = 0;
  734. var rheight = 0;
  735. if (this._idealWidth) {
  736. rwidth = (this.getSize().width) / this._idealWidth;
  737. }
  738. if (this._idealHeight) {
  739. rheight = (this.getSize().height) / this._idealHeight;
  740. }
  741. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  742. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  743. }
  744. if (this._idealWidth) { // horizontal
  745. return rwidth;
  746. }
  747. if (this._idealHeight) { // vertical
  748. return rheight;
  749. }
  750. return 1;
  751. },
  752. enumerable: true,
  753. configurable: true
  754. });
  755. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  756. /**
  757. * Gets the underlying layer used to render the texture when in fullscreen mode
  758. */
  759. get: function () {
  760. return this._layerToDispose;
  761. },
  762. enumerable: true,
  763. configurable: true
  764. });
  765. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  766. /**
  767. * Gets the root container control
  768. */
  769. get: function () {
  770. return this._rootContainer;
  771. },
  772. enumerable: true,
  773. configurable: true
  774. });
  775. /**
  776. * Returns an array containing the root container.
  777. * This is mostly used to let the Inspector introspects the ADT
  778. * @returns an array containing the rootContainer
  779. */
  780. AdvancedDynamicTexture.prototype.getChildren = function () {
  781. return [this._rootContainer];
  782. };
  783. /**
  784. * Will return all controls that are inside this texture
  785. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  786. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  787. * @return all child controls
  788. */
  789. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  790. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  791. };
  792. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  793. /**
  794. * Gets or sets the current focused control
  795. */
  796. get: function () {
  797. return this._focusedControl;
  798. },
  799. set: function (control) {
  800. if (this._focusedControl == control) {
  801. return;
  802. }
  803. if (this._focusedControl) {
  804. this._focusedControl.onBlur();
  805. }
  806. if (control) {
  807. control.onFocus();
  808. }
  809. this._focusedControl = control;
  810. },
  811. enumerable: true,
  812. configurable: true
  813. });
  814. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  815. /**
  816. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  817. */
  818. get: function () {
  819. if (!this.layer) {
  820. return true;
  821. }
  822. return (!this.layer.isBackground);
  823. },
  824. set: function (value) {
  825. if (!this.layer) {
  826. return;
  827. }
  828. if (this.layer.isBackground === !value) {
  829. return;
  830. }
  831. this.layer.isBackground = !value;
  832. },
  833. enumerable: true,
  834. configurable: true
  835. });
  836. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  837. /**
  838. * Gets or set information about clipboardData
  839. */
  840. get: function () {
  841. return this._clipboardData;
  842. },
  843. set: function (value) {
  844. this._clipboardData = value;
  845. },
  846. enumerable: true,
  847. configurable: true
  848. });
  849. /**
  850. * Get the current class name of the texture useful for serialization or dynamic coding.
  851. * @returns "AdvancedDynamicTexture"
  852. */
  853. AdvancedDynamicTexture.prototype.getClassName = function () {
  854. return "AdvancedDynamicTexture";
  855. };
  856. /**
  857. * Function used to execute a function on all controls
  858. * @param func defines the function to execute
  859. * @param container defines the container where controls belong. If null the root container will be used
  860. */
  861. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  862. if (!container) {
  863. container = this._rootContainer;
  864. }
  865. func(container);
  866. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  867. var child = _a[_i];
  868. if (child.children) {
  869. this.executeOnAllControls(func, child);
  870. continue;
  871. }
  872. func(child);
  873. }
  874. };
  875. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  876. /**
  877. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  878. */
  879. get: function () {
  880. return this._useInvalidateRectOptimization;
  881. },
  882. set: function (value) {
  883. this._useInvalidateRectOptimization = value;
  884. },
  885. enumerable: true,
  886. configurable: true
  887. });
  888. /**
  889. * Invalidates a rectangle area on the gui texture
  890. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  891. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  892. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  893. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  894. */
  895. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  896. if (!this._useInvalidateRectOptimization) {
  897. return;
  898. }
  899. if (!this._invalidatedRectangle) {
  900. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  901. }
  902. else {
  903. // Compute intersection
  904. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  905. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  906. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  907. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  908. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  909. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  910. }
  911. };
  912. /**
  913. * Marks the texture as dirty forcing a complete update
  914. */
  915. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  916. this._isDirty = true;
  917. };
  918. /**
  919. * Helper function used to create a new style
  920. * @returns a new style
  921. * @see http://doc.babylonjs.com/how_to/gui#styles
  922. */
  923. AdvancedDynamicTexture.prototype.createStyle = function () {
  924. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  925. };
  926. /**
  927. * Adds a new control to the root container
  928. * @param control defines the control to add
  929. * @returns the current texture
  930. */
  931. AdvancedDynamicTexture.prototype.addControl = function (control) {
  932. this._rootContainer.addControl(control);
  933. return this;
  934. };
  935. /**
  936. * Removes a control from the root container
  937. * @param control defines the control to remove
  938. * @returns the current texture
  939. */
  940. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  941. this._rootContainer.removeControl(control);
  942. return this;
  943. };
  944. /**
  945. * Release all resources
  946. */
  947. AdvancedDynamicTexture.prototype.dispose = function () {
  948. var scene = this.getScene();
  949. if (!scene) {
  950. return;
  951. }
  952. this._rootElement = null;
  953. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  954. if (this._resizeObserver) {
  955. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  956. }
  957. if (this._pointerMoveObserver) {
  958. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  959. }
  960. if (this._pointerObserver) {
  961. scene.onPointerObservable.remove(this._pointerObserver);
  962. }
  963. if (this._preKeyboardObserver) {
  964. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  965. }
  966. if (this._canvasPointerOutObserver) {
  967. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  968. }
  969. if (this._layerToDispose) {
  970. this._layerToDispose.texture = null;
  971. this._layerToDispose.dispose();
  972. this._layerToDispose = null;
  973. }
  974. this._rootContainer.dispose();
  975. this.onClipboardObservable.clear();
  976. this.onControlPickedObservable.clear();
  977. this.onBeginRenderObservable.clear();
  978. this.onEndRenderObservable.clear();
  979. this.onBeginLayoutObservable.clear();
  980. this.onEndLayoutObservable.clear();
  981. _super.prototype.dispose.call(this);
  982. };
  983. AdvancedDynamicTexture.prototype._onResize = function () {
  984. var scene = this.getScene();
  985. if (!scene) {
  986. return;
  987. }
  988. // Check size
  989. var engine = scene.getEngine();
  990. var textureSize = this.getSize();
  991. var renderWidth = engine.getRenderWidth() * this._renderScale;
  992. var renderHeight = engine.getRenderHeight() * this._renderScale;
  993. if (this._renderAtIdealSize) {
  994. if (this._idealWidth) {
  995. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  996. renderWidth = this._idealWidth;
  997. }
  998. else if (this._idealHeight) {
  999. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1000. renderHeight = this._idealHeight;
  1001. }
  1002. }
  1003. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1004. this.scaleTo(renderWidth, renderHeight);
  1005. this.markAsDirty();
  1006. if (this._idealWidth || this._idealHeight) {
  1007. this._rootContainer._markAllAsDirty();
  1008. }
  1009. }
  1010. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1011. };
  1012. /** @hidden */
  1013. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1014. var engine = scene.getEngine();
  1015. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1016. };
  1017. /**
  1018. * Get screen coordinates for a vector3
  1019. * @param position defines the position to project
  1020. * @param worldMatrix defines the world matrix to use
  1021. * @returns the projected position
  1022. */
  1023. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1024. var scene = this.getScene();
  1025. if (!scene) {
  1026. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1027. }
  1028. var globalViewport = this._getGlobalViewport(scene);
  1029. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1030. projectedPosition.scaleInPlace(this.renderScale);
  1031. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1032. };
  1033. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1034. if (this._layerToDispose) {
  1035. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1036. return;
  1037. }
  1038. }
  1039. if (this._isFullscreen && this._linkedControls.length) {
  1040. var scene = this.getScene();
  1041. if (!scene) {
  1042. return;
  1043. }
  1044. var globalViewport = this._getGlobalViewport(scene);
  1045. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1046. var control = _a[_i];
  1047. if (!control.isVisible) {
  1048. continue;
  1049. }
  1050. var mesh = control._linkedMesh;
  1051. if (!mesh || mesh.isDisposed()) {
  1052. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1053. control.linkWithMesh(null);
  1054. });
  1055. continue;
  1056. }
  1057. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1058. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1059. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1060. control.notRenderable = true;
  1061. continue;
  1062. }
  1063. control.notRenderable = false;
  1064. // Account for RenderScale.
  1065. projectedPosition.scaleInPlace(this.renderScale);
  1066. control._moveToProjectedPosition(projectedPosition);
  1067. }
  1068. }
  1069. if (!this._isDirty && !this._rootContainer.isDirty) {
  1070. return;
  1071. }
  1072. this._isDirty = false;
  1073. this._render();
  1074. this.update(true, this.premulAlpha);
  1075. };
  1076. AdvancedDynamicTexture.prototype._render = function () {
  1077. var textureSize = this.getSize();
  1078. var renderWidth = textureSize.width;
  1079. var renderHeight = textureSize.height;
  1080. var context = this.getContext();
  1081. context.font = "18px Arial";
  1082. context.strokeStyle = "white";
  1083. // Layout
  1084. this.onBeginLayoutObservable.notifyObservers(this);
  1085. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1086. this._numLayoutCalls = 0;
  1087. this._rootContainer._layout(measure, context);
  1088. this.onEndLayoutObservable.notifyObservers(this);
  1089. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1090. // Clear
  1091. if (this._invalidatedRectangle) {
  1092. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1093. }
  1094. else {
  1095. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1096. }
  1097. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1098. if (this._background) {
  1099. context.save();
  1100. context.fillStyle = this._background;
  1101. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1102. context.restore();
  1103. }
  1104. // Render
  1105. this.onBeginRenderObservable.notifyObservers(this);
  1106. this._numRenderCalls = 0;
  1107. this._rootContainer._render(context, this._invalidatedRectangle);
  1108. this.onEndRenderObservable.notifyObservers(this);
  1109. this._invalidatedRectangle = null;
  1110. };
  1111. /** @hidden */
  1112. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1113. if (this._rootElement) {
  1114. this._rootElement.style.cursor = cursor;
  1115. this._cursorChanged = true;
  1116. }
  1117. };
  1118. /** @hidden */
  1119. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1120. this._lastControlDown[pointerId] = control;
  1121. this.onControlPickedObservable.notifyObservers(control);
  1122. };
  1123. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1124. var scene = this.getScene();
  1125. if (!scene) {
  1126. return;
  1127. }
  1128. var engine = scene.getEngine();
  1129. var textureSize = this.getSize();
  1130. if (this._isFullscreen) {
  1131. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1132. var viewport = camera.viewport;
  1133. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1134. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1135. }
  1136. if (this._capturingControl[pointerId]) {
  1137. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1138. return;
  1139. }
  1140. this._cursorChanged = false;
  1141. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  1142. this._changeCursor("");
  1143. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1144. if (this._lastControlOver[pointerId]) {
  1145. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1146. delete this._lastControlOver[pointerId];
  1147. }
  1148. }
  1149. }
  1150. if (!this._cursorChanged) {
  1151. this._changeCursor("");
  1152. }
  1153. this._manageFocus();
  1154. };
  1155. /** @hidden */
  1156. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1157. for (var pointerId in list) {
  1158. if (!list.hasOwnProperty(pointerId)) {
  1159. continue;
  1160. }
  1161. var lastControlOver = list[pointerId];
  1162. if (lastControlOver === control) {
  1163. delete list[pointerId];
  1164. }
  1165. }
  1166. };
  1167. /** @hidden */
  1168. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1169. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1170. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1171. };
  1172. /** Attach to all scene events required to support pointer events */
  1173. AdvancedDynamicTexture.prototype.attach = function () {
  1174. var _this = this;
  1175. var scene = this.getScene();
  1176. if (!scene) {
  1177. return;
  1178. }
  1179. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1180. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1181. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1182. return;
  1183. }
  1184. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1185. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1186. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN
  1187. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  1188. return;
  1189. }
  1190. if (!scene) {
  1191. return;
  1192. }
  1193. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1194. var engine = scene.getEngine();
  1195. if (!camera) {
  1196. tempViewport.x = 0;
  1197. tempViewport.y = 0;
  1198. tempViewport.width = engine.getRenderWidth();
  1199. tempViewport.height = engine.getRenderHeight();
  1200. }
  1201. else {
  1202. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1203. }
  1204. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1205. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1206. _this._shouldBlockPointer = false;
  1207. // Do picking modifies _shouldBlockPointer
  1208. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button, pi.event.deltaX, pi.event.deltaY);
  1209. // Avoid overwriting a true skipOnPointerObservable to false
  1210. if (_this._shouldBlockPointer) {
  1211. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1212. }
  1213. });
  1214. this._attachToOnPointerOut(scene);
  1215. };
  1216. /**
  1217. * Register the clipboard Events onto the canvas
  1218. */
  1219. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1220. self.addEventListener("copy", this.onClipboardCopy, false);
  1221. self.addEventListener("cut", this.onClipboardCut, false);
  1222. self.addEventListener("paste", this.onClipboardPaste, false);
  1223. };
  1224. /**
  1225. * Unregister the clipboard Events from the canvas
  1226. */
  1227. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1228. self.removeEventListener("copy", this.onClipboardCopy);
  1229. self.removeEventListener("cut", this.onClipboardCut);
  1230. self.removeEventListener("paste", this.onClipboardPaste);
  1231. };
  1232. /**
  1233. * Connect the texture to a hosting mesh to enable interactions
  1234. * @param mesh defines the mesh to attach to
  1235. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1236. */
  1237. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1238. var _this = this;
  1239. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1240. var scene = this.getScene();
  1241. if (!scene) {
  1242. return;
  1243. }
  1244. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1245. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1246. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1247. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1248. return;
  1249. }
  1250. var pointerId = pi.event.pointerId || 0;
  1251. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1252. var uv = pi.pickInfo.getTextureCoordinates();
  1253. if (uv) {
  1254. var size = _this.getSize();
  1255. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1256. }
  1257. }
  1258. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1259. if (_this._lastControlDown[pointerId]) {
  1260. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1261. }
  1262. delete _this._lastControlDown[pointerId];
  1263. if (_this.focusedControl) {
  1264. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1265. var canMoveFocus = true;
  1266. if (friendlyControls) {
  1267. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1268. var control = friendlyControls_1[_i];
  1269. // Same host, no need to keep the focus
  1270. if (_this === control._host) {
  1271. continue;
  1272. }
  1273. // Different hosts
  1274. var otherHost = control._host;
  1275. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1276. canMoveFocus = false;
  1277. break;
  1278. }
  1279. }
  1280. }
  1281. if (canMoveFocus) {
  1282. _this.focusedControl = null;
  1283. }
  1284. }
  1285. }
  1286. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1287. if (_this._lastControlOver[pointerId]) {
  1288. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1289. }
  1290. delete _this._lastControlOver[pointerId];
  1291. }
  1292. });
  1293. mesh.enablePointerMoveEvents = supportPointerMove;
  1294. this._attachToOnPointerOut(scene);
  1295. };
  1296. /**
  1297. * Move the focus to a specific control
  1298. * @param control defines the control which will receive the focus
  1299. */
  1300. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1301. this.focusedControl = control;
  1302. this._lastPickedControl = control;
  1303. this._blockNextFocusCheck = true;
  1304. };
  1305. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1306. if (this._blockNextFocusCheck) {
  1307. this._blockNextFocusCheck = false;
  1308. this._lastPickedControl = this._focusedControl;
  1309. return;
  1310. }
  1311. // Focus management
  1312. if (this._focusedControl) {
  1313. if (this._focusedControl !== this._lastPickedControl) {
  1314. if (this._lastPickedControl.isFocusInvisible) {
  1315. return;
  1316. }
  1317. this.focusedControl = null;
  1318. }
  1319. }
  1320. };
  1321. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1322. var _this = this;
  1323. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1324. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1325. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1326. }
  1327. delete _this._lastControlOver[pointerEvent.pointerId];
  1328. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1329. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1330. delete _this._lastControlDown[pointerEvent.pointerId];
  1331. }
  1332. });
  1333. };
  1334. // Statics
  1335. /**
  1336. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1337. * @param mesh defines the mesh which will receive the texture
  1338. * @param width defines the texture width (1024 by default)
  1339. * @param height defines the texture height (1024 by default)
  1340. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1341. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1342. * @returns a new AdvancedDynamicTexture
  1343. */
  1344. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1345. if (width === void 0) { width = 1024; }
  1346. if (height === void 0) { height = 1024; }
  1347. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1348. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1349. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1350. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1351. material.backFaceCulling = false;
  1352. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1353. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1354. if (onlyAlphaTesting) {
  1355. material.diffuseTexture = result;
  1356. material.emissiveTexture = result;
  1357. result.hasAlpha = true;
  1358. }
  1359. else {
  1360. material.emissiveTexture = result;
  1361. material.opacityTexture = result;
  1362. }
  1363. mesh.material = material;
  1364. result.attachToMesh(mesh, supportPointerMove);
  1365. return result;
  1366. };
  1367. /**
  1368. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1369. * In this mode the texture will rely on a layer for its rendering.
  1370. * This allows it to be treated like any other layer.
  1371. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1372. * LayerMask is set through advancedTexture.layer.layerMask
  1373. * @param name defines name for the texture
  1374. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1375. * @param scene defines the hsoting scene
  1376. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1377. * @returns a new AdvancedDynamicTexture
  1378. */
  1379. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1380. if (foreground === void 0) { foreground = true; }
  1381. if (scene === void 0) { scene = null; }
  1382. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1383. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1384. // Display
  1385. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1386. layer.texture = result;
  1387. result._layerToDispose = layer;
  1388. result._isFullscreen = true;
  1389. // Attach
  1390. result.attach();
  1391. return result;
  1392. };
  1393. return AdvancedDynamicTexture;
  1394. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1395. /***/ }),
  1396. /***/ "./2D/controls/button.ts":
  1397. /*!*******************************!*\
  1398. !*** ./2D/controls/button.ts ***!
  1399. \*******************************/
  1400. /*! exports provided: Button */
  1401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1402. "use strict";
  1403. __webpack_require__.r(__webpack_exports__);
  1404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1405. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1406. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1407. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1408. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1409. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1410. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  1411. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1412. /**
  1413. * Class used to create 2D buttons
  1414. */
  1415. var Button = /** @class */ (function (_super) {
  1416. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1417. /**
  1418. * Creates a new Button
  1419. * @param name defines the name of the button
  1420. */
  1421. function Button(name) {
  1422. var _this = _super.call(this, name) || this;
  1423. _this.name = name;
  1424. /**
  1425. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1426. */
  1427. _this.delegatePickingToChildren = false;
  1428. _this.thickness = 1;
  1429. _this.isPointerBlocker = true;
  1430. var alphaStore = null;
  1431. _this.pointerEnterAnimation = function () {
  1432. alphaStore = _this.alpha;
  1433. _this.alpha -= 0.1;
  1434. };
  1435. _this.pointerOutAnimation = function () {
  1436. if (alphaStore !== null) {
  1437. _this.alpha = alphaStore;
  1438. }
  1439. };
  1440. _this.pointerDownAnimation = function () {
  1441. _this.scaleX -= 0.05;
  1442. _this.scaleY -= 0.05;
  1443. };
  1444. _this.pointerUpAnimation = function () {
  1445. _this.scaleX += 0.05;
  1446. _this.scaleY += 0.05;
  1447. };
  1448. return _this;
  1449. }
  1450. Object.defineProperty(Button.prototype, "image", {
  1451. /**
  1452. * Returns the image part of the button (if any)
  1453. */
  1454. get: function () {
  1455. return this._image;
  1456. },
  1457. enumerable: true,
  1458. configurable: true
  1459. });
  1460. Object.defineProperty(Button.prototype, "textBlock", {
  1461. /**
  1462. * Returns the image part of the button (if any)
  1463. */
  1464. get: function () {
  1465. return this._textBlock;
  1466. },
  1467. enumerable: true,
  1468. configurable: true
  1469. });
  1470. Button.prototype._getTypeName = function () {
  1471. return "Button";
  1472. };
  1473. // While being a container, the button behaves like a control.
  1474. /** @hidden */
  1475. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1476. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1477. return false;
  1478. }
  1479. if (!_super.prototype.contains.call(this, x, y)) {
  1480. return false;
  1481. }
  1482. if (this.delegatePickingToChildren) {
  1483. var contains = false;
  1484. for (var index = this._children.length - 1; index >= 0; index--) {
  1485. var child = this._children[index];
  1486. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1487. contains = true;
  1488. break;
  1489. }
  1490. }
  1491. if (!contains) {
  1492. return false;
  1493. }
  1494. }
  1495. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  1496. return true;
  1497. };
  1498. /** @hidden */
  1499. Button.prototype._onPointerEnter = function (target) {
  1500. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1501. return false;
  1502. }
  1503. if (this.pointerEnterAnimation) {
  1504. this.pointerEnterAnimation();
  1505. }
  1506. return true;
  1507. };
  1508. /** @hidden */
  1509. Button.prototype._onPointerOut = function (target, force) {
  1510. if (force === void 0) { force = false; }
  1511. if (this.pointerOutAnimation) {
  1512. this.pointerOutAnimation();
  1513. }
  1514. _super.prototype._onPointerOut.call(this, target, force);
  1515. };
  1516. /** @hidden */
  1517. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1518. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1519. return false;
  1520. }
  1521. if (this.pointerDownAnimation) {
  1522. this.pointerDownAnimation();
  1523. }
  1524. return true;
  1525. };
  1526. /** @hidden */
  1527. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1528. if (this.pointerUpAnimation) {
  1529. this.pointerUpAnimation();
  1530. }
  1531. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1532. };
  1533. // Statics
  1534. /**
  1535. * Creates a new button made with an image and a text
  1536. * @param name defines the name of the button
  1537. * @param text defines the text of the button
  1538. * @param imageUrl defines the url of the image
  1539. * @returns a new Button
  1540. */
  1541. Button.CreateImageButton = function (name, text, imageUrl) {
  1542. var result = new Button(name);
  1543. // Adding text
  1544. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1545. textBlock.textWrapping = true;
  1546. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1547. textBlock.paddingLeft = "20%";
  1548. result.addControl(textBlock);
  1549. // Adding image
  1550. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1551. iconImage.width = "20%";
  1552. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1553. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1554. result.addControl(iconImage);
  1555. // Store
  1556. result._image = iconImage;
  1557. result._textBlock = textBlock;
  1558. return result;
  1559. };
  1560. /**
  1561. * Creates a new button made with an image
  1562. * @param name defines the name of the button
  1563. * @param imageUrl defines the url of the image
  1564. * @returns a new Button
  1565. */
  1566. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1567. var result = new Button(name);
  1568. // Adding image
  1569. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1570. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1571. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1572. result.addControl(iconImage);
  1573. // Store
  1574. result._image = iconImage;
  1575. return result;
  1576. };
  1577. /**
  1578. * Creates a new button made with a text
  1579. * @param name defines the name of the button
  1580. * @param text defines the text of the button
  1581. * @returns a new Button
  1582. */
  1583. Button.CreateSimpleButton = function (name, text) {
  1584. var result = new Button(name);
  1585. // Adding text
  1586. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1587. textBlock.textWrapping = true;
  1588. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1589. result.addControl(textBlock);
  1590. // Store
  1591. result._textBlock = textBlock;
  1592. return result;
  1593. };
  1594. /**
  1595. * Creates a new button made with an image and a centered text
  1596. * @param name defines the name of the button
  1597. * @param text defines the text of the button
  1598. * @param imageUrl defines the url of the image
  1599. * @returns a new Button
  1600. */
  1601. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1602. var result = new Button(name);
  1603. // Adding image
  1604. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1605. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1606. result.addControl(iconImage);
  1607. // Adding text
  1608. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1609. textBlock.textWrapping = true;
  1610. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1611. result.addControl(textBlock);
  1612. // Store
  1613. result._image = iconImage;
  1614. result._textBlock = textBlock;
  1615. return result;
  1616. };
  1617. return Button;
  1618. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1619. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1620. /***/ }),
  1621. /***/ "./2D/controls/checkbox.ts":
  1622. /*!*********************************!*\
  1623. !*** ./2D/controls/checkbox.ts ***!
  1624. \*********************************/
  1625. /*! exports provided: Checkbox */
  1626. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1627. "use strict";
  1628. __webpack_require__.r(__webpack_exports__);
  1629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1630. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1631. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  1632. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1633. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1634. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1635. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1636. /**
  1637. * Class used to represent a 2D checkbox
  1638. */
  1639. var Checkbox = /** @class */ (function (_super) {
  1640. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1641. /**
  1642. * Creates a new CheckBox
  1643. * @param name defines the control name
  1644. */
  1645. function Checkbox(name) {
  1646. var _this = _super.call(this, name) || this;
  1647. _this.name = name;
  1648. _this._isChecked = false;
  1649. _this._background = "black";
  1650. _this._checkSizeRatio = 0.8;
  1651. _this._thickness = 1;
  1652. /**
  1653. * Observable raised when isChecked property changes
  1654. */
  1655. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1656. _this.isPointerBlocker = true;
  1657. return _this;
  1658. }
  1659. Object.defineProperty(Checkbox.prototype, "thickness", {
  1660. /** Gets or sets border thickness */
  1661. get: function () {
  1662. return this._thickness;
  1663. },
  1664. set: function (value) {
  1665. if (this._thickness === value) {
  1666. return;
  1667. }
  1668. this._thickness = value;
  1669. this._markAsDirty();
  1670. },
  1671. enumerable: true,
  1672. configurable: true
  1673. });
  1674. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1675. /** Gets or sets a value indicating the ratio between overall size and check size */
  1676. get: function () {
  1677. return this._checkSizeRatio;
  1678. },
  1679. set: function (value) {
  1680. value = Math.max(Math.min(1, value), 0);
  1681. if (this._checkSizeRatio === value) {
  1682. return;
  1683. }
  1684. this._checkSizeRatio = value;
  1685. this._markAsDirty();
  1686. },
  1687. enumerable: true,
  1688. configurable: true
  1689. });
  1690. Object.defineProperty(Checkbox.prototype, "background", {
  1691. /** Gets or sets background color */
  1692. get: function () {
  1693. return this._background;
  1694. },
  1695. set: function (value) {
  1696. if (this._background === value) {
  1697. return;
  1698. }
  1699. this._background = value;
  1700. this._markAsDirty();
  1701. },
  1702. enumerable: true,
  1703. configurable: true
  1704. });
  1705. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1706. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1707. get: function () {
  1708. return this._isChecked;
  1709. },
  1710. set: function (value) {
  1711. if (this._isChecked === value) {
  1712. return;
  1713. }
  1714. this._isChecked = value;
  1715. this._markAsDirty();
  1716. this.onIsCheckedChangedObservable.notifyObservers(value);
  1717. },
  1718. enumerable: true,
  1719. configurable: true
  1720. });
  1721. Checkbox.prototype._getTypeName = function () {
  1722. return "Checkbox";
  1723. };
  1724. /** @hidden */
  1725. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1726. context.save();
  1727. this._applyStates(context);
  1728. var actualWidth = this._currentMeasure.width - this._thickness;
  1729. var actualHeight = this._currentMeasure.height - this._thickness;
  1730. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1731. context.shadowColor = this.shadowColor;
  1732. context.shadowBlur = this.shadowBlur;
  1733. context.shadowOffsetX = this.shadowOffsetX;
  1734. context.shadowOffsetY = this.shadowOffsetY;
  1735. }
  1736. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1737. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1738. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1739. context.shadowBlur = 0;
  1740. context.shadowOffsetX = 0;
  1741. context.shadowOffsetY = 0;
  1742. }
  1743. if (this._isChecked) {
  1744. context.fillStyle = this._isEnabled ? this.color : this._disabledColorItem;
  1745. var offsetWidth = actualWidth * this._checkSizeRatio;
  1746. var offseHeight = actualHeight * this._checkSizeRatio;
  1747. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1748. }
  1749. context.strokeStyle = this.color;
  1750. context.lineWidth = this._thickness;
  1751. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1752. context.restore();
  1753. };
  1754. // Events
  1755. /** @hidden */
  1756. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1757. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1758. return false;
  1759. }
  1760. this.isChecked = !this.isChecked;
  1761. return true;
  1762. };
  1763. /**
  1764. * Utility function to easily create a checkbox with a header
  1765. * @param title defines the label to use for the header
  1766. * @param onValueChanged defines the callback to call when value changes
  1767. * @returns a StackPanel containing the checkbox and a textBlock
  1768. */
  1769. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1770. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1771. panel.isVertical = false;
  1772. panel.height = "30px";
  1773. var checkbox = new Checkbox();
  1774. checkbox.width = "20px";
  1775. checkbox.height = "20px";
  1776. checkbox.isChecked = true;
  1777. checkbox.color = "green";
  1778. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1779. panel.addControl(checkbox);
  1780. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1781. header.text = title;
  1782. header.width = "180px";
  1783. header.paddingLeft = "5px";
  1784. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1785. header.color = "white";
  1786. panel.addControl(header);
  1787. return panel;
  1788. };
  1789. return Checkbox;
  1790. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1791. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1792. /***/ }),
  1793. /***/ "./2D/controls/colorpicker.ts":
  1794. /*!************************************!*\
  1795. !*** ./2D/controls/colorpicker.ts ***!
  1796. \************************************/
  1797. /*! exports provided: ColorPicker */
  1798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1799. "use strict";
  1800. __webpack_require__.r(__webpack_exports__);
  1801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1802. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1803. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  1804. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1805. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1806. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1807. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1808. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1809. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1810. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1811. /** Class used to create color pickers */
  1812. var ColorPicker = /** @class */ (function (_super) {
  1813. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1814. /**
  1815. * Creates a new ColorPicker
  1816. * @param name defines the control name
  1817. */
  1818. function ColorPicker(name) {
  1819. var _this = _super.call(this, name) || this;
  1820. _this.name = name;
  1821. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1822. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1823. _this._pointerStartedOnSquare = false;
  1824. _this._pointerStartedOnWheel = false;
  1825. _this._squareLeft = 0;
  1826. _this._squareTop = 0;
  1827. _this._squareSize = 0;
  1828. _this._h = 360;
  1829. _this._s = 1;
  1830. _this._v = 1;
  1831. _this._lastPointerDownID = -1;
  1832. /**
  1833. * Observable raised when the value changes
  1834. */
  1835. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1836. // Events
  1837. _this._pointerIsDown = false;
  1838. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1839. _this.size = "200px";
  1840. _this.isPointerBlocker = true;
  1841. return _this;
  1842. }
  1843. Object.defineProperty(ColorPicker.prototype, "value", {
  1844. /** Gets or sets the color of the color picker */
  1845. get: function () {
  1846. return this._value;
  1847. },
  1848. set: function (value) {
  1849. if (this._value.equals(value)) {
  1850. return;
  1851. }
  1852. this._value.copyFrom(value);
  1853. this._value.toHSVToRef(this._tmpColor);
  1854. this._h = this._tmpColor.r;
  1855. this._s = Math.max(this._tmpColor.g, 0.00001);
  1856. this._v = Math.max(this._tmpColor.b, 0.00001);
  1857. this._markAsDirty();
  1858. if (this._value.r <= ColorPicker._Epsilon) {
  1859. this._value.r = 0;
  1860. }
  1861. if (this._value.g <= ColorPicker._Epsilon) {
  1862. this._value.g = 0;
  1863. }
  1864. if (this._value.b <= ColorPicker._Epsilon) {
  1865. this._value.b = 0;
  1866. }
  1867. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1868. this._value.r = 1.0;
  1869. }
  1870. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1871. this._value.g = 1.0;
  1872. }
  1873. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1874. this._value.b = 1.0;
  1875. }
  1876. this.onValueChangedObservable.notifyObservers(this._value);
  1877. },
  1878. enumerable: true,
  1879. configurable: true
  1880. });
  1881. Object.defineProperty(ColorPicker.prototype, "width", {
  1882. /**
  1883. * Gets or sets control width
  1884. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1885. */
  1886. get: function () {
  1887. return this._width.toString(this._host);
  1888. },
  1889. set: function (value) {
  1890. if (this._width.toString(this._host) === value) {
  1891. return;
  1892. }
  1893. if (this._width.fromString(value)) {
  1894. this._height.fromString(value);
  1895. this._markAsDirty();
  1896. }
  1897. },
  1898. enumerable: true,
  1899. configurable: true
  1900. });
  1901. Object.defineProperty(ColorPicker.prototype, "height", {
  1902. /**
  1903. * Gets or sets control height
  1904. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1905. */
  1906. get: function () {
  1907. return this._height.toString(this._host);
  1908. },
  1909. /** Gets or sets control height */
  1910. set: function (value) {
  1911. if (this._height.toString(this._host) === value) {
  1912. return;
  1913. }
  1914. if (this._height.fromString(value)) {
  1915. this._width.fromString(value);
  1916. this._markAsDirty();
  1917. }
  1918. },
  1919. enumerable: true,
  1920. configurable: true
  1921. });
  1922. Object.defineProperty(ColorPicker.prototype, "size", {
  1923. /** Gets or sets control size */
  1924. get: function () {
  1925. return this.width;
  1926. },
  1927. set: function (value) {
  1928. this.width = value;
  1929. },
  1930. enumerable: true,
  1931. configurable: true
  1932. });
  1933. ColorPicker.prototype._getTypeName = function () {
  1934. return "ColorPicker";
  1935. };
  1936. /** @hidden */
  1937. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1938. if (parentMeasure.width < parentMeasure.height) {
  1939. this._currentMeasure.height = parentMeasure.width;
  1940. }
  1941. else {
  1942. this._currentMeasure.width = parentMeasure.height;
  1943. }
  1944. };
  1945. ColorPicker.prototype._updateSquareProps = function () {
  1946. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1947. var wheelThickness = radius * .2;
  1948. var innerDiameter = (radius - wheelThickness) * 2;
  1949. var squareSize = innerDiameter / (Math.sqrt(2));
  1950. var offset = radius - squareSize * .5;
  1951. this._squareLeft = this._currentMeasure.left + offset;
  1952. this._squareTop = this._currentMeasure.top + offset;
  1953. this._squareSize = squareSize;
  1954. };
  1955. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1956. var lgh = context.createLinearGradient(left, top, width + left, top);
  1957. lgh.addColorStop(0, '#fff');
  1958. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1959. context.fillStyle = lgh;
  1960. context.fillRect(left, top, width, height);
  1961. var lgv = context.createLinearGradient(left, top, left, height + top);
  1962. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1963. lgv.addColorStop(1, '#000');
  1964. context.fillStyle = lgv;
  1965. context.fillRect(left, top, width, height);
  1966. };
  1967. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1968. context.beginPath();
  1969. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1970. context.lineWidth = 3;
  1971. context.strokeStyle = '#333333';
  1972. context.stroke();
  1973. context.beginPath();
  1974. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1975. context.lineWidth = 3;
  1976. context.strokeStyle = '#ffffff';
  1977. context.stroke();
  1978. };
  1979. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1980. var canvas = document.createElement("canvas");
  1981. canvas.width = radius * 2;
  1982. canvas.height = radius * 2;
  1983. var context = canvas.getContext("2d");
  1984. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1985. var data = image.data;
  1986. var color = this._tmpColor;
  1987. var maxDistSq = radius * radius;
  1988. var innerRadius = radius - thickness;
  1989. var minDistSq = innerRadius * innerRadius;
  1990. for (var x = -radius; x < radius; x++) {
  1991. for (var y = -radius; y < radius; y++) {
  1992. var distSq = x * x + y * y;
  1993. if (distSq > maxDistSq || distSq < minDistSq) {
  1994. continue;
  1995. }
  1996. var dist = Math.sqrt(distSq);
  1997. var ang = Math.atan2(y, x);
  1998. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1999. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  2000. data[index] = color.r * 255;
  2001. data[index + 1] = color.g * 255;
  2002. data[index + 2] = color.b * 255;
  2003. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2004. //apply less alpha to bigger color pickers
  2005. var alphaAmount = .2;
  2006. var maxAlpha = .2;
  2007. var minAlpha = .04;
  2008. var lowerRadius = 50;
  2009. var upperRadius = 150;
  2010. if (radius < lowerRadius) {
  2011. alphaAmount = maxAlpha;
  2012. }
  2013. else if (radius > upperRadius) {
  2014. alphaAmount = minAlpha;
  2015. }
  2016. else {
  2017. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2018. }
  2019. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2020. if (alphaRatio < alphaAmount) {
  2021. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2022. }
  2023. else if (alphaRatio > 1 - alphaAmount) {
  2024. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2025. }
  2026. else {
  2027. data[index + 3] = 255;
  2028. }
  2029. }
  2030. }
  2031. context.putImageData(image, 0, 0);
  2032. return canvas;
  2033. };
  2034. /** @hidden */
  2035. ColorPicker.prototype._draw = function (context) {
  2036. context.save();
  2037. this._applyStates(context);
  2038. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2039. var wheelThickness = radius * .2;
  2040. var left = this._currentMeasure.left;
  2041. var top = this._currentMeasure.top;
  2042. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2043. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2044. }
  2045. this._updateSquareProps();
  2046. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2047. context.shadowColor = this.shadowColor;
  2048. context.shadowBlur = this.shadowBlur;
  2049. context.shadowOffsetX = this.shadowOffsetX;
  2050. context.shadowOffsetY = this.shadowOffsetY;
  2051. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2052. }
  2053. context.drawImage(this._colorWheelCanvas, left, top);
  2054. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2055. context.shadowBlur = 0;
  2056. context.shadowOffsetX = 0;
  2057. context.shadowOffsetY = 0;
  2058. }
  2059. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2060. var cx = this._squareLeft + this._squareSize * this._s;
  2061. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2062. this._drawCircle(cx, cy, radius * .04, context);
  2063. var dist = radius - wheelThickness * .5;
  2064. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2065. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2066. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2067. context.restore();
  2068. };
  2069. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2070. if (this._pointerStartedOnWheel) {
  2071. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2072. var centerX = radius + this._currentMeasure.left;
  2073. var centerY = radius + this._currentMeasure.top;
  2074. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2075. }
  2076. else if (this._pointerStartedOnSquare) {
  2077. this._updateSquareProps();
  2078. this._s = (x - this._squareLeft) / this._squareSize;
  2079. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2080. this._s = Math.min(this._s, 1);
  2081. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2082. this._v = Math.min(this._v, 1);
  2083. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2084. }
  2085. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2086. this.value = this._tmpColor;
  2087. };
  2088. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2089. this._updateSquareProps();
  2090. var left = this._squareLeft;
  2091. var top = this._squareTop;
  2092. var size = this._squareSize;
  2093. if (x >= left && x <= left + size &&
  2094. y >= top && y <= top + size) {
  2095. return true;
  2096. }
  2097. return false;
  2098. };
  2099. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2100. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2101. var centerX = radius + this._currentMeasure.left;
  2102. var centerY = radius + this._currentMeasure.top;
  2103. var wheelThickness = radius * .2;
  2104. var innerRadius = radius - wheelThickness;
  2105. var radiusSq = radius * radius;
  2106. var innerRadiusSq = innerRadius * innerRadius;
  2107. var dx = x - centerX;
  2108. var dy = y - centerY;
  2109. var distSq = dx * dx + dy * dy;
  2110. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2111. return true;
  2112. }
  2113. return false;
  2114. };
  2115. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2116. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2117. return false;
  2118. }
  2119. this._pointerIsDown = true;
  2120. this._pointerStartedOnSquare = false;
  2121. this._pointerStartedOnWheel = false;
  2122. // Invert transform
  2123. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2124. var x = this._transformedPosition.x;
  2125. var y = this._transformedPosition.y;
  2126. if (this._isPointOnSquare(x, y)) {
  2127. this._pointerStartedOnSquare = true;
  2128. }
  2129. else if (this._isPointOnWheel(x, y)) {
  2130. this._pointerStartedOnWheel = true;
  2131. }
  2132. this._updateValueFromPointer(x, y);
  2133. this._host._capturingControl[pointerId] = this;
  2134. this._lastPointerDownID = pointerId;
  2135. return true;
  2136. };
  2137. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2138. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2139. if (pointerId != this._lastPointerDownID) {
  2140. return;
  2141. }
  2142. // Invert transform
  2143. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2144. var x = this._transformedPosition.x;
  2145. var y = this._transformedPosition.y;
  2146. if (this._pointerIsDown) {
  2147. this._updateValueFromPointer(x, y);
  2148. }
  2149. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2150. };
  2151. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2152. this._pointerIsDown = false;
  2153. delete this._host._capturingControl[pointerId];
  2154. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2155. };
  2156. /**
  2157. * This function expands the color picker by creating a color picker dialog with manual
  2158. * color value input and the ability to save colors into an array to be used later in
  2159. * subsequent launches of the dialogue.
  2160. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2161. * @param options defines size for dialog and options for saved colors. Also accepts last color picked as hex string and saved colors array as hex strings.
  2162. * @returns picked color as a hex string and the saved colors array as hex strings.
  2163. */
  2164. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2165. return new Promise(function (resolve, reject) {
  2166. // Default options
  2167. options.pickerWidth = options.pickerWidth || "640px";
  2168. options.pickerHeight = options.pickerHeight || "400px";
  2169. options.headerHeight = options.headerHeight || "35px";
  2170. options.lastColor = options.lastColor || "#000000";
  2171. options.swatchLimit = options.swatchLimit || 20;
  2172. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2173. // Window size settings
  2174. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2175. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2176. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2177. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2178. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2179. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2180. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2181. // Button Colors
  2182. var buttonColor = "#c0c0c0";
  2183. var buttonBackgroundColor = "#535353";
  2184. var buttonBackgroundHoverColor = "#414141";
  2185. var buttonBackgroundClickColor = "515151";
  2186. var buttonDisabledColor = "#555555";
  2187. var buttonDisabledBackgroundColor = "#454545";
  2188. var currentSwatchesOutlineColor = "#404040";
  2189. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2190. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2191. var iconColorDark = "#aaaaaa";
  2192. var iconColorLight = "#ffffff";
  2193. var closeIconColor;
  2194. // Button settings
  2195. var buttonFontSize;
  2196. var butEdit;
  2197. var buttonWidth;
  2198. var buttonHeight;
  2199. // Input Text Colors
  2200. var inputFieldLabels = ["R", "G", "B"];
  2201. var inputTextBackgroundColor = "#454545";
  2202. var inputTextColor = "#f0f0f0";
  2203. // This is the current color as set by either the picker or by entering a value
  2204. var currentColor;
  2205. // This int is used for naming swatches and serves as the index for calling them from the list
  2206. var swatchNumber;
  2207. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2208. var swatchDrawer;
  2209. var editSwatchMode = false;
  2210. // Color InputText fields that will be updated upon value change
  2211. var picker;
  2212. var rValInt;
  2213. var gValInt;
  2214. var bValInt;
  2215. var rValDec;
  2216. var gValDec;
  2217. var bValDec;
  2218. var hexVal;
  2219. var newSwatch;
  2220. var lastVal;
  2221. var activeField;
  2222. /**
  2223. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2224. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2225. * are will receive no update. This is to prevent the input from the user being overwritten.
  2226. */
  2227. function updateValues(value, inputField) {
  2228. activeField = inputField;
  2229. var pickedColor = value.toHexString();
  2230. newSwatch.background = pickedColor;
  2231. if (rValInt.name != activeField) {
  2232. rValInt.text = Math.floor(value.r * 255).toString();
  2233. }
  2234. if (gValInt.name != activeField) {
  2235. gValInt.text = Math.floor(value.g * 255).toString();
  2236. }
  2237. if (bValInt.name != activeField) {
  2238. bValInt.text = Math.floor(value.b * 255).toString();
  2239. }
  2240. if (rValDec.name != activeField) {
  2241. rValDec.text = value.r.toString();
  2242. }
  2243. if (gValDec.name != activeField) {
  2244. gValDec.text = value.g.toString();
  2245. }
  2246. if (bValDec.name != activeField) {
  2247. bValDec.text = value.b.toString();
  2248. }
  2249. if (hexVal.name != activeField) {
  2250. var minusPound = pickedColor.split("#");
  2251. hexVal.text = minusPound[1];
  2252. }
  2253. if (picker.name != activeField) {
  2254. picker.value = value;
  2255. }
  2256. }
  2257. // When the user enters an integer for R, G, or B we check to make sure it is a valid number and replace if not.
  2258. function updateInt(field, channel) {
  2259. var newValue = field.text;
  2260. var checkVal = /[^0-9]/g.test(newValue);
  2261. if (checkVal) {
  2262. field.text = lastVal;
  2263. return;
  2264. }
  2265. else {
  2266. if (newValue != "") {
  2267. if (Math.floor(parseInt(newValue)) < 0) {
  2268. newValue = "0";
  2269. }
  2270. else if (Math.floor(parseInt(newValue)) > 255) {
  2271. newValue = "255";
  2272. }
  2273. else if (isNaN(parseInt(newValue))) {
  2274. newValue = "0";
  2275. }
  2276. }
  2277. if (activeField == field.name) {
  2278. lastVal = newValue;
  2279. }
  2280. }
  2281. if (newValue != "") {
  2282. newValue = parseInt(newValue).toString();
  2283. field.text = newValue;
  2284. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2285. if (activeField == field.name) {
  2286. if (channel == "r") {
  2287. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2288. }
  2289. else if (channel == "g") {
  2290. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2291. }
  2292. else {
  2293. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2294. }
  2295. }
  2296. }
  2297. }
  2298. // When the user enters a float for R, G, or B we check to make sure it is a valid number and replace if not.
  2299. function updateFloat(field, channel) {
  2300. var newValue = field.text;
  2301. var checkVal = /[^0-9\.]/g.test(newValue);
  2302. if (checkVal) {
  2303. field.text = lastVal;
  2304. return;
  2305. }
  2306. else {
  2307. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2308. if (parseFloat(newValue) < 0.0) {
  2309. newValue = "0.0";
  2310. }
  2311. else if (parseFloat(newValue) > 1.0) {
  2312. newValue = "1.0";
  2313. }
  2314. else if (isNaN(parseFloat(newValue))) {
  2315. newValue = "0.0";
  2316. }
  2317. }
  2318. if (activeField == field.name) {
  2319. lastVal = newValue;
  2320. }
  2321. }
  2322. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2323. newValue = parseFloat(newValue).toString();
  2324. field.text = newValue;
  2325. }
  2326. else {
  2327. newValue = "0.0";
  2328. }
  2329. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2330. if (activeField == field.name) {
  2331. if (channel == "r") {
  2332. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2333. }
  2334. else if (channel == "g") {
  2335. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2336. }
  2337. else {
  2338. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2339. }
  2340. }
  2341. }
  2342. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2343. function deleteSwatch(index) {
  2344. if (options.savedColors) {
  2345. options.savedColors.splice(index, 1);
  2346. }
  2347. if (options.savedColors && options.savedColors.length == 0) {
  2348. setEditButtonVisibility(false);
  2349. editSwatchMode = false;
  2350. }
  2351. }
  2352. // Creates and styles an individual swatch when updateSwatches is called.
  2353. function createSwatch() {
  2354. if (options.savedColors && options.savedColors[swatchNumber]) {
  2355. if (editSwatchMode) {
  2356. var icon = "b";
  2357. }
  2358. else {
  2359. var icon = "";
  2360. }
  2361. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2362. swatch.fontFamily = "BabylonJSglyphs";
  2363. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2364. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2365. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2366. if (swatchLuminence > luminanceLimit) {
  2367. swatch.color = iconColorDark;
  2368. }
  2369. else {
  2370. swatch.color = iconColorLight;
  2371. }
  2372. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2373. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2374. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2375. swatch.background = options.savedColors[swatchNumber];
  2376. swatch.thickness = 2;
  2377. var metadata_1 = swatchNumber;
  2378. swatch.pointerDownAnimation = function () {
  2379. swatch.thickness = 4;
  2380. };
  2381. swatch.pointerUpAnimation = function () {
  2382. swatch.thickness = 3;
  2383. };
  2384. swatch.pointerEnterAnimation = function () {
  2385. swatch.thickness = 3;
  2386. };
  2387. swatch.pointerOutAnimation = function () {
  2388. swatch.thickness = 2;
  2389. };
  2390. swatch.onPointerClickObservable.add(function () {
  2391. if (!editSwatchMode) {
  2392. if (options.savedColors) {
  2393. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2394. }
  2395. }
  2396. else {
  2397. deleteSwatch(metadata_1);
  2398. updateSwatches("", butSave);
  2399. }
  2400. });
  2401. return swatch;
  2402. }
  2403. else {
  2404. return null;
  2405. }
  2406. }
  2407. // Mode switch to render button text and close symbols on swatch controls
  2408. function editSwatches(mode) {
  2409. if (mode !== undefined) {
  2410. editSwatchMode = mode;
  2411. }
  2412. if (editSwatchMode) {
  2413. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2414. var thisButton = swatchDrawer.children[i];
  2415. thisButton.textBlock.text = "b";
  2416. }
  2417. if (butEdit !== undefined) {
  2418. butEdit.textBlock.text = "Done";
  2419. }
  2420. }
  2421. else {
  2422. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2423. var thisButton = swatchDrawer.children[i];
  2424. thisButton.textBlock.text = "";
  2425. }
  2426. if (butEdit !== undefined) {
  2427. butEdit.textBlock.text = "Edit";
  2428. }
  2429. }
  2430. }
  2431. /**
  2432. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2433. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2434. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2435. * saved colors there are and how many can be stored per row.
  2436. */
  2437. function updateSwatches(color, button) {
  2438. if (options.savedColors) {
  2439. if (color != "") {
  2440. options.savedColors.push(color);
  2441. }
  2442. swatchNumber = 0;
  2443. swatchDrawer.clearControls();
  2444. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2445. if (rowCount == 0) {
  2446. var gutterCount = 0;
  2447. }
  2448. else {
  2449. var gutterCount = rowCount + 1;
  2450. }
  2451. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2452. var currentRows = swatchDrawer.rowCount;
  2453. for (var i = 0; i < currentRows; i++) {
  2454. swatchDrawer.removeRowDefinition(0);
  2455. }
  2456. for (var i = 0; i < rowCount + gutterCount; i++) {
  2457. if (i % 2) {
  2458. swatchDrawer.addRowDefinition(swatchSize, true);
  2459. }
  2460. else {
  2461. swatchDrawer.addRowDefinition(gutterSize, true);
  2462. }
  2463. }
  2464. }
  2465. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2466. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2467. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2468. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2469. var totalButtonsThisRow = options.numSwatchesPerLine;
  2470. }
  2471. else {
  2472. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2473. }
  2474. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2475. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2476. if (x > options.numSwatchesPerLine) {
  2477. continue;
  2478. }
  2479. var swatch = createSwatch();
  2480. if (swatch != null) {
  2481. swatchDrawer.addControl(swatch, y, w);
  2482. w += 2;
  2483. swatchNumber++;
  2484. }
  2485. else {
  2486. continue;
  2487. }
  2488. }
  2489. }
  2490. if (options.savedColors.length >= options.swatchLimit) {
  2491. disableButton(button, true);
  2492. }
  2493. else {
  2494. disableButton(button, false);
  2495. }
  2496. }
  2497. }
  2498. // Shows or hides edit swatches button depending on if there are saved swatches
  2499. function setEditButtonVisibility(enableButton) {
  2500. if (enableButton) {
  2501. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2502. butEdit.width = buttonWidth;
  2503. butEdit.height = buttonHeight;
  2504. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2505. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2506. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2507. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2508. butEdit.thickness = 2;
  2509. butEdit.color = buttonColor;
  2510. butEdit.fontSize = buttonFontSize;
  2511. butEdit.background = buttonBackgroundColor;
  2512. butEdit.onPointerEnterObservable.add(function () {
  2513. butEdit.background = buttonBackgroundHoverColor;
  2514. });
  2515. butEdit.onPointerOutObservable.add(function () {
  2516. butEdit.background = buttonBackgroundColor;
  2517. });
  2518. butEdit.pointerDownAnimation = function () {
  2519. butEdit.background = buttonBackgroundClickColor;
  2520. };
  2521. butEdit.pointerUpAnimation = function () {
  2522. butEdit.background = buttonBackgroundHoverColor;
  2523. };
  2524. butEdit.onPointerClickObservable.add(function () {
  2525. if (editSwatchMode) {
  2526. editSwatchMode = false;
  2527. }
  2528. else {
  2529. editSwatchMode = true;
  2530. }
  2531. editSwatches();
  2532. });
  2533. pickerGrid.addControl(butEdit, 1, 0);
  2534. }
  2535. else {
  2536. pickerGrid.removeControl(butEdit);
  2537. }
  2538. }
  2539. // Called when the user hits the limit of saved colors in the drawer.
  2540. function disableButton(button, disabled) {
  2541. if (disabled) {
  2542. button.color = buttonDisabledColor;
  2543. button.background = buttonDisabledBackgroundColor;
  2544. }
  2545. else {
  2546. button.color = buttonColor;
  2547. button.background = buttonBackgroundColor;
  2548. }
  2549. }
  2550. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2551. function closePicker(color) {
  2552. if (options.savedColors && options.savedColors.length > 0) {
  2553. resolve({
  2554. savedColors: options.savedColors,
  2555. pickedColor: color
  2556. });
  2557. }
  2558. else {
  2559. resolve({
  2560. pickedColor: color
  2561. });
  2562. }
  2563. advancedTexture.removeControl(dialogContainer);
  2564. }
  2565. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2566. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2567. dialogContainer.name = "Dialog Container";
  2568. dialogContainer.width = options.pickerWidth;
  2569. if (options.savedColors) {
  2570. dialogContainer.height = containerSize;
  2571. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2572. dialogContainer.addRowDefinition(topRow, false);
  2573. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2574. }
  2575. else {
  2576. dialogContainer.height = options.pickerHeight;
  2577. dialogContainer.addRowDefinition(1.0, false);
  2578. }
  2579. advancedTexture.addControl(dialogContainer);
  2580. // Swatch drawer which contains all saved color buttons
  2581. if (options.savedColors) {
  2582. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2583. swatchDrawer.name = "Swatch Drawer";
  2584. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2585. swatchDrawer.background = buttonBackgroundColor;
  2586. swatchDrawer.width = options.pickerWidth;
  2587. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2588. if (initialRows == 0) {
  2589. var gutterCount = 0;
  2590. }
  2591. else {
  2592. var gutterCount = initialRows + 1;
  2593. }
  2594. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2595. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2596. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2597. if (i % 2 != 0) {
  2598. swatchDrawer.addRowDefinition(swatchSize, true);
  2599. }
  2600. else {
  2601. swatchDrawer.addRowDefinition(gutterSize, true);
  2602. }
  2603. }
  2604. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2605. if (i % 2 != 0) {
  2606. swatchDrawer.addColumnDefinition(swatchSize, true);
  2607. }
  2608. else {
  2609. swatchDrawer.addColumnDefinition(gutterSize, true);
  2610. }
  2611. }
  2612. dialogContainer.addControl(swatchDrawer, 1, 0);
  2613. }
  2614. // Picker container
  2615. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2616. pickerPanel.name = "Picker Panel";
  2617. pickerPanel.height = options.pickerHeight;
  2618. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2619. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2620. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2621. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2622. dialogContainer.addControl(pickerPanel, 0, 0);
  2623. // Picker container header
  2624. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2625. header.name = "Dialogue Header Bar";
  2626. header.background = "#cccccc";
  2627. header.thickness = 0;
  2628. pickerPanel.addControl(header, 0, 0);
  2629. // Header close button
  2630. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2631. closeButton.fontFamily = "BabylonJSglyphs";
  2632. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2633. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2634. closeButton.color = closeIconColor.toHexString();
  2635. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2636. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2637. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2638. closeButton.height = closeButton.width = options.headerHeight;
  2639. closeButton.background = header.background;
  2640. closeButton.thickness = 0;
  2641. closeButton.pointerDownAnimation = function () {
  2642. };
  2643. closeButton.pointerUpAnimation = function () {
  2644. closeButton.background = header.background;
  2645. };
  2646. closeButton.pointerEnterAnimation = function () {
  2647. closeButton.color = header.background;
  2648. closeButton.background = "red";
  2649. };
  2650. closeButton.pointerOutAnimation = function () {
  2651. closeButton.color = closeIconColor.toHexString();
  2652. closeButton.background = header.background;
  2653. };
  2654. closeButton.onPointerClickObservable.add(function () {
  2655. closePicker(currentSwatch.background);
  2656. });
  2657. pickerPanel.addControl(closeButton, 0, 0);
  2658. // Dialog container body
  2659. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2660. dialogBody.name = "Dialogue Body";
  2661. dialogBody.background = buttonBackgroundColor;
  2662. var dialogBodyCols = [0.4375, 0.5625];
  2663. dialogBody.addRowDefinition(1.0, false);
  2664. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2665. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2666. pickerPanel.addControl(dialogBody, 1, 0);
  2667. // Picker grid
  2668. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2669. pickerGrid.name = "Picker Grid";
  2670. pickerGrid.addRowDefinition(0.85, false);
  2671. pickerGrid.addRowDefinition(0.15, false);
  2672. dialogBody.addControl(pickerGrid, 0, 0);
  2673. // Picker control
  2674. picker = new ColorPicker();
  2675. picker.name = "GUI Color Picker";
  2676. if (options.pickerHeight < options.pickerWidth) {
  2677. picker.width = 0.89;
  2678. }
  2679. else {
  2680. picker.height = 0.89;
  2681. }
  2682. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2683. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2684. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2685. picker.onPointerDownObservable.add(function () {
  2686. activeField = picker.name;
  2687. lastVal = "";
  2688. editSwatches(false);
  2689. });
  2690. picker.onValueChangedObservable.add(function (value) {
  2691. if (activeField == picker.name) {
  2692. updateValues(value, picker.name);
  2693. }
  2694. });
  2695. pickerGrid.addControl(picker, 0, 0);
  2696. // Picker body right quarant
  2697. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2698. pickerBodyRight.name = "Dialogue Right Half";
  2699. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2700. var pickerBodyRightRows = [0.514, 0.486];
  2701. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2702. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2703. dialogBody.addControl(pickerBodyRight, 1, 1);
  2704. // Picker container swatches and buttons
  2705. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2706. pickerSwatchesButtons.name = "Swatches and Buttons";
  2707. var pickerButtonsCol = [0.417, 0.583];
  2708. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2709. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2710. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2711. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2712. // Picker Swatches quadrant
  2713. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2714. pickerSwatches.name = "New and Current Swatches";
  2715. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2716. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2717. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2718. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2719. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2720. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2721. // Active swatches
  2722. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2723. activeSwatches.name = "Active Swatches";
  2724. activeSwatches.width = 0.67;
  2725. activeSwatches.addRowDefinition(0.5, false);
  2726. activeSwatches.addRowDefinition(0.5, false);
  2727. pickerSwatches.addControl(activeSwatches, 2, 0);
  2728. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2729. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2730. if (options.pickerWidth > options.pickerHeight) {
  2731. var labelTextSize = labelHeight;
  2732. }
  2733. else {
  2734. var labelTextSize = labelWidth;
  2735. }
  2736. // New color swatch and previous color button
  2737. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2738. newText.text = "new";
  2739. newText.name = "New Color Label";
  2740. newText.color = buttonColor;
  2741. newText.fontSize = labelTextSize;
  2742. pickerSwatches.addControl(newText, 1, 0);
  2743. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2744. newSwatch.name = "New Color Swatch";
  2745. newSwatch.background = options.lastColor;
  2746. newSwatch.thickness = 0;
  2747. activeSwatches.addControl(newSwatch, 0, 0);
  2748. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2749. currentSwatch.background = options.lastColor;
  2750. currentSwatch.thickness = 0;
  2751. currentSwatch.onPointerClickObservable.add(function () {
  2752. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2753. updateValues(revertColor, currentSwatch.name);
  2754. editSwatches(false);
  2755. });
  2756. currentSwatch.pointerDownAnimation = function () { };
  2757. currentSwatch.pointerUpAnimation = function () { };
  2758. currentSwatch.pointerEnterAnimation = function () { };
  2759. currentSwatch.pointerOutAnimation = function () { };
  2760. activeSwatches.addControl(currentSwatch, 1, 0);
  2761. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2762. swatchOutline.name = "Swatch Outline";
  2763. swatchOutline.width = 0.67;
  2764. swatchOutline.thickness = 2;
  2765. swatchOutline.color = currentSwatchesOutlineColor;
  2766. swatchOutline.isHitTestVisible = false;
  2767. pickerSwatches.addControl(swatchOutline, 2, 0);
  2768. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2769. currentText.name = "Current Color Label";
  2770. currentText.text = "current";
  2771. currentText.color = buttonColor;
  2772. currentText.fontSize = labelTextSize;
  2773. pickerSwatches.addControl(currentText, 3, 0);
  2774. // Buttons grid
  2775. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2776. buttonGrid.name = "Button Grid";
  2777. buttonGrid.height = 0.8;
  2778. var buttonGridRows = 1 / 3;
  2779. buttonGrid.addRowDefinition(buttonGridRows, false);
  2780. buttonGrid.addRowDefinition(buttonGridRows, false);
  2781. buttonGrid.addRowDefinition(buttonGridRows, false);
  2782. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2783. // Determine pixel width and height for all buttons from overall panel dimensions
  2784. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2785. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2786. // Determine button type size
  2787. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2788. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2789. }
  2790. else {
  2791. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2792. }
  2793. // Panel Buttons
  2794. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2795. butOK.width = buttonWidth;
  2796. butOK.height = buttonHeight;
  2797. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2798. butOK.thickness = 2;
  2799. butOK.color = buttonColor;
  2800. butOK.fontSize = buttonFontSize;
  2801. butOK.background = buttonBackgroundColor;
  2802. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2803. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2804. butOK.pointerDownAnimation = function () {
  2805. butOK.background = buttonBackgroundClickColor;
  2806. };
  2807. butOK.pointerUpAnimation = function () {
  2808. butOK.background = buttonBackgroundHoverColor;
  2809. };
  2810. butOK.onPointerClickObservable.add(function () {
  2811. editSwatches(false);
  2812. closePicker(newSwatch.background);
  2813. });
  2814. buttonGrid.addControl(butOK, 0, 0);
  2815. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2816. butCancel.width = buttonWidth;
  2817. butCancel.height = buttonHeight;
  2818. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2819. butCancel.thickness = 2;
  2820. butCancel.color = buttonColor;
  2821. butCancel.fontSize = buttonFontSize;
  2822. butCancel.background = buttonBackgroundColor;
  2823. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2824. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2825. butCancel.pointerDownAnimation = function () {
  2826. butCancel.background = buttonBackgroundClickColor;
  2827. };
  2828. butCancel.pointerUpAnimation = function () {
  2829. butCancel.background = buttonBackgroundHoverColor;
  2830. };
  2831. butCancel.onPointerClickObservable.add(function () {
  2832. editSwatches(false);
  2833. closePicker(currentSwatch.background);
  2834. });
  2835. buttonGrid.addControl(butCancel, 1, 0);
  2836. if (options.savedColors) {
  2837. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2838. butSave.width = buttonWidth;
  2839. butSave.height = buttonHeight;
  2840. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2841. butSave.thickness = 2;
  2842. butSave.fontSize = buttonFontSize;
  2843. if (options.savedColors.length < options.swatchLimit) {
  2844. butSave.color = buttonColor;
  2845. butSave.background = buttonBackgroundColor;
  2846. }
  2847. else {
  2848. disableButton(butSave, true);
  2849. }
  2850. butSave.onPointerEnterObservable.add(function () {
  2851. if (options.savedColors) {
  2852. if (options.savedColors.length < options.swatchLimit) {
  2853. butSave.background = buttonBackgroundHoverColor;
  2854. }
  2855. }
  2856. });
  2857. butSave.onPointerOutObservable.add(function () {
  2858. if (options.savedColors) {
  2859. if (options.savedColors.length < options.swatchLimit) {
  2860. butSave.background = buttonBackgroundColor;
  2861. }
  2862. }
  2863. });
  2864. butSave.pointerDownAnimation = function () {
  2865. if (options.savedColors) {
  2866. if (options.savedColors.length < options.swatchLimit) {
  2867. butSave.background = buttonBackgroundClickColor;
  2868. }
  2869. }
  2870. };
  2871. butSave.pointerUpAnimation = function () {
  2872. if (options.savedColors) {
  2873. if (options.savedColors.length < options.swatchLimit) {
  2874. butSave.background = buttonBackgroundHoverColor;
  2875. }
  2876. }
  2877. };
  2878. butSave.onPointerClickObservable.add(function () {
  2879. if (options.savedColors) {
  2880. if (options.savedColors.length == 0) {
  2881. setEditButtonVisibility(true);
  2882. }
  2883. if (options.savedColors.length < options.swatchLimit) {
  2884. updateSwatches(newSwatch.background, butSave);
  2885. }
  2886. editSwatches(false);
  2887. }
  2888. });
  2889. if (options.savedColors.length > 0) {
  2890. setEditButtonVisibility(true);
  2891. }
  2892. buttonGrid.addControl(butSave, 2, 0);
  2893. }
  2894. // Picker color values input
  2895. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2896. pickerColorValues.name = "Dialog Lower Right";
  2897. pickerColorValues.addRowDefinition(0.02, false);
  2898. pickerColorValues.addRowDefinition(0.63, false);
  2899. pickerColorValues.addRowDefinition(0.21, false);
  2900. pickerColorValues.addRowDefinition(0.14, false);
  2901. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2902. // RGB values text boxes
  2903. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2904. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2905. rgbValuesQuadrant.name = "RGB Values";
  2906. rgbValuesQuadrant.width = 0.82;
  2907. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2908. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2909. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2910. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2911. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2912. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2913. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2914. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2915. for (var i = 0; i < inputFieldLabels.length; i++) {
  2916. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2917. labelText.text = inputFieldLabels[i];
  2918. labelText.color = buttonColor;
  2919. labelText.fontSize = buttonFontSize;
  2920. rgbValuesQuadrant.addControl(labelText, i, 0);
  2921. }
  2922. // Input fields for RGB values
  2923. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2924. rValInt.width = 0.83;
  2925. rValInt.height = 0.72;
  2926. rValInt.name = "rIntField";
  2927. rValInt.fontSize = buttonFontSize;
  2928. rValInt.text = (currentColor.r * 255).toString();
  2929. rValInt.color = inputTextColor;
  2930. rValInt.background = inputTextBackgroundColor;
  2931. rValInt.onFocusObservable.add(function () {
  2932. activeField = rValInt.name;
  2933. lastVal = rValInt.text;
  2934. editSwatches(false);
  2935. });
  2936. rValInt.onBlurObservable.add(function () {
  2937. if (rValInt.text == "") {
  2938. rValInt.text = "0";
  2939. }
  2940. updateInt(rValInt, "r");
  2941. if (activeField == rValInt.name) {
  2942. activeField = "";
  2943. }
  2944. });
  2945. rValInt.onTextChangedObservable.add(function () {
  2946. if (activeField == rValInt.name) {
  2947. updateInt(rValInt, "r");
  2948. }
  2949. });
  2950. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2951. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2952. gValInt.width = 0.83;
  2953. gValInt.height = 0.72;
  2954. gValInt.name = "gIntField";
  2955. gValInt.fontSize = buttonFontSize;
  2956. gValInt.text = (currentColor.g * 255).toString();
  2957. gValInt.color = inputTextColor;
  2958. gValInt.background = inputTextBackgroundColor;
  2959. gValInt.onFocusObservable.add(function () {
  2960. activeField = gValInt.name;
  2961. lastVal = gValInt.text;
  2962. editSwatches(false);
  2963. });
  2964. gValInt.onBlurObservable.add(function () {
  2965. if (gValInt.text == "") {
  2966. gValInt.text = "0";
  2967. }
  2968. updateInt(gValInt, "g");
  2969. if (activeField == gValInt.name) {
  2970. activeField = "";
  2971. }
  2972. });
  2973. gValInt.onTextChangedObservable.add(function () {
  2974. if (activeField == gValInt.name) {
  2975. updateInt(gValInt, "g");
  2976. }
  2977. });
  2978. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2979. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2980. bValInt.width = 0.83;
  2981. bValInt.height = 0.72;
  2982. bValInt.name = "bIntField";
  2983. bValInt.fontSize = buttonFontSize;
  2984. bValInt.text = (currentColor.b * 255).toString();
  2985. bValInt.color = inputTextColor;
  2986. bValInt.background = inputTextBackgroundColor;
  2987. bValInt.onFocusObservable.add(function () {
  2988. activeField = bValInt.name;
  2989. lastVal = bValInt.text;
  2990. editSwatches(false);
  2991. });
  2992. bValInt.onBlurObservable.add(function () {
  2993. if (bValInt.text == "") {
  2994. bValInt.text = "0";
  2995. }
  2996. updateInt(bValInt, "b");
  2997. if (activeField == bValInt.name) {
  2998. activeField = "";
  2999. }
  3000. });
  3001. bValInt.onTextChangedObservable.add(function () {
  3002. if (activeField == bValInt.name) {
  3003. updateInt(bValInt, "b");
  3004. }
  3005. });
  3006. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3007. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3008. rValDec.width = 0.95;
  3009. rValDec.height = 0.72;
  3010. rValDec.name = "rDecField";
  3011. rValDec.fontSize = buttonFontSize;
  3012. rValDec.text = currentColor.r.toString();
  3013. rValDec.color = inputTextColor;
  3014. rValDec.background = inputTextBackgroundColor;
  3015. rValDec.onFocusObservable.add(function () {
  3016. activeField = rValDec.name;
  3017. lastVal = rValDec.text;
  3018. editSwatches(false);
  3019. });
  3020. rValDec.onBlurObservable.add(function () {
  3021. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3022. rValDec.text = "0";
  3023. updateFloat(rValDec, "r");
  3024. }
  3025. if (activeField == rValDec.name) {
  3026. activeField = "";
  3027. }
  3028. });
  3029. rValDec.onTextChangedObservable.add(function () {
  3030. if (activeField == rValDec.name) {
  3031. updateFloat(rValDec, "r");
  3032. }
  3033. });
  3034. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3035. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3036. gValDec.width = 0.95;
  3037. gValDec.height = 0.72;
  3038. gValDec.name = "gDecField";
  3039. gValDec.fontSize = buttonFontSize;
  3040. gValDec.text = currentColor.g.toString();
  3041. gValDec.color = inputTextColor;
  3042. gValDec.background = inputTextBackgroundColor;
  3043. gValDec.onFocusObservable.add(function () {
  3044. activeField = gValDec.name;
  3045. lastVal = gValDec.text;
  3046. editSwatches(false);
  3047. });
  3048. gValDec.onBlurObservable.add(function () {
  3049. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3050. gValDec.text = "0";
  3051. updateFloat(gValDec, "g");
  3052. }
  3053. if (activeField == gValDec.name) {
  3054. activeField = "";
  3055. }
  3056. });
  3057. gValDec.onTextChangedObservable.add(function () {
  3058. if (activeField == gValDec.name) {
  3059. updateFloat(gValDec, "g");
  3060. }
  3061. });
  3062. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3063. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3064. bValDec.width = 0.95;
  3065. bValDec.height = 0.72;
  3066. bValDec.name = "bDecField";
  3067. bValDec.fontSize = buttonFontSize;
  3068. bValDec.text = currentColor.b.toString();
  3069. bValDec.color = inputTextColor;
  3070. bValDec.background = inputTextBackgroundColor;
  3071. bValDec.onFocusObservable.add(function () {
  3072. activeField = bValDec.name;
  3073. lastVal = bValDec.text;
  3074. editSwatches(false);
  3075. });
  3076. bValDec.onBlurObservable.add(function () {
  3077. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3078. bValDec.text = "0";
  3079. updateFloat(bValDec, "b");
  3080. }
  3081. if (activeField == bValDec.name) {
  3082. activeField = "";
  3083. }
  3084. });
  3085. bValDec.onTextChangedObservable.add(function () {
  3086. if (activeField == bValDec.name) {
  3087. updateFloat(bValDec, "b");
  3088. }
  3089. });
  3090. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3091. // Hex value input
  3092. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3093. hexValueQuadrant.name = "Hex Value";
  3094. hexValueQuadrant.width = 0.82;
  3095. hexValueQuadrant.addRowDefinition(1.0, false);
  3096. hexValueQuadrant.addColumnDefinition(0.1, false);
  3097. hexValueQuadrant.addColumnDefinition(0.9, false);
  3098. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3099. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3100. labelText.text = "#";
  3101. labelText.color = buttonColor;
  3102. labelText.fontSize = buttonFontSize;
  3103. hexValueQuadrant.addControl(labelText, 0, 0);
  3104. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3105. hexVal.width = 0.96;
  3106. hexVal.height = 0.72;
  3107. hexVal.name = "hexField";
  3108. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3109. hexVal.fontSize = buttonFontSize;
  3110. var minusPound = options.lastColor.split("#");
  3111. hexVal.text = minusPound[1];
  3112. hexVal.color = inputTextColor;
  3113. hexVal.background = inputTextBackgroundColor;
  3114. hexVal.onFocusObservable.add(function () {
  3115. activeField = hexVal.name;
  3116. lastVal = hexVal.text;
  3117. editSwatches(false);
  3118. });
  3119. hexVal.onBlurObservable.add(function () {
  3120. if (hexVal.text.length == 3) {
  3121. var val = hexVal.text.split("");
  3122. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3123. }
  3124. if (hexVal.text == "") {
  3125. hexVal.text = "000000";
  3126. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3127. }
  3128. if (activeField == hexVal.name) {
  3129. activeField = "";
  3130. }
  3131. });
  3132. hexVal.onTextChangedObservable.add(function () {
  3133. var newHexValue = hexVal.text;
  3134. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3135. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3136. hexVal.text = lastVal;
  3137. }
  3138. else {
  3139. if (hexVal.text.length < 6) {
  3140. var leadingZero = 6 - hexVal.text.length;
  3141. for (var i = 0; i < leadingZero; i++) {
  3142. newHexValue = "0" + newHexValue;
  3143. }
  3144. }
  3145. if (hexVal.text.length == 3) {
  3146. var val = hexVal.text.split("");
  3147. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3148. }
  3149. newHexValue = "#" + newHexValue;
  3150. if (activeField == hexVal.name) {
  3151. lastVal = hexVal.text;
  3152. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3153. }
  3154. }
  3155. });
  3156. hexValueQuadrant.addControl(hexVal, 0, 1);
  3157. if (options.savedColors && options.savedColors.length > 0) {
  3158. updateSwatches("", butSave);
  3159. }
  3160. });
  3161. };
  3162. ColorPicker._Epsilon = 0.000001;
  3163. return ColorPicker;
  3164. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3165. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3166. /***/ }),
  3167. /***/ "./2D/controls/container.ts":
  3168. /*!**********************************!*\
  3169. !*** ./2D/controls/container.ts ***!
  3170. \**********************************/
  3171. /*! exports provided: Container */
  3172. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3173. "use strict";
  3174. __webpack_require__.r(__webpack_exports__);
  3175. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3176. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3177. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Maths/math.vector");
  3178. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3179. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3180. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3181. /**
  3182. * Root class for 2D containers
  3183. * @see http://doc.babylonjs.com/how_to/gui#containers
  3184. */
  3185. var Container = /** @class */ (function (_super) {
  3186. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3187. /**
  3188. * Creates a new Container
  3189. * @param name defines the name of the container
  3190. */
  3191. function Container(name) {
  3192. var _this = _super.call(this, name) || this;
  3193. _this.name = name;
  3194. /** @hidden */
  3195. _this._children = new Array();
  3196. /** @hidden */
  3197. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3198. /** @hidden */
  3199. _this._background = "";
  3200. /** @hidden */
  3201. _this._adaptWidthToChildren = false;
  3202. /** @hidden */
  3203. _this._adaptHeightToChildren = false;
  3204. /**
  3205. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3206. */
  3207. _this.logLayoutCycleErrors = false;
  3208. /**
  3209. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3210. */
  3211. _this.maxLayoutCycle = 3;
  3212. return _this;
  3213. }
  3214. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3215. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3216. get: function () {
  3217. return this._adaptHeightToChildren;
  3218. },
  3219. set: function (value) {
  3220. if (this._adaptHeightToChildren === value) {
  3221. return;
  3222. }
  3223. this._adaptHeightToChildren = value;
  3224. if (value) {
  3225. this.height = "100%";
  3226. }
  3227. this._markAsDirty();
  3228. },
  3229. enumerable: true,
  3230. configurable: true
  3231. });
  3232. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3233. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3234. get: function () {
  3235. return this._adaptWidthToChildren;
  3236. },
  3237. set: function (value) {
  3238. if (this._adaptWidthToChildren === value) {
  3239. return;
  3240. }
  3241. this._adaptWidthToChildren = value;
  3242. if (value) {
  3243. this.width = "100%";
  3244. }
  3245. this._markAsDirty();
  3246. },
  3247. enumerable: true,
  3248. configurable: true
  3249. });
  3250. Object.defineProperty(Container.prototype, "background", {
  3251. /** Gets or sets background color */
  3252. get: function () {
  3253. return this._background;
  3254. },
  3255. set: function (value) {
  3256. if (this._background === value) {
  3257. return;
  3258. }
  3259. this._background = value;
  3260. this._markAsDirty();
  3261. },
  3262. enumerable: true,
  3263. configurable: true
  3264. });
  3265. Object.defineProperty(Container.prototype, "children", {
  3266. /** Gets the list of children */
  3267. get: function () {
  3268. return this._children;
  3269. },
  3270. enumerable: true,
  3271. configurable: true
  3272. });
  3273. Container.prototype._getTypeName = function () {
  3274. return "Container";
  3275. };
  3276. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3277. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3278. var child = _a[_i];
  3279. child._markMatrixAsDirty();
  3280. }
  3281. };
  3282. /**
  3283. * Gets a child using its name
  3284. * @param name defines the child name to look for
  3285. * @returns the child control if found
  3286. */
  3287. Container.prototype.getChildByName = function (name) {
  3288. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3289. var child = _a[_i];
  3290. if (child.name === name) {
  3291. return child;
  3292. }
  3293. }
  3294. return null;
  3295. };
  3296. /**
  3297. * Gets a child using its type and its name
  3298. * @param name defines the child name to look for
  3299. * @param type defines the child type to look for
  3300. * @returns the child control if found
  3301. */
  3302. Container.prototype.getChildByType = function (name, type) {
  3303. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3304. var child = _a[_i];
  3305. if (child.typeName === type) {
  3306. return child;
  3307. }
  3308. }
  3309. return null;
  3310. };
  3311. /**
  3312. * Search for a specific control in children
  3313. * @param control defines the control to look for
  3314. * @returns true if the control is in child list
  3315. */
  3316. Container.prototype.containsControl = function (control) {
  3317. return this.children.indexOf(control) !== -1;
  3318. };
  3319. /**
  3320. * Adds a new control to the current container
  3321. * @param control defines the control to add
  3322. * @returns the current container
  3323. */
  3324. Container.prototype.addControl = function (control) {
  3325. if (!control) {
  3326. return this;
  3327. }
  3328. var index = this._children.indexOf(control);
  3329. if (index !== -1) {
  3330. return this;
  3331. }
  3332. control._link(this._host);
  3333. control._markAllAsDirty();
  3334. this._reOrderControl(control);
  3335. this._markAsDirty();
  3336. return this;
  3337. };
  3338. /**
  3339. * Removes all controls from the current container
  3340. * @returns the current container
  3341. */
  3342. Container.prototype.clearControls = function () {
  3343. var children = this.children.slice();
  3344. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3345. var child = children_1[_i];
  3346. this.removeControl(child);
  3347. }
  3348. return this;
  3349. };
  3350. /**
  3351. * Removes a control from the current container
  3352. * @param control defines the control to remove
  3353. * @returns the current container
  3354. */
  3355. Container.prototype.removeControl = function (control) {
  3356. var index = this._children.indexOf(control);
  3357. if (index !== -1) {
  3358. this._children.splice(index, 1);
  3359. control.parent = null;
  3360. }
  3361. control.linkWithMesh(null);
  3362. if (this._host) {
  3363. this._host._cleanControlAfterRemoval(control);
  3364. }
  3365. this._markAsDirty();
  3366. return this;
  3367. };
  3368. /** @hidden */
  3369. Container.prototype._reOrderControl = function (control) {
  3370. this.removeControl(control);
  3371. var wasAdded = false;
  3372. for (var index = 0; index < this._children.length; index++) {
  3373. if (this._children[index].zIndex > control.zIndex) {
  3374. this._children.splice(index, 0, control);
  3375. wasAdded = true;
  3376. break;
  3377. }
  3378. }
  3379. if (!wasAdded) {
  3380. this._children.push(control);
  3381. }
  3382. control.parent = this;
  3383. this._markAsDirty();
  3384. };
  3385. /** @hidden */
  3386. Container.prototype._offsetLeft = function (offset) {
  3387. _super.prototype._offsetLeft.call(this, offset);
  3388. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3389. var child = _a[_i];
  3390. child._offsetLeft(offset);
  3391. }
  3392. };
  3393. /** @hidden */
  3394. Container.prototype._offsetTop = function (offset) {
  3395. _super.prototype._offsetTop.call(this, offset);
  3396. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3397. var child = _a[_i];
  3398. child._offsetTop(offset);
  3399. }
  3400. };
  3401. /** @hidden */
  3402. Container.prototype._markAllAsDirty = function () {
  3403. _super.prototype._markAllAsDirty.call(this);
  3404. for (var index = 0; index < this._children.length; index++) {
  3405. this._children[index]._markAllAsDirty();
  3406. }
  3407. };
  3408. /** @hidden */
  3409. Container.prototype._localDraw = function (context) {
  3410. if (this._background) {
  3411. context.save();
  3412. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3413. context.shadowColor = this.shadowColor;
  3414. context.shadowBlur = this.shadowBlur;
  3415. context.shadowOffsetX = this.shadowOffsetX;
  3416. context.shadowOffsetY = this.shadowOffsetY;
  3417. }
  3418. context.fillStyle = this._background;
  3419. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3420. context.restore();
  3421. }
  3422. };
  3423. /** @hidden */
  3424. Container.prototype._link = function (host) {
  3425. _super.prototype._link.call(this, host);
  3426. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3427. var child = _a[_i];
  3428. child._link(host);
  3429. }
  3430. };
  3431. /** @hidden */
  3432. Container.prototype._beforeLayout = function () {
  3433. // Do nothing
  3434. };
  3435. /** @hidden */
  3436. Container.prototype._processMeasures = function (parentMeasure, context) {
  3437. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3438. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3439. this._evaluateClippingState(parentMeasure);
  3440. }
  3441. };
  3442. /** @hidden */
  3443. Container.prototype._layout = function (parentMeasure, context) {
  3444. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3445. return false;
  3446. }
  3447. this.host._numLayoutCalls++;
  3448. if (this._isDirty) {
  3449. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3450. }
  3451. var rebuildCount = 0;
  3452. context.save();
  3453. this._applyStates(context);
  3454. this._beforeLayout();
  3455. do {
  3456. var computedWidth = -1;
  3457. var computedHeight = -1;
  3458. this._rebuildLayout = false;
  3459. this._processMeasures(parentMeasure, context);
  3460. if (!this._isClipped) {
  3461. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3462. var child = _a[_i];
  3463. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3464. if (child._layout(this._measureForChildren, context)) {
  3465. if (this.adaptWidthToChildren && child._width.isPixel) {
  3466. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3467. }
  3468. if (this.adaptHeightToChildren && child._height.isPixel) {
  3469. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3470. }
  3471. }
  3472. }
  3473. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3474. if (this.width !== computedWidth + "px") {
  3475. this.width = computedWidth + "px";
  3476. this._rebuildLayout = true;
  3477. }
  3478. }
  3479. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3480. if (this.height !== computedHeight + "px") {
  3481. this.height = computedHeight + "px";
  3482. this._rebuildLayout = true;
  3483. }
  3484. }
  3485. this._postMeasure();
  3486. }
  3487. rebuildCount++;
  3488. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3489. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3490. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3491. }
  3492. context.restore();
  3493. if (this._isDirty) {
  3494. this.invalidateRect();
  3495. this._isDirty = false;
  3496. }
  3497. return true;
  3498. };
  3499. Container.prototype._postMeasure = function () {
  3500. // Do nothing by default
  3501. };
  3502. /** @hidden */
  3503. Container.prototype._draw = function (context, invalidatedRectangle) {
  3504. this._localDraw(context);
  3505. if (this.clipChildren) {
  3506. this._clipForChildren(context);
  3507. }
  3508. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3509. var child = _a[_i];
  3510. // Only redraw parts of the screen that are invalidated
  3511. if (invalidatedRectangle) {
  3512. if (!child._intersectsRect(invalidatedRectangle)) {
  3513. continue;
  3514. }
  3515. }
  3516. child._render(context, invalidatedRectangle);
  3517. }
  3518. };
  3519. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3520. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3521. if (!this.children) {
  3522. return;
  3523. }
  3524. for (var index = 0; index < this.children.length; index++) {
  3525. var item = this.children[index];
  3526. if (!predicate || predicate(item)) {
  3527. results.push(item);
  3528. }
  3529. if (!directDescendantsOnly) {
  3530. item.getDescendantsToRef(results, false, predicate);
  3531. }
  3532. }
  3533. };
  3534. /** @hidden */
  3535. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  3536. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3537. return false;
  3538. }
  3539. if (!_super.prototype.contains.call(this, x, y)) {
  3540. return false;
  3541. }
  3542. // Checking backwards to pick closest first
  3543. for (var index = this._children.length - 1; index >= 0; index--) {
  3544. var child = this._children[index];
  3545. if (child._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  3546. if (child.hoverCursor) {
  3547. this._host._changeCursor(child.hoverCursor);
  3548. }
  3549. return true;
  3550. }
  3551. }
  3552. if (!this.isHitTestVisible) {
  3553. return false;
  3554. }
  3555. return this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  3556. };
  3557. /** @hidden */
  3558. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3559. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3560. this._measureForChildren.copyFrom(this._currentMeasure);
  3561. };
  3562. /** Releases associated resources */
  3563. Container.prototype.dispose = function () {
  3564. _super.prototype.dispose.call(this);
  3565. for (var index = this.children.length - 1; index >= 0; index--) {
  3566. this.children[index].dispose();
  3567. }
  3568. };
  3569. return Container;
  3570. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3571. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3572. /***/ }),
  3573. /***/ "./2D/controls/control.ts":
  3574. /*!********************************!*\
  3575. !*** ./2D/controls/control.ts ***!
  3576. \********************************/
  3577. /*! exports provided: Control */
  3578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3579. "use strict";
  3580. __webpack_require__.r(__webpack_exports__);
  3581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3582. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  3583. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3584. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3585. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3586. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3587. /**
  3588. * Root class used for all 2D controls
  3589. * @see http://doc.babylonjs.com/how_to/gui#controls
  3590. */
  3591. var Control = /** @class */ (function () {
  3592. // Functions
  3593. /**
  3594. * Creates a new control
  3595. * @param name defines the name of the control
  3596. */
  3597. function Control(
  3598. /** defines the name of the control */
  3599. name) {
  3600. this.name = name;
  3601. this._alpha = 1;
  3602. this._alphaSet = false;
  3603. this._zIndex = 0;
  3604. /** @hidden */
  3605. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3606. this._fontFamily = "Arial";
  3607. this._fontStyle = "";
  3608. this._fontWeight = "";
  3609. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3610. /** @hidden */
  3611. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3612. /** @hidden */
  3613. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3614. this._color = "";
  3615. this._style = null;
  3616. /** @hidden */
  3617. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3618. /** @hidden */
  3619. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3620. /** @hidden */
  3621. this._isDirty = true;
  3622. /** @hidden */
  3623. this._wasDirty = false;
  3624. /** @hidden */
  3625. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3626. /** @hidden */
  3627. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3628. /** @hidden */
  3629. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3630. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3631. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3632. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3633. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3634. /** @hidden */
  3635. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3636. /** @hidden */
  3637. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3638. this._scaleX = 1.0;
  3639. this._scaleY = 1.0;
  3640. this._rotation = 0;
  3641. this._transformCenterX = 0.5;
  3642. this._transformCenterY = 0.5;
  3643. /** @hidden */
  3644. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3645. /** @hidden */
  3646. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3647. /** @hidden */
  3648. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3649. this._isMatrixDirty = true;
  3650. this._isVisible = true;
  3651. this._isHighlighted = false;
  3652. this._fontSet = false;
  3653. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3654. this._downCount = 0;
  3655. this._enterCount = -1;
  3656. this._doNotRender = false;
  3657. this._downPointerIds = {};
  3658. this._isEnabled = true;
  3659. this._disabledColor = "#9a9a9a";
  3660. this._disabledColorItem = "#6a6a6a";
  3661. /** @hidden */
  3662. this._rebuildLayout = false;
  3663. /** @hidden */
  3664. this._customData = {};
  3665. /** @hidden */
  3666. this._isClipped = false;
  3667. /** @hidden */
  3668. this._automaticSize = false;
  3669. /**
  3670. * Gets or sets an object used to store user defined information for the node
  3671. */
  3672. this.metadata = null;
  3673. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3674. this.isHitTestVisible = true;
  3675. /** Gets or sets a boolean indicating if the control can block pointer events */
  3676. this.isPointerBlocker = false;
  3677. /** Gets or sets a boolean indicating if the control can be focusable */
  3678. this.isFocusInvisible = false;
  3679. /**
  3680. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3681. * 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
  3682. */
  3683. this.clipChildren = true;
  3684. /**
  3685. * Gets or sets a boolean indicating that control content must be clipped
  3686. * 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
  3687. */
  3688. this.clipContent = true;
  3689. /**
  3690. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3691. */
  3692. this.useBitmapCache = false;
  3693. this._shadowOffsetX = 0;
  3694. this._shadowOffsetY = 0;
  3695. this._shadowBlur = 0;
  3696. this._shadowColor = 'black';
  3697. /** Gets or sets the cursor to use when the control is hovered */
  3698. this.hoverCursor = "";
  3699. /** @hidden */
  3700. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3701. /** @hidden */
  3702. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3703. /**
  3704. * An event triggered when pointer wheel is scrolled
  3705. */
  3706. this.onWheelObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3707. /**
  3708. * An event triggered when the pointer move over the control.
  3709. */
  3710. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3711. /**
  3712. * An event triggered when the pointer move out of the control.
  3713. */
  3714. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3715. /**
  3716. * An event triggered when the pointer taps the control
  3717. */
  3718. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3719. /**
  3720. * An event triggered when pointer up
  3721. */
  3722. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3723. /**
  3724. * An event triggered when a control is clicked on
  3725. */
  3726. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3727. /**
  3728. * An event triggered when pointer enters the control
  3729. */
  3730. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3731. /**
  3732. * An event triggered when the control is marked as dirty
  3733. */
  3734. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3735. /**
  3736. * An event triggered before drawing the control
  3737. */
  3738. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3739. /**
  3740. * An event triggered after the control was drawn
  3741. */
  3742. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3743. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3744. }
  3745. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3746. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3747. get: function () {
  3748. return this._shadowOffsetX;
  3749. },
  3750. set: function (value) {
  3751. if (this._shadowOffsetX === value) {
  3752. return;
  3753. }
  3754. this._shadowOffsetX = value;
  3755. this._markAsDirty();
  3756. },
  3757. enumerable: true,
  3758. configurable: true
  3759. });
  3760. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3761. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3762. get: function () {
  3763. return this._shadowOffsetY;
  3764. },
  3765. set: function (value) {
  3766. if (this._shadowOffsetY === value) {
  3767. return;
  3768. }
  3769. this._shadowOffsetY = value;
  3770. this._markAsDirty();
  3771. },
  3772. enumerable: true,
  3773. configurable: true
  3774. });
  3775. Object.defineProperty(Control.prototype, "shadowBlur", {
  3776. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3777. get: function () {
  3778. return this._shadowBlur;
  3779. },
  3780. set: function (value) {
  3781. if (this._shadowBlur === value) {
  3782. return;
  3783. }
  3784. this._shadowBlur = value;
  3785. this._markAsDirty();
  3786. },
  3787. enumerable: true,
  3788. configurable: true
  3789. });
  3790. Object.defineProperty(Control.prototype, "shadowColor", {
  3791. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3792. get: function () {
  3793. return this._shadowColor;
  3794. },
  3795. set: function (value) {
  3796. if (this._shadowColor === value) {
  3797. return;
  3798. }
  3799. this._shadowColor = value;
  3800. this._markAsDirty();
  3801. },
  3802. enumerable: true,
  3803. configurable: true
  3804. });
  3805. Object.defineProperty(Control.prototype, "typeName", {
  3806. // Properties
  3807. /** Gets the control type name */
  3808. get: function () {
  3809. return this._getTypeName();
  3810. },
  3811. enumerable: true,
  3812. configurable: true
  3813. });
  3814. /**
  3815. * Get the current class name of the control.
  3816. * @returns current class name
  3817. */
  3818. Control.prototype.getClassName = function () {
  3819. return this._getTypeName();
  3820. };
  3821. Object.defineProperty(Control.prototype, "host", {
  3822. /**
  3823. * Get the hosting AdvancedDynamicTexture
  3824. */
  3825. get: function () {
  3826. return this._host;
  3827. },
  3828. enumerable: true,
  3829. configurable: true
  3830. });
  3831. Object.defineProperty(Control.prototype, "fontOffset", {
  3832. /** Gets or set information about font offsets (used to render and align text) */
  3833. get: function () {
  3834. return this._fontOffset;
  3835. },
  3836. set: function (offset) {
  3837. this._fontOffset = offset;
  3838. },
  3839. enumerable: true,
  3840. configurable: true
  3841. });
  3842. Object.defineProperty(Control.prototype, "alpha", {
  3843. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3844. get: function () {
  3845. return this._alpha;
  3846. },
  3847. set: function (value) {
  3848. if (this._alpha === value) {
  3849. return;
  3850. }
  3851. this._alphaSet = true;
  3852. this._alpha = value;
  3853. this._markAsDirty();
  3854. },
  3855. enumerable: true,
  3856. configurable: true
  3857. });
  3858. Object.defineProperty(Control.prototype, "isHighlighted", {
  3859. /**
  3860. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3861. */
  3862. get: function () {
  3863. return this._isHighlighted;
  3864. },
  3865. set: function (value) {
  3866. if (this._isHighlighted === value) {
  3867. return;
  3868. }
  3869. this._isHighlighted = value;
  3870. this._markAsDirty();
  3871. },
  3872. enumerable: true,
  3873. configurable: true
  3874. });
  3875. Object.defineProperty(Control.prototype, "scaleX", {
  3876. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3877. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3878. */
  3879. get: function () {
  3880. return this._scaleX;
  3881. },
  3882. set: function (value) {
  3883. if (this._scaleX === value) {
  3884. return;
  3885. }
  3886. this._scaleX = value;
  3887. this._markAsDirty();
  3888. this._markMatrixAsDirty();
  3889. },
  3890. enumerable: true,
  3891. configurable: true
  3892. });
  3893. Object.defineProperty(Control.prototype, "scaleY", {
  3894. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3895. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3896. */
  3897. get: function () {
  3898. return this._scaleY;
  3899. },
  3900. set: function (value) {
  3901. if (this._scaleY === value) {
  3902. return;
  3903. }
  3904. this._scaleY = value;
  3905. this._markAsDirty();
  3906. this._markMatrixAsDirty();
  3907. },
  3908. enumerable: true,
  3909. configurable: true
  3910. });
  3911. Object.defineProperty(Control.prototype, "rotation", {
  3912. /** Gets or sets the rotation angle (0 by default)
  3913. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3914. */
  3915. get: function () {
  3916. return this._rotation;
  3917. },
  3918. set: function (value) {
  3919. if (this._rotation === value) {
  3920. return;
  3921. }
  3922. this._rotation = value;
  3923. this._markAsDirty();
  3924. this._markMatrixAsDirty();
  3925. },
  3926. enumerable: true,
  3927. configurable: true
  3928. });
  3929. Object.defineProperty(Control.prototype, "transformCenterY", {
  3930. /** Gets or sets the transformation center on Y axis (0 by default)
  3931. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3932. */
  3933. get: function () {
  3934. return this._transformCenterY;
  3935. },
  3936. set: function (value) {
  3937. if (this._transformCenterY === value) {
  3938. return;
  3939. }
  3940. this._transformCenterY = value;
  3941. this._markAsDirty();
  3942. this._markMatrixAsDirty();
  3943. },
  3944. enumerable: true,
  3945. configurable: true
  3946. });
  3947. Object.defineProperty(Control.prototype, "transformCenterX", {
  3948. /** Gets or sets the transformation center on X axis (0 by default)
  3949. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3950. */
  3951. get: function () {
  3952. return this._transformCenterX;
  3953. },
  3954. set: function (value) {
  3955. if (this._transformCenterX === value) {
  3956. return;
  3957. }
  3958. this._transformCenterX = value;
  3959. this._markAsDirty();
  3960. this._markMatrixAsDirty();
  3961. },
  3962. enumerable: true,
  3963. configurable: true
  3964. });
  3965. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3966. /**
  3967. * Gets or sets the horizontal alignment
  3968. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3969. */
  3970. get: function () {
  3971. return this._horizontalAlignment;
  3972. },
  3973. set: function (value) {
  3974. if (this._horizontalAlignment === value) {
  3975. return;
  3976. }
  3977. this._horizontalAlignment = value;
  3978. this._markAsDirty();
  3979. },
  3980. enumerable: true,
  3981. configurable: true
  3982. });
  3983. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3984. /**
  3985. * Gets or sets the vertical alignment
  3986. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3987. */
  3988. get: function () {
  3989. return this._verticalAlignment;
  3990. },
  3991. set: function (value) {
  3992. if (this._verticalAlignment === value) {
  3993. return;
  3994. }
  3995. this._verticalAlignment = value;
  3996. this._markAsDirty();
  3997. },
  3998. enumerable: true,
  3999. configurable: true
  4000. });
  4001. Object.defineProperty(Control.prototype, "width", {
  4002. /**
  4003. * Gets or sets control width
  4004. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4005. */
  4006. get: function () {
  4007. return this._width.toString(this._host);
  4008. },
  4009. set: function (value) {
  4010. if (this._width.toString(this._host) === value) {
  4011. return;
  4012. }
  4013. if (this._width.fromString(value)) {
  4014. this._markAsDirty();
  4015. }
  4016. },
  4017. enumerable: true,
  4018. configurable: true
  4019. });
  4020. Object.defineProperty(Control.prototype, "widthInPixels", {
  4021. /**
  4022. * Gets or sets the control width in pixel
  4023. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4024. */
  4025. get: function () {
  4026. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4027. },
  4028. set: function (value) {
  4029. if (isNaN(value)) {
  4030. return;
  4031. }
  4032. this.width = value + "px";
  4033. },
  4034. enumerable: true,
  4035. configurable: true
  4036. });
  4037. Object.defineProperty(Control.prototype, "height", {
  4038. /**
  4039. * Gets or sets control height
  4040. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4041. */
  4042. get: function () {
  4043. return this._height.toString(this._host);
  4044. },
  4045. set: function (value) {
  4046. if (this._height.toString(this._host) === value) {
  4047. return;
  4048. }
  4049. if (this._height.fromString(value)) {
  4050. this._markAsDirty();
  4051. }
  4052. },
  4053. enumerable: true,
  4054. configurable: true
  4055. });
  4056. Object.defineProperty(Control.prototype, "heightInPixels", {
  4057. /**
  4058. * Gets or sets control height in pixel
  4059. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4060. */
  4061. get: function () {
  4062. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4063. },
  4064. set: function (value) {
  4065. if (isNaN(value)) {
  4066. return;
  4067. }
  4068. this.height = value + "px";
  4069. },
  4070. enumerable: true,
  4071. configurable: true
  4072. });
  4073. Object.defineProperty(Control.prototype, "fontFamily", {
  4074. /** Gets or set font family */
  4075. get: function () {
  4076. if (!this._fontSet) {
  4077. return "";
  4078. }
  4079. return this._fontFamily;
  4080. },
  4081. set: function (value) {
  4082. if (this._fontFamily === value) {
  4083. return;
  4084. }
  4085. this._fontFamily = value;
  4086. this._resetFontCache();
  4087. },
  4088. enumerable: true,
  4089. configurable: true
  4090. });
  4091. Object.defineProperty(Control.prototype, "fontStyle", {
  4092. /** Gets or sets font style */
  4093. get: function () {
  4094. return this._fontStyle;
  4095. },
  4096. set: function (value) {
  4097. if (this._fontStyle === value) {
  4098. return;
  4099. }
  4100. this._fontStyle = value;
  4101. this._resetFontCache();
  4102. },
  4103. enumerable: true,
  4104. configurable: true
  4105. });
  4106. Object.defineProperty(Control.prototype, "fontWeight", {
  4107. /** Gets or sets font weight */
  4108. get: function () {
  4109. return this._fontWeight;
  4110. },
  4111. set: function (value) {
  4112. if (this._fontWeight === value) {
  4113. return;
  4114. }
  4115. this._fontWeight = value;
  4116. this._resetFontCache();
  4117. },
  4118. enumerable: true,
  4119. configurable: true
  4120. });
  4121. Object.defineProperty(Control.prototype, "style", {
  4122. /**
  4123. * Gets or sets style
  4124. * @see http://doc.babylonjs.com/how_to/gui#styles
  4125. */
  4126. get: function () {
  4127. return this._style;
  4128. },
  4129. set: function (value) {
  4130. var _this = this;
  4131. if (this._style) {
  4132. this._style.onChangedObservable.remove(this._styleObserver);
  4133. this._styleObserver = null;
  4134. }
  4135. this._style = value;
  4136. if (this._style) {
  4137. this._styleObserver = this._style.onChangedObservable.add(function () {
  4138. _this._markAsDirty();
  4139. _this._resetFontCache();
  4140. });
  4141. }
  4142. this._markAsDirty();
  4143. this._resetFontCache();
  4144. },
  4145. enumerable: true,
  4146. configurable: true
  4147. });
  4148. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4149. /** @hidden */
  4150. get: function () {
  4151. return this._fontSize.isPercentage;
  4152. },
  4153. enumerable: true,
  4154. configurable: true
  4155. });
  4156. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4157. /** Gets or sets font size in pixels */
  4158. get: function () {
  4159. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4160. if (fontSizeToUse.isPixel) {
  4161. return fontSizeToUse.getValue(this._host);
  4162. }
  4163. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4164. },
  4165. set: function (value) {
  4166. if (isNaN(value)) {
  4167. return;
  4168. }
  4169. this.fontSize = value + "px";
  4170. },
  4171. enumerable: true,
  4172. configurable: true
  4173. });
  4174. Object.defineProperty(Control.prototype, "fontSize", {
  4175. /** Gets or sets font size */
  4176. get: function () {
  4177. return this._fontSize.toString(this._host);
  4178. },
  4179. set: function (value) {
  4180. if (this._fontSize.toString(this._host) === value) {
  4181. return;
  4182. }
  4183. if (this._fontSize.fromString(value)) {
  4184. this._markAsDirty();
  4185. this._resetFontCache();
  4186. }
  4187. },
  4188. enumerable: true,
  4189. configurable: true
  4190. });
  4191. Object.defineProperty(Control.prototype, "color", {
  4192. /** Gets or sets foreground color */
  4193. get: function () {
  4194. return this._color;
  4195. },
  4196. set: function (value) {
  4197. if (this._color === value) {
  4198. return;
  4199. }
  4200. this._color = value;
  4201. this._markAsDirty();
  4202. },
  4203. enumerable: true,
  4204. configurable: true
  4205. });
  4206. Object.defineProperty(Control.prototype, "zIndex", {
  4207. /** Gets or sets z index which is used to reorder controls on the z axis */
  4208. get: function () {
  4209. return this._zIndex;
  4210. },
  4211. set: function (value) {
  4212. if (this.zIndex === value) {
  4213. return;
  4214. }
  4215. this._zIndex = value;
  4216. if (this.parent) {
  4217. this.parent._reOrderControl(this);
  4218. }
  4219. },
  4220. enumerable: true,
  4221. configurable: true
  4222. });
  4223. Object.defineProperty(Control.prototype, "notRenderable", {
  4224. /** Gets or sets a boolean indicating if the control can be rendered */
  4225. get: function () {
  4226. return this._doNotRender;
  4227. },
  4228. set: function (value) {
  4229. if (this._doNotRender === value) {
  4230. return;
  4231. }
  4232. this._doNotRender = value;
  4233. this._markAsDirty();
  4234. },
  4235. enumerable: true,
  4236. configurable: true
  4237. });
  4238. Object.defineProperty(Control.prototype, "isVisible", {
  4239. /** Gets or sets a boolean indicating if the control is visible */
  4240. get: function () {
  4241. return this._isVisible;
  4242. },
  4243. set: function (value) {
  4244. if (this._isVisible === value) {
  4245. return;
  4246. }
  4247. this._isVisible = value;
  4248. this._markAsDirty(true);
  4249. },
  4250. enumerable: true,
  4251. configurable: true
  4252. });
  4253. Object.defineProperty(Control.prototype, "isDirty", {
  4254. /** Gets a boolean indicating that the control needs to update its rendering */
  4255. get: function () {
  4256. return this._isDirty;
  4257. },
  4258. enumerable: true,
  4259. configurable: true
  4260. });
  4261. Object.defineProperty(Control.prototype, "linkedMesh", {
  4262. /**
  4263. * Gets the current linked mesh (or null if none)
  4264. */
  4265. get: function () {
  4266. return this._linkedMesh;
  4267. },
  4268. enumerable: true,
  4269. configurable: true
  4270. });
  4271. Object.defineProperty(Control.prototype, "paddingLeft", {
  4272. /**
  4273. * Gets or sets a value indicating the padding to use on the left of the control
  4274. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4275. */
  4276. get: function () {
  4277. return this._paddingLeft.toString(this._host);
  4278. },
  4279. set: function (value) {
  4280. if (this._paddingLeft.fromString(value)) {
  4281. this._markAsDirty();
  4282. }
  4283. },
  4284. enumerable: true,
  4285. configurable: true
  4286. });
  4287. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4288. /**
  4289. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4290. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4291. */
  4292. get: function () {
  4293. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4294. },
  4295. set: function (value) {
  4296. if (isNaN(value)) {
  4297. return;
  4298. }
  4299. this.paddingLeft = value + "px";
  4300. },
  4301. enumerable: true,
  4302. configurable: true
  4303. });
  4304. Object.defineProperty(Control.prototype, "paddingRight", {
  4305. /**
  4306. * Gets or sets a value indicating the padding to use on the right of the control
  4307. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4308. */
  4309. get: function () {
  4310. return this._paddingRight.toString(this._host);
  4311. },
  4312. set: function (value) {
  4313. if (this._paddingRight.fromString(value)) {
  4314. this._markAsDirty();
  4315. }
  4316. },
  4317. enumerable: true,
  4318. configurable: true
  4319. });
  4320. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4321. /**
  4322. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4323. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4324. */
  4325. get: function () {
  4326. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4327. },
  4328. set: function (value) {
  4329. if (isNaN(value)) {
  4330. return;
  4331. }
  4332. this.paddingRight = value + "px";
  4333. },
  4334. enumerable: true,
  4335. configurable: true
  4336. });
  4337. Object.defineProperty(Control.prototype, "paddingTop", {
  4338. /**
  4339. * Gets or sets a value indicating the padding to use on the top of the control
  4340. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4341. */
  4342. get: function () {
  4343. return this._paddingTop.toString(this._host);
  4344. },
  4345. set: function (value) {
  4346. if (this._paddingTop.fromString(value)) {
  4347. this._markAsDirty();
  4348. }
  4349. },
  4350. enumerable: true,
  4351. configurable: true
  4352. });
  4353. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4354. /**
  4355. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4356. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4357. */
  4358. get: function () {
  4359. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4360. },
  4361. set: function (value) {
  4362. if (isNaN(value)) {
  4363. return;
  4364. }
  4365. this.paddingTop = value + "px";
  4366. },
  4367. enumerable: true,
  4368. configurable: true
  4369. });
  4370. Object.defineProperty(Control.prototype, "paddingBottom", {
  4371. /**
  4372. * Gets or sets a value indicating the padding to use on the bottom of the control
  4373. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4374. */
  4375. get: function () {
  4376. return this._paddingBottom.toString(this._host);
  4377. },
  4378. set: function (value) {
  4379. if (this._paddingBottom.fromString(value)) {
  4380. this._markAsDirty();
  4381. }
  4382. },
  4383. enumerable: true,
  4384. configurable: true
  4385. });
  4386. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4387. /**
  4388. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4389. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4390. */
  4391. get: function () {
  4392. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4393. },
  4394. set: function (value) {
  4395. if (isNaN(value)) {
  4396. return;
  4397. }
  4398. this.paddingBottom = value + "px";
  4399. },
  4400. enumerable: true,
  4401. configurable: true
  4402. });
  4403. Object.defineProperty(Control.prototype, "left", {
  4404. /**
  4405. * Gets or sets a value indicating the left coordinate of the control
  4406. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4407. */
  4408. get: function () {
  4409. return this._left.toString(this._host);
  4410. },
  4411. set: function (value) {
  4412. if (this._left.fromString(value)) {
  4413. this._markAsDirty();
  4414. }
  4415. },
  4416. enumerable: true,
  4417. configurable: true
  4418. });
  4419. Object.defineProperty(Control.prototype, "leftInPixels", {
  4420. /**
  4421. * Gets or sets a value indicating the left coordinate in pixels of the control
  4422. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4423. */
  4424. get: function () {
  4425. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4426. },
  4427. set: function (value) {
  4428. if (isNaN(value)) {
  4429. return;
  4430. }
  4431. this.left = value + "px";
  4432. },
  4433. enumerable: true,
  4434. configurable: true
  4435. });
  4436. Object.defineProperty(Control.prototype, "top", {
  4437. /**
  4438. * Gets or sets a value indicating the top coordinate of the control
  4439. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4440. */
  4441. get: function () {
  4442. return this._top.toString(this._host);
  4443. },
  4444. set: function (value) {
  4445. if (this._top.fromString(value)) {
  4446. this._markAsDirty();
  4447. }
  4448. },
  4449. enumerable: true,
  4450. configurable: true
  4451. });
  4452. Object.defineProperty(Control.prototype, "topInPixels", {
  4453. /**
  4454. * Gets or sets a value indicating the top coordinate in pixels of the control
  4455. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4456. */
  4457. get: function () {
  4458. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4459. },
  4460. set: function (value) {
  4461. if (isNaN(value)) {
  4462. return;
  4463. }
  4464. this.top = value + "px";
  4465. },
  4466. enumerable: true,
  4467. configurable: true
  4468. });
  4469. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4470. /**
  4471. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4472. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4473. */
  4474. get: function () {
  4475. return this._linkOffsetX.toString(this._host);
  4476. },
  4477. set: function (value) {
  4478. if (this._linkOffsetX.fromString(value)) {
  4479. this._markAsDirty();
  4480. }
  4481. },
  4482. enumerable: true,
  4483. configurable: true
  4484. });
  4485. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4486. /**
  4487. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4488. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4489. */
  4490. get: function () {
  4491. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4492. },
  4493. set: function (value) {
  4494. if (isNaN(value)) {
  4495. return;
  4496. }
  4497. this.linkOffsetX = value + "px";
  4498. },
  4499. enumerable: true,
  4500. configurable: true
  4501. });
  4502. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4503. /**
  4504. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4505. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4506. */
  4507. get: function () {
  4508. return this._linkOffsetY.toString(this._host);
  4509. },
  4510. set: function (value) {
  4511. if (this._linkOffsetY.fromString(value)) {
  4512. this._markAsDirty();
  4513. }
  4514. },
  4515. enumerable: true,
  4516. configurable: true
  4517. });
  4518. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4519. /**
  4520. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4521. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4522. */
  4523. get: function () {
  4524. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4525. },
  4526. set: function (value) {
  4527. if (isNaN(value)) {
  4528. return;
  4529. }
  4530. this.linkOffsetY = value + "px";
  4531. },
  4532. enumerable: true,
  4533. configurable: true
  4534. });
  4535. Object.defineProperty(Control.prototype, "centerX", {
  4536. /** Gets the center coordinate on X axis */
  4537. get: function () {
  4538. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4539. },
  4540. enumerable: true,
  4541. configurable: true
  4542. });
  4543. Object.defineProperty(Control.prototype, "centerY", {
  4544. /** Gets the center coordinate on Y axis */
  4545. get: function () {
  4546. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4547. },
  4548. enumerable: true,
  4549. configurable: true
  4550. });
  4551. Object.defineProperty(Control.prototype, "isEnabled", {
  4552. /** Gets or sets if control is Enabled*/
  4553. get: function () {
  4554. return this._isEnabled;
  4555. },
  4556. set: function (value) {
  4557. if (this._isEnabled === value) {
  4558. return;
  4559. }
  4560. this._isEnabled = value;
  4561. this._markAsDirty();
  4562. },
  4563. enumerable: true,
  4564. configurable: true
  4565. });
  4566. Object.defineProperty(Control.prototype, "disabledColor", {
  4567. /** Gets or sets background color of control if it's disabled*/
  4568. get: function () {
  4569. return this._disabledColor;
  4570. },
  4571. set: function (value) {
  4572. if (this._disabledColor === value) {
  4573. return;
  4574. }
  4575. this._disabledColor = value;
  4576. this._markAsDirty();
  4577. },
  4578. enumerable: true,
  4579. configurable: true
  4580. });
  4581. Object.defineProperty(Control.prototype, "disabledColorItem", {
  4582. /** Gets or sets front color of control if it's disabled*/
  4583. get: function () {
  4584. return this._disabledColorItem;
  4585. },
  4586. set: function (value) {
  4587. if (this._disabledColorItem === value) {
  4588. return;
  4589. }
  4590. this._disabledColorItem = value;
  4591. this._markAsDirty();
  4592. },
  4593. enumerable: true,
  4594. configurable: true
  4595. });
  4596. /** @hidden */
  4597. Control.prototype._getTypeName = function () {
  4598. return "Control";
  4599. };
  4600. /**
  4601. * Gets the first ascendant in the hierarchy of the given type
  4602. * @param className defines the required type
  4603. * @returns the ascendant or null if not found
  4604. */
  4605. Control.prototype.getAscendantOfClass = function (className) {
  4606. if (!this.parent) {
  4607. return null;
  4608. }
  4609. if (this.parent.getClassName() === className) {
  4610. return this.parent;
  4611. }
  4612. return this.parent.getAscendantOfClass(className);
  4613. };
  4614. /** @hidden */
  4615. Control.prototype._resetFontCache = function () {
  4616. this._fontSet = true;
  4617. this._markAsDirty();
  4618. };
  4619. /**
  4620. * Determines if a container is an ascendant of the current control
  4621. * @param container defines the container to look for
  4622. * @returns true if the container is one of the ascendant of the control
  4623. */
  4624. Control.prototype.isAscendant = function (container) {
  4625. if (!this.parent) {
  4626. return false;
  4627. }
  4628. if (this.parent === container) {
  4629. return true;
  4630. }
  4631. return this.parent.isAscendant(container);
  4632. };
  4633. /**
  4634. * Gets coordinates in local control space
  4635. * @param globalCoordinates defines the coordinates to transform
  4636. * @returns the new coordinates in local space
  4637. */
  4638. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4639. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4640. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4641. return result;
  4642. };
  4643. /**
  4644. * Gets coordinates in local control space
  4645. * @param globalCoordinates defines the coordinates to transform
  4646. * @param result defines the target vector2 where to store the result
  4647. * @returns the current control
  4648. */
  4649. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4650. result.x = globalCoordinates.x - this._currentMeasure.left;
  4651. result.y = globalCoordinates.y - this._currentMeasure.top;
  4652. return this;
  4653. };
  4654. /**
  4655. * Gets coordinates in parent local control space
  4656. * @param globalCoordinates defines the coordinates to transform
  4657. * @returns the new coordinates in parent local space
  4658. */
  4659. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4660. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4661. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4662. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4663. return result;
  4664. };
  4665. /**
  4666. * Move the current control to a vector3 position projected onto the screen.
  4667. * @param position defines the target position
  4668. * @param scene defines the hosting scene
  4669. */
  4670. Control.prototype.moveToVector3 = function (position, scene) {
  4671. if (!this._host || this.parent !== this._host._rootContainer) {
  4672. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4673. return;
  4674. }
  4675. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4676. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4677. var globalViewport = this._host._getGlobalViewport(scene);
  4678. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4679. this._moveToProjectedPosition(projectedPosition);
  4680. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4681. this.notRenderable = true;
  4682. return;
  4683. }
  4684. this.notRenderable = false;
  4685. };
  4686. /**
  4687. * Will store all controls that have this control as ascendant in a given array
  4688. * @param results defines the array where to store the descendants
  4689. * @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
  4690. * @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
  4691. */
  4692. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4693. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4694. // Do nothing by default
  4695. };
  4696. /**
  4697. * Will return all controls that have this control as ascendant
  4698. * @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
  4699. * @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
  4700. * @return all child controls
  4701. */
  4702. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4703. var results = new Array();
  4704. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4705. return results;
  4706. };
  4707. /**
  4708. * Link current control with a target mesh
  4709. * @param mesh defines the mesh to link with
  4710. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4711. */
  4712. Control.prototype.linkWithMesh = function (mesh) {
  4713. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4714. if (mesh) {
  4715. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4716. }
  4717. return;
  4718. }
  4719. var index = this._host._linkedControls.indexOf(this);
  4720. if (index !== -1) {
  4721. this._linkedMesh = mesh;
  4722. if (!mesh) {
  4723. this._host._linkedControls.splice(index, 1);
  4724. }
  4725. return;
  4726. }
  4727. else if (!mesh) {
  4728. return;
  4729. }
  4730. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4731. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4732. this._linkedMesh = mesh;
  4733. this._host._linkedControls.push(this);
  4734. };
  4735. /** @hidden */
  4736. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4737. var oldLeft = this._left.getValue(this._host);
  4738. var oldTop = this._top.getValue(this._host);
  4739. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4740. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4741. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4742. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4743. newLeft = oldLeft;
  4744. }
  4745. if (Math.abs(newTop - oldTop) < 0.5) {
  4746. newTop = oldTop;
  4747. }
  4748. }
  4749. this.left = newLeft + "px";
  4750. this.top = newTop + "px";
  4751. this._left.ignoreAdaptiveScaling = true;
  4752. this._top.ignoreAdaptiveScaling = true;
  4753. this._markAsDirty();
  4754. };
  4755. /** @hidden */
  4756. Control.prototype._offsetLeft = function (offset) {
  4757. this._isDirty = true;
  4758. this._currentMeasure.left += offset;
  4759. };
  4760. /** @hidden */
  4761. Control.prototype._offsetTop = function (offset) {
  4762. this._isDirty = true;
  4763. this._currentMeasure.top += offset;
  4764. };
  4765. /** @hidden */
  4766. Control.prototype._markMatrixAsDirty = function () {
  4767. this._isMatrixDirty = true;
  4768. this._flagDescendantsAsMatrixDirty();
  4769. };
  4770. /** @hidden */
  4771. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4772. // No child
  4773. };
  4774. /** @hidden */
  4775. Control.prototype._intersectsRect = function (rect) {
  4776. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4777. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4778. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4779. return false;
  4780. }
  4781. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4782. return false;
  4783. }
  4784. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4785. return false;
  4786. }
  4787. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4788. return false;
  4789. }
  4790. return true;
  4791. };
  4792. /** @hidden */
  4793. Control.prototype.invalidateRect = function () {
  4794. this._transform();
  4795. if (this.host && this.host.useInvalidateRectOptimization) {
  4796. // Rotate by transform to get the measure transformed to global space
  4797. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4798. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4799. // the previous measure is used to properly clear a control that is scaled down
  4800. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4801. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4802. // Expand rect based on shadows
  4803. var shadowOffsetX = this.shadowOffsetX;
  4804. var shadowOffsetY = this.shadowOffsetY;
  4805. var shadowBlur = this.shadowBlur;
  4806. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4807. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4808. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4809. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4810. 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));
  4811. }
  4812. else {
  4813. 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));
  4814. }
  4815. }
  4816. };
  4817. /** @hidden */
  4818. Control.prototype._markAsDirty = function (force) {
  4819. if (force === void 0) { force = false; }
  4820. if (!this._isVisible && !force) {
  4821. return;
  4822. }
  4823. this._isDirty = true;
  4824. // Redraw only this rectangle
  4825. if (this._host) {
  4826. this._host.markAsDirty();
  4827. }
  4828. };
  4829. /** @hidden */
  4830. Control.prototype._markAllAsDirty = function () {
  4831. this._markAsDirty();
  4832. if (this._font) {
  4833. this._prepareFont();
  4834. }
  4835. };
  4836. /** @hidden */
  4837. Control.prototype._link = function (host) {
  4838. this._host = host;
  4839. if (this._host) {
  4840. this.uniqueId = this._host.getScene().getUniqueId();
  4841. }
  4842. };
  4843. /** @hidden */
  4844. Control.prototype._transform = function (context) {
  4845. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4846. return;
  4847. }
  4848. // postTranslate
  4849. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4850. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4851. if (context) {
  4852. context.translate(offsetX, offsetY);
  4853. // rotate
  4854. context.rotate(this._rotation);
  4855. // scale
  4856. context.scale(this._scaleX, this._scaleY);
  4857. // preTranslate
  4858. context.translate(-offsetX, -offsetY);
  4859. }
  4860. // Need to update matrices?
  4861. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4862. this._cachedOffsetX = offsetX;
  4863. this._cachedOffsetY = offsetY;
  4864. this._isMatrixDirty = false;
  4865. this._flagDescendantsAsMatrixDirty();
  4866. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4867. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4868. }
  4869. };
  4870. /** @hidden */
  4871. Control.prototype._renderHighlight = function (context) {
  4872. if (!this.isHighlighted) {
  4873. return;
  4874. }
  4875. context.save();
  4876. context.strokeStyle = "#4affff";
  4877. context.lineWidth = 2;
  4878. this._renderHighlightSpecific(context);
  4879. context.restore();
  4880. };
  4881. /** @hidden */
  4882. Control.prototype._renderHighlightSpecific = function (context) {
  4883. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4884. };
  4885. /** @hidden */
  4886. Control.prototype._applyStates = function (context) {
  4887. if (this._isFontSizeInPercentage) {
  4888. this._fontSet = true;
  4889. }
  4890. if (this._fontSet) {
  4891. this._prepareFont();
  4892. this._fontSet = false;
  4893. }
  4894. if (this._font) {
  4895. context.font = this._font;
  4896. }
  4897. if (this._color) {
  4898. context.fillStyle = this._color;
  4899. }
  4900. if (Control.AllowAlphaInheritance) {
  4901. context.globalAlpha *= this._alpha;
  4902. }
  4903. else if (this._alphaSet) {
  4904. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4905. }
  4906. };
  4907. /** @hidden */
  4908. Control.prototype._layout = function (parentMeasure, context) {
  4909. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4910. return false;
  4911. }
  4912. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4913. this.host._numLayoutCalls++;
  4914. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4915. context.save();
  4916. this._applyStates(context);
  4917. var rebuildCount = 0;
  4918. do {
  4919. this._rebuildLayout = false;
  4920. this._processMeasures(parentMeasure, context);
  4921. rebuildCount++;
  4922. } while (this._rebuildLayout && rebuildCount < 3);
  4923. if (rebuildCount >= 3) {
  4924. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4925. }
  4926. context.restore();
  4927. this.invalidateRect();
  4928. this._evaluateClippingState(parentMeasure);
  4929. }
  4930. this._wasDirty = this._isDirty;
  4931. this._isDirty = false;
  4932. return true;
  4933. };
  4934. /** @hidden */
  4935. Control.prototype._processMeasures = function (parentMeasure, context) {
  4936. this._currentMeasure.copyFrom(parentMeasure);
  4937. // Let children take some pre-measurement actions
  4938. this._preMeasure(parentMeasure, context);
  4939. this._measure();
  4940. this._computeAlignment(parentMeasure, context);
  4941. // Convert to int values
  4942. this._currentMeasure.left = this._currentMeasure.left | 0;
  4943. this._currentMeasure.top = this._currentMeasure.top | 0;
  4944. this._currentMeasure.width = this._currentMeasure.width | 0;
  4945. this._currentMeasure.height = this._currentMeasure.height | 0;
  4946. // Let children add more features
  4947. this._additionalProcessing(parentMeasure, context);
  4948. this._cachedParentMeasure.copyFrom(parentMeasure);
  4949. if (this.onDirtyObservable.hasObservers()) {
  4950. this.onDirtyObservable.notifyObservers(this);
  4951. }
  4952. };
  4953. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4954. if (this.parent && this.parent.clipChildren) {
  4955. // Early clip
  4956. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4957. this._isClipped = true;
  4958. return;
  4959. }
  4960. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4961. this._isClipped = true;
  4962. return;
  4963. }
  4964. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4965. this._isClipped = true;
  4966. return;
  4967. }
  4968. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4969. this._isClipped = true;
  4970. return;
  4971. }
  4972. }
  4973. this._isClipped = false;
  4974. };
  4975. /** @hidden */
  4976. Control.prototype._measure = function () {
  4977. // Width / Height
  4978. if (this._width.isPixel) {
  4979. this._currentMeasure.width = this._width.getValue(this._host);
  4980. }
  4981. else {
  4982. this._currentMeasure.width *= this._width.getValue(this._host);
  4983. }
  4984. if (this._height.isPixel) {
  4985. this._currentMeasure.height = this._height.getValue(this._host);
  4986. }
  4987. else {
  4988. this._currentMeasure.height *= this._height.getValue(this._host);
  4989. }
  4990. };
  4991. /** @hidden */
  4992. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4993. var width = this._currentMeasure.width;
  4994. var height = this._currentMeasure.height;
  4995. var parentWidth = parentMeasure.width;
  4996. var parentHeight = parentMeasure.height;
  4997. // Left / top
  4998. var x = 0;
  4999. var y = 0;
  5000. switch (this.horizontalAlignment) {
  5001. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  5002. x = 0;
  5003. break;
  5004. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  5005. x = parentWidth - width;
  5006. break;
  5007. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  5008. x = (parentWidth - width) / 2;
  5009. break;
  5010. }
  5011. switch (this.verticalAlignment) {
  5012. case Control.VERTICAL_ALIGNMENT_TOP:
  5013. y = 0;
  5014. break;
  5015. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5016. y = parentHeight - height;
  5017. break;
  5018. case Control.VERTICAL_ALIGNMENT_CENTER:
  5019. y = (parentHeight - height) / 2;
  5020. break;
  5021. }
  5022. if (this._paddingLeft.isPixel) {
  5023. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5024. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5025. }
  5026. else {
  5027. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5028. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5029. }
  5030. if (this._paddingRight.isPixel) {
  5031. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5032. }
  5033. else {
  5034. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5035. }
  5036. if (this._paddingTop.isPixel) {
  5037. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5038. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5039. }
  5040. else {
  5041. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5042. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5043. }
  5044. if (this._paddingBottom.isPixel) {
  5045. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5046. }
  5047. else {
  5048. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5049. }
  5050. if (this._left.isPixel) {
  5051. this._currentMeasure.left += this._left.getValue(this._host);
  5052. }
  5053. else {
  5054. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5055. }
  5056. if (this._top.isPixel) {
  5057. this._currentMeasure.top += this._top.getValue(this._host);
  5058. }
  5059. else {
  5060. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5061. }
  5062. this._currentMeasure.left += x;
  5063. this._currentMeasure.top += y;
  5064. };
  5065. /** @hidden */
  5066. Control.prototype._preMeasure = function (parentMeasure, context) {
  5067. // Do nothing
  5068. };
  5069. /** @hidden */
  5070. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5071. // Do nothing
  5072. };
  5073. /** @hidden */
  5074. Control.prototype._clipForChildren = function (context) {
  5075. // DO nothing
  5076. };
  5077. Control.prototype._clip = function (context, invalidatedRectangle) {
  5078. context.beginPath();
  5079. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5080. if (invalidatedRectangle) {
  5081. // Rotate the invalidated rect into the control's space
  5082. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5083. // Get the intersection of the rect in context space and the current context
  5084. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5085. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5086. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5087. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5088. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5089. Control._ClipMeasure.copyFrom(intersection);
  5090. }
  5091. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5092. var shadowOffsetX = this.shadowOffsetX;
  5093. var shadowOffsetY = this.shadowOffsetY;
  5094. var shadowBlur = this.shadowBlur;
  5095. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5096. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5097. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5098. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5099. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5100. }
  5101. else {
  5102. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5103. }
  5104. context.clip();
  5105. };
  5106. /** @hidden */
  5107. Control.prototype._render = function (context, invalidatedRectangle) {
  5108. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5109. this._isDirty = false;
  5110. return false;
  5111. }
  5112. this.host._numRenderCalls++;
  5113. context.save();
  5114. this._applyStates(context);
  5115. // Transform
  5116. this._transform(context);
  5117. // Clip
  5118. if (this.clipContent) {
  5119. this._clip(context, invalidatedRectangle);
  5120. }
  5121. if (this.onBeforeDrawObservable.hasObservers()) {
  5122. this.onBeforeDrawObservable.notifyObservers(this);
  5123. }
  5124. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5125. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5126. }
  5127. else {
  5128. this._draw(context, invalidatedRectangle);
  5129. }
  5130. if (this.useBitmapCache && this._wasDirty) {
  5131. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5132. }
  5133. this._renderHighlight(context);
  5134. if (this.onAfterDrawObservable.hasObservers()) {
  5135. this.onAfterDrawObservable.notifyObservers(this);
  5136. }
  5137. context.restore();
  5138. return true;
  5139. };
  5140. /** @hidden */
  5141. Control.prototype._draw = function (context, invalidatedRectangle) {
  5142. // Do nothing
  5143. };
  5144. /**
  5145. * Tests if a given coordinates belong to the current control
  5146. * @param x defines x coordinate to test
  5147. * @param y defines y coordinate to test
  5148. * @returns true if the coordinates are inside the control
  5149. */
  5150. Control.prototype.contains = function (x, y) {
  5151. // Invert transform
  5152. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5153. x = this._transformedPosition.x;
  5154. y = this._transformedPosition.y;
  5155. // Check
  5156. if (x < this._currentMeasure.left) {
  5157. return false;
  5158. }
  5159. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5160. return false;
  5161. }
  5162. if (y < this._currentMeasure.top) {
  5163. return false;
  5164. }
  5165. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5166. return false;
  5167. }
  5168. if (this.isPointerBlocker) {
  5169. this._host._shouldBlockPointer = true;
  5170. }
  5171. return true;
  5172. };
  5173. /** @hidden */
  5174. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  5175. if (!this._isEnabled) {
  5176. return false;
  5177. }
  5178. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5179. return false;
  5180. }
  5181. if (!this.contains(x, y)) {
  5182. return false;
  5183. }
  5184. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  5185. return true;
  5186. };
  5187. /** @hidden */
  5188. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5189. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5190. if (canNotify && this.parent != null) {
  5191. this.parent._onPointerMove(target, coordinates, pointerId);
  5192. }
  5193. };
  5194. /** @hidden */
  5195. Control.prototype._onPointerEnter = function (target) {
  5196. if (!this._isEnabled) {
  5197. return false;
  5198. }
  5199. if (this._enterCount > 0) {
  5200. return false;
  5201. }
  5202. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5203. this._enterCount = 0;
  5204. }
  5205. this._enterCount++;
  5206. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5207. if (canNotify && this.parent != null) {
  5208. this.parent._onPointerEnter(target);
  5209. }
  5210. return true;
  5211. };
  5212. /** @hidden */
  5213. Control.prototype._onPointerOut = function (target, force) {
  5214. if (force === void 0) { force = false; }
  5215. if (!force && (!this._isEnabled || target === this)) {
  5216. return;
  5217. }
  5218. this._enterCount = 0;
  5219. var canNotify = true;
  5220. if (!target.isAscendant(this)) {
  5221. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5222. }
  5223. if (canNotify && this.parent != null) {
  5224. this.parent._onPointerOut(target, force);
  5225. }
  5226. };
  5227. /** @hidden */
  5228. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5229. // Prevent pointerout to lose control context.
  5230. // Event redundancy is checked inside the function.
  5231. this._onPointerEnter(this);
  5232. if (this._downCount !== 0) {
  5233. return false;
  5234. }
  5235. this._downCount++;
  5236. this._downPointerIds[pointerId] = true;
  5237. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5238. if (canNotify && this.parent != null) {
  5239. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5240. }
  5241. return true;
  5242. };
  5243. /** @hidden */
  5244. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5245. if (!this._isEnabled) {
  5246. return;
  5247. }
  5248. this._downCount = 0;
  5249. delete this._downPointerIds[pointerId];
  5250. var canNotifyClick = notifyClick;
  5251. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5252. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5253. }
  5254. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5255. if (canNotify && this.parent != null) {
  5256. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5257. }
  5258. };
  5259. /** @hidden */
  5260. Control.prototype._forcePointerUp = function (pointerId) {
  5261. if (pointerId === void 0) { pointerId = null; }
  5262. if (pointerId !== null) {
  5263. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5264. }
  5265. else {
  5266. for (var key in this._downPointerIds) {
  5267. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5268. }
  5269. }
  5270. };
  5271. /** @hidden */
  5272. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5273. if (!this._isEnabled) {
  5274. return;
  5275. }
  5276. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"](deltaX, deltaY));
  5277. if (canNotify && this.parent != null) {
  5278. this.parent._onWheelScroll(deltaX, deltaY);
  5279. }
  5280. };
  5281. /** @hidden */
  5282. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex, deltaX, deltaY) {
  5283. if (!this._isEnabled) {
  5284. return false;
  5285. }
  5286. this._dummyVector2.copyFromFloats(x, y);
  5287. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5288. this._onPointerMove(this, this._dummyVector2, pointerId);
  5289. var previousControlOver = this._host._lastControlOver[pointerId];
  5290. if (previousControlOver && previousControlOver !== this) {
  5291. previousControlOver._onPointerOut(this);
  5292. }
  5293. if (previousControlOver !== this) {
  5294. this._onPointerEnter(this);
  5295. }
  5296. this._host._lastControlOver[pointerId] = this;
  5297. return true;
  5298. }
  5299. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5300. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5301. this._host._registerLastControlDown(this, pointerId);
  5302. this._host._lastPickedControl = this;
  5303. return true;
  5304. }
  5305. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5306. if (this._host._lastControlDown[pointerId]) {
  5307. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5308. }
  5309. delete this._host._lastControlDown[pointerId];
  5310. return true;
  5311. }
  5312. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL) {
  5313. if (this._host._lastControlOver[pointerId]) {
  5314. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5315. return true;
  5316. }
  5317. }
  5318. return false;
  5319. };
  5320. Control.prototype._prepareFont = function () {
  5321. if (!this._font && !this._fontSet) {
  5322. return;
  5323. }
  5324. if (this._style) {
  5325. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5326. }
  5327. else {
  5328. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5329. }
  5330. this._fontOffset = Control._GetFontOffset(this._font);
  5331. };
  5332. /** Releases associated resources */
  5333. Control.prototype.dispose = function () {
  5334. this.onDirtyObservable.clear();
  5335. this.onBeforeDrawObservable.clear();
  5336. this.onAfterDrawObservable.clear();
  5337. this.onPointerDownObservable.clear();
  5338. this.onPointerEnterObservable.clear();
  5339. this.onPointerMoveObservable.clear();
  5340. this.onPointerOutObservable.clear();
  5341. this.onPointerUpObservable.clear();
  5342. this.onPointerClickObservable.clear();
  5343. this.onWheelObservable.clear();
  5344. if (this._styleObserver && this._style) {
  5345. this._style.onChangedObservable.remove(this._styleObserver);
  5346. this._styleObserver = null;
  5347. }
  5348. if (this.parent) {
  5349. this.parent.removeControl(this);
  5350. this.parent = null;
  5351. }
  5352. if (this._host) {
  5353. var index = this._host._linkedControls.indexOf(this);
  5354. if (index > -1) {
  5355. this.linkWithMesh(null);
  5356. }
  5357. }
  5358. };
  5359. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5360. /** HORIZONTAL_ALIGNMENT_LEFT */
  5361. get: function () {
  5362. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5363. },
  5364. enumerable: true,
  5365. configurable: true
  5366. });
  5367. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5368. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5369. get: function () {
  5370. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5371. },
  5372. enumerable: true,
  5373. configurable: true
  5374. });
  5375. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5376. /** HORIZONTAL_ALIGNMENT_CENTER */
  5377. get: function () {
  5378. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5379. },
  5380. enumerable: true,
  5381. configurable: true
  5382. });
  5383. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5384. /** VERTICAL_ALIGNMENT_TOP */
  5385. get: function () {
  5386. return Control._VERTICAL_ALIGNMENT_TOP;
  5387. },
  5388. enumerable: true,
  5389. configurable: true
  5390. });
  5391. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5392. /** VERTICAL_ALIGNMENT_BOTTOM */
  5393. get: function () {
  5394. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5395. },
  5396. enumerable: true,
  5397. configurable: true
  5398. });
  5399. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5400. /** VERTICAL_ALIGNMENT_CENTER */
  5401. get: function () {
  5402. return Control._VERTICAL_ALIGNMENT_CENTER;
  5403. },
  5404. enumerable: true,
  5405. configurable: true
  5406. });
  5407. /** @hidden */
  5408. Control._GetFontOffset = function (font) {
  5409. if (Control._FontHeightSizes[font]) {
  5410. return Control._FontHeightSizes[font];
  5411. }
  5412. var text = document.createElement("span");
  5413. text.innerHTML = "Hg";
  5414. text.style.font = font;
  5415. var block = document.createElement("div");
  5416. block.style.display = "inline-block";
  5417. block.style.width = "1px";
  5418. block.style.height = "0px";
  5419. block.style.verticalAlign = "bottom";
  5420. var div = document.createElement("div");
  5421. div.appendChild(text);
  5422. div.appendChild(block);
  5423. document.body.appendChild(div);
  5424. var fontAscent = 0;
  5425. var fontHeight = 0;
  5426. try {
  5427. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5428. block.style.verticalAlign = "baseline";
  5429. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5430. }
  5431. finally {
  5432. document.body.removeChild(div);
  5433. }
  5434. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5435. Control._FontHeightSizes[font] = result;
  5436. return result;
  5437. };
  5438. /** @hidden */
  5439. Control.drawEllipse = function (x, y, width, height, context) {
  5440. context.translate(x, y);
  5441. context.scale(width, height);
  5442. context.beginPath();
  5443. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5444. context.closePath();
  5445. context.scale(1 / width, 1 / height);
  5446. context.translate(-x, -y);
  5447. };
  5448. /**
  5449. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5450. */
  5451. Control.AllowAlphaInheritance = false;
  5452. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5453. // Statics
  5454. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5455. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5456. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5457. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5458. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5459. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5460. Control._FontHeightSizes = {};
  5461. /**
  5462. * Creates a stack panel that can be used to render headers
  5463. * @param control defines the control to associate with the header
  5464. * @param text defines the text of the header
  5465. * @param size defines the size of the header
  5466. * @param options defines options used to configure the header
  5467. * @returns a new StackPanel
  5468. * @ignore
  5469. * @hidden
  5470. */
  5471. Control.AddHeader = function () { };
  5472. return Control;
  5473. }());
  5474. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5475. /***/ }),
  5476. /***/ "./2D/controls/displayGrid.ts":
  5477. /*!************************************!*\
  5478. !*** ./2D/controls/displayGrid.ts ***!
  5479. \************************************/
  5480. /*! exports provided: DisplayGrid */
  5481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5482. "use strict";
  5483. __webpack_require__.r(__webpack_exports__);
  5484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5485. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5486. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5487. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  5488. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5489. /** Class used to render a grid */
  5490. var DisplayGrid = /** @class */ (function (_super) {
  5491. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5492. /**
  5493. * Creates a new GridDisplayRectangle
  5494. * @param name defines the control name
  5495. */
  5496. function DisplayGrid(name) {
  5497. var _this = _super.call(this, name) || this;
  5498. _this.name = name;
  5499. _this._cellWidth = 20;
  5500. _this._cellHeight = 20;
  5501. _this._minorLineTickness = 1;
  5502. _this._minorLineColor = "DarkGray";
  5503. _this._majorLineTickness = 2;
  5504. _this._majorLineColor = "White";
  5505. _this._majorLineFrequency = 5;
  5506. _this._background = "Black";
  5507. _this._displayMajorLines = true;
  5508. _this._displayMinorLines = true;
  5509. return _this;
  5510. }
  5511. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5512. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5513. get: function () {
  5514. return this._displayMinorLines;
  5515. },
  5516. set: function (value) {
  5517. if (this._displayMinorLines === value) {
  5518. return;
  5519. }
  5520. this._displayMinorLines = value;
  5521. this._markAsDirty();
  5522. },
  5523. enumerable: true,
  5524. configurable: true
  5525. });
  5526. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5527. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5528. get: function () {
  5529. return this._displayMajorLines;
  5530. },
  5531. set: function (value) {
  5532. if (this._displayMajorLines === value) {
  5533. return;
  5534. }
  5535. this._displayMajorLines = value;
  5536. this._markAsDirty();
  5537. },
  5538. enumerable: true,
  5539. configurable: true
  5540. });
  5541. Object.defineProperty(DisplayGrid.prototype, "background", {
  5542. /** Gets or sets background color (Black by default) */
  5543. get: function () {
  5544. return this._background;
  5545. },
  5546. set: function (value) {
  5547. if (this._background === value) {
  5548. return;
  5549. }
  5550. this._background = value;
  5551. this._markAsDirty();
  5552. },
  5553. enumerable: true,
  5554. configurable: true
  5555. });
  5556. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5557. /** Gets or sets the width of each cell (20 by default) */
  5558. get: function () {
  5559. return this._cellWidth;
  5560. },
  5561. set: function (value) {
  5562. this._cellWidth = value;
  5563. this._markAsDirty();
  5564. },
  5565. enumerable: true,
  5566. configurable: true
  5567. });
  5568. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5569. /** Gets or sets the height of each cell (20 by default) */
  5570. get: function () {
  5571. return this._cellHeight;
  5572. },
  5573. set: function (value) {
  5574. this._cellHeight = value;
  5575. this._markAsDirty();
  5576. },
  5577. enumerable: true,
  5578. configurable: true
  5579. });
  5580. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5581. /** Gets or sets the tickness of minor lines (1 by default) */
  5582. get: function () {
  5583. return this._minorLineTickness;
  5584. },
  5585. set: function (value) {
  5586. this._minorLineTickness = value;
  5587. this._markAsDirty();
  5588. },
  5589. enumerable: true,
  5590. configurable: true
  5591. });
  5592. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5593. /** Gets or sets the color of minor lines (DarkGray by default) */
  5594. get: function () {
  5595. return this._minorLineColor;
  5596. },
  5597. set: function (value) {
  5598. this._minorLineColor = value;
  5599. this._markAsDirty();
  5600. },
  5601. enumerable: true,
  5602. configurable: true
  5603. });
  5604. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5605. /** Gets or sets the tickness of major lines (2 by default) */
  5606. get: function () {
  5607. return this._majorLineTickness;
  5608. },
  5609. set: function (value) {
  5610. this._majorLineTickness = value;
  5611. this._markAsDirty();
  5612. },
  5613. enumerable: true,
  5614. configurable: true
  5615. });
  5616. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5617. /** Gets or sets the color of major lines (White by default) */
  5618. get: function () {
  5619. return this._majorLineColor;
  5620. },
  5621. set: function (value) {
  5622. this._majorLineColor = value;
  5623. this._markAsDirty();
  5624. },
  5625. enumerable: true,
  5626. configurable: true
  5627. });
  5628. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5629. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5630. get: function () {
  5631. return this._majorLineFrequency;
  5632. },
  5633. set: function (value) {
  5634. this._majorLineFrequency = value;
  5635. this._markAsDirty();
  5636. },
  5637. enumerable: true,
  5638. configurable: true
  5639. });
  5640. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5641. context.save();
  5642. this._applyStates(context);
  5643. if (this._isEnabled) {
  5644. if (this._background) {
  5645. context.fillStyle = this._background;
  5646. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5647. }
  5648. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5649. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5650. // Minor lines
  5651. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5652. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5653. if (this._displayMinorLines) {
  5654. context.strokeStyle = this._minorLineColor;
  5655. context.lineWidth = this._minorLineTickness;
  5656. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5657. var cellX = left + x * this.cellWidth;
  5658. context.beginPath();
  5659. context.moveTo(cellX, this._currentMeasure.top);
  5660. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5661. context.stroke();
  5662. }
  5663. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5664. var cellY = top_1 + y * this.cellHeight;
  5665. context.beginPath();
  5666. context.moveTo(this._currentMeasure.left, cellY);
  5667. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5668. context.stroke();
  5669. }
  5670. }
  5671. // Major lines
  5672. if (this._displayMajorLines) {
  5673. context.strokeStyle = this._majorLineColor;
  5674. context.lineWidth = this._majorLineTickness;
  5675. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5676. var cellX = left + x * this.cellWidth;
  5677. context.beginPath();
  5678. context.moveTo(cellX, this._currentMeasure.top);
  5679. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5680. context.stroke();
  5681. }
  5682. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5683. var cellY = top_1 + y * this.cellHeight;
  5684. context.moveTo(this._currentMeasure.left, cellY);
  5685. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5686. context.closePath();
  5687. context.stroke();
  5688. }
  5689. }
  5690. }
  5691. context.restore();
  5692. };
  5693. DisplayGrid.prototype._getTypeName = function () {
  5694. return "DisplayGrid";
  5695. };
  5696. return DisplayGrid;
  5697. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5698. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5699. /***/ }),
  5700. /***/ "./2D/controls/ellipse.ts":
  5701. /*!********************************!*\
  5702. !*** ./2D/controls/ellipse.ts ***!
  5703. \********************************/
  5704. /*! exports provided: Ellipse */
  5705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5706. "use strict";
  5707. __webpack_require__.r(__webpack_exports__);
  5708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5709. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5710. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5711. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5712. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  5713. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5714. /** Class used to create 2D ellipse containers */
  5715. var Ellipse = /** @class */ (function (_super) {
  5716. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5717. /**
  5718. * Creates a new Ellipse
  5719. * @param name defines the control name
  5720. */
  5721. function Ellipse(name) {
  5722. var _this = _super.call(this, name) || this;
  5723. _this.name = name;
  5724. _this._thickness = 1;
  5725. return _this;
  5726. }
  5727. Object.defineProperty(Ellipse.prototype, "thickness", {
  5728. /** Gets or sets border thickness */
  5729. get: function () {
  5730. return this._thickness;
  5731. },
  5732. set: function (value) {
  5733. if (this._thickness === value) {
  5734. return;
  5735. }
  5736. this._thickness = value;
  5737. this._markAsDirty();
  5738. },
  5739. enumerable: true,
  5740. configurable: true
  5741. });
  5742. Ellipse.prototype._getTypeName = function () {
  5743. return "Ellipse";
  5744. };
  5745. Ellipse.prototype._localDraw = function (context) {
  5746. context.save();
  5747. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5748. context.shadowColor = this.shadowColor;
  5749. context.shadowBlur = this.shadowBlur;
  5750. context.shadowOffsetX = this.shadowOffsetX;
  5751. context.shadowOffsetY = this.shadowOffsetY;
  5752. }
  5753. _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);
  5754. if (this._background) {
  5755. context.fillStyle = this._background;
  5756. context.fill();
  5757. }
  5758. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5759. context.shadowBlur = 0;
  5760. context.shadowOffsetX = 0;
  5761. context.shadowOffsetY = 0;
  5762. }
  5763. if (this._thickness) {
  5764. if (this.color) {
  5765. context.strokeStyle = this.color;
  5766. }
  5767. context.lineWidth = this._thickness;
  5768. context.stroke();
  5769. }
  5770. context.restore();
  5771. };
  5772. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5773. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5774. this._measureForChildren.width -= 2 * this._thickness;
  5775. this._measureForChildren.height -= 2 * this._thickness;
  5776. this._measureForChildren.left += this._thickness;
  5777. this._measureForChildren.top += this._thickness;
  5778. };
  5779. Ellipse.prototype._clipForChildren = function (context) {
  5780. _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);
  5781. context.clip();
  5782. };
  5783. return Ellipse;
  5784. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5785. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5786. /***/ }),
  5787. /***/ "./2D/controls/grid.ts":
  5788. /*!*****************************!*\
  5789. !*** ./2D/controls/grid.ts ***!
  5790. \*****************************/
  5791. /*! exports provided: Grid */
  5792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5793. "use strict";
  5794. __webpack_require__.r(__webpack_exports__);
  5795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5796. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5797. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5798. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5799. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5800. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  5801. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5802. /**
  5803. * Class used to create a 2D grid container
  5804. */
  5805. var Grid = /** @class */ (function (_super) {
  5806. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5807. /**
  5808. * Creates a new Grid
  5809. * @param name defines control name
  5810. */
  5811. function Grid(name) {
  5812. var _this = _super.call(this, name) || this;
  5813. _this.name = name;
  5814. _this._rowDefinitions = new Array();
  5815. _this._columnDefinitions = new Array();
  5816. _this._cells = {};
  5817. _this._childControls = new Array();
  5818. return _this;
  5819. }
  5820. Object.defineProperty(Grid.prototype, "columnCount", {
  5821. /**
  5822. * Gets the number of columns
  5823. */
  5824. get: function () {
  5825. return this._columnDefinitions.length;
  5826. },
  5827. enumerable: true,
  5828. configurable: true
  5829. });
  5830. Object.defineProperty(Grid.prototype, "rowCount", {
  5831. /**
  5832. * Gets the number of rows
  5833. */
  5834. get: function () {
  5835. return this._rowDefinitions.length;
  5836. },
  5837. enumerable: true,
  5838. configurable: true
  5839. });
  5840. Object.defineProperty(Grid.prototype, "children", {
  5841. /** Gets the list of children */
  5842. get: function () {
  5843. return this._childControls;
  5844. },
  5845. enumerable: true,
  5846. configurable: true
  5847. });
  5848. Object.defineProperty(Grid.prototype, "cells", {
  5849. /** Gets the list of cells (e.g. the containers) */
  5850. get: function () {
  5851. return this._cells;
  5852. },
  5853. enumerable: true,
  5854. configurable: true
  5855. });
  5856. /**
  5857. * Gets the definition of a specific row
  5858. * @param index defines the index of the row
  5859. * @returns the row definition
  5860. */
  5861. Grid.prototype.getRowDefinition = function (index) {
  5862. if (index < 0 || index >= this._rowDefinitions.length) {
  5863. return null;
  5864. }
  5865. return this._rowDefinitions[index];
  5866. };
  5867. /**
  5868. * Gets the definition of a specific column
  5869. * @param index defines the index of the column
  5870. * @returns the column definition
  5871. */
  5872. Grid.prototype.getColumnDefinition = function (index) {
  5873. if (index < 0 || index >= this._columnDefinitions.length) {
  5874. return null;
  5875. }
  5876. return this._columnDefinitions[index];
  5877. };
  5878. /**
  5879. * Adds a new row to the grid
  5880. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5881. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5882. * @returns the current grid
  5883. */
  5884. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5885. if (isPixel === void 0) { isPixel = false; }
  5886. 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));
  5887. this._markAsDirty();
  5888. return this;
  5889. };
  5890. /**
  5891. * Adds a new column to the grid
  5892. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5893. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5894. * @returns the current grid
  5895. */
  5896. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5897. if (isPixel === void 0) { isPixel = false; }
  5898. 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));
  5899. this._markAsDirty();
  5900. return this;
  5901. };
  5902. /**
  5903. * Update a row definition
  5904. * @param index defines the index of the row to update
  5905. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5906. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5907. * @returns the current grid
  5908. */
  5909. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5910. if (isPixel === void 0) { isPixel = false; }
  5911. if (index < 0 || index >= this._rowDefinitions.length) {
  5912. return this;
  5913. }
  5914. var current = this._rowDefinitions[index];
  5915. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5916. return this;
  5917. }
  5918. 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);
  5919. this._markAsDirty();
  5920. return this;
  5921. };
  5922. /**
  5923. * Update a column definition
  5924. * @param index defines the index of the column to update
  5925. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5926. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5927. * @returns the current grid
  5928. */
  5929. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5930. if (isPixel === void 0) { isPixel = false; }
  5931. if (index < 0 || index >= this._columnDefinitions.length) {
  5932. return this;
  5933. }
  5934. var current = this._columnDefinitions[index];
  5935. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5936. return this;
  5937. }
  5938. 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);
  5939. this._markAsDirty();
  5940. return this;
  5941. };
  5942. /**
  5943. * Gets the list of children stored in a specific cell
  5944. * @param row defines the row to check
  5945. * @param column defines the column to check
  5946. * @returns the list of controls
  5947. */
  5948. Grid.prototype.getChildrenAt = function (row, column) {
  5949. var cell = this._cells[row + ":" + column];
  5950. if (!cell) {
  5951. return null;
  5952. }
  5953. return cell.children;
  5954. };
  5955. /**
  5956. * Gets a string representing the child cell info (row x column)
  5957. * @param child defines the control to get info from
  5958. * @returns a string containing the child cell info (row x column)
  5959. */
  5960. Grid.prototype.getChildCellInfo = function (child) {
  5961. return child._tag;
  5962. };
  5963. Grid.prototype._removeCell = function (cell, key) {
  5964. if (!cell) {
  5965. return;
  5966. }
  5967. _super.prototype.removeControl.call(this, cell);
  5968. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5969. var control = _a[_i];
  5970. var childIndex = this._childControls.indexOf(control);
  5971. if (childIndex !== -1) {
  5972. this._childControls.splice(childIndex, 1);
  5973. }
  5974. }
  5975. delete this._cells[key];
  5976. };
  5977. Grid.prototype._offsetCell = function (previousKey, key) {
  5978. if (!this._cells[key]) {
  5979. return;
  5980. }
  5981. this._cells[previousKey] = this._cells[key];
  5982. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5983. var control = _a[_i];
  5984. control._tag = previousKey;
  5985. }
  5986. delete this._cells[key];
  5987. };
  5988. /**
  5989. * Remove a column definition at specified index
  5990. * @param index defines the index of the column to remove
  5991. * @returns the current grid
  5992. */
  5993. Grid.prototype.removeColumnDefinition = function (index) {
  5994. if (index < 0 || index >= this._columnDefinitions.length) {
  5995. return this;
  5996. }
  5997. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5998. var key = x + ":" + index;
  5999. var cell = this._cells[key];
  6000. this._removeCell(cell, key);
  6001. }
  6002. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6003. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6004. var previousKey = x + ":" + (y - 1);
  6005. var key = x + ":" + y;
  6006. this._offsetCell(previousKey, key);
  6007. }
  6008. }
  6009. this._columnDefinitions.splice(index, 1);
  6010. this._markAsDirty();
  6011. return this;
  6012. };
  6013. /**
  6014. * Remove a row definition at specified index
  6015. * @param index defines the index of the row to remove
  6016. * @returns the current grid
  6017. */
  6018. Grid.prototype.removeRowDefinition = function (index) {
  6019. if (index < 0 || index >= this._rowDefinitions.length) {
  6020. return this;
  6021. }
  6022. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6023. var key = index + ":" + y;
  6024. var cell = this._cells[key];
  6025. this._removeCell(cell, key);
  6026. }
  6027. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6028. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6029. var previousKey = x - 1 + ":" + y;
  6030. var key = x + ":" + y;
  6031. this._offsetCell(previousKey, key);
  6032. }
  6033. }
  6034. this._rowDefinitions.splice(index, 1);
  6035. this._markAsDirty();
  6036. return this;
  6037. };
  6038. /**
  6039. * Adds a new control to the current grid
  6040. * @param control defines the control to add
  6041. * @param row defines the row where to add the control (0 by default)
  6042. * @param column defines the column where to add the control (0 by default)
  6043. * @returns the current grid
  6044. */
  6045. Grid.prototype.addControl = function (control, row, column) {
  6046. if (row === void 0) { row = 0; }
  6047. if (column === void 0) { column = 0; }
  6048. if (this._rowDefinitions.length === 0) {
  6049. // Add default row definition
  6050. this.addRowDefinition(1, false);
  6051. }
  6052. if (this._columnDefinitions.length === 0) {
  6053. // Add default column definition
  6054. this.addColumnDefinition(1, false);
  6055. }
  6056. if (this._childControls.indexOf(control) !== -1) {
  6057. 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");
  6058. return this;
  6059. }
  6060. var x = Math.min(row, this._rowDefinitions.length - 1);
  6061. var y = Math.min(column, this._columnDefinitions.length - 1);
  6062. var key = x + ":" + y;
  6063. var goodContainer = this._cells[key];
  6064. if (!goodContainer) {
  6065. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6066. this._cells[key] = goodContainer;
  6067. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6068. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6069. _super.prototype.addControl.call(this, goodContainer);
  6070. }
  6071. goodContainer.addControl(control);
  6072. this._childControls.push(control);
  6073. control._tag = key;
  6074. control.parent = this;
  6075. this._markAsDirty();
  6076. return this;
  6077. };
  6078. /**
  6079. * Removes a control from the current container
  6080. * @param control defines the control to remove
  6081. * @returns the current container
  6082. */
  6083. Grid.prototype.removeControl = function (control) {
  6084. var index = this._childControls.indexOf(control);
  6085. if (index !== -1) {
  6086. this._childControls.splice(index, 1);
  6087. }
  6088. var cell = this._cells[control._tag];
  6089. if (cell) {
  6090. cell.removeControl(control);
  6091. control._tag = null;
  6092. }
  6093. this._markAsDirty();
  6094. return this;
  6095. };
  6096. Grid.prototype._getTypeName = function () {
  6097. return "Grid";
  6098. };
  6099. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6100. var widths = [];
  6101. var heights = [];
  6102. var lefts = [];
  6103. var tops = [];
  6104. var availableWidth = this._currentMeasure.width;
  6105. var globalWidthPercentage = 0;
  6106. var availableHeight = this._currentMeasure.height;
  6107. var globalHeightPercentage = 0;
  6108. // Heights
  6109. var index = 0;
  6110. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6111. var value = _a[_i];
  6112. if (value.isPixel) {
  6113. var height = value.getValue(this._host);
  6114. availableHeight -= height;
  6115. heights[index] = height;
  6116. }
  6117. else {
  6118. globalHeightPercentage += value.internalValue;
  6119. }
  6120. index++;
  6121. }
  6122. var top = 0;
  6123. index = 0;
  6124. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6125. var value = _c[_b];
  6126. tops.push(top);
  6127. if (!value.isPixel) {
  6128. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6129. top += height;
  6130. heights[index] = height;
  6131. }
  6132. else {
  6133. top += value.getValue(this._host);
  6134. }
  6135. index++;
  6136. }
  6137. // Widths
  6138. index = 0;
  6139. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6140. var value = _e[_d];
  6141. if (value.isPixel) {
  6142. var width = value.getValue(this._host);
  6143. availableWidth -= width;
  6144. widths[index] = width;
  6145. }
  6146. else {
  6147. globalWidthPercentage += value.internalValue;
  6148. }
  6149. index++;
  6150. }
  6151. var left = 0;
  6152. index = 0;
  6153. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6154. var value = _g[_f];
  6155. lefts.push(left);
  6156. if (!value.isPixel) {
  6157. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6158. left += width;
  6159. widths[index] = width;
  6160. }
  6161. else {
  6162. left += value.getValue(this._host);
  6163. }
  6164. index++;
  6165. }
  6166. definitionCallback(lefts, tops, widths, heights);
  6167. };
  6168. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6169. var _this = this;
  6170. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6171. // Setting child sizes
  6172. for (var key in _this._cells) {
  6173. if (!_this._cells.hasOwnProperty(key)) {
  6174. continue;
  6175. }
  6176. var split = key.split(":");
  6177. var x = parseInt(split[0]);
  6178. var y = parseInt(split[1]);
  6179. var cell = _this._cells[key];
  6180. cell.left = lefts[y] + "px";
  6181. cell.top = tops[x] + "px";
  6182. cell.width = widths[y] + "px";
  6183. cell.height = heights[x] + "px";
  6184. cell._left.ignoreAdaptiveScaling = true;
  6185. cell._top.ignoreAdaptiveScaling = true;
  6186. cell._width.ignoreAdaptiveScaling = true;
  6187. cell._height.ignoreAdaptiveScaling = true;
  6188. }
  6189. });
  6190. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6191. };
  6192. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6193. for (var key in this._cells) {
  6194. if (!this._cells.hasOwnProperty(key)) {
  6195. continue;
  6196. }
  6197. var child = this._cells[key];
  6198. child._markMatrixAsDirty();
  6199. }
  6200. };
  6201. Grid.prototype._renderHighlightSpecific = function (context) {
  6202. var _this = this;
  6203. _super.prototype._renderHighlightSpecific.call(this, context);
  6204. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6205. // Columns
  6206. for (var index = 0; index < lefts.length; index++) {
  6207. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6208. context.beginPath();
  6209. context.moveTo(left, _this._currentMeasure.top);
  6210. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6211. context.stroke();
  6212. }
  6213. // Rows
  6214. for (var index = 0; index < tops.length; index++) {
  6215. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6216. context.beginPath();
  6217. context.moveTo(_this._currentMeasure.left, top_1);
  6218. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6219. context.stroke();
  6220. }
  6221. });
  6222. context.restore();
  6223. };
  6224. /** Releases associated resources */
  6225. Grid.prototype.dispose = function () {
  6226. _super.prototype.dispose.call(this);
  6227. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6228. var control = _a[_i];
  6229. control.dispose();
  6230. }
  6231. this._childControls = [];
  6232. };
  6233. return Grid;
  6234. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6235. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6236. /***/ }),
  6237. /***/ "./2D/controls/image.ts":
  6238. /*!******************************!*\
  6239. !*** ./2D/controls/image.ts ***!
  6240. \******************************/
  6241. /*! exports provided: Image */
  6242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6243. "use strict";
  6244. __webpack_require__.r(__webpack_exports__);
  6245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6246. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6247. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  6248. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6249. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6250. /**
  6251. * Class used to create 2D images
  6252. */
  6253. var Image = /** @class */ (function (_super) {
  6254. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6255. /**
  6256. * Creates a new Image
  6257. * @param name defines the control name
  6258. * @param url defines the image url
  6259. */
  6260. function Image(name, url) {
  6261. if (url === void 0) { url = null; }
  6262. var _this = _super.call(this, name) || this;
  6263. _this.name = name;
  6264. _this._workingCanvas = null;
  6265. _this._loaded = false;
  6266. _this._stretch = Image.STRETCH_FILL;
  6267. _this._autoScale = false;
  6268. _this._sourceLeft = 0;
  6269. _this._sourceTop = 0;
  6270. _this._sourceWidth = 0;
  6271. _this._sourceHeight = 0;
  6272. _this._svgAttributesComputationCompleted = false;
  6273. _this._isSVG = false;
  6274. _this._cellWidth = 0;
  6275. _this._cellHeight = 0;
  6276. _this._cellId = -1;
  6277. _this._populateNinePatchSlicesFromImage = false;
  6278. /**
  6279. * Observable notified when the content is loaded
  6280. */
  6281. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6282. /**
  6283. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6284. */
  6285. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6286. _this.source = url;
  6287. return _this;
  6288. }
  6289. Object.defineProperty(Image.prototype, "isLoaded", {
  6290. /**
  6291. * Gets a boolean indicating that the content is loaded
  6292. */
  6293. get: function () {
  6294. return this._loaded;
  6295. },
  6296. enumerable: true,
  6297. configurable: true
  6298. });
  6299. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6300. /**
  6301. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6302. */
  6303. get: function () {
  6304. return this._populateNinePatchSlicesFromImage;
  6305. },
  6306. set: function (value) {
  6307. if (this._populateNinePatchSlicesFromImage === value) {
  6308. return;
  6309. }
  6310. this._populateNinePatchSlicesFromImage = value;
  6311. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6312. this._extractNinePatchSliceDataFromImage();
  6313. }
  6314. },
  6315. enumerable: true,
  6316. configurable: true
  6317. });
  6318. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6319. /**
  6320. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6321. * Beware using this as this will comsume more memory as the image has to be stored twice
  6322. */
  6323. get: function () {
  6324. return this._detectPointerOnOpaqueOnly;
  6325. },
  6326. set: function (value) {
  6327. if (this._detectPointerOnOpaqueOnly === value) {
  6328. return;
  6329. }
  6330. this._detectPointerOnOpaqueOnly = value;
  6331. },
  6332. enumerable: true,
  6333. configurable: true
  6334. });
  6335. Object.defineProperty(Image.prototype, "sliceLeft", {
  6336. /**
  6337. * Gets or sets the left value for slicing (9-patch)
  6338. */
  6339. get: function () {
  6340. return this._sliceLeft;
  6341. },
  6342. set: function (value) {
  6343. if (this._sliceLeft === value) {
  6344. return;
  6345. }
  6346. this._sliceLeft = value;
  6347. this._markAsDirty();
  6348. },
  6349. enumerable: true,
  6350. configurable: true
  6351. });
  6352. Object.defineProperty(Image.prototype, "sliceRight", {
  6353. /**
  6354. * Gets or sets the right value for slicing (9-patch)
  6355. */
  6356. get: function () {
  6357. return this._sliceRight;
  6358. },
  6359. set: function (value) {
  6360. if (this._sliceRight === value) {
  6361. return;
  6362. }
  6363. this._sliceRight = value;
  6364. this._markAsDirty();
  6365. },
  6366. enumerable: true,
  6367. configurable: true
  6368. });
  6369. Object.defineProperty(Image.prototype, "sliceTop", {
  6370. /**
  6371. * Gets or sets the top value for slicing (9-patch)
  6372. */
  6373. get: function () {
  6374. return this._sliceTop;
  6375. },
  6376. set: function (value) {
  6377. if (this._sliceTop === value) {
  6378. return;
  6379. }
  6380. this._sliceTop = value;
  6381. this._markAsDirty();
  6382. },
  6383. enumerable: true,
  6384. configurable: true
  6385. });
  6386. Object.defineProperty(Image.prototype, "sliceBottom", {
  6387. /**
  6388. * Gets or sets the bottom value for slicing (9-patch)
  6389. */
  6390. get: function () {
  6391. return this._sliceBottom;
  6392. },
  6393. set: function (value) {
  6394. if (this._sliceBottom === value) {
  6395. return;
  6396. }
  6397. this._sliceBottom = value;
  6398. this._markAsDirty();
  6399. },
  6400. enumerable: true,
  6401. configurable: true
  6402. });
  6403. Object.defineProperty(Image.prototype, "sourceLeft", {
  6404. /**
  6405. * Gets or sets the left coordinate in the source image
  6406. */
  6407. get: function () {
  6408. return this._sourceLeft;
  6409. },
  6410. set: function (value) {
  6411. if (this._sourceLeft === value) {
  6412. return;
  6413. }
  6414. this._sourceLeft = value;
  6415. this._markAsDirty();
  6416. },
  6417. enumerable: true,
  6418. configurable: true
  6419. });
  6420. Object.defineProperty(Image.prototype, "sourceTop", {
  6421. /**
  6422. * Gets or sets the top coordinate in the source image
  6423. */
  6424. get: function () {
  6425. return this._sourceTop;
  6426. },
  6427. set: function (value) {
  6428. if (this._sourceTop === value) {
  6429. return;
  6430. }
  6431. this._sourceTop = value;
  6432. this._markAsDirty();
  6433. },
  6434. enumerable: true,
  6435. configurable: true
  6436. });
  6437. Object.defineProperty(Image.prototype, "sourceWidth", {
  6438. /**
  6439. * Gets or sets the width to capture in the source image
  6440. */
  6441. get: function () {
  6442. return this._sourceWidth;
  6443. },
  6444. set: function (value) {
  6445. if (this._sourceWidth === value) {
  6446. return;
  6447. }
  6448. this._sourceWidth = value;
  6449. this._markAsDirty();
  6450. },
  6451. enumerable: true,
  6452. configurable: true
  6453. });
  6454. Object.defineProperty(Image.prototype, "sourceHeight", {
  6455. /**
  6456. * Gets or sets the height to capture in the source image
  6457. */
  6458. get: function () {
  6459. return this._sourceHeight;
  6460. },
  6461. set: function (value) {
  6462. if (this._sourceHeight === value) {
  6463. return;
  6464. }
  6465. this._sourceHeight = value;
  6466. this._markAsDirty();
  6467. },
  6468. enumerable: true,
  6469. configurable: true
  6470. });
  6471. Object.defineProperty(Image.prototype, "isSVG", {
  6472. /** Indicates if the format of the image is SVG */
  6473. get: function () {
  6474. return this._isSVG;
  6475. },
  6476. enumerable: true,
  6477. configurable: true
  6478. });
  6479. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6480. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6481. get: function () {
  6482. return this._svgAttributesComputationCompleted;
  6483. },
  6484. enumerable: true,
  6485. configurable: true
  6486. });
  6487. Object.defineProperty(Image.prototype, "autoScale", {
  6488. /**
  6489. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6490. * @see http://doc.babylonjs.com/how_to/gui#image
  6491. */
  6492. get: function () {
  6493. return this._autoScale;
  6494. },
  6495. set: function (value) {
  6496. if (this._autoScale === value) {
  6497. return;
  6498. }
  6499. this._autoScale = value;
  6500. if (value && this._loaded) {
  6501. this.synchronizeSizeWithContent();
  6502. }
  6503. },
  6504. enumerable: true,
  6505. configurable: true
  6506. });
  6507. Object.defineProperty(Image.prototype, "stretch", {
  6508. /** Gets or sets the streching mode used by the image */
  6509. get: function () {
  6510. return this._stretch;
  6511. },
  6512. set: function (value) {
  6513. if (this._stretch === value) {
  6514. return;
  6515. }
  6516. this._stretch = value;
  6517. this._markAsDirty();
  6518. },
  6519. enumerable: true,
  6520. configurable: true
  6521. });
  6522. /** @hidden */
  6523. Image.prototype._rotate90 = function (n, preserveProperties) {
  6524. if (preserveProperties === void 0) { preserveProperties = false; }
  6525. var canvas = document.createElement('canvas');
  6526. var context = canvas.getContext('2d');
  6527. var width = this._domImage.width;
  6528. var height = this._domImage.height;
  6529. canvas.width = height;
  6530. canvas.height = width;
  6531. context.translate(canvas.width / 2, canvas.height / 2);
  6532. context.rotate(n * Math.PI / 2);
  6533. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6534. var dataUrl = canvas.toDataURL("image/jpg");
  6535. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6536. if (preserveProperties) {
  6537. rotatedImage._stretch = this._stretch;
  6538. rotatedImage._autoScale = this._autoScale;
  6539. rotatedImage._cellId = this._cellId;
  6540. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6541. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6542. }
  6543. this._handleRotationForSVGImage(this, rotatedImage, n);
  6544. return rotatedImage;
  6545. };
  6546. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6547. var _this = this;
  6548. if (!srcImage._isSVG) {
  6549. return;
  6550. }
  6551. if (srcImage._svgAttributesComputationCompleted) {
  6552. this._rotate90SourceProperties(srcImage, dstImage, n);
  6553. this._markAsDirty();
  6554. }
  6555. else {
  6556. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6557. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6558. _this._markAsDirty();
  6559. });
  6560. }
  6561. };
  6562. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6563. var _a, _b;
  6564. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6565. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6566. if (n != 0) {
  6567. var mult = n < 0 ? -1 : 1;
  6568. n = n % 4;
  6569. for (var i = 0; i < Math.abs(n); ++i) {
  6570. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6571. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6572. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6573. if (n < 0) {
  6574. dstTop -= dstHeight;
  6575. }
  6576. else {
  6577. dstLeft -= dstWidth;
  6578. }
  6579. srcLeft = dstLeft;
  6580. srcTop = dstTop;
  6581. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6582. }
  6583. }
  6584. dstImage.sourceLeft = dstLeft;
  6585. dstImage.sourceTop = dstTop;
  6586. dstImage.sourceWidth = dstWidth;
  6587. dstImage.sourceHeight = dstHeight;
  6588. };
  6589. Object.defineProperty(Image.prototype, "domImage", {
  6590. get: function () {
  6591. return this._domImage;
  6592. },
  6593. /**
  6594. * Gets or sets the internal DOM image used to render the control
  6595. */
  6596. set: function (value) {
  6597. var _this = this;
  6598. this._domImage = value;
  6599. this._loaded = false;
  6600. if (this._domImage.width) {
  6601. this._onImageLoaded();
  6602. }
  6603. else {
  6604. this._domImage.onload = function () {
  6605. _this._onImageLoaded();
  6606. };
  6607. }
  6608. },
  6609. enumerable: true,
  6610. configurable: true
  6611. });
  6612. Image.prototype._onImageLoaded = function () {
  6613. this._imageWidth = this._domImage.width;
  6614. this._imageHeight = this._domImage.height;
  6615. this._loaded = true;
  6616. if (this._populateNinePatchSlicesFromImage) {
  6617. this._extractNinePatchSliceDataFromImage();
  6618. }
  6619. if (this._autoScale) {
  6620. this.synchronizeSizeWithContent();
  6621. }
  6622. this.onImageLoadedObservable.notifyObservers(this);
  6623. this._markAsDirty();
  6624. };
  6625. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6626. if (!this._workingCanvas) {
  6627. this._workingCanvas = document.createElement('canvas');
  6628. }
  6629. var canvas = this._workingCanvas;
  6630. var context = canvas.getContext('2d');
  6631. var width = this._domImage.width;
  6632. var height = this._domImage.height;
  6633. canvas.width = width;
  6634. canvas.height = height;
  6635. context.drawImage(this._domImage, 0, 0, width, height);
  6636. var imageData = context.getImageData(0, 0, width, height);
  6637. // Left and right
  6638. this._sliceLeft = -1;
  6639. this._sliceRight = -1;
  6640. for (var x = 0; x < width; x++) {
  6641. var alpha = imageData.data[x * 4 + 3];
  6642. if (alpha > 127 && this._sliceLeft === -1) {
  6643. this._sliceLeft = x;
  6644. continue;
  6645. }
  6646. if (alpha < 127 && this._sliceLeft > -1) {
  6647. this._sliceRight = x;
  6648. break;
  6649. }
  6650. }
  6651. // top and bottom
  6652. this._sliceTop = -1;
  6653. this._sliceBottom = -1;
  6654. for (var y = 0; y < height; y++) {
  6655. var alpha = imageData.data[y * width * 4 + 3];
  6656. if (alpha > 127 && this._sliceTop === -1) {
  6657. this._sliceTop = y;
  6658. continue;
  6659. }
  6660. if (alpha < 127 && this._sliceTop > -1) {
  6661. this._sliceBottom = y;
  6662. break;
  6663. }
  6664. }
  6665. };
  6666. Object.defineProperty(Image.prototype, "source", {
  6667. /**
  6668. * Gets or sets image source url
  6669. */
  6670. set: function (value) {
  6671. var _this = this;
  6672. if (this._source === value) {
  6673. return;
  6674. }
  6675. this._loaded = false;
  6676. this._source = value;
  6677. if (value) {
  6678. value = this._svgCheck(value);
  6679. }
  6680. this._domImage = document.createElement("img");
  6681. this._domImage.onload = function () {
  6682. _this._onImageLoaded();
  6683. };
  6684. if (value) {
  6685. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6686. this._domImage.src = value;
  6687. }
  6688. },
  6689. enumerable: true,
  6690. configurable: true
  6691. });
  6692. /**
  6693. * Checks for svg document with icon id present
  6694. */
  6695. Image.prototype._svgCheck = function (value) {
  6696. var _this = this;
  6697. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6698. this._isSVG = true;
  6699. var svgsrc = value.split('#')[0];
  6700. var elemid = value.split('#')[1];
  6701. // check if object alr exist in document
  6702. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6703. if (svgExist) {
  6704. var svgDoc = svgExist.contentDocument;
  6705. // get viewbox width and height, get svg document width and height in px
  6706. if (svgDoc && svgDoc.documentElement) {
  6707. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6708. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6709. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6710. var elem = svgDoc.getElementById(elemid);
  6711. if (elem && vb && docwidth && docheight) {
  6712. this._getSVGAttribs(svgExist, elemid);
  6713. return value;
  6714. }
  6715. }
  6716. // wait for object to load
  6717. svgExist.addEventListener("load", function () {
  6718. _this._getSVGAttribs(svgExist, elemid);
  6719. });
  6720. }
  6721. else {
  6722. // create document object
  6723. var svgImage = document.createElement("object");
  6724. svgImage.data = svgsrc;
  6725. svgImage.type = "image/svg+xml";
  6726. svgImage.width = "0%";
  6727. svgImage.height = "0%";
  6728. document.body.appendChild(svgImage);
  6729. // when the object has loaded, get the element attribs
  6730. svgImage.onload = function () {
  6731. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6732. if (svgobj) {
  6733. _this._getSVGAttribs(svgobj, elemid);
  6734. }
  6735. };
  6736. }
  6737. return svgsrc;
  6738. }
  6739. else {
  6740. return value;
  6741. }
  6742. };
  6743. /**
  6744. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6745. * given external svg file and icon id
  6746. */
  6747. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6748. var svgDoc = svgsrc.contentDocument;
  6749. // get viewbox width and height, get svg document width and height in px
  6750. if (svgDoc && svgDoc.documentElement) {
  6751. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6752. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6753. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6754. // get element bbox and matrix transform
  6755. var elem = svgDoc.getElementById(elemid);
  6756. if (vb && docwidth && docheight && elem) {
  6757. var vb_width = Number(vb.split(" ")[2]);
  6758. var vb_height = Number(vb.split(" ")[3]);
  6759. var elem_bbox = elem.getBBox();
  6760. var elem_matrix_a = 1;
  6761. var elem_matrix_d = 1;
  6762. var elem_matrix_e = 0;
  6763. var elem_matrix_f = 0;
  6764. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6765. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6766. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6767. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6768. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6769. }
  6770. // compute source coordinates and dimensions
  6771. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6772. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6773. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6774. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6775. this._svgAttributesComputationCompleted = true;
  6776. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6777. }
  6778. }
  6779. };
  6780. Object.defineProperty(Image.prototype, "cellWidth", {
  6781. /**
  6782. * Gets or sets the cell width to use when animation sheet is enabled
  6783. * @see http://doc.babylonjs.com/how_to/gui#image
  6784. */
  6785. get: function () {
  6786. return this._cellWidth;
  6787. },
  6788. set: function (value) {
  6789. if (this._cellWidth === value) {
  6790. return;
  6791. }
  6792. this._cellWidth = value;
  6793. this._markAsDirty();
  6794. },
  6795. enumerable: true,
  6796. configurable: true
  6797. });
  6798. Object.defineProperty(Image.prototype, "cellHeight", {
  6799. /**
  6800. * Gets or sets the cell height to use when animation sheet is enabled
  6801. * @see http://doc.babylonjs.com/how_to/gui#image
  6802. */
  6803. get: function () {
  6804. return this._cellHeight;
  6805. },
  6806. set: function (value) {
  6807. if (this._cellHeight === value) {
  6808. return;
  6809. }
  6810. this._cellHeight = value;
  6811. this._markAsDirty();
  6812. },
  6813. enumerable: true,
  6814. configurable: true
  6815. });
  6816. Object.defineProperty(Image.prototype, "cellId", {
  6817. /**
  6818. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6819. * @see http://doc.babylonjs.com/how_to/gui#image
  6820. */
  6821. get: function () {
  6822. return this._cellId;
  6823. },
  6824. set: function (value) {
  6825. if (this._cellId === value) {
  6826. return;
  6827. }
  6828. this._cellId = value;
  6829. this._markAsDirty();
  6830. },
  6831. enumerable: true,
  6832. configurable: true
  6833. });
  6834. /**
  6835. * Tests if a given coordinates belong to the current control
  6836. * @param x defines x coordinate to test
  6837. * @param y defines y coordinate to test
  6838. * @returns true if the coordinates are inside the control
  6839. */
  6840. Image.prototype.contains = function (x, y) {
  6841. if (!_super.prototype.contains.call(this, x, y)) {
  6842. return false;
  6843. }
  6844. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6845. return true;
  6846. }
  6847. var canvas = this._workingCanvas;
  6848. var context = canvas.getContext("2d");
  6849. var width = this._currentMeasure.width | 0;
  6850. var height = this._currentMeasure.height | 0;
  6851. var imageData = context.getImageData(0, 0, width, height).data;
  6852. x = (x - this._currentMeasure.left) | 0;
  6853. y = (y - this._currentMeasure.top) | 0;
  6854. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6855. return pickedPixel > 0;
  6856. };
  6857. Image.prototype._getTypeName = function () {
  6858. return "Image";
  6859. };
  6860. /** Force the control to synchronize with its content */
  6861. Image.prototype.synchronizeSizeWithContent = function () {
  6862. if (!this._loaded) {
  6863. return;
  6864. }
  6865. this.width = this._domImage.width + "px";
  6866. this.height = this._domImage.height + "px";
  6867. };
  6868. Image.prototype._processMeasures = function (parentMeasure, context) {
  6869. if (this._loaded) {
  6870. switch (this._stretch) {
  6871. case Image.STRETCH_NONE:
  6872. break;
  6873. case Image.STRETCH_FILL:
  6874. break;
  6875. case Image.STRETCH_UNIFORM:
  6876. break;
  6877. case Image.STRETCH_NINE_PATCH:
  6878. break;
  6879. case Image.STRETCH_EXTEND:
  6880. if (this._autoScale) {
  6881. this.synchronizeSizeWithContent();
  6882. }
  6883. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6884. this.parent.adaptWidthToChildren = true;
  6885. this.parent.adaptHeightToChildren = true;
  6886. }
  6887. break;
  6888. }
  6889. }
  6890. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6891. };
  6892. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6893. if (!this._detectPointerOnOpaqueOnly) {
  6894. return;
  6895. }
  6896. if (!this._workingCanvas) {
  6897. this._workingCanvas = document.createElement('canvas');
  6898. }
  6899. var canvas = this._workingCanvas;
  6900. var width = this._currentMeasure.width;
  6901. var height = this._currentMeasure.height;
  6902. var context = canvas.getContext("2d");
  6903. canvas.width = width;
  6904. canvas.height = height;
  6905. context.clearRect(0, 0, width, height);
  6906. };
  6907. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6908. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6909. if (!this._detectPointerOnOpaqueOnly) {
  6910. return;
  6911. }
  6912. var canvas = this._workingCanvas;
  6913. context = canvas.getContext("2d");
  6914. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6915. };
  6916. Image.prototype._draw = function (context) {
  6917. context.save();
  6918. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6919. context.shadowColor = this.shadowColor;
  6920. context.shadowBlur = this.shadowBlur;
  6921. context.shadowOffsetX = this.shadowOffsetX;
  6922. context.shadowOffsetY = this.shadowOffsetY;
  6923. }
  6924. var x, y, width, height;
  6925. if (this.cellId == -1) {
  6926. x = this._sourceLeft;
  6927. y = this._sourceTop;
  6928. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6929. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6930. }
  6931. else {
  6932. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6933. var column = (this.cellId / rowCount) >> 0;
  6934. var row = this.cellId % rowCount;
  6935. x = this.cellWidth * row;
  6936. y = this.cellHeight * column;
  6937. width = this.cellWidth;
  6938. height = this.cellHeight;
  6939. }
  6940. this._prepareWorkingCanvasForOpaqueDetection();
  6941. this._applyStates(context);
  6942. if (this._loaded) {
  6943. switch (this._stretch) {
  6944. case Image.STRETCH_NONE:
  6945. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6946. break;
  6947. case Image.STRETCH_FILL:
  6948. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6949. break;
  6950. case Image.STRETCH_UNIFORM:
  6951. var hRatio = this._currentMeasure.width / width;
  6952. var vRatio = this._currentMeasure.height / height;
  6953. var ratio = Math.min(hRatio, vRatio);
  6954. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6955. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6956. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6957. break;
  6958. case Image.STRETCH_EXTEND:
  6959. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6960. break;
  6961. case Image.STRETCH_NINE_PATCH:
  6962. this._renderNinePatch(context);
  6963. break;
  6964. }
  6965. }
  6966. context.restore();
  6967. };
  6968. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6969. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6970. };
  6971. Image.prototype._renderNinePatch = function (context) {
  6972. var height = this._imageHeight;
  6973. var leftWidth = this._sliceLeft;
  6974. var topHeight = this._sliceTop;
  6975. var bottomHeight = this._imageHeight - this._sliceBottom;
  6976. var rightWidth = this._imageWidth - this._sliceRight;
  6977. var left = 0;
  6978. var top = 0;
  6979. if (this._populateNinePatchSlicesFromImage) {
  6980. left = 1;
  6981. top = 1;
  6982. height -= 2;
  6983. leftWidth -= 1;
  6984. topHeight -= 1;
  6985. bottomHeight -= 1;
  6986. rightWidth -= 1;
  6987. }
  6988. var centerWidth = this._sliceRight - this._sliceLeft;
  6989. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  6990. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6991. // Corners
  6992. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6993. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6994. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6995. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6996. // Center
  6997. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  6998. // Borders
  6999. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7000. 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);
  7001. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  7002. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  7003. };
  7004. Image.prototype.dispose = function () {
  7005. _super.prototype.dispose.call(this);
  7006. this.onImageLoadedObservable.clear();
  7007. this.onSVGAttributesComputedObservable.clear();
  7008. };
  7009. // Static
  7010. /** STRETCH_NONE */
  7011. Image.STRETCH_NONE = 0;
  7012. /** STRETCH_FILL */
  7013. Image.STRETCH_FILL = 1;
  7014. /** STRETCH_UNIFORM */
  7015. Image.STRETCH_UNIFORM = 2;
  7016. /** STRETCH_EXTEND */
  7017. Image.STRETCH_EXTEND = 3;
  7018. /** NINE_PATCH */
  7019. Image.STRETCH_NINE_PATCH = 4;
  7020. return Image;
  7021. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7022. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7023. /***/ }),
  7024. /***/ "./2D/controls/index.ts":
  7025. /*!******************************!*\
  7026. !*** ./2D/controls/index.ts ***!
  7027. \******************************/
  7028. /*! 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 */
  7029. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7030. "use strict";
  7031. __webpack_require__.r(__webpack_exports__);
  7032. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7034. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7036. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7038. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7040. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7042. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7044. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  7046. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  7048. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  7050. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  7052. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  7054. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  7056. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  7058. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  7060. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  7062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  7063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  7064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  7065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  7066. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  7068. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  7070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  7071. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  7073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  7074. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  7076. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  7078. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  7080. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  7082. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  7084. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  7086. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  7088. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  7090. /***/ }),
  7091. /***/ "./2D/controls/inputPassword.ts":
  7092. /*!**************************************!*\
  7093. !*** ./2D/controls/inputPassword.ts ***!
  7094. \**************************************/
  7095. /*! exports provided: InputPassword */
  7096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7097. "use strict";
  7098. __webpack_require__.r(__webpack_exports__);
  7099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7100. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7101. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7102. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  7103. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7104. /**
  7105. * Class used to create a password control
  7106. */
  7107. var InputPassword = /** @class */ (function (_super) {
  7108. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7109. function InputPassword() {
  7110. return _super !== null && _super.apply(this, arguments) || this;
  7111. }
  7112. InputPassword.prototype._beforeRenderText = function (text) {
  7113. var txt = "";
  7114. for (var i = 0; i < text.length; i++) {
  7115. txt += "\u2022";
  7116. }
  7117. return txt;
  7118. };
  7119. return InputPassword;
  7120. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7121. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7122. /***/ }),
  7123. /***/ "./2D/controls/inputText.ts":
  7124. /*!**********************************!*\
  7125. !*** ./2D/controls/inputText.ts ***!
  7126. \**********************************/
  7127. /*! exports provided: InputText */
  7128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7129. "use strict";
  7130. __webpack_require__.r(__webpack_exports__);
  7131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7132. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7133. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  7134. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7135. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7136. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7137. /**
  7138. * Class used to create input text control
  7139. */
  7140. var InputText = /** @class */ (function (_super) {
  7141. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7142. /**
  7143. * Creates a new InputText
  7144. * @param name defines the control name
  7145. * @param text defines the text of the control
  7146. */
  7147. function InputText(name, text) {
  7148. if (text === void 0) { text = ""; }
  7149. var _this = _super.call(this, name) || this;
  7150. _this.name = name;
  7151. _this._text = "";
  7152. _this._placeholderText = "";
  7153. _this._background = "#222222";
  7154. _this._focusedBackground = "#000000";
  7155. _this._focusedColor = "white";
  7156. _this._placeholderColor = "gray";
  7157. _this._thickness = 1;
  7158. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7159. _this._autoStretchWidth = true;
  7160. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7161. _this._isFocused = false;
  7162. _this._blinkIsEven = false;
  7163. _this._cursorOffset = 0;
  7164. _this._deadKey = false;
  7165. _this._addKey = true;
  7166. _this._currentKey = "";
  7167. _this._isTextHighlightOn = false;
  7168. _this._textHighlightColor = "#d5e0ff";
  7169. _this._highligherOpacity = 0.4;
  7170. _this._highlightedText = "";
  7171. _this._startHighlightIndex = 0;
  7172. _this._endHighlightIndex = 0;
  7173. _this._cursorIndex = -1;
  7174. _this._onFocusSelectAll = false;
  7175. _this._isPointerDown = false;
  7176. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7177. _this.promptMessage = "Please enter text:";
  7178. /** Force disable prompt on mobile device */
  7179. _this.disableMobilePrompt = false;
  7180. /** Observable raised when the text changes */
  7181. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7182. /** Observable raised just before an entered character is to be added */
  7183. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7184. /** Observable raised when the control gets the focus */
  7185. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7186. /** Observable raised when the control loses the focus */
  7187. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7188. /**Observable raised when the text is highlighted */
  7189. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7190. /**Observable raised when copy event is triggered */
  7191. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7192. /** Observable raised when cut event is triggered */
  7193. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7194. /** Observable raised when paste event is triggered */
  7195. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7196. /** Observable raised when a key event was processed */
  7197. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7198. _this.text = text;
  7199. _this.isPointerBlocker = true;
  7200. return _this;
  7201. }
  7202. Object.defineProperty(InputText.prototype, "maxWidth", {
  7203. /** Gets or sets the maximum width allowed by the control */
  7204. get: function () {
  7205. return this._maxWidth.toString(this._host);
  7206. },
  7207. set: function (value) {
  7208. if (this._maxWidth.toString(this._host) === value) {
  7209. return;
  7210. }
  7211. if (this._maxWidth.fromString(value)) {
  7212. this._markAsDirty();
  7213. }
  7214. },
  7215. enumerable: true,
  7216. configurable: true
  7217. });
  7218. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7219. /** Gets the maximum width allowed by the control in pixels */
  7220. get: function () {
  7221. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7222. },
  7223. enumerable: true,
  7224. configurable: true
  7225. });
  7226. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7227. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7228. get: function () {
  7229. return this._highligherOpacity;
  7230. },
  7231. set: function (value) {
  7232. if (this._highligherOpacity === value) {
  7233. return;
  7234. }
  7235. this._highligherOpacity = value;
  7236. this._markAsDirty();
  7237. },
  7238. enumerable: true,
  7239. configurable: true
  7240. });
  7241. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7242. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7243. get: function () {
  7244. return this._onFocusSelectAll;
  7245. },
  7246. set: function (value) {
  7247. if (this._onFocusSelectAll === value) {
  7248. return;
  7249. }
  7250. this._onFocusSelectAll = value;
  7251. this._markAsDirty();
  7252. },
  7253. enumerable: true,
  7254. configurable: true
  7255. });
  7256. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7257. /** Gets or sets the text hightlight color */
  7258. get: function () {
  7259. return this._textHighlightColor;
  7260. },
  7261. set: function (value) {
  7262. if (this._textHighlightColor === value) {
  7263. return;
  7264. }
  7265. this._textHighlightColor = value;
  7266. this._markAsDirty();
  7267. },
  7268. enumerable: true,
  7269. configurable: true
  7270. });
  7271. Object.defineProperty(InputText.prototype, "margin", {
  7272. /** Gets or sets control margin */
  7273. get: function () {
  7274. return this._margin.toString(this._host);
  7275. },
  7276. set: function (value) {
  7277. if (this._margin.toString(this._host) === value) {
  7278. return;
  7279. }
  7280. if (this._margin.fromString(value)) {
  7281. this._markAsDirty();
  7282. }
  7283. },
  7284. enumerable: true,
  7285. configurable: true
  7286. });
  7287. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7288. /** Gets control margin in pixels */
  7289. get: function () {
  7290. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7291. },
  7292. enumerable: true,
  7293. configurable: true
  7294. });
  7295. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7296. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7297. get: function () {
  7298. return this._autoStretchWidth;
  7299. },
  7300. set: function (value) {
  7301. if (this._autoStretchWidth === value) {
  7302. return;
  7303. }
  7304. this._autoStretchWidth = value;
  7305. this._markAsDirty();
  7306. },
  7307. enumerable: true,
  7308. configurable: true
  7309. });
  7310. Object.defineProperty(InputText.prototype, "thickness", {
  7311. /** Gets or sets border thickness */
  7312. get: function () {
  7313. return this._thickness;
  7314. },
  7315. set: function (value) {
  7316. if (this._thickness === value) {
  7317. return;
  7318. }
  7319. this._thickness = value;
  7320. this._markAsDirty();
  7321. },
  7322. enumerable: true,
  7323. configurable: true
  7324. });
  7325. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7326. /** Gets or sets the background color when focused */
  7327. get: function () {
  7328. return this._focusedBackground;
  7329. },
  7330. set: function (value) {
  7331. if (this._focusedBackground === value) {
  7332. return;
  7333. }
  7334. this._focusedBackground = value;
  7335. this._markAsDirty();
  7336. },
  7337. enumerable: true,
  7338. configurable: true
  7339. });
  7340. Object.defineProperty(InputText.prototype, "focusedColor", {
  7341. /** Gets or sets the background color when focused */
  7342. get: function () {
  7343. return this._focusedColor;
  7344. },
  7345. set: function (value) {
  7346. if (this._focusedColor === value) {
  7347. return;
  7348. }
  7349. this._focusedColor = value;
  7350. this._markAsDirty();
  7351. },
  7352. enumerable: true,
  7353. configurable: true
  7354. });
  7355. Object.defineProperty(InputText.prototype, "background", {
  7356. /** Gets or sets the background color */
  7357. get: function () {
  7358. return this._background;
  7359. },
  7360. set: function (value) {
  7361. if (this._background === value) {
  7362. return;
  7363. }
  7364. this._background = value;
  7365. this._markAsDirty();
  7366. },
  7367. enumerable: true,
  7368. configurable: true
  7369. });
  7370. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7371. /** Gets or sets the placeholder color */
  7372. get: function () {
  7373. return this._placeholderColor;
  7374. },
  7375. set: function (value) {
  7376. if (this._placeholderColor === value) {
  7377. return;
  7378. }
  7379. this._placeholderColor = value;
  7380. this._markAsDirty();
  7381. },
  7382. enumerable: true,
  7383. configurable: true
  7384. });
  7385. Object.defineProperty(InputText.prototype, "placeholderText", {
  7386. /** Gets or sets the text displayed when the control is empty */
  7387. get: function () {
  7388. return this._placeholderText;
  7389. },
  7390. set: function (value) {
  7391. if (this._placeholderText === value) {
  7392. return;
  7393. }
  7394. this._placeholderText = value;
  7395. this._markAsDirty();
  7396. },
  7397. enumerable: true,
  7398. configurable: true
  7399. });
  7400. Object.defineProperty(InputText.prototype, "deadKey", {
  7401. /** Gets or sets the dead key flag */
  7402. get: function () {
  7403. return this._deadKey;
  7404. },
  7405. set: function (flag) {
  7406. this._deadKey = flag;
  7407. },
  7408. enumerable: true,
  7409. configurable: true
  7410. });
  7411. Object.defineProperty(InputText.prototype, "highlightedText", {
  7412. /** Gets or sets the highlight text */
  7413. get: function () {
  7414. return this._highlightedText;
  7415. },
  7416. set: function (text) {
  7417. if (this._highlightedText === text) {
  7418. return;
  7419. }
  7420. this._highlightedText = text;
  7421. this._markAsDirty();
  7422. },
  7423. enumerable: true,
  7424. configurable: true
  7425. });
  7426. Object.defineProperty(InputText.prototype, "addKey", {
  7427. /** Gets or sets if the current key should be added */
  7428. get: function () {
  7429. return this._addKey;
  7430. },
  7431. set: function (flag) {
  7432. this._addKey = flag;
  7433. },
  7434. enumerable: true,
  7435. configurable: true
  7436. });
  7437. Object.defineProperty(InputText.prototype, "currentKey", {
  7438. /** Gets or sets the value of the current key being entered */
  7439. get: function () {
  7440. return this._currentKey;
  7441. },
  7442. set: function (key) {
  7443. this._currentKey = key;
  7444. },
  7445. enumerable: true,
  7446. configurable: true
  7447. });
  7448. Object.defineProperty(InputText.prototype, "text", {
  7449. /** Gets or sets the text displayed in the control */
  7450. get: function () {
  7451. return this._text;
  7452. },
  7453. set: function (value) {
  7454. var valueAsString = value.toString(); // Forcing convertion
  7455. if (this._text === valueAsString) {
  7456. return;
  7457. }
  7458. this._text = valueAsString;
  7459. this._markAsDirty();
  7460. this.onTextChangedObservable.notifyObservers(this);
  7461. },
  7462. enumerable: true,
  7463. configurable: true
  7464. });
  7465. Object.defineProperty(InputText.prototype, "width", {
  7466. /** Gets or sets control width */
  7467. get: function () {
  7468. return this._width.toString(this._host);
  7469. },
  7470. set: function (value) {
  7471. if (this._width.toString(this._host) === value) {
  7472. return;
  7473. }
  7474. if (this._width.fromString(value)) {
  7475. this._markAsDirty();
  7476. }
  7477. this.autoStretchWidth = false;
  7478. },
  7479. enumerable: true,
  7480. configurable: true
  7481. });
  7482. /** @hidden */
  7483. InputText.prototype.onBlur = function () {
  7484. this._isFocused = false;
  7485. this._scrollLeft = null;
  7486. this._cursorOffset = 0;
  7487. clearTimeout(this._blinkTimeout);
  7488. this._markAsDirty();
  7489. this.onBlurObservable.notifyObservers(this);
  7490. this._host.unRegisterClipboardEvents();
  7491. if (this._onClipboardObserver) {
  7492. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7493. }
  7494. var scene = this._host.getScene();
  7495. if (this._onPointerDblTapObserver && scene) {
  7496. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7497. }
  7498. };
  7499. /** @hidden */
  7500. InputText.prototype.onFocus = function () {
  7501. var _this = this;
  7502. if (!this._isEnabled) {
  7503. return;
  7504. }
  7505. this._scrollLeft = null;
  7506. this._isFocused = true;
  7507. this._blinkIsEven = false;
  7508. this._cursorOffset = 0;
  7509. this._markAsDirty();
  7510. this.onFocusObservable.notifyObservers(this);
  7511. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7512. var value = prompt(this.promptMessage);
  7513. if (value !== null) {
  7514. this.text = value;
  7515. }
  7516. this._host.focusedControl = null;
  7517. return;
  7518. }
  7519. this._host.registerClipboardEvents();
  7520. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7521. // process clipboard event, can be configured.
  7522. switch (clipboardInfo.type) {
  7523. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7524. _this._onCopyText(clipboardInfo.event);
  7525. _this.onTextCopyObservable.notifyObservers(_this);
  7526. break;
  7527. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7528. _this._onCutText(clipboardInfo.event);
  7529. _this.onTextCutObservable.notifyObservers(_this);
  7530. break;
  7531. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7532. _this._onPasteText(clipboardInfo.event);
  7533. _this.onTextPasteObservable.notifyObservers(_this);
  7534. break;
  7535. default: return;
  7536. }
  7537. });
  7538. var scene = this._host.getScene();
  7539. if (scene) {
  7540. //register the pointer double tap event
  7541. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7542. if (!_this._isFocused) {
  7543. return;
  7544. }
  7545. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7546. _this._processDblClick(pointerInfo);
  7547. }
  7548. });
  7549. }
  7550. if (this._onFocusSelectAll) {
  7551. this._selectAllText();
  7552. }
  7553. };
  7554. InputText.prototype._getTypeName = function () {
  7555. return "InputText";
  7556. };
  7557. /**
  7558. * Function called to get the list of controls that should not steal the focus from this control
  7559. * @returns an array of controls
  7560. */
  7561. InputText.prototype.keepsFocusWith = function () {
  7562. if (!this._connectedVirtualKeyboard) {
  7563. return null;
  7564. }
  7565. return [this._connectedVirtualKeyboard];
  7566. };
  7567. /** @hidden */
  7568. InputText.prototype.processKey = function (keyCode, key, evt) {
  7569. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7570. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7571. return;
  7572. }
  7573. //select all
  7574. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7575. this._selectAllText();
  7576. evt.preventDefault();
  7577. return;
  7578. }
  7579. // Specific cases
  7580. switch (keyCode) {
  7581. case 32: //SPACE
  7582. key = " "; //ie11 key for space is "Spacebar"
  7583. break;
  7584. case 191: //SLASH
  7585. if (evt) {
  7586. evt.preventDefault();
  7587. }
  7588. break;
  7589. case 8: // BACKSPACE
  7590. if (this._text && this._text.length > 0) {
  7591. //delete the highlighted text
  7592. if (this._isTextHighlightOn) {
  7593. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7594. this._isTextHighlightOn = false;
  7595. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7596. this._blinkIsEven = false;
  7597. if (evt) {
  7598. evt.preventDefault();
  7599. }
  7600. return;
  7601. }
  7602. //delete single character
  7603. if (this._cursorOffset === 0) {
  7604. this.text = this._text.substr(0, this._text.length - 1);
  7605. }
  7606. else {
  7607. var deletePosition = this._text.length - this._cursorOffset;
  7608. if (deletePosition > 0) {
  7609. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7610. }
  7611. }
  7612. }
  7613. if (evt) {
  7614. evt.preventDefault();
  7615. }
  7616. return;
  7617. case 46: // DELETE
  7618. if (this._isTextHighlightOn) {
  7619. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7620. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7621. while (decrementor > 0 && this._cursorOffset > 0) {
  7622. this._cursorOffset--;
  7623. }
  7624. this._isTextHighlightOn = false;
  7625. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7626. if (evt) {
  7627. evt.preventDefault();
  7628. }
  7629. return;
  7630. }
  7631. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7632. var deletePosition = this._text.length - this._cursorOffset;
  7633. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7634. this._cursorOffset--;
  7635. }
  7636. if (evt) {
  7637. evt.preventDefault();
  7638. }
  7639. return;
  7640. case 13: // RETURN
  7641. this._host.focusedControl = null;
  7642. this._isTextHighlightOn = false;
  7643. return;
  7644. case 35: // END
  7645. this._cursorOffset = 0;
  7646. this._blinkIsEven = false;
  7647. this._isTextHighlightOn = false;
  7648. this._markAsDirty();
  7649. return;
  7650. case 36: // HOME
  7651. this._cursorOffset = this._text.length;
  7652. this._blinkIsEven = false;
  7653. this._isTextHighlightOn = false;
  7654. this._markAsDirty();
  7655. return;
  7656. case 37: // LEFT
  7657. this._cursorOffset++;
  7658. if (this._cursorOffset > this._text.length) {
  7659. this._cursorOffset = this._text.length;
  7660. }
  7661. if (evt && evt.shiftKey) {
  7662. // update the cursor
  7663. this._blinkIsEven = false;
  7664. // shift + ctrl/cmd + <-
  7665. if (evt.ctrlKey || evt.metaKey) {
  7666. if (!this._isTextHighlightOn) {
  7667. if (this._text.length === this._cursorOffset) {
  7668. return;
  7669. }
  7670. else {
  7671. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7672. }
  7673. }
  7674. this._startHighlightIndex = 0;
  7675. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7676. this._cursorOffset = this._text.length;
  7677. this._isTextHighlightOn = true;
  7678. this._markAsDirty();
  7679. return;
  7680. }
  7681. //store the starting point
  7682. if (!this._isTextHighlightOn) {
  7683. this._isTextHighlightOn = true;
  7684. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7685. }
  7686. //if text is already highlighted
  7687. else if (this._cursorIndex === -1) {
  7688. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7689. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7690. }
  7691. //set the highlight indexes
  7692. if (this._cursorIndex < this._cursorOffset) {
  7693. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7694. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7695. }
  7696. else if (this._cursorIndex > this._cursorOffset) {
  7697. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7698. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7699. }
  7700. else {
  7701. this._isTextHighlightOn = false;
  7702. }
  7703. this._markAsDirty();
  7704. return;
  7705. }
  7706. if (this._isTextHighlightOn) {
  7707. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7708. this._isTextHighlightOn = false;
  7709. }
  7710. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7711. this._cursorOffset = this.text.length;
  7712. evt.preventDefault();
  7713. }
  7714. this._blinkIsEven = false;
  7715. this._isTextHighlightOn = false;
  7716. this._cursorIndex = -1;
  7717. this._markAsDirty();
  7718. return;
  7719. case 39: // RIGHT
  7720. this._cursorOffset--;
  7721. if (this._cursorOffset < 0) {
  7722. this._cursorOffset = 0;
  7723. }
  7724. if (evt && evt.shiftKey) {
  7725. //update the cursor
  7726. this._blinkIsEven = false;
  7727. //shift + ctrl/cmd + ->
  7728. if (evt.ctrlKey || evt.metaKey) {
  7729. if (!this._isTextHighlightOn) {
  7730. if (this._cursorOffset === 0) {
  7731. return;
  7732. }
  7733. else {
  7734. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7735. }
  7736. }
  7737. this._endHighlightIndex = this._text.length;
  7738. this._isTextHighlightOn = true;
  7739. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7740. this._cursorOffset = 0;
  7741. this._markAsDirty();
  7742. return;
  7743. }
  7744. if (!this._isTextHighlightOn) {
  7745. this._isTextHighlightOn = true;
  7746. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7747. }
  7748. //if text is already highlighted
  7749. else if (this._cursorIndex === -1) {
  7750. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7751. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7752. }
  7753. //set the highlight indexes
  7754. if (this._cursorIndex < this._cursorOffset) {
  7755. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7756. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7757. }
  7758. else if (this._cursorIndex > this._cursorOffset) {
  7759. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7760. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7761. }
  7762. else {
  7763. this._isTextHighlightOn = false;
  7764. }
  7765. this._markAsDirty();
  7766. return;
  7767. }
  7768. if (this._isTextHighlightOn) {
  7769. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7770. this._isTextHighlightOn = false;
  7771. }
  7772. //ctr + ->
  7773. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7774. this._cursorOffset = 0;
  7775. evt.preventDefault();
  7776. }
  7777. this._blinkIsEven = false;
  7778. this._isTextHighlightOn = false;
  7779. this._cursorIndex = -1;
  7780. this._markAsDirty();
  7781. return;
  7782. case 222: // Dead
  7783. if (evt) {
  7784. evt.preventDefault();
  7785. }
  7786. this._cursorIndex = -1;
  7787. this.deadKey = true;
  7788. break;
  7789. }
  7790. // Printable characters
  7791. if (key &&
  7792. ((keyCode === -1) || // Direct access
  7793. (keyCode === 32) || // Space
  7794. (keyCode > 47 && keyCode < 64) || // Numbers
  7795. (keyCode > 64 && keyCode < 91) || // Letters
  7796. (keyCode > 159 && keyCode < 193) || // Special characters
  7797. (keyCode > 218 && keyCode < 223) || // Special characters
  7798. (keyCode > 95 && keyCode < 112))) { // Numpad
  7799. this._currentKey = key;
  7800. this.onBeforeKeyAddObservable.notifyObservers(this);
  7801. key = this._currentKey;
  7802. if (this._addKey) {
  7803. if (this._isTextHighlightOn) {
  7804. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7805. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7806. this._isTextHighlightOn = false;
  7807. this._blinkIsEven = false;
  7808. this._markAsDirty();
  7809. }
  7810. else if (this._cursorOffset === 0) {
  7811. this.text += key;
  7812. }
  7813. else {
  7814. var insertPosition = this._text.length - this._cursorOffset;
  7815. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7816. }
  7817. }
  7818. }
  7819. };
  7820. /** @hidden */
  7821. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7822. //update the cursor
  7823. this._blinkIsEven = false;
  7824. if (this._cursorIndex === -1) {
  7825. this._cursorIndex = offset;
  7826. }
  7827. else {
  7828. if (this._cursorIndex < this._cursorOffset) {
  7829. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7830. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7831. }
  7832. else if (this._cursorIndex > this._cursorOffset) {
  7833. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7834. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7835. }
  7836. else {
  7837. this._isTextHighlightOn = false;
  7838. this._markAsDirty();
  7839. return;
  7840. }
  7841. }
  7842. this._isTextHighlightOn = true;
  7843. this._markAsDirty();
  7844. };
  7845. /** @hidden */
  7846. InputText.prototype._processDblClick = function (evt) {
  7847. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7848. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7849. this._endHighlightIndex = this._startHighlightIndex;
  7850. var rWord = /\w+/g, moveLeft, moveRight;
  7851. do {
  7852. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7853. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7854. } while (moveLeft || moveRight);
  7855. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7856. this.onTextHighlightObservable.notifyObservers(this);
  7857. this._isTextHighlightOn = true;
  7858. this._clickedCoordinate = null;
  7859. this._blinkIsEven = true;
  7860. this._cursorIndex = -1;
  7861. this._markAsDirty();
  7862. };
  7863. /** @hidden */
  7864. InputText.prototype._selectAllText = function () {
  7865. this._blinkIsEven = true;
  7866. this._isTextHighlightOn = true;
  7867. this._startHighlightIndex = 0;
  7868. this._endHighlightIndex = this._text.length;
  7869. this._cursorOffset = this._text.length;
  7870. this._cursorIndex = -1;
  7871. this._markAsDirty();
  7872. };
  7873. /**
  7874. * Handles the keyboard event
  7875. * @param evt Defines the KeyboardEvent
  7876. */
  7877. InputText.prototype.processKeyboard = function (evt) {
  7878. // process pressed key
  7879. this.processKey(evt.keyCode, evt.key, evt);
  7880. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7881. };
  7882. /** @hidden */
  7883. InputText.prototype._onCopyText = function (ev) {
  7884. this._isTextHighlightOn = false;
  7885. //when write permission to clipbaord data is denied
  7886. try {
  7887. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7888. }
  7889. catch (_a) { } //pass
  7890. this._host.clipboardData = this._highlightedText;
  7891. };
  7892. /** @hidden */
  7893. InputText.prototype._onCutText = function (ev) {
  7894. if (!this._highlightedText) {
  7895. return;
  7896. }
  7897. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7898. this._isTextHighlightOn = false;
  7899. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7900. //when write permission to clipbaord data is denied
  7901. try {
  7902. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7903. }
  7904. catch (_a) { } //pass
  7905. this._host.clipboardData = this._highlightedText;
  7906. this._highlightedText = "";
  7907. };
  7908. /** @hidden */
  7909. InputText.prototype._onPasteText = function (ev) {
  7910. var data = "";
  7911. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7912. data = ev.clipboardData.getData("text/plain");
  7913. }
  7914. else {
  7915. //get the cached data; returns blank string by default
  7916. data = this._host.clipboardData;
  7917. }
  7918. var insertPosition = this._text.length - this._cursorOffset;
  7919. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7920. };
  7921. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7922. var _this = this;
  7923. context.save();
  7924. this._applyStates(context);
  7925. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7926. context.shadowColor = this.shadowColor;
  7927. context.shadowBlur = this.shadowBlur;
  7928. context.shadowOffsetX = this.shadowOffsetX;
  7929. context.shadowOffsetY = this.shadowOffsetY;
  7930. }
  7931. // Background
  7932. if (this._isFocused) {
  7933. if (this._focusedBackground) {
  7934. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7935. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7936. }
  7937. }
  7938. else if (this._background) {
  7939. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7940. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7941. }
  7942. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7943. context.shadowBlur = 0;
  7944. context.shadowOffsetX = 0;
  7945. context.shadowOffsetY = 0;
  7946. }
  7947. if (!this._fontOffset) {
  7948. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7949. }
  7950. // Text
  7951. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7952. if (this.color) {
  7953. context.fillStyle = this.color;
  7954. }
  7955. var text = this._beforeRenderText(this._text);
  7956. if (!this._isFocused && !this._text && this._placeholderText) {
  7957. text = this._placeholderText;
  7958. if (this._placeholderColor) {
  7959. context.fillStyle = this._placeholderColor;
  7960. }
  7961. }
  7962. this._textWidth = context.measureText(text).width;
  7963. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7964. if (this._autoStretchWidth) {
  7965. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7966. }
  7967. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7968. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7969. context.save();
  7970. context.beginPath();
  7971. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7972. context.clip();
  7973. if (this._isFocused && this._textWidth > availableWidth) {
  7974. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7975. if (!this._scrollLeft) {
  7976. this._scrollLeft = textLeft;
  7977. }
  7978. }
  7979. else {
  7980. this._scrollLeft = clipTextLeft;
  7981. }
  7982. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7983. // Cursor
  7984. if (this._isFocused) {
  7985. // Need to move cursor
  7986. if (this._clickedCoordinate) {
  7987. var rightPosition = this._scrollLeft + this._textWidth;
  7988. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7989. var currentSize = 0;
  7990. this._cursorOffset = 0;
  7991. var previousDist = 0;
  7992. do {
  7993. if (this._cursorOffset) {
  7994. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7995. }
  7996. this._cursorOffset++;
  7997. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7998. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7999. // Find closest move
  8000. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8001. this._cursorOffset--;
  8002. }
  8003. this._blinkIsEven = false;
  8004. this._clickedCoordinate = null;
  8005. }
  8006. // Render cursor
  8007. if (!this._blinkIsEven) {
  8008. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  8009. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8010. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8011. if (cursorLeft < clipTextLeft) {
  8012. this._scrollLeft += (clipTextLeft - cursorLeft);
  8013. cursorLeft = clipTextLeft;
  8014. this._markAsDirty();
  8015. }
  8016. else if (cursorLeft > clipTextLeft + availableWidth) {
  8017. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8018. cursorLeft = clipTextLeft + availableWidth;
  8019. this._markAsDirty();
  8020. }
  8021. if (!this._isTextHighlightOn) {
  8022. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8023. }
  8024. }
  8025. clearTimeout(this._blinkTimeout);
  8026. this._blinkTimeout = setTimeout(function () {
  8027. _this._blinkIsEven = !_this._blinkIsEven;
  8028. _this._markAsDirty();
  8029. }, 500);
  8030. //show the highlighted text
  8031. if (this._isTextHighlightOn) {
  8032. clearTimeout(this._blinkTimeout);
  8033. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  8034. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8035. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8036. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8037. if (highlightCursorLeft < clipTextLeft) {
  8038. width = width - (clipTextLeft - highlightCursorLeft);
  8039. if (!width) {
  8040. // when using left arrow on text.length > availableWidth;
  8041. // assigns the width of the first letter after clipTextLeft
  8042. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  8043. }
  8044. highlightCursorLeft = clipTextLeft;
  8045. }
  8046. //for transparancy
  8047. context.globalAlpha = this._highligherOpacity;
  8048. context.fillStyle = this._textHighlightColor;
  8049. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8050. context.globalAlpha = 1.0;
  8051. }
  8052. }
  8053. context.restore();
  8054. // Border
  8055. if (this._thickness) {
  8056. if (this._isFocused) {
  8057. if (this.focusedColor) {
  8058. context.strokeStyle = this.focusedColor;
  8059. }
  8060. }
  8061. else {
  8062. if (this.color) {
  8063. context.strokeStyle = this.color;
  8064. }
  8065. }
  8066. context.lineWidth = this._thickness;
  8067. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8068. }
  8069. context.restore();
  8070. };
  8071. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8072. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8073. return false;
  8074. }
  8075. this._clickedCoordinate = coordinates.x;
  8076. this._isTextHighlightOn = false;
  8077. this._highlightedText = "";
  8078. this._cursorIndex = -1;
  8079. this._isPointerDown = true;
  8080. this._host._capturingControl[pointerId] = this;
  8081. if (this._host.focusedControl === this) {
  8082. // Move cursor
  8083. clearTimeout(this._blinkTimeout);
  8084. this._markAsDirty();
  8085. return true;
  8086. }
  8087. if (!this._isEnabled) {
  8088. return false;
  8089. }
  8090. this._host.focusedControl = this;
  8091. return true;
  8092. };
  8093. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  8094. if (this._host.focusedControl === this && this._isPointerDown) {
  8095. this._clickedCoordinate = coordinates.x;
  8096. this._markAsDirty();
  8097. this._updateValueFromCursorIndex(this._cursorOffset);
  8098. }
  8099. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  8100. };
  8101. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8102. this._isPointerDown = false;
  8103. delete this._host._capturingControl[pointerId];
  8104. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8105. };
  8106. InputText.prototype._beforeRenderText = function (text) {
  8107. return text;
  8108. };
  8109. InputText.prototype.dispose = function () {
  8110. _super.prototype.dispose.call(this);
  8111. this.onBlurObservable.clear();
  8112. this.onFocusObservable.clear();
  8113. this.onTextChangedObservable.clear();
  8114. this.onTextCopyObservable.clear();
  8115. this.onTextCutObservable.clear();
  8116. this.onTextPasteObservable.clear();
  8117. this.onTextHighlightObservable.clear();
  8118. this.onKeyboardEventProcessedObservable.clear();
  8119. };
  8120. return InputText;
  8121. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8122. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8123. /***/ }),
  8124. /***/ "./2D/controls/line.ts":
  8125. /*!*****************************!*\
  8126. !*** ./2D/controls/line.ts ***!
  8127. \*****************************/
  8128. /*! exports provided: Line */
  8129. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8130. "use strict";
  8131. __webpack_require__.r(__webpack_exports__);
  8132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8133. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8134. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  8135. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8136. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8137. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8138. /** Class used to render 2D lines */
  8139. var Line = /** @class */ (function (_super) {
  8140. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8141. /**
  8142. * Creates a new Line
  8143. * @param name defines the control name
  8144. */
  8145. function Line(name) {
  8146. var _this = _super.call(this, name) || this;
  8147. _this.name = name;
  8148. _this._lineWidth = 1;
  8149. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8150. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8151. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8152. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8153. _this._dash = new Array();
  8154. _this._automaticSize = true;
  8155. _this.isHitTestVisible = false;
  8156. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8157. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8158. return _this;
  8159. }
  8160. Object.defineProperty(Line.prototype, "dash", {
  8161. /** Gets or sets the dash pattern */
  8162. get: function () {
  8163. return this._dash;
  8164. },
  8165. set: function (value) {
  8166. if (this._dash === value) {
  8167. return;
  8168. }
  8169. this._dash = value;
  8170. this._markAsDirty();
  8171. },
  8172. enumerable: true,
  8173. configurable: true
  8174. });
  8175. Object.defineProperty(Line.prototype, "connectedControl", {
  8176. /** Gets or sets the control connected with the line end */
  8177. get: function () {
  8178. return this._connectedControl;
  8179. },
  8180. set: function (value) {
  8181. var _this = this;
  8182. if (this._connectedControl === value) {
  8183. return;
  8184. }
  8185. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8186. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8187. this._connectedControlDirtyObserver = null;
  8188. }
  8189. if (value) {
  8190. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8191. }
  8192. this._connectedControl = value;
  8193. this._markAsDirty();
  8194. },
  8195. enumerable: true,
  8196. configurable: true
  8197. });
  8198. Object.defineProperty(Line.prototype, "x1", {
  8199. /** Gets or sets start coordinates on X axis */
  8200. get: function () {
  8201. return this._x1.toString(this._host);
  8202. },
  8203. set: function (value) {
  8204. if (this._x1.toString(this._host) === value) {
  8205. return;
  8206. }
  8207. if (this._x1.fromString(value)) {
  8208. this._markAsDirty();
  8209. }
  8210. },
  8211. enumerable: true,
  8212. configurable: true
  8213. });
  8214. Object.defineProperty(Line.prototype, "y1", {
  8215. /** Gets or sets start coordinates on Y axis */
  8216. get: function () {
  8217. return this._y1.toString(this._host);
  8218. },
  8219. set: function (value) {
  8220. if (this._y1.toString(this._host) === value) {
  8221. return;
  8222. }
  8223. if (this._y1.fromString(value)) {
  8224. this._markAsDirty();
  8225. }
  8226. },
  8227. enumerable: true,
  8228. configurable: true
  8229. });
  8230. Object.defineProperty(Line.prototype, "x2", {
  8231. /** Gets or sets end coordinates on X axis */
  8232. get: function () {
  8233. return this._x2.toString(this._host);
  8234. },
  8235. set: function (value) {
  8236. if (this._x2.toString(this._host) === value) {
  8237. return;
  8238. }
  8239. if (this._x2.fromString(value)) {
  8240. this._markAsDirty();
  8241. }
  8242. },
  8243. enumerable: true,
  8244. configurable: true
  8245. });
  8246. Object.defineProperty(Line.prototype, "y2", {
  8247. /** Gets or sets end coordinates on Y axis */
  8248. get: function () {
  8249. return this._y2.toString(this._host);
  8250. },
  8251. set: function (value) {
  8252. if (this._y2.toString(this._host) === value) {
  8253. return;
  8254. }
  8255. if (this._y2.fromString(value)) {
  8256. this._markAsDirty();
  8257. }
  8258. },
  8259. enumerable: true,
  8260. configurable: true
  8261. });
  8262. Object.defineProperty(Line.prototype, "lineWidth", {
  8263. /** Gets or sets line width */
  8264. get: function () {
  8265. return this._lineWidth;
  8266. },
  8267. set: function (value) {
  8268. if (this._lineWidth === value) {
  8269. return;
  8270. }
  8271. this._lineWidth = value;
  8272. this._markAsDirty();
  8273. },
  8274. enumerable: true,
  8275. configurable: true
  8276. });
  8277. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8278. /** Gets or sets horizontal alignment */
  8279. set: function (value) {
  8280. return;
  8281. },
  8282. enumerable: true,
  8283. configurable: true
  8284. });
  8285. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8286. /** Gets or sets vertical alignment */
  8287. set: function (value) {
  8288. return;
  8289. },
  8290. enumerable: true,
  8291. configurable: true
  8292. });
  8293. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8294. get: function () {
  8295. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8296. },
  8297. enumerable: true,
  8298. configurable: true
  8299. });
  8300. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8301. get: function () {
  8302. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8303. },
  8304. enumerable: true,
  8305. configurable: true
  8306. });
  8307. Line.prototype._getTypeName = function () {
  8308. return "Line";
  8309. };
  8310. Line.prototype._draw = function (context) {
  8311. context.save();
  8312. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8313. context.shadowColor = this.shadowColor;
  8314. context.shadowBlur = this.shadowBlur;
  8315. context.shadowOffsetX = this.shadowOffsetX;
  8316. context.shadowOffsetY = this.shadowOffsetY;
  8317. }
  8318. this._applyStates(context);
  8319. context.strokeStyle = this.color;
  8320. context.lineWidth = this._lineWidth;
  8321. context.setLineDash(this._dash);
  8322. context.beginPath();
  8323. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8324. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8325. context.stroke();
  8326. context.restore();
  8327. };
  8328. Line.prototype._measure = function () {
  8329. // Width / Height
  8330. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8331. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8332. };
  8333. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8334. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8335. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8336. };
  8337. /**
  8338. * Move one end of the line given 3D cartesian coordinates.
  8339. * @param position Targeted world position
  8340. * @param scene Scene
  8341. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8342. */
  8343. Line.prototype.moveToVector3 = function (position, scene, end) {
  8344. if (end === void 0) { end = false; }
  8345. if (!this._host || this.parent !== this._host._rootContainer) {
  8346. 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");
  8347. return;
  8348. }
  8349. var globalViewport = this._host._getGlobalViewport(scene);
  8350. 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);
  8351. this._moveToProjectedPosition(projectedPosition, end);
  8352. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8353. this.notRenderable = true;
  8354. return;
  8355. }
  8356. this.notRenderable = false;
  8357. };
  8358. /**
  8359. * Move one end of the line to a position in screen absolute space.
  8360. * @param projectedPosition Position in screen absolute space (X, Y)
  8361. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8362. */
  8363. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8364. if (end === void 0) { end = false; }
  8365. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8366. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8367. if (end) {
  8368. this.x2 = x;
  8369. this.y2 = y;
  8370. this._x2.ignoreAdaptiveScaling = true;
  8371. this._y2.ignoreAdaptiveScaling = true;
  8372. }
  8373. else {
  8374. this.x1 = x;
  8375. this.y1 = y;
  8376. this._x1.ignoreAdaptiveScaling = true;
  8377. this._y1.ignoreAdaptiveScaling = true;
  8378. }
  8379. };
  8380. return Line;
  8381. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8382. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8383. /***/ }),
  8384. /***/ "./2D/controls/multiLine.ts":
  8385. /*!**********************************!*\
  8386. !*** ./2D/controls/multiLine.ts ***!
  8387. \**********************************/
  8388. /*! exports provided: MultiLine */
  8389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8390. "use strict";
  8391. __webpack_require__.r(__webpack_exports__);
  8392. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8393. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8394. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Maths/math.vector");
  8395. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8396. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8397. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8398. /**
  8399. * Class used to create multi line control
  8400. */
  8401. var MultiLine = /** @class */ (function (_super) {
  8402. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8403. /**
  8404. * Creates a new MultiLine
  8405. * @param name defines the control name
  8406. */
  8407. function MultiLine(name) {
  8408. var _this = _super.call(this, name) || this;
  8409. _this.name = name;
  8410. _this._lineWidth = 1;
  8411. /** Function called when a point is updated */
  8412. _this.onPointUpdate = function () {
  8413. _this._markAsDirty();
  8414. };
  8415. _this._automaticSize = true;
  8416. _this.isHitTestVisible = false;
  8417. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8418. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8419. _this._dash = [];
  8420. _this._points = [];
  8421. return _this;
  8422. }
  8423. Object.defineProperty(MultiLine.prototype, "dash", {
  8424. /** Gets or sets dash pattern */
  8425. get: function () {
  8426. return this._dash;
  8427. },
  8428. set: function (value) {
  8429. if (this._dash === value) {
  8430. return;
  8431. }
  8432. this._dash = value;
  8433. this._markAsDirty();
  8434. },
  8435. enumerable: true,
  8436. configurable: true
  8437. });
  8438. /**
  8439. * Gets point stored at specified index
  8440. * @param index defines the index to look for
  8441. * @returns the requested point if found
  8442. */
  8443. MultiLine.prototype.getAt = function (index) {
  8444. if (!this._points[index]) {
  8445. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8446. }
  8447. return this._points[index];
  8448. };
  8449. /**
  8450. * Adds new points to the point collection
  8451. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8452. * @returns the list of created MultiLinePoint
  8453. */
  8454. MultiLine.prototype.add = function () {
  8455. var _this = this;
  8456. var items = [];
  8457. for (var _i = 0; _i < arguments.length; _i++) {
  8458. items[_i] = arguments[_i];
  8459. }
  8460. return items.map(function (item) { return _this.push(item); });
  8461. };
  8462. /**
  8463. * Adds a new point to the point collection
  8464. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8465. * @returns the created MultiLinePoint
  8466. */
  8467. MultiLine.prototype.push = function (item) {
  8468. var point = this.getAt(this._points.length);
  8469. if (item == null) {
  8470. return point;
  8471. }
  8472. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8473. point.mesh = item;
  8474. }
  8475. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8476. point.control = item;
  8477. }
  8478. else if (item.x != null && item.y != null) {
  8479. point.x = item.x;
  8480. point.y = item.y;
  8481. }
  8482. return point;
  8483. };
  8484. /**
  8485. * Remove a specific value or point from the active point collection
  8486. * @param value defines the value or point to remove
  8487. */
  8488. MultiLine.prototype.remove = function (value) {
  8489. var index;
  8490. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8491. index = this._points.indexOf(value);
  8492. if (index === -1) {
  8493. return;
  8494. }
  8495. }
  8496. else {
  8497. index = value;
  8498. }
  8499. var point = this._points[index];
  8500. if (!point) {
  8501. return;
  8502. }
  8503. point.dispose();
  8504. this._points.splice(index, 1);
  8505. };
  8506. /**
  8507. * Resets this object to initial state (no point)
  8508. */
  8509. MultiLine.prototype.reset = function () {
  8510. while (this._points.length > 0) {
  8511. this.remove(this._points.length - 1);
  8512. }
  8513. };
  8514. /**
  8515. * Resets all links
  8516. */
  8517. MultiLine.prototype.resetLinks = function () {
  8518. this._points.forEach(function (point) {
  8519. if (point != null) {
  8520. point.resetLinks();
  8521. }
  8522. });
  8523. };
  8524. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8525. /** Gets or sets line width */
  8526. get: function () {
  8527. return this._lineWidth;
  8528. },
  8529. set: function (value) {
  8530. if (this._lineWidth === value) {
  8531. return;
  8532. }
  8533. this._lineWidth = value;
  8534. this._markAsDirty();
  8535. },
  8536. enumerable: true,
  8537. configurable: true
  8538. });
  8539. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8540. set: function (value) {
  8541. return;
  8542. },
  8543. enumerable: true,
  8544. configurable: true
  8545. });
  8546. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8547. set: function (value) {
  8548. return;
  8549. },
  8550. enumerable: true,
  8551. configurable: true
  8552. });
  8553. MultiLine.prototype._getTypeName = function () {
  8554. return "MultiLine";
  8555. };
  8556. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8557. context.save();
  8558. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8559. context.shadowColor = this.shadowColor;
  8560. context.shadowBlur = this.shadowBlur;
  8561. context.shadowOffsetX = this.shadowOffsetX;
  8562. context.shadowOffsetY = this.shadowOffsetY;
  8563. }
  8564. this._applyStates(context);
  8565. context.strokeStyle = this.color;
  8566. context.lineWidth = this._lineWidth;
  8567. context.setLineDash(this._dash);
  8568. context.beginPath();
  8569. var first = true; //first index is not necessarily 0
  8570. this._points.forEach(function (point) {
  8571. if (!point) {
  8572. return;
  8573. }
  8574. if (first) {
  8575. context.moveTo(point._point.x, point._point.y);
  8576. first = false;
  8577. }
  8578. else {
  8579. context.lineTo(point._point.x, point._point.y);
  8580. }
  8581. });
  8582. context.stroke();
  8583. context.restore();
  8584. };
  8585. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8586. var _this = this;
  8587. this._minX = null;
  8588. this._minY = null;
  8589. this._maxX = null;
  8590. this._maxY = null;
  8591. this._points.forEach(function (point, index) {
  8592. if (!point) {
  8593. return;
  8594. }
  8595. point.translate();
  8596. if (_this._minX == null || point._point.x < _this._minX) {
  8597. _this._minX = point._point.x;
  8598. }
  8599. if (_this._minY == null || point._point.y < _this._minY) {
  8600. _this._minY = point._point.y;
  8601. }
  8602. if (_this._maxX == null || point._point.x > _this._maxX) {
  8603. _this._maxX = point._point.x;
  8604. }
  8605. if (_this._maxY == null || point._point.y > _this._maxY) {
  8606. _this._maxY = point._point.y;
  8607. }
  8608. });
  8609. if (this._minX == null) {
  8610. this._minX = 0;
  8611. }
  8612. if (this._minY == null) {
  8613. this._minY = 0;
  8614. }
  8615. if (this._maxX == null) {
  8616. this._maxX = 0;
  8617. }
  8618. if (this._maxY == null) {
  8619. this._maxY = 0;
  8620. }
  8621. };
  8622. MultiLine.prototype._measure = function () {
  8623. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8624. return;
  8625. }
  8626. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8627. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8628. };
  8629. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8630. if (this._minX == null || this._minY == null) {
  8631. return;
  8632. }
  8633. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8634. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8635. };
  8636. MultiLine.prototype.dispose = function () {
  8637. this.reset();
  8638. _super.prototype.dispose.call(this);
  8639. };
  8640. return MultiLine;
  8641. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8642. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8643. /***/ }),
  8644. /***/ "./2D/controls/radioButton.ts":
  8645. /*!************************************!*\
  8646. !*** ./2D/controls/radioButton.ts ***!
  8647. \************************************/
  8648. /*! exports provided: RadioButton */
  8649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8650. "use strict";
  8651. __webpack_require__.r(__webpack_exports__);
  8652. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8653. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8654. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  8655. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8656. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8657. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8658. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8659. /**
  8660. * Class used to create radio button controls
  8661. */
  8662. var RadioButton = /** @class */ (function (_super) {
  8663. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8664. /**
  8665. * Creates a new RadioButton
  8666. * @param name defines the control name
  8667. */
  8668. function RadioButton(name) {
  8669. var _this = _super.call(this, name) || this;
  8670. _this.name = name;
  8671. _this._isChecked = false;
  8672. _this._background = "black";
  8673. _this._checkSizeRatio = 0.8;
  8674. _this._thickness = 1;
  8675. /** Gets or sets group name */
  8676. _this.group = "";
  8677. /** Observable raised when isChecked is changed */
  8678. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8679. _this.isPointerBlocker = true;
  8680. return _this;
  8681. }
  8682. Object.defineProperty(RadioButton.prototype, "thickness", {
  8683. /** Gets or sets border thickness */
  8684. get: function () {
  8685. return this._thickness;
  8686. },
  8687. set: function (value) {
  8688. if (this._thickness === value) {
  8689. return;
  8690. }
  8691. this._thickness = value;
  8692. this._markAsDirty();
  8693. },
  8694. enumerable: true,
  8695. configurable: true
  8696. });
  8697. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8698. /** Gets or sets a value indicating the ratio between overall size and check size */
  8699. get: function () {
  8700. return this._checkSizeRatio;
  8701. },
  8702. set: function (value) {
  8703. value = Math.max(Math.min(1, value), 0);
  8704. if (this._checkSizeRatio === value) {
  8705. return;
  8706. }
  8707. this._checkSizeRatio = value;
  8708. this._markAsDirty();
  8709. },
  8710. enumerable: true,
  8711. configurable: true
  8712. });
  8713. Object.defineProperty(RadioButton.prototype, "background", {
  8714. /** Gets or sets background color */
  8715. get: function () {
  8716. return this._background;
  8717. },
  8718. set: function (value) {
  8719. if (this._background === value) {
  8720. return;
  8721. }
  8722. this._background = value;
  8723. this._markAsDirty();
  8724. },
  8725. enumerable: true,
  8726. configurable: true
  8727. });
  8728. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8729. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8730. get: function () {
  8731. return this._isChecked;
  8732. },
  8733. set: function (value) {
  8734. var _this = this;
  8735. if (this._isChecked === value) {
  8736. return;
  8737. }
  8738. this._isChecked = value;
  8739. this._markAsDirty();
  8740. this.onIsCheckedChangedObservable.notifyObservers(value);
  8741. if (this._isChecked && this._host) {
  8742. // Update all controls from same group
  8743. this._host.executeOnAllControls(function (control) {
  8744. if (control === _this) {
  8745. return;
  8746. }
  8747. if (control.group === undefined) {
  8748. return;
  8749. }
  8750. var childRadio = control;
  8751. if (childRadio.group === _this.group) {
  8752. childRadio.isChecked = false;
  8753. }
  8754. });
  8755. }
  8756. },
  8757. enumerable: true,
  8758. configurable: true
  8759. });
  8760. RadioButton.prototype._getTypeName = function () {
  8761. return "RadioButton";
  8762. };
  8763. RadioButton.prototype._draw = function (context) {
  8764. context.save();
  8765. this._applyStates(context);
  8766. var actualWidth = this._currentMeasure.width - this._thickness;
  8767. var actualHeight = this._currentMeasure.height - this._thickness;
  8768. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8769. context.shadowColor = this.shadowColor;
  8770. context.shadowBlur = this.shadowBlur;
  8771. context.shadowOffsetX = this.shadowOffsetX;
  8772. context.shadowOffsetY = this.shadowOffsetY;
  8773. }
  8774. // Outer
  8775. _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);
  8776. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8777. context.fill();
  8778. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8779. context.shadowBlur = 0;
  8780. context.shadowOffsetX = 0;
  8781. context.shadowOffsetY = 0;
  8782. }
  8783. context.strokeStyle = this.color;
  8784. context.lineWidth = this._thickness;
  8785. context.stroke();
  8786. // Inner
  8787. if (this._isChecked) {
  8788. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8789. var offsetWidth = actualWidth * this._checkSizeRatio;
  8790. var offseHeight = actualHeight * this._checkSizeRatio;
  8791. _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);
  8792. context.fill();
  8793. }
  8794. context.restore();
  8795. };
  8796. // Events
  8797. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8798. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8799. return false;
  8800. }
  8801. if (!this.isChecked) {
  8802. this.isChecked = true;
  8803. }
  8804. return true;
  8805. };
  8806. /**
  8807. * Utility function to easily create a radio button with a header
  8808. * @param title defines the label to use for the header
  8809. * @param group defines the group to use for the radio button
  8810. * @param isChecked defines the initial state of the radio button
  8811. * @param onValueChanged defines the callback to call when value changes
  8812. * @returns a StackPanel containing the radio button and a textBlock
  8813. */
  8814. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8815. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8816. panel.isVertical = false;
  8817. panel.height = "30px";
  8818. var radio = new RadioButton();
  8819. radio.width = "20px";
  8820. radio.height = "20px";
  8821. radio.isChecked = isChecked;
  8822. radio.color = "green";
  8823. radio.group = group;
  8824. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8825. panel.addControl(radio);
  8826. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8827. header.text = title;
  8828. header.width = "180px";
  8829. header.paddingLeft = "5px";
  8830. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8831. header.color = "white";
  8832. panel.addControl(header);
  8833. return panel;
  8834. };
  8835. return RadioButton;
  8836. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8837. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8838. /***/ }),
  8839. /***/ "./2D/controls/rectangle.ts":
  8840. /*!**********************************!*\
  8841. !*** ./2D/controls/rectangle.ts ***!
  8842. \**********************************/
  8843. /*! exports provided: Rectangle */
  8844. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8845. "use strict";
  8846. __webpack_require__.r(__webpack_exports__);
  8847. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8848. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8849. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8850. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  8851. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8852. /** Class used to create rectangle container */
  8853. var Rectangle = /** @class */ (function (_super) {
  8854. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8855. /**
  8856. * Creates a new Rectangle
  8857. * @param name defines the control name
  8858. */
  8859. function Rectangle(name) {
  8860. var _this = _super.call(this, name) || this;
  8861. _this.name = name;
  8862. _this._thickness = 1;
  8863. _this._cornerRadius = 0;
  8864. return _this;
  8865. }
  8866. Object.defineProperty(Rectangle.prototype, "thickness", {
  8867. /** Gets or sets border thickness */
  8868. get: function () {
  8869. return this._thickness;
  8870. },
  8871. set: function (value) {
  8872. if (this._thickness === value) {
  8873. return;
  8874. }
  8875. this._thickness = value;
  8876. this._markAsDirty();
  8877. },
  8878. enumerable: true,
  8879. configurable: true
  8880. });
  8881. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8882. /** Gets or sets the corner radius angle */
  8883. get: function () {
  8884. return this._cornerRadius;
  8885. },
  8886. set: function (value) {
  8887. if (value < 0) {
  8888. value = 0;
  8889. }
  8890. if (this._cornerRadius === value) {
  8891. return;
  8892. }
  8893. this._cornerRadius = value;
  8894. this._markAsDirty();
  8895. },
  8896. enumerable: true,
  8897. configurable: true
  8898. });
  8899. Rectangle.prototype._getTypeName = function () {
  8900. return "Rectangle";
  8901. };
  8902. Rectangle.prototype._localDraw = function (context) {
  8903. context.save();
  8904. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8905. context.shadowColor = this.shadowColor;
  8906. context.shadowBlur = this.shadowBlur;
  8907. context.shadowOffsetX = this.shadowOffsetX;
  8908. context.shadowOffsetY = this.shadowOffsetY;
  8909. }
  8910. if (this._background) {
  8911. context.fillStyle = this._background;
  8912. if (this._cornerRadius) {
  8913. this._drawRoundedRect(context, this._thickness / 2);
  8914. context.fill();
  8915. }
  8916. else {
  8917. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8918. }
  8919. }
  8920. if (this._thickness) {
  8921. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8922. context.shadowBlur = 0;
  8923. context.shadowOffsetX = 0;
  8924. context.shadowOffsetY = 0;
  8925. }
  8926. if (this.color) {
  8927. context.strokeStyle = this.color;
  8928. }
  8929. context.lineWidth = this._thickness;
  8930. if (this._cornerRadius) {
  8931. this._drawRoundedRect(context, this._thickness / 2);
  8932. context.stroke();
  8933. }
  8934. else {
  8935. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8936. }
  8937. }
  8938. context.restore();
  8939. };
  8940. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8941. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8942. this._measureForChildren.width -= 2 * this._thickness;
  8943. this._measureForChildren.height -= 2 * this._thickness;
  8944. this._measureForChildren.left += this._thickness;
  8945. this._measureForChildren.top += this._thickness;
  8946. };
  8947. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8948. if (offset === void 0) { offset = 0; }
  8949. var x = this._currentMeasure.left + offset;
  8950. var y = this._currentMeasure.top + offset;
  8951. var width = this._currentMeasure.width - offset * 2;
  8952. var height = this._currentMeasure.height - offset * 2;
  8953. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8954. context.beginPath();
  8955. context.moveTo(x + radius, y);
  8956. context.lineTo(x + width - radius, y);
  8957. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8958. context.lineTo(x + width, y + height - radius);
  8959. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8960. context.lineTo(x + radius, y + height);
  8961. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8962. context.lineTo(x, y + radius);
  8963. context.quadraticCurveTo(x, y, x + radius, y);
  8964. context.closePath();
  8965. };
  8966. Rectangle.prototype._clipForChildren = function (context) {
  8967. if (this._cornerRadius) {
  8968. this._drawRoundedRect(context, this._thickness);
  8969. context.clip();
  8970. }
  8971. };
  8972. return Rectangle;
  8973. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8974. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8975. /***/ }),
  8976. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8977. /*!***************************************************!*\
  8978. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8979. \***************************************************/
  8980. /*! exports provided: ScrollViewer */
  8981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8982. "use strict";
  8983. __webpack_require__.r(__webpack_exports__);
  8984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8985. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8986. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8987. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8988. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8989. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8990. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8991. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  8992. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  8993. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  8994. /**
  8995. * Class used to hold a viewer window and sliders in a grid
  8996. */
  8997. var ScrollViewer = /** @class */ (function (_super) {
  8998. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  8999. /**
  9000. * Creates a new ScrollViewer
  9001. * @param name of ScrollViewer
  9002. */
  9003. function ScrollViewer(name, isImageBased) {
  9004. var _this = _super.call(this, name) || this;
  9005. _this._barSize = 20;
  9006. _this._pointerIsOver = false;
  9007. _this._wheelPrecision = 0.05;
  9008. _this._thumbLength = 0.5;
  9009. _this._thumbHeight = 1;
  9010. _this._barImageHeight = 1;
  9011. _this._horizontalBarImageHeight = 1;
  9012. _this._verticalBarImageHeight = 1;
  9013. _this._forceHorizontalBar = false;
  9014. _this._forceVerticalBar = false;
  9015. _this._useImageBar = isImageBased ? isImageBased : false;
  9016. _this.onDirtyObservable.add(function () {
  9017. _this._horizontalBarSpace.color = _this.color;
  9018. _this._verticalBarSpace.color = _this.color;
  9019. _this._dragSpace.color = _this.color;
  9020. });
  9021. _this.onPointerEnterObservable.add(function () {
  9022. _this._pointerIsOver = true;
  9023. });
  9024. _this.onPointerOutObservable.add(function () {
  9025. _this._pointerIsOver = false;
  9026. });
  9027. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9028. if (_this._useImageBar) {
  9029. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9030. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9031. }
  9032. else {
  9033. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9034. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9035. }
  9036. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9037. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9038. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9039. _this._grid.addColumnDefinition(1);
  9040. _this._grid.addColumnDefinition(0, true);
  9041. _this._grid.addRowDefinition(1);
  9042. _this._grid.addRowDefinition(0, true);
  9043. _super.prototype.addControl.call(_this, _this._grid);
  9044. _this._grid.addControl(_this._window, 0, 0);
  9045. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9046. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9047. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9048. _this._verticalBarSpace.thickness = 1;
  9049. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9050. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9051. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9052. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9053. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9054. _this._horizontalBarSpace.thickness = 1;
  9055. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9056. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9057. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9058. _this._dragSpace.thickness = 1;
  9059. _this._grid.addControl(_this._dragSpace, 1, 1);
  9060. // Colors
  9061. if (!_this._useImageBar) {
  9062. _this.barColor = "grey";
  9063. _this.barBackground = "transparent";
  9064. }
  9065. return _this;
  9066. }
  9067. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9068. /**
  9069. * Gets the horizontal scrollbar
  9070. */
  9071. get: function () {
  9072. return this._horizontalBar;
  9073. },
  9074. enumerable: true,
  9075. configurable: true
  9076. });
  9077. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9078. /**
  9079. * Gets the vertical scrollbar
  9080. */
  9081. get: function () {
  9082. return this._verticalBar;
  9083. },
  9084. enumerable: true,
  9085. configurable: true
  9086. });
  9087. /**
  9088. * Adds a new control to the current container
  9089. * @param control defines the control to add
  9090. * @returns the current container
  9091. */
  9092. ScrollViewer.prototype.addControl = function (control) {
  9093. if (!control) {
  9094. return this;
  9095. }
  9096. this._window.addControl(control);
  9097. return this;
  9098. };
  9099. /**
  9100. * Removes a control from the current container
  9101. * @param control defines the control to remove
  9102. * @returns the current container
  9103. */
  9104. ScrollViewer.prototype.removeControl = function (control) {
  9105. this._window.removeControl(control);
  9106. return this;
  9107. };
  9108. Object.defineProperty(ScrollViewer.prototype, "children", {
  9109. /** Gets the list of children */
  9110. get: function () {
  9111. return this._window.children;
  9112. },
  9113. enumerable: true,
  9114. configurable: true
  9115. });
  9116. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9117. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9118. var child = _a[_i];
  9119. child._markMatrixAsDirty();
  9120. }
  9121. };
  9122. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9123. /**
  9124. * Freezes or unfreezes the controls in the window.
  9125. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9126. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9127. */
  9128. get: function () {
  9129. return this._window.freezeControls;
  9130. },
  9131. set: function (value) {
  9132. this._window.freezeControls = value;
  9133. },
  9134. enumerable: true,
  9135. configurable: true
  9136. });
  9137. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9138. /** Gets the bucket width */
  9139. get: function () {
  9140. return this._window.bucketWidth;
  9141. },
  9142. enumerable: true,
  9143. configurable: true
  9144. });
  9145. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9146. /** Gets the bucket height */
  9147. get: function () {
  9148. return this._window.bucketHeight;
  9149. },
  9150. enumerable: true,
  9151. configurable: true
  9152. });
  9153. /**
  9154. * Sets the bucket sizes.
  9155. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9156. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9157. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9158. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9159. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9160. * used), that's why it is not enabled by default.
  9161. * @param width width of the bucket
  9162. * @param height height of the bucket
  9163. */
  9164. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9165. this._window.setBucketSizes(width, height);
  9166. };
  9167. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9168. /**
  9169. * Forces the horizontal scroll bar to be displayed
  9170. */
  9171. get: function () {
  9172. return this._forceHorizontalBar;
  9173. },
  9174. set: function (value) {
  9175. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9176. this._horizontalBar.isVisible = value;
  9177. this._forceHorizontalBar = value;
  9178. },
  9179. enumerable: true,
  9180. configurable: true
  9181. });
  9182. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9183. /**
  9184. * Forces the vertical scroll bar to be displayed
  9185. */
  9186. get: function () {
  9187. return this._forceVerticalBar;
  9188. },
  9189. set: function (value) {
  9190. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9191. this._verticalBar.isVisible = value;
  9192. this._forceVerticalBar = value;
  9193. },
  9194. enumerable: true,
  9195. configurable: true
  9196. });
  9197. /** Reset the scroll viewer window to initial size */
  9198. ScrollViewer.prototype.resetWindow = function () {
  9199. this._window.width = "100%";
  9200. this._window.height = "100%";
  9201. };
  9202. ScrollViewer.prototype._getTypeName = function () {
  9203. return "ScrollViewer";
  9204. };
  9205. ScrollViewer.prototype._buildClientSizes = function () {
  9206. var ratio = this.host.idealRatio;
  9207. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9208. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9209. this._clientWidth = this._window.parentClientWidth;
  9210. this._clientHeight = this._window.parentClientHeight;
  9211. };
  9212. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9213. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9214. this._buildClientSizes();
  9215. };
  9216. ScrollViewer.prototype._postMeasure = function () {
  9217. _super.prototype._postMeasure.call(this);
  9218. this._updateScroller();
  9219. };
  9220. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9221. /**
  9222. * Gets or sets the mouse wheel precision
  9223. * from 0 to 1 with a default value of 0.05
  9224. * */
  9225. get: function () {
  9226. return this._wheelPrecision;
  9227. },
  9228. set: function (value) {
  9229. if (this._wheelPrecision === value) {
  9230. return;
  9231. }
  9232. if (value < 0) {
  9233. value = 0;
  9234. }
  9235. if (value > 1) {
  9236. value = 1;
  9237. }
  9238. this._wheelPrecision = value;
  9239. },
  9240. enumerable: true,
  9241. configurable: true
  9242. });
  9243. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9244. /** Gets or sets the scroll bar container background color */
  9245. get: function () {
  9246. return this._horizontalBarSpace.background;
  9247. },
  9248. set: function (color) {
  9249. if (this._horizontalBarSpace.background === color) {
  9250. return;
  9251. }
  9252. this._horizontalBarSpace.background = color;
  9253. this._verticalBarSpace.background = color;
  9254. },
  9255. enumerable: true,
  9256. configurable: true
  9257. });
  9258. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9259. /** Gets or sets the bar color */
  9260. get: function () {
  9261. return this._barColor;
  9262. },
  9263. set: function (color) {
  9264. if (this._barColor === color) {
  9265. return;
  9266. }
  9267. this._barColor = color;
  9268. this._horizontalBar.color = color;
  9269. this._verticalBar.color = color;
  9270. },
  9271. enumerable: true,
  9272. configurable: true
  9273. });
  9274. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9275. /** Gets or sets the bar image */
  9276. get: function () {
  9277. return this._barImage;
  9278. },
  9279. set: function (value) {
  9280. if (this._barImage === value) {
  9281. return;
  9282. }
  9283. this._barImage = value;
  9284. var hb = this._horizontalBar;
  9285. var vb = this._verticalBar;
  9286. hb.thumbImage = value;
  9287. vb.thumbImage = value;
  9288. },
  9289. enumerable: true,
  9290. configurable: true
  9291. });
  9292. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9293. /** Gets or sets the horizontal bar image */
  9294. get: function () {
  9295. return this._horizontalBarImage;
  9296. },
  9297. set: function (value) {
  9298. if (this._horizontalBarImage === value) {
  9299. return;
  9300. }
  9301. this._horizontalBarImage = value;
  9302. var hb = this._horizontalBar;
  9303. hb.thumbImage = value;
  9304. },
  9305. enumerable: true,
  9306. configurable: true
  9307. });
  9308. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9309. /** Gets or sets the vertical bar image */
  9310. get: function () {
  9311. return this._verticalBarImage;
  9312. },
  9313. set: function (value) {
  9314. if (this._verticalBarImage === value) {
  9315. return;
  9316. }
  9317. this._verticalBarImage = value;
  9318. var vb = this._verticalBar;
  9319. vb.thumbImage = value;
  9320. },
  9321. enumerable: true,
  9322. configurable: true
  9323. });
  9324. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9325. /** Gets or sets the size of the bar */
  9326. get: function () {
  9327. return this._barSize;
  9328. },
  9329. set: function (value) {
  9330. if (this._barSize === value) {
  9331. return;
  9332. }
  9333. this._barSize = value;
  9334. this._markAsDirty();
  9335. if (this._horizontalBar.isVisible) {
  9336. this._grid.setRowDefinition(1, this._barSize, true);
  9337. }
  9338. if (this._verticalBar.isVisible) {
  9339. this._grid.setColumnDefinition(1, this._barSize, true);
  9340. }
  9341. },
  9342. enumerable: true,
  9343. configurable: true
  9344. });
  9345. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9346. /** Gets or sets the length of the thumb */
  9347. get: function () {
  9348. return this._thumbLength;
  9349. },
  9350. set: function (value) {
  9351. if (this._thumbLength === value) {
  9352. return;
  9353. }
  9354. if (value <= 0) {
  9355. value = 0.1;
  9356. }
  9357. if (value > 1) {
  9358. value = 1;
  9359. }
  9360. this._thumbLength = value;
  9361. var hb = this._horizontalBar;
  9362. var vb = this._verticalBar;
  9363. hb.thumbLength = value;
  9364. vb.thumbLength = value;
  9365. this._markAsDirty();
  9366. },
  9367. enumerable: true,
  9368. configurable: true
  9369. });
  9370. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9371. /** Gets or sets the height of the thumb */
  9372. get: function () {
  9373. return this._thumbHeight;
  9374. },
  9375. set: function (value) {
  9376. if (this._thumbHeight === value) {
  9377. return;
  9378. }
  9379. if (value <= 0) {
  9380. value = 0.1;
  9381. }
  9382. if (value > 1) {
  9383. value = 1;
  9384. }
  9385. this._thumbHeight = value;
  9386. var hb = this._horizontalBar;
  9387. var vb = this._verticalBar;
  9388. hb.thumbHeight = value;
  9389. vb.thumbHeight = value;
  9390. this._markAsDirty();
  9391. },
  9392. enumerable: true,
  9393. configurable: true
  9394. });
  9395. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9396. /** Gets or sets the height of the bar image */
  9397. get: function () {
  9398. return this._barImageHeight;
  9399. },
  9400. set: function (value) {
  9401. if (this._barImageHeight === value) {
  9402. return;
  9403. }
  9404. if (value <= 0) {
  9405. value = 0.1;
  9406. }
  9407. if (value > 1) {
  9408. value = 1;
  9409. }
  9410. this._barImageHeight = value;
  9411. var hb = this._horizontalBar;
  9412. var vb = this._verticalBar;
  9413. hb.barImageHeight = value;
  9414. vb.barImageHeight = value;
  9415. this._markAsDirty();
  9416. },
  9417. enumerable: true,
  9418. configurable: true
  9419. });
  9420. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9421. /** Gets or sets the height of the horizontal bar image */
  9422. get: function () {
  9423. return this._horizontalBarImageHeight;
  9424. },
  9425. set: function (value) {
  9426. if (this._horizontalBarImageHeight === value) {
  9427. return;
  9428. }
  9429. if (value <= 0) {
  9430. value = 0.1;
  9431. }
  9432. if (value > 1) {
  9433. value = 1;
  9434. }
  9435. this._horizontalBarImageHeight = value;
  9436. var hb = this._horizontalBar;
  9437. hb.barImageHeight = value;
  9438. this._markAsDirty();
  9439. },
  9440. enumerable: true,
  9441. configurable: true
  9442. });
  9443. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9444. /** Gets or sets the height of the vertical bar image */
  9445. get: function () {
  9446. return this._verticalBarImageHeight;
  9447. },
  9448. set: function (value) {
  9449. if (this._verticalBarImageHeight === value) {
  9450. return;
  9451. }
  9452. if (value <= 0) {
  9453. value = 0.1;
  9454. }
  9455. if (value > 1) {
  9456. value = 1;
  9457. }
  9458. this._verticalBarImageHeight = value;
  9459. var vb = this._verticalBar;
  9460. vb.barImageHeight = value;
  9461. this._markAsDirty();
  9462. },
  9463. enumerable: true,
  9464. configurable: true
  9465. });
  9466. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9467. /** Gets or sets the bar background */
  9468. get: function () {
  9469. return this._barBackground;
  9470. },
  9471. set: function (color) {
  9472. if (this._barBackground === color) {
  9473. return;
  9474. }
  9475. this._barBackground = color;
  9476. var hb = this._horizontalBar;
  9477. var vb = this._verticalBar;
  9478. hb.background = color;
  9479. vb.background = color;
  9480. this._dragSpace.background = color;
  9481. },
  9482. enumerable: true,
  9483. configurable: true
  9484. });
  9485. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9486. /** Gets or sets the bar background image */
  9487. get: function () {
  9488. return this._barBackgroundImage;
  9489. },
  9490. set: function (value) {
  9491. if (this._barBackgroundImage === value) {
  9492. }
  9493. this._barBackgroundImage = value;
  9494. var hb = this._horizontalBar;
  9495. var vb = this._verticalBar;
  9496. hb.backgroundImage = value;
  9497. vb.backgroundImage = value;
  9498. },
  9499. enumerable: true,
  9500. configurable: true
  9501. });
  9502. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9503. /** Gets or sets the horizontal bar background image */
  9504. get: function () {
  9505. return this._horizontalBarBackgroundImage;
  9506. },
  9507. set: function (value) {
  9508. if (this._horizontalBarBackgroundImage === value) {
  9509. }
  9510. this._horizontalBarBackgroundImage = value;
  9511. var hb = this._horizontalBar;
  9512. hb.backgroundImage = value;
  9513. },
  9514. enumerable: true,
  9515. configurable: true
  9516. });
  9517. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9518. /** Gets or sets the vertical bar background image */
  9519. get: function () {
  9520. return this._verticalBarBackgroundImage;
  9521. },
  9522. set: function (value) {
  9523. if (this._verticalBarBackgroundImage === value) {
  9524. }
  9525. this._verticalBarBackgroundImage = value;
  9526. var vb = this._verticalBar;
  9527. vb.backgroundImage = value;
  9528. },
  9529. enumerable: true,
  9530. configurable: true
  9531. });
  9532. ScrollViewer.prototype._setWindowPosition = function () {
  9533. var ratio = this.host.idealRatio;
  9534. var windowContentsWidth = this._window._currentMeasure.width;
  9535. var windowContentsHeight = this._window._currentMeasure.height;
  9536. var _endLeft = this._clientWidth - windowContentsWidth;
  9537. var _endTop = this._clientHeight - windowContentsHeight;
  9538. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9539. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9540. if (newLeft !== this._window.left) {
  9541. this._window.left = newLeft;
  9542. if (!this.freezeControls) {
  9543. this._rebuildLayout = true;
  9544. }
  9545. }
  9546. if (newTop !== this._window.top) {
  9547. this._window.top = newTop;
  9548. if (!this.freezeControls) {
  9549. this._rebuildLayout = true;
  9550. }
  9551. }
  9552. };
  9553. /** @hidden */
  9554. ScrollViewer.prototype._updateScroller = function () {
  9555. var windowContentsWidth = this._window._currentMeasure.width;
  9556. var windowContentsHeight = this._window._currentMeasure.height;
  9557. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9558. this._grid.setRowDefinition(1, 0, true);
  9559. this._horizontalBar.isVisible = false;
  9560. this._horizontalBar.value = 0;
  9561. this._rebuildLayout = true;
  9562. }
  9563. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9564. this._grid.setRowDefinition(1, this._barSize, true);
  9565. this._horizontalBar.isVisible = true;
  9566. this._rebuildLayout = true;
  9567. }
  9568. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9569. this._grid.setColumnDefinition(1, 0, true);
  9570. this._verticalBar.isVisible = false;
  9571. this._verticalBar.value = 0;
  9572. this._rebuildLayout = true;
  9573. }
  9574. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9575. this._grid.setColumnDefinition(1, this._barSize, true);
  9576. this._verticalBar.isVisible = true;
  9577. this._rebuildLayout = true;
  9578. }
  9579. this._buildClientSizes();
  9580. var ratio = this.host.idealRatio;
  9581. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9582. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9583. };
  9584. ScrollViewer.prototype._link = function (host) {
  9585. _super.prototype._link.call(this, host);
  9586. this._attachWheel();
  9587. };
  9588. /** @hidden */
  9589. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9590. var _this = this;
  9591. barControl.paddingLeft = 0;
  9592. barControl.width = "100%";
  9593. barControl.height = "100%";
  9594. barControl.barOffset = 0;
  9595. barControl.value = 0;
  9596. barControl.maximum = 1;
  9597. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9598. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9599. barControl.isVertical = isVertical;
  9600. barControl.rotation = rotation;
  9601. barControl.isVisible = false;
  9602. barContainer.addControl(barControl);
  9603. barControl.onValueChangedObservable.add(function (value) {
  9604. _this._setWindowPosition();
  9605. });
  9606. };
  9607. /** @hidden */
  9608. ScrollViewer.prototype._attachWheel = function () {
  9609. var _this = this;
  9610. if (!this._host || this._onWheelObserver) {
  9611. return;
  9612. }
  9613. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  9614. if (!_this._pointerIsOver) {
  9615. return;
  9616. }
  9617. if (_this._verticalBar.isVisible == true) {
  9618. if (pi.y < 0 && _this._verticalBar.value > 0) {
  9619. _this._verticalBar.value -= _this._wheelPrecision;
  9620. }
  9621. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9622. _this._verticalBar.value += _this._wheelPrecision;
  9623. }
  9624. }
  9625. if (_this._horizontalBar.isVisible == true) {
  9626. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9627. _this._horizontalBar.value += _this._wheelPrecision;
  9628. }
  9629. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  9630. _this._horizontalBar.value -= _this._wheelPrecision;
  9631. }
  9632. }
  9633. });
  9634. };
  9635. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9636. if (!this.isHighlighted) {
  9637. return;
  9638. }
  9639. _super.prototype._renderHighlightSpecific.call(this, context);
  9640. this._grid._renderHighlightSpecific(context);
  9641. context.restore();
  9642. };
  9643. /** Releases associated resources */
  9644. ScrollViewer.prototype.dispose = function () {
  9645. this.onWheelObservable.remove(this._onWheelObserver);
  9646. this._onWheelObserver = null;
  9647. _super.prototype.dispose.call(this);
  9648. };
  9649. return ScrollViewer;
  9650. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9651. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9652. /***/ }),
  9653. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9654. /*!*********************************************************!*\
  9655. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9656. \*********************************************************/
  9657. /*! exports provided: _ScrollViewerWindow */
  9658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9659. "use strict";
  9660. __webpack_require__.r(__webpack_exports__);
  9661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9662. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9663. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9664. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9665. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9666. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9667. /**
  9668. * Class used to hold a the container for ScrollViewer
  9669. * @hidden
  9670. */
  9671. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9672. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9673. /**
  9674. * Creates a new ScrollViewerWindow
  9675. * @param name of ScrollViewerWindow
  9676. */
  9677. function _ScrollViewerWindow(name) {
  9678. var _this = _super.call(this, name) || this;
  9679. _this._freezeControls = false;
  9680. _this._bucketWidth = 0;
  9681. _this._bucketHeight = 0;
  9682. _this._buckets = {};
  9683. return _this;
  9684. }
  9685. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9686. get: function () {
  9687. return this._freezeControls;
  9688. },
  9689. set: function (value) {
  9690. if (this._freezeControls === value) {
  9691. return;
  9692. }
  9693. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9694. this._freezeControls = false;
  9695. var textureSize = this.host.getSize();
  9696. var renderWidth = textureSize.width;
  9697. var renderHeight = textureSize.height;
  9698. var context = this.host.getContext();
  9699. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9700. this.host._numLayoutCalls = 0;
  9701. this.host._rootContainer._layout(measure, context);
  9702. // in freeze mode, prepare children measures accordingly
  9703. if (value) {
  9704. this._updateMeasures();
  9705. if (this._useBuckets()) {
  9706. this._makeBuckets();
  9707. }
  9708. }
  9709. this._freezeControls = value;
  9710. this.host.markAsDirty(); // redraw with the (new) current settings
  9711. },
  9712. enumerable: true,
  9713. configurable: true
  9714. });
  9715. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9716. get: function () {
  9717. return this._bucketWidth;
  9718. },
  9719. enumerable: true,
  9720. configurable: true
  9721. });
  9722. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9723. get: function () {
  9724. return this._bucketHeight;
  9725. },
  9726. enumerable: true,
  9727. configurable: true
  9728. });
  9729. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9730. this._bucketWidth = width;
  9731. this._bucketHeight = height;
  9732. if (this._useBuckets()) {
  9733. if (this._freezeControls) {
  9734. this._makeBuckets();
  9735. }
  9736. }
  9737. else {
  9738. this._buckets = {};
  9739. }
  9740. };
  9741. _ScrollViewerWindow.prototype._useBuckets = function () {
  9742. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9743. };
  9744. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9745. this._buckets = {};
  9746. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9747. this._dispatchInBuckets(this._children);
  9748. };
  9749. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9750. for (var i = 0; i < children.length; ++i) {
  9751. var child = children[i];
  9752. var bStartX = Math.max(0, Math.floor((child._currentMeasure.left - this._currentMeasure.left) / this._bucketWidth)), bEndX = Math.floor((child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width - 1) / this._bucketWidth), bStartY = Math.max(0, Math.floor((child._currentMeasure.top - this._currentMeasure.top) / this._bucketHeight)), bEndY = Math.floor((child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height - 1) / this._bucketHeight);
  9753. while (bStartY <= bEndY) {
  9754. for (var x = bStartX; x <= bEndX; ++x) {
  9755. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9756. if (!lstc) {
  9757. lstc = [];
  9758. this._buckets[bucket] = lstc;
  9759. }
  9760. lstc.push(child);
  9761. }
  9762. bStartY++;
  9763. }
  9764. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9765. this._dispatchInBuckets(child._children);
  9766. }
  9767. }
  9768. };
  9769. // reset left and top measures for the window and all its children
  9770. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9771. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9772. this._measureForChildren.left -= left;
  9773. this._measureForChildren.top -= top;
  9774. this._currentMeasure.left -= left;
  9775. this._currentMeasure.top -= top;
  9776. this._updateChildrenMeasures(this._children, left, top);
  9777. };
  9778. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9779. for (var i = 0; i < children.length; ++i) {
  9780. var child = children[i];
  9781. child._currentMeasure.left -= left;
  9782. child._currentMeasure.top -= top;
  9783. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9784. child._customData._origTop = child._currentMeasure.top;
  9785. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9786. this._updateChildrenMeasures(child._children, left, top);
  9787. }
  9788. }
  9789. };
  9790. _ScrollViewerWindow.prototype._getTypeName = function () {
  9791. return "ScrollViewerWindow";
  9792. };
  9793. /** @hidden */
  9794. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9795. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9796. this._parentMeasure = parentMeasure;
  9797. this._measureForChildren.left = this._currentMeasure.left;
  9798. this._measureForChildren.top = this._currentMeasure.top;
  9799. this._measureForChildren.width = parentMeasure.width;
  9800. this._measureForChildren.height = parentMeasure.height;
  9801. };
  9802. /** @hidden */
  9803. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9804. if (this._freezeControls) {
  9805. this.invalidateRect(); // will trigger a redraw of the window
  9806. return false;
  9807. }
  9808. return _super.prototype._layout.call(this, parentMeasure, context);
  9809. };
  9810. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9811. for (var i = 0; i < children.length; ++i) {
  9812. var child = children[i];
  9813. child._currentMeasure.left = child._customData._origLeft + left;
  9814. child._currentMeasure.top = child._customData._origTop + top;
  9815. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9816. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9817. this._scrollChildren(child._children, left, top);
  9818. }
  9819. }
  9820. };
  9821. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9822. 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);
  9823. while (bStartY <= bEndY) {
  9824. for (var x = bStartX; x <= bEndX; ++x) {
  9825. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9826. if (lstc) {
  9827. for (var i = 0; i < lstc.length; ++i) {
  9828. var child = lstc[i];
  9829. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9830. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9831. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9832. }
  9833. }
  9834. }
  9835. bStartY++;
  9836. }
  9837. };
  9838. /** @hidden */
  9839. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9840. if (!this._freezeControls) {
  9841. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9842. return;
  9843. }
  9844. this._localDraw(context);
  9845. if (this.clipChildren) {
  9846. this._clipForChildren(context);
  9847. }
  9848. var left = this.leftInPixels, top = this.topInPixels;
  9849. if (this._useBuckets()) {
  9850. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  9851. this._scrollChildrenWithBuckets(left, top, left, top);
  9852. }
  9853. else {
  9854. this._scrollChildren(this._children, left, top);
  9855. }
  9856. this._oldLeft = left;
  9857. this._oldTop = top;
  9858. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9859. var child = _a[_i];
  9860. if (!child._intersectsRect(this._parentMeasure)) {
  9861. continue;
  9862. }
  9863. child._render(context, this._parentMeasure);
  9864. }
  9865. };
  9866. _ScrollViewerWindow.prototype._postMeasure = function () {
  9867. if (this._freezeControls) {
  9868. _super.prototype._postMeasure.call(this);
  9869. return;
  9870. }
  9871. var maxWidth = this.parentClientWidth;
  9872. var maxHeight = this.parentClientHeight;
  9873. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9874. var child = _a[_i];
  9875. if (!child.isVisible || child.notRenderable) {
  9876. continue;
  9877. }
  9878. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9879. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9880. }
  9881. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9882. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9883. }
  9884. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9885. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9886. }
  9887. if (this._currentMeasure.width !== maxWidth) {
  9888. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9889. this._currentMeasure.width = maxWidth;
  9890. this._rebuildLayout = true;
  9891. this._isDirty = true;
  9892. }
  9893. if (this._currentMeasure.height !== maxHeight) {
  9894. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9895. this._currentMeasure.height = maxHeight;
  9896. this._rebuildLayout = true;
  9897. this._isDirty = true;
  9898. }
  9899. _super.prototype._postMeasure.call(this);
  9900. };
  9901. return _ScrollViewerWindow;
  9902. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  9903. /***/ }),
  9904. /***/ "./2D/controls/selector.ts":
  9905. /*!*********************************!*\
  9906. !*** ./2D/controls/selector.ts ***!
  9907. \*********************************/
  9908. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9910. "use strict";
  9911. __webpack_require__.r(__webpack_exports__);
  9912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9914. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9916. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9917. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9918. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9919. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9920. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9921. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9922. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9923. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9924. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9925. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9926. /** Class used to create a RadioGroup
  9927. * which contains groups of radio buttons
  9928. */
  9929. var SelectorGroup = /** @class */ (function () {
  9930. /**
  9931. * Creates a new SelectorGroup
  9932. * @param name of group, used as a group heading
  9933. */
  9934. function SelectorGroup(
  9935. /** name of SelectorGroup */
  9936. name) {
  9937. this.name = name;
  9938. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9939. this._selectors = new Array();
  9940. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9941. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9942. this._groupHeader = this._addGroupHeader(name);
  9943. }
  9944. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9945. /** Gets the groupPanel of the SelectorGroup */
  9946. get: function () {
  9947. return this._groupPanel;
  9948. },
  9949. enumerable: true,
  9950. configurable: true
  9951. });
  9952. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9953. /** Gets the selectors array */
  9954. get: function () {
  9955. return this._selectors;
  9956. },
  9957. enumerable: true,
  9958. configurable: true
  9959. });
  9960. Object.defineProperty(SelectorGroup.prototype, "header", {
  9961. /** Gets and sets the group header */
  9962. get: function () {
  9963. return this._groupHeader.text;
  9964. },
  9965. set: function (label) {
  9966. if (this._groupHeader.text === "label") {
  9967. return;
  9968. }
  9969. this._groupHeader.text = label;
  9970. },
  9971. enumerable: true,
  9972. configurable: true
  9973. });
  9974. /** @hidden */
  9975. SelectorGroup.prototype._addGroupHeader = function (text) {
  9976. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9977. groupHeading.width = 0.9;
  9978. groupHeading.height = "30px";
  9979. groupHeading.textWrapping = true;
  9980. groupHeading.color = "black";
  9981. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9982. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9983. groupHeading.left = "2px";
  9984. this._groupPanel.addControl(groupHeading);
  9985. return groupHeading;
  9986. };
  9987. /** @hidden*/
  9988. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9989. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9990. return;
  9991. }
  9992. return this._selectors[selectorNb];
  9993. };
  9994. /** Removes the selector at the given position
  9995. * @param selectorNb the position of the selector within the group
  9996. */
  9997. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9998. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9999. return;
  10000. }
  10001. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10002. this._selectors.splice(selectorNb, 1);
  10003. };
  10004. return SelectorGroup;
  10005. }());
  10006. /** Class used to create a CheckboxGroup
  10007. * which contains groups of checkbox buttons
  10008. */
  10009. var CheckboxGroup = /** @class */ (function (_super) {
  10010. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10011. function CheckboxGroup() {
  10012. return _super !== null && _super.apply(this, arguments) || this;
  10013. }
  10014. /** Adds a checkbox as a control
  10015. * @param text is the label for the selector
  10016. * @param func is the function called when the Selector is checked
  10017. * @param checked is true when Selector is checked
  10018. */
  10019. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10020. if (func === void 0) { func = function (s) { }; }
  10021. if (checked === void 0) { checked = false; }
  10022. var checked = checked || false;
  10023. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10024. button.width = "20px";
  10025. button.height = "20px";
  10026. button.color = "#364249";
  10027. button.background = "#CCCCCC";
  10028. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10029. button.onIsCheckedChangedObservable.add(function (state) {
  10030. func(state);
  10031. });
  10032. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10033. _selector.height = "30px";
  10034. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10035. _selector.left = "4px";
  10036. this.groupPanel.addControl(_selector);
  10037. this.selectors.push(_selector);
  10038. button.isChecked = checked;
  10039. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10040. button.color = this.groupPanel.parent.parent.buttonColor;
  10041. button.background = this.groupPanel.parent.parent.buttonBackground;
  10042. }
  10043. };
  10044. /** @hidden */
  10045. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10046. this.selectors[selectorNb].children[1].text = label;
  10047. };
  10048. /** @hidden */
  10049. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10050. this.selectors[selectorNb].children[1].color = color;
  10051. };
  10052. /** @hidden */
  10053. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10054. this.selectors[selectorNb].children[0].color = color;
  10055. };
  10056. /** @hidden */
  10057. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10058. this.selectors[selectorNb].children[0].background = color;
  10059. };
  10060. return CheckboxGroup;
  10061. }(SelectorGroup));
  10062. /** Class used to create a RadioGroup
  10063. * which contains groups of radio buttons
  10064. */
  10065. var RadioGroup = /** @class */ (function (_super) {
  10066. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10067. function RadioGroup() {
  10068. var _this = _super !== null && _super.apply(this, arguments) || this;
  10069. _this._selectNb = 0;
  10070. return _this;
  10071. }
  10072. /** Adds a radio button as a control
  10073. * @param label is the label for the selector
  10074. * @param func is the function called when the Selector is checked
  10075. * @param checked is true when Selector is checked
  10076. */
  10077. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10078. if (func === void 0) { func = function (n) { }; }
  10079. if (checked === void 0) { checked = false; }
  10080. var nb = this._selectNb++;
  10081. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10082. button.name = label;
  10083. button.width = "20px";
  10084. button.height = "20px";
  10085. button.color = "#364249";
  10086. button.background = "#CCCCCC";
  10087. button.group = this.name;
  10088. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10089. button.onIsCheckedChangedObservable.add(function (state) {
  10090. if (state) {
  10091. func(nb);
  10092. }
  10093. });
  10094. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10095. _selector.height = "30px";
  10096. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10097. _selector.left = "4px";
  10098. this.groupPanel.addControl(_selector);
  10099. this.selectors.push(_selector);
  10100. button.isChecked = checked;
  10101. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10102. button.color = this.groupPanel.parent.parent.buttonColor;
  10103. button.background = this.groupPanel.parent.parent.buttonBackground;
  10104. }
  10105. };
  10106. /** @hidden */
  10107. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10108. this.selectors[selectorNb].children[1].text = label;
  10109. };
  10110. /** @hidden */
  10111. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10112. this.selectors[selectorNb].children[1].color = color;
  10113. };
  10114. /** @hidden */
  10115. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10116. this.selectors[selectorNb].children[0].color = color;
  10117. };
  10118. /** @hidden */
  10119. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10120. this.selectors[selectorNb].children[0].background = color;
  10121. };
  10122. return RadioGroup;
  10123. }(SelectorGroup));
  10124. /** Class used to create a SliderGroup
  10125. * which contains groups of slider buttons
  10126. */
  10127. var SliderGroup = /** @class */ (function (_super) {
  10128. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10129. function SliderGroup() {
  10130. return _super !== null && _super.apply(this, arguments) || this;
  10131. }
  10132. /**
  10133. * Adds a slider to the SelectorGroup
  10134. * @param label is the label for the SliderBar
  10135. * @param func is the function called when the Slider moves
  10136. * @param unit is a string describing the units used, eg degrees or metres
  10137. * @param min is the minimum value for the Slider
  10138. * @param max is the maximum value for the Slider
  10139. * @param value is the start value for the Slider between min and max
  10140. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10141. */
  10142. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10143. if (func === void 0) { func = function (v) { }; }
  10144. if (unit === void 0) { unit = "Units"; }
  10145. if (min === void 0) { min = 0; }
  10146. if (max === void 0) { max = 0; }
  10147. if (value === void 0) { value = 0; }
  10148. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10149. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10150. button.name = unit;
  10151. button.value = value;
  10152. button.minimum = min;
  10153. button.maximum = max;
  10154. button.width = 0.9;
  10155. button.height = "20px";
  10156. button.color = "#364249";
  10157. button.background = "#CCCCCC";
  10158. button.borderColor = "black";
  10159. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10160. button.left = "4px";
  10161. button.paddingBottom = "4px";
  10162. button.onValueChangedObservable.add(function (value) {
  10163. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10164. func(value);
  10165. });
  10166. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10167. _selector.height = "60px";
  10168. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10169. _selector.left = "4px";
  10170. _selector.children[0].name = label;
  10171. this.groupPanel.addControl(_selector);
  10172. this.selectors.push(_selector);
  10173. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10174. button.color = this.groupPanel.parent.parent.buttonColor;
  10175. button.background = this.groupPanel.parent.parent.buttonBackground;
  10176. }
  10177. };
  10178. /** @hidden */
  10179. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10180. this.selectors[selectorNb].children[0].name = label;
  10181. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10182. };
  10183. /** @hidden */
  10184. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10185. this.selectors[selectorNb].children[0].color = color;
  10186. };
  10187. /** @hidden */
  10188. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10189. this.selectors[selectorNb].children[1].color = color;
  10190. };
  10191. /** @hidden */
  10192. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10193. this.selectors[selectorNb].children[1].background = color;
  10194. };
  10195. return SliderGroup;
  10196. }(SelectorGroup));
  10197. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10198. * @see http://doc.babylonjs.com/how_to/selector
  10199. */
  10200. var SelectionPanel = /** @class */ (function (_super) {
  10201. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10202. /**
  10203. * Creates a new SelectionPanel
  10204. * @param name of SelectionPanel
  10205. * @param groups is an array of SelectionGroups
  10206. */
  10207. function SelectionPanel(
  10208. /** name of SelectionPanel */
  10209. name,
  10210. /** an array of SelectionGroups */
  10211. groups) {
  10212. if (groups === void 0) { groups = []; }
  10213. var _this = _super.call(this, name) || this;
  10214. _this.name = name;
  10215. _this.groups = groups;
  10216. _this._buttonColor = "#364249";
  10217. _this._buttonBackground = "#CCCCCC";
  10218. _this._headerColor = "black";
  10219. _this._barColor = "white";
  10220. _this._barHeight = "2px";
  10221. _this._spacerHeight = "20px";
  10222. _this._bars = new Array();
  10223. _this._groups = groups;
  10224. _this.thickness = 2;
  10225. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10226. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10227. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10228. _this._panel.top = 5;
  10229. _this._panel.left = 5;
  10230. _this._panel.width = 0.95;
  10231. if (groups.length > 0) {
  10232. for (var i = 0; i < groups.length - 1; i++) {
  10233. _this._panel.addControl(groups[i].groupPanel);
  10234. _this._addSpacer();
  10235. }
  10236. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10237. }
  10238. _this.addControl(_this._panel);
  10239. return _this;
  10240. }
  10241. SelectionPanel.prototype._getTypeName = function () {
  10242. return "SelectionPanel";
  10243. };
  10244. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10245. /** Gets or sets the headerColor */
  10246. get: function () {
  10247. return this._headerColor;
  10248. },
  10249. set: function (color) {
  10250. if (this._headerColor === color) {
  10251. return;
  10252. }
  10253. this._headerColor = color;
  10254. this._setHeaderColor();
  10255. },
  10256. enumerable: true,
  10257. configurable: true
  10258. });
  10259. SelectionPanel.prototype._setHeaderColor = function () {
  10260. for (var i = 0; i < this._groups.length; i++) {
  10261. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10262. }
  10263. };
  10264. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10265. /** Gets or sets the button color */
  10266. get: function () {
  10267. return this._buttonColor;
  10268. },
  10269. set: function (color) {
  10270. if (this._buttonColor === color) {
  10271. return;
  10272. }
  10273. this._buttonColor = color;
  10274. this._setbuttonColor();
  10275. },
  10276. enumerable: true,
  10277. configurable: true
  10278. });
  10279. SelectionPanel.prototype._setbuttonColor = function () {
  10280. for (var i = 0; i < this._groups.length; i++) {
  10281. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10282. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10283. }
  10284. }
  10285. };
  10286. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10287. /** Gets or sets the label color */
  10288. get: function () {
  10289. return this._labelColor;
  10290. },
  10291. set: function (color) {
  10292. if (this._labelColor === color) {
  10293. return;
  10294. }
  10295. this._labelColor = color;
  10296. this._setLabelColor();
  10297. },
  10298. enumerable: true,
  10299. configurable: true
  10300. });
  10301. SelectionPanel.prototype._setLabelColor = function () {
  10302. for (var i = 0; i < this._groups.length; i++) {
  10303. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10304. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10305. }
  10306. }
  10307. };
  10308. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10309. /** Gets or sets the button background */
  10310. get: function () {
  10311. return this._buttonBackground;
  10312. },
  10313. set: function (color) {
  10314. if (this._buttonBackground === color) {
  10315. return;
  10316. }
  10317. this._buttonBackground = color;
  10318. this._setButtonBackground();
  10319. },
  10320. enumerable: true,
  10321. configurable: true
  10322. });
  10323. SelectionPanel.prototype._setButtonBackground = function () {
  10324. for (var i = 0; i < this._groups.length; i++) {
  10325. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10326. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10327. }
  10328. }
  10329. };
  10330. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10331. /** Gets or sets the color of separator bar */
  10332. get: function () {
  10333. return this._barColor;
  10334. },
  10335. set: function (color) {
  10336. if (this._barColor === color) {
  10337. return;
  10338. }
  10339. this._barColor = color;
  10340. this._setBarColor();
  10341. },
  10342. enumerable: true,
  10343. configurable: true
  10344. });
  10345. SelectionPanel.prototype._setBarColor = function () {
  10346. for (var i = 0; i < this._bars.length; i++) {
  10347. this._bars[i].children[0].background = this._barColor;
  10348. }
  10349. };
  10350. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10351. /** Gets or sets the height of separator bar */
  10352. get: function () {
  10353. return this._barHeight;
  10354. },
  10355. set: function (value) {
  10356. if (this._barHeight === value) {
  10357. return;
  10358. }
  10359. this._barHeight = value;
  10360. this._setBarHeight();
  10361. },
  10362. enumerable: true,
  10363. configurable: true
  10364. });
  10365. SelectionPanel.prototype._setBarHeight = function () {
  10366. for (var i = 0; i < this._bars.length; i++) {
  10367. this._bars[i].children[0].height = this._barHeight;
  10368. }
  10369. };
  10370. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10371. /** Gets or sets the height of spacers*/
  10372. get: function () {
  10373. return this._spacerHeight;
  10374. },
  10375. set: function (value) {
  10376. if (this._spacerHeight === value) {
  10377. return;
  10378. }
  10379. this._spacerHeight = value;
  10380. this._setSpacerHeight();
  10381. },
  10382. enumerable: true,
  10383. configurable: true
  10384. });
  10385. SelectionPanel.prototype._setSpacerHeight = function () {
  10386. for (var i = 0; i < this._bars.length; i++) {
  10387. this._bars[i].height = this._spacerHeight;
  10388. }
  10389. };
  10390. /** Adds a bar between groups */
  10391. SelectionPanel.prototype._addSpacer = function () {
  10392. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10393. separator.width = 1;
  10394. separator.height = this._spacerHeight;
  10395. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10396. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10397. bar.width = 1;
  10398. bar.height = this._barHeight;
  10399. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10400. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10401. bar.background = this._barColor;
  10402. bar.color = "transparent";
  10403. separator.addControl(bar);
  10404. this._panel.addControl(separator);
  10405. this._bars.push(separator);
  10406. };
  10407. /** Add a group to the selection panel
  10408. * @param group is the selector group to add
  10409. */
  10410. SelectionPanel.prototype.addGroup = function (group) {
  10411. if (this._groups.length > 0) {
  10412. this._addSpacer();
  10413. }
  10414. this._panel.addControl(group.groupPanel);
  10415. this._groups.push(group);
  10416. group.groupPanel.children[0].color = this._headerColor;
  10417. for (var j = 0; j < group.selectors.length; j++) {
  10418. group._setSelectorButtonColor(j, this._buttonColor);
  10419. group._setSelectorButtonBackground(j, this._buttonBackground);
  10420. }
  10421. };
  10422. /** Remove the group from the given position
  10423. * @param groupNb is the position of the group in the list
  10424. */
  10425. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10426. if (groupNb < 0 || groupNb >= this._groups.length) {
  10427. return;
  10428. }
  10429. var group = this._groups[groupNb];
  10430. this._panel.removeControl(group.groupPanel);
  10431. this._groups.splice(groupNb, 1);
  10432. if (groupNb < this._bars.length) {
  10433. this._panel.removeControl(this._bars[groupNb]);
  10434. this._bars.splice(groupNb, 1);
  10435. }
  10436. };
  10437. /** Change a group header label
  10438. * @param label is the new group header label
  10439. * @param groupNb is the number of the group to relabel
  10440. * */
  10441. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10442. if (groupNb < 0 || groupNb >= this._groups.length) {
  10443. return;
  10444. }
  10445. var group = this._groups[groupNb];
  10446. group.groupPanel.children[0].text = label;
  10447. };
  10448. /** Change selector label to the one given
  10449. * @param label is the new selector label
  10450. * @param groupNb is the number of the groupcontaining the selector
  10451. * @param selectorNb is the number of the selector within a group to relabel
  10452. * */
  10453. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10454. if (groupNb < 0 || groupNb >= this._groups.length) {
  10455. return;
  10456. }
  10457. var group = this._groups[groupNb];
  10458. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10459. return;
  10460. }
  10461. group._setSelectorLabel(selectorNb, label);
  10462. };
  10463. /** For a given group position remove the selector at the given position
  10464. * @param groupNb is the number of the group to remove the selector from
  10465. * @param selectorNb is the number of the selector within the group
  10466. */
  10467. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10468. if (groupNb < 0 || groupNb >= this._groups.length) {
  10469. return;
  10470. }
  10471. var group = this._groups[groupNb];
  10472. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10473. return;
  10474. }
  10475. group.removeSelector(selectorNb);
  10476. };
  10477. /** For a given group position of correct type add a checkbox button
  10478. * @param groupNb is the number of the group to remove the selector from
  10479. * @param label is the label for the selector
  10480. * @param func is the function called when the Selector is checked
  10481. * @param checked is true when Selector is checked
  10482. */
  10483. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10484. if (func === void 0) { func = function () { }; }
  10485. if (checked === void 0) { checked = false; }
  10486. if (groupNb < 0 || groupNb >= this._groups.length) {
  10487. return;
  10488. }
  10489. var group = this._groups[groupNb];
  10490. group.addCheckbox(label, func, checked);
  10491. };
  10492. /** For a given group position of correct type add a radio button
  10493. * @param groupNb is the number of the group to remove the selector from
  10494. * @param label is the label for the selector
  10495. * @param func is the function called when the Selector is checked
  10496. * @param checked is true when Selector is checked
  10497. */
  10498. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10499. if (func === void 0) { func = function () { }; }
  10500. if (checked === void 0) { checked = false; }
  10501. if (groupNb < 0 || groupNb >= this._groups.length) {
  10502. return;
  10503. }
  10504. var group = this._groups[groupNb];
  10505. group.addRadio(label, func, checked);
  10506. };
  10507. /**
  10508. * For a given slider group add a slider
  10509. * @param groupNb is the number of the group to add the slider to
  10510. * @param label is the label for the Slider
  10511. * @param func is the function called when the Slider moves
  10512. * @param unit is a string describing the units used, eg degrees or metres
  10513. * @param min is the minimum value for the Slider
  10514. * @param max is the maximum value for the Slider
  10515. * @param value is the start value for the Slider between min and max
  10516. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10517. */
  10518. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10519. if (func === void 0) { func = function () { }; }
  10520. if (unit === void 0) { unit = "Units"; }
  10521. if (min === void 0) { min = 0; }
  10522. if (max === void 0) { max = 0; }
  10523. if (value === void 0) { value = 0; }
  10524. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10525. if (groupNb < 0 || groupNb >= this._groups.length) {
  10526. return;
  10527. }
  10528. var group = this._groups[groupNb];
  10529. group.addSlider(label, func, unit, min, max, value, onVal);
  10530. };
  10531. return SelectionPanel;
  10532. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10533. /***/ }),
  10534. /***/ "./2D/controls/sliders/baseSlider.ts":
  10535. /*!*******************************************!*\
  10536. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10537. \*******************************************/
  10538. /*! exports provided: BaseSlider */
  10539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10540. "use strict";
  10541. __webpack_require__.r(__webpack_exports__);
  10542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10543. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10544. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  10545. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10546. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10547. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10548. /**
  10549. * Class used to create slider controls
  10550. */
  10551. var BaseSlider = /** @class */ (function (_super) {
  10552. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10553. /**
  10554. * Creates a new BaseSlider
  10555. * @param name defines the control name
  10556. */
  10557. function BaseSlider(name) {
  10558. var _this = _super.call(this, name) || this;
  10559. _this.name = name;
  10560. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10561. _this._minimum = 0;
  10562. _this._maximum = 100;
  10563. _this._value = 50;
  10564. _this._isVertical = false;
  10565. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10566. _this._isThumbClamped = false;
  10567. _this._displayThumb = true;
  10568. _this._step = 0;
  10569. _this._lastPointerDownID = -1;
  10570. // Shared rendering info
  10571. _this._effectiveBarOffset = 0;
  10572. /** Observable raised when the sldier value changes */
  10573. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10574. // Events
  10575. _this._pointerIsDown = false;
  10576. _this.isPointerBlocker = true;
  10577. return _this;
  10578. }
  10579. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10580. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10581. get: function () {
  10582. return this._displayThumb;
  10583. },
  10584. set: function (value) {
  10585. if (this._displayThumb === value) {
  10586. return;
  10587. }
  10588. this._displayThumb = value;
  10589. this._markAsDirty();
  10590. },
  10591. enumerable: true,
  10592. configurable: true
  10593. });
  10594. Object.defineProperty(BaseSlider.prototype, "step", {
  10595. /** Gets or sets a step to apply to values (0 by default) */
  10596. get: function () {
  10597. return this._step;
  10598. },
  10599. set: function (value) {
  10600. if (this._step === value) {
  10601. return;
  10602. }
  10603. this._step = value;
  10604. this._markAsDirty();
  10605. },
  10606. enumerable: true,
  10607. configurable: true
  10608. });
  10609. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10610. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10611. get: function () {
  10612. return this._barOffset.toString(this._host);
  10613. },
  10614. set: function (value) {
  10615. if (this._barOffset.toString(this._host) === value) {
  10616. return;
  10617. }
  10618. if (this._barOffset.fromString(value)) {
  10619. this._markAsDirty();
  10620. }
  10621. },
  10622. enumerable: true,
  10623. configurable: true
  10624. });
  10625. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10626. /** Gets main bar offset in pixels*/
  10627. get: function () {
  10628. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10629. },
  10630. enumerable: true,
  10631. configurable: true
  10632. });
  10633. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10634. /** Gets or sets thumb width */
  10635. get: function () {
  10636. return this._thumbWidth.toString(this._host);
  10637. },
  10638. set: function (value) {
  10639. if (this._thumbWidth.toString(this._host) === value) {
  10640. return;
  10641. }
  10642. if (this._thumbWidth.fromString(value)) {
  10643. this._markAsDirty();
  10644. }
  10645. },
  10646. enumerable: true,
  10647. configurable: true
  10648. });
  10649. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10650. /** Gets thumb width in pixels */
  10651. get: function () {
  10652. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10653. },
  10654. enumerable: true,
  10655. configurable: true
  10656. });
  10657. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10658. /** Gets or sets minimum value */
  10659. get: function () {
  10660. return this._minimum;
  10661. },
  10662. set: function (value) {
  10663. if (this._minimum === value) {
  10664. return;
  10665. }
  10666. this._minimum = value;
  10667. this._markAsDirty();
  10668. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10669. },
  10670. enumerable: true,
  10671. configurable: true
  10672. });
  10673. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10674. /** Gets or sets maximum value */
  10675. get: function () {
  10676. return this._maximum;
  10677. },
  10678. set: function (value) {
  10679. if (this._maximum === value) {
  10680. return;
  10681. }
  10682. this._maximum = value;
  10683. this._markAsDirty();
  10684. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10685. },
  10686. enumerable: true,
  10687. configurable: true
  10688. });
  10689. Object.defineProperty(BaseSlider.prototype, "value", {
  10690. /** Gets or sets current value */
  10691. get: function () {
  10692. return this._value;
  10693. },
  10694. set: function (value) {
  10695. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10696. if (this._value === value) {
  10697. return;
  10698. }
  10699. this._value = value;
  10700. this._markAsDirty();
  10701. this.onValueChangedObservable.notifyObservers(this._value);
  10702. },
  10703. enumerable: true,
  10704. configurable: true
  10705. });
  10706. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10707. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10708. get: function () {
  10709. return this._isVertical;
  10710. },
  10711. set: function (value) {
  10712. if (this._isVertical === value) {
  10713. return;
  10714. }
  10715. this._isVertical = value;
  10716. this._markAsDirty();
  10717. },
  10718. enumerable: true,
  10719. configurable: true
  10720. });
  10721. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10722. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10723. get: function () {
  10724. return this._isThumbClamped;
  10725. },
  10726. set: function (value) {
  10727. if (this._isThumbClamped === value) {
  10728. return;
  10729. }
  10730. this._isThumbClamped = value;
  10731. this._markAsDirty();
  10732. },
  10733. enumerable: true,
  10734. configurable: true
  10735. });
  10736. BaseSlider.prototype._getTypeName = function () {
  10737. return "BaseSlider";
  10738. };
  10739. BaseSlider.prototype._getThumbPosition = function () {
  10740. if (this.isVertical) {
  10741. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10742. }
  10743. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10744. };
  10745. BaseSlider.prototype._getThumbThickness = function (type) {
  10746. var thumbThickness = 0;
  10747. switch (type) {
  10748. case "circle":
  10749. if (this._thumbWidth.isPixel) {
  10750. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10751. }
  10752. else {
  10753. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10754. }
  10755. break;
  10756. case "rectangle":
  10757. if (this._thumbWidth.isPixel) {
  10758. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10759. }
  10760. else {
  10761. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10762. }
  10763. }
  10764. return thumbThickness;
  10765. };
  10766. BaseSlider.prototype._prepareRenderingData = function (type) {
  10767. // Main bar
  10768. this._effectiveBarOffset = 0;
  10769. this._renderLeft = this._currentMeasure.left;
  10770. this._renderTop = this._currentMeasure.top;
  10771. this._renderWidth = this._currentMeasure.width;
  10772. this._renderHeight = this._currentMeasure.height;
  10773. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10774. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10775. this._effectiveThumbThickness = this._getThumbThickness(type);
  10776. if (this.displayThumb) {
  10777. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10778. }
  10779. //throw error when height is less than width for vertical slider
  10780. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10781. console.error("Height should be greater than width");
  10782. return;
  10783. }
  10784. if (this._barOffset.isPixel) {
  10785. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10786. }
  10787. else {
  10788. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10789. }
  10790. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10791. if (this.isVertical) {
  10792. this._renderLeft += this._effectiveBarOffset;
  10793. if (!this.isThumbClamped && this.displayThumb) {
  10794. this._renderTop += (this._effectiveThumbThickness / 2);
  10795. }
  10796. this._renderHeight = this._backgroundBoxLength;
  10797. this._renderWidth = this._backgroundBoxThickness;
  10798. }
  10799. else {
  10800. this._renderTop += this._effectiveBarOffset;
  10801. if (!this.isThumbClamped && this.displayThumb) {
  10802. this._renderLeft += (this._effectiveThumbThickness / 2);
  10803. }
  10804. this._renderHeight = this._backgroundBoxThickness;
  10805. this._renderWidth = this._backgroundBoxLength;
  10806. }
  10807. };
  10808. /** @hidden */
  10809. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10810. if (this.rotation != 0) {
  10811. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10812. x = this._transformedPosition.x;
  10813. y = this._transformedPosition.y;
  10814. }
  10815. var value;
  10816. if (this._isVertical) {
  10817. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10818. }
  10819. else {
  10820. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10821. }
  10822. var mult = (1 / this._step) | 0;
  10823. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10824. };
  10825. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10826. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10827. return false;
  10828. }
  10829. this._pointerIsDown = true;
  10830. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10831. this._host._capturingControl[pointerId] = this;
  10832. this._lastPointerDownID = pointerId;
  10833. return true;
  10834. };
  10835. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10836. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10837. if (pointerId != this._lastPointerDownID) {
  10838. return;
  10839. }
  10840. if (this._pointerIsDown) {
  10841. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10842. }
  10843. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10844. };
  10845. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10846. this._pointerIsDown = false;
  10847. delete this._host._capturingControl[pointerId];
  10848. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10849. };
  10850. return BaseSlider;
  10851. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10852. /***/ }),
  10853. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10854. /*!*************************************************!*\
  10855. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10856. \*************************************************/
  10857. /*! exports provided: ImageBasedSlider */
  10858. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10859. "use strict";
  10860. __webpack_require__.r(__webpack_exports__);
  10861. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10862. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10863. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10864. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10865. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  10866. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10867. /**
  10868. * Class used to create slider controls based on images
  10869. */
  10870. var ImageBasedSlider = /** @class */ (function (_super) {
  10871. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10872. /**
  10873. * Creates a new ImageBasedSlider
  10874. * @param name defines the control name
  10875. */
  10876. function ImageBasedSlider(name) {
  10877. var _this = _super.call(this, name) || this;
  10878. _this.name = name;
  10879. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10880. return _this;
  10881. }
  10882. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10883. get: function () {
  10884. return this._displayThumb && this.thumbImage != null;
  10885. },
  10886. set: function (value) {
  10887. if (this._displayThumb === value) {
  10888. return;
  10889. }
  10890. this._displayThumb = value;
  10891. this._markAsDirty();
  10892. },
  10893. enumerable: true,
  10894. configurable: true
  10895. });
  10896. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10897. /**
  10898. * Gets or sets the image used to render the background
  10899. */
  10900. get: function () {
  10901. return this._backgroundImage;
  10902. },
  10903. set: function (value) {
  10904. var _this = this;
  10905. if (this._backgroundImage === value) {
  10906. return;
  10907. }
  10908. this._backgroundImage = value;
  10909. if (value && !value.isLoaded) {
  10910. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10911. }
  10912. this._markAsDirty();
  10913. },
  10914. enumerable: true,
  10915. configurable: true
  10916. });
  10917. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10918. /**
  10919. * Gets or sets the image used to render the value bar
  10920. */
  10921. get: function () {
  10922. return this._valueBarImage;
  10923. },
  10924. set: function (value) {
  10925. var _this = this;
  10926. if (this._valueBarImage === value) {
  10927. return;
  10928. }
  10929. this._valueBarImage = value;
  10930. if (value && !value.isLoaded) {
  10931. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10932. }
  10933. this._markAsDirty();
  10934. },
  10935. enumerable: true,
  10936. configurable: true
  10937. });
  10938. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10939. /**
  10940. * Gets or sets the image used to render the thumb
  10941. */
  10942. get: function () {
  10943. return this._thumbImage;
  10944. },
  10945. set: function (value) {
  10946. var _this = this;
  10947. if (this._thumbImage === value) {
  10948. return;
  10949. }
  10950. this._thumbImage = value;
  10951. if (value && !value.isLoaded) {
  10952. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10953. }
  10954. this._markAsDirty();
  10955. },
  10956. enumerable: true,
  10957. configurable: true
  10958. });
  10959. ImageBasedSlider.prototype._getTypeName = function () {
  10960. return "ImageBasedSlider";
  10961. };
  10962. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  10963. context.save();
  10964. this._applyStates(context);
  10965. this._prepareRenderingData("rectangle");
  10966. var thumbPosition = this._getThumbPosition();
  10967. var left = this._renderLeft;
  10968. var top = this._renderTop;
  10969. var width = this._renderWidth;
  10970. var height = this._renderHeight;
  10971. // Background
  10972. if (this._backgroundImage) {
  10973. this._tempMeasure.copyFromFloats(left, top, width, height);
  10974. if (this.isThumbClamped && this.displayThumb) {
  10975. if (this.isVertical) {
  10976. this._tempMeasure.height += this._effectiveThumbThickness;
  10977. }
  10978. else {
  10979. this._tempMeasure.width += this._effectiveThumbThickness;
  10980. }
  10981. }
  10982. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10983. this._backgroundImage._draw(context);
  10984. }
  10985. // Bar
  10986. if (this._valueBarImage) {
  10987. if (this.isVertical) {
  10988. if (this.isThumbClamped && this.displayThumb) {
  10989. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10990. }
  10991. else {
  10992. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10993. }
  10994. }
  10995. else {
  10996. if (this.isThumbClamped && this.displayThumb) {
  10997. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10998. }
  10999. else {
  11000. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11001. }
  11002. }
  11003. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11004. this._valueBarImage._draw(context);
  11005. }
  11006. // Thumb
  11007. if (this.displayThumb) {
  11008. if (this.isVertical) {
  11009. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11010. }
  11011. else {
  11012. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11013. }
  11014. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11015. this._thumbImage._draw(context);
  11016. }
  11017. context.restore();
  11018. };
  11019. return ImageBasedSlider;
  11020. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11021. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11022. /***/ }),
  11023. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11024. /*!***********************************************!*\
  11025. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11026. \***********************************************/
  11027. /*! exports provided: ImageScrollBar */
  11028. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11029. "use strict";
  11030. __webpack_require__.r(__webpack_exports__);
  11031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11032. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11033. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11034. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11035. /**
  11036. * Class used to create slider controls
  11037. */
  11038. var ImageScrollBar = /** @class */ (function (_super) {
  11039. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11040. /**
  11041. * Creates a new ImageScrollBar
  11042. * @param name defines the control name
  11043. */
  11044. function ImageScrollBar(name) {
  11045. var _this = _super.call(this, name) || this;
  11046. _this.name = name;
  11047. _this._thumbLength = 0.5;
  11048. _this._thumbHeight = 1;
  11049. _this._barImageHeight = 1;
  11050. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11051. /** Number of 90° rotation to apply on the images when in vertical mode */
  11052. _this.num90RotationInVerticalMode = 1;
  11053. return _this;
  11054. }
  11055. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11056. /**
  11057. * Gets or sets the image used to render the background for horizontal bar
  11058. */
  11059. get: function () {
  11060. return this._backgroundBaseImage;
  11061. },
  11062. set: function (value) {
  11063. var _this = this;
  11064. if (this._backgroundBaseImage === value) {
  11065. return;
  11066. }
  11067. this._backgroundBaseImage = value;
  11068. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11069. if (!value.isLoaded) {
  11070. value.onImageLoadedObservable.addOnce(function () {
  11071. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11072. _this._backgroundImage = rotatedValue;
  11073. if (!rotatedValue.isLoaded) {
  11074. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11075. _this._markAsDirty();
  11076. });
  11077. }
  11078. _this._markAsDirty();
  11079. });
  11080. }
  11081. else {
  11082. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11083. this._markAsDirty();
  11084. }
  11085. }
  11086. else {
  11087. this._backgroundImage = value;
  11088. if (value && !value.isLoaded) {
  11089. value.onImageLoadedObservable.addOnce(function () {
  11090. _this._markAsDirty();
  11091. });
  11092. }
  11093. this._markAsDirty();
  11094. }
  11095. },
  11096. enumerable: true,
  11097. configurable: true
  11098. });
  11099. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11100. /**
  11101. * Gets or sets the image used to render the thumb
  11102. */
  11103. get: function () {
  11104. return this._thumbBaseImage;
  11105. },
  11106. set: function (value) {
  11107. var _this = this;
  11108. if (this._thumbBaseImage === value) {
  11109. return;
  11110. }
  11111. this._thumbBaseImage = value;
  11112. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11113. if (!value.isLoaded) {
  11114. value.onImageLoadedObservable.addOnce(function () {
  11115. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11116. _this._thumbImage = rotatedValue;
  11117. if (!rotatedValue.isLoaded) {
  11118. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11119. _this._markAsDirty();
  11120. });
  11121. }
  11122. _this._markAsDirty();
  11123. });
  11124. }
  11125. else {
  11126. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11127. this._markAsDirty();
  11128. }
  11129. }
  11130. else {
  11131. this._thumbImage = value;
  11132. if (value && !value.isLoaded) {
  11133. value.onImageLoadedObservable.addOnce(function () {
  11134. _this._markAsDirty();
  11135. });
  11136. }
  11137. this._markAsDirty();
  11138. }
  11139. },
  11140. enumerable: true,
  11141. configurable: true
  11142. });
  11143. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11144. /**
  11145. * Gets or sets the length of the thumb
  11146. */
  11147. get: function () {
  11148. return this._thumbLength;
  11149. },
  11150. set: function (value) {
  11151. if (this._thumbLength === value) {
  11152. return;
  11153. }
  11154. this._thumbLength = value;
  11155. this._markAsDirty();
  11156. },
  11157. enumerable: true,
  11158. configurable: true
  11159. });
  11160. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11161. /**
  11162. * Gets or sets the height of the thumb
  11163. */
  11164. get: function () {
  11165. return this._thumbHeight;
  11166. },
  11167. set: function (value) {
  11168. if (this._thumbLength === value) {
  11169. return;
  11170. }
  11171. this._thumbHeight = value;
  11172. this._markAsDirty();
  11173. },
  11174. enumerable: true,
  11175. configurable: true
  11176. });
  11177. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11178. /**
  11179. * Gets or sets the height of the bar image
  11180. */
  11181. get: function () {
  11182. return this._barImageHeight;
  11183. },
  11184. set: function (value) {
  11185. if (this._barImageHeight === value) {
  11186. return;
  11187. }
  11188. this._barImageHeight = value;
  11189. this._markAsDirty();
  11190. },
  11191. enumerable: true,
  11192. configurable: true
  11193. });
  11194. ImageScrollBar.prototype._getTypeName = function () {
  11195. return "ImageScrollBar";
  11196. };
  11197. ImageScrollBar.prototype._getThumbThickness = function () {
  11198. var thumbThickness = 0;
  11199. if (this._thumbWidth.isPixel) {
  11200. thumbThickness = this._thumbWidth.getValue(this._host);
  11201. }
  11202. else {
  11203. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11204. }
  11205. return thumbThickness;
  11206. };
  11207. ImageScrollBar.prototype._draw = function (context) {
  11208. context.save();
  11209. this._applyStates(context);
  11210. this._prepareRenderingData("rectangle");
  11211. var thumbPosition = this._getThumbPosition();
  11212. var left = this._renderLeft;
  11213. var top = this._renderTop;
  11214. var width = this._renderWidth;
  11215. var height = this._renderHeight;
  11216. // Background
  11217. if (this._backgroundImage) {
  11218. this._tempMeasure.copyFromFloats(left, top, width, height);
  11219. if (this.isVertical) {
  11220. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11221. this._tempMeasure.height += this._effectiveThumbThickness;
  11222. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11223. }
  11224. else {
  11225. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11226. this._tempMeasure.width += this._effectiveThumbThickness;
  11227. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11228. }
  11229. this._backgroundImage._draw(context);
  11230. }
  11231. // Thumb
  11232. if (this.isVertical) {
  11233. 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);
  11234. }
  11235. else {
  11236. 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);
  11237. }
  11238. if (this._thumbImage) {
  11239. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11240. this._thumbImage._draw(context);
  11241. }
  11242. context.restore();
  11243. };
  11244. /** @hidden */
  11245. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11246. if (this.rotation != 0) {
  11247. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11248. x = this._transformedPosition.x;
  11249. y = this._transformedPosition.y;
  11250. }
  11251. if (this._first) {
  11252. this._first = false;
  11253. this._originX = x;
  11254. this._originY = y;
  11255. // Check if move is required
  11256. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11257. if (this.isVertical) {
  11258. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11259. }
  11260. else {
  11261. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11262. }
  11263. }
  11264. }
  11265. // Delta mode
  11266. var delta = 0;
  11267. if (this.isVertical) {
  11268. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11269. }
  11270. else {
  11271. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11272. }
  11273. this.value += delta * (this.maximum - this.minimum);
  11274. this._originX = x;
  11275. this._originY = y;
  11276. };
  11277. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11278. this._first = true;
  11279. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11280. };
  11281. return ImageScrollBar;
  11282. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11283. /***/ }),
  11284. /***/ "./2D/controls/sliders/scrollBar.ts":
  11285. /*!******************************************!*\
  11286. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11287. \******************************************/
  11288. /*! exports provided: ScrollBar */
  11289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11290. "use strict";
  11291. __webpack_require__.r(__webpack_exports__);
  11292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11293. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11294. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11295. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11296. /**
  11297. * Class used to create slider controls
  11298. */
  11299. var ScrollBar = /** @class */ (function (_super) {
  11300. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11301. /**
  11302. * Creates a new Slider
  11303. * @param name defines the control name
  11304. */
  11305. function ScrollBar(name) {
  11306. var _this = _super.call(this, name) || this;
  11307. _this.name = name;
  11308. _this._background = "black";
  11309. _this._borderColor = "white";
  11310. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11311. return _this;
  11312. }
  11313. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11314. /** Gets or sets border color */
  11315. get: function () {
  11316. return this._borderColor;
  11317. },
  11318. set: function (value) {
  11319. if (this._borderColor === value) {
  11320. return;
  11321. }
  11322. this._borderColor = value;
  11323. this._markAsDirty();
  11324. },
  11325. enumerable: true,
  11326. configurable: true
  11327. });
  11328. Object.defineProperty(ScrollBar.prototype, "background", {
  11329. /** Gets or sets background color */
  11330. get: function () {
  11331. return this._background;
  11332. },
  11333. set: function (value) {
  11334. if (this._background === value) {
  11335. return;
  11336. }
  11337. this._background = value;
  11338. this._markAsDirty();
  11339. },
  11340. enumerable: true,
  11341. configurable: true
  11342. });
  11343. ScrollBar.prototype._getTypeName = function () {
  11344. return "Scrollbar";
  11345. };
  11346. ScrollBar.prototype._getThumbThickness = function () {
  11347. var thumbThickness = 0;
  11348. if (this._thumbWidth.isPixel) {
  11349. thumbThickness = this._thumbWidth.getValue(this._host);
  11350. }
  11351. else {
  11352. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11353. }
  11354. return thumbThickness;
  11355. };
  11356. ScrollBar.prototype._draw = function (context) {
  11357. context.save();
  11358. this._applyStates(context);
  11359. this._prepareRenderingData("rectangle");
  11360. var left = this._renderLeft;
  11361. var thumbPosition = this._getThumbPosition();
  11362. context.fillStyle = this._background;
  11363. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11364. // Value bar
  11365. context.fillStyle = this.color;
  11366. // Thumb
  11367. if (this.isVertical) {
  11368. this._tempMeasure.left = left - this._effectiveBarOffset;
  11369. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11370. this._tempMeasure.width = this._currentMeasure.width;
  11371. this._tempMeasure.height = this._effectiveThumbThickness;
  11372. }
  11373. else {
  11374. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11375. this._tempMeasure.top = this._currentMeasure.top;
  11376. this._tempMeasure.width = this._effectiveThumbThickness;
  11377. this._tempMeasure.height = this._currentMeasure.height;
  11378. }
  11379. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11380. context.restore();
  11381. };
  11382. /** @hidden */
  11383. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11384. if (this.rotation != 0) {
  11385. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11386. x = this._transformedPosition.x;
  11387. y = this._transformedPosition.y;
  11388. }
  11389. if (this._first) {
  11390. this._first = false;
  11391. this._originX = x;
  11392. this._originY = y;
  11393. // Check if move is required
  11394. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11395. if (this.isVertical) {
  11396. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11397. }
  11398. else {
  11399. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11400. }
  11401. }
  11402. }
  11403. // Delta mode
  11404. var delta = 0;
  11405. if (this.isVertical) {
  11406. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11407. }
  11408. else {
  11409. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11410. }
  11411. this.value += delta * (this.maximum - this.minimum);
  11412. this._originX = x;
  11413. this._originY = y;
  11414. };
  11415. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11416. this._first = true;
  11417. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11418. };
  11419. return ScrollBar;
  11420. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11421. /***/ }),
  11422. /***/ "./2D/controls/sliders/slider.ts":
  11423. /*!***************************************!*\
  11424. !*** ./2D/controls/sliders/slider.ts ***!
  11425. \***************************************/
  11426. /*! exports provided: Slider */
  11427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11428. "use strict";
  11429. __webpack_require__.r(__webpack_exports__);
  11430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11431. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11432. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11433. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  11434. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11435. /**
  11436. * Class used to create slider controls
  11437. */
  11438. var Slider = /** @class */ (function (_super) {
  11439. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11440. /**
  11441. * Creates a new Slider
  11442. * @param name defines the control name
  11443. */
  11444. function Slider(name) {
  11445. var _this = _super.call(this, name) || this;
  11446. _this.name = name;
  11447. _this._background = "black";
  11448. _this._borderColor = "white";
  11449. _this._isThumbCircle = false;
  11450. _this._displayValueBar = true;
  11451. return _this;
  11452. }
  11453. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11454. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11455. get: function () {
  11456. return this._displayValueBar;
  11457. },
  11458. set: function (value) {
  11459. if (this._displayValueBar === value) {
  11460. return;
  11461. }
  11462. this._displayValueBar = value;
  11463. this._markAsDirty();
  11464. },
  11465. enumerable: true,
  11466. configurable: true
  11467. });
  11468. Object.defineProperty(Slider.prototype, "borderColor", {
  11469. /** Gets or sets border color */
  11470. get: function () {
  11471. return this._borderColor;
  11472. },
  11473. set: function (value) {
  11474. if (this._borderColor === value) {
  11475. return;
  11476. }
  11477. this._borderColor = value;
  11478. this._markAsDirty();
  11479. },
  11480. enumerable: true,
  11481. configurable: true
  11482. });
  11483. Object.defineProperty(Slider.prototype, "background", {
  11484. /** Gets or sets background color */
  11485. get: function () {
  11486. return this._background;
  11487. },
  11488. set: function (value) {
  11489. if (this._background === value) {
  11490. return;
  11491. }
  11492. this._background = value;
  11493. this._markAsDirty();
  11494. },
  11495. enumerable: true,
  11496. configurable: true
  11497. });
  11498. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11499. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11500. get: function () {
  11501. return this._isThumbCircle;
  11502. },
  11503. set: function (value) {
  11504. if (this._isThumbCircle === value) {
  11505. return;
  11506. }
  11507. this._isThumbCircle = value;
  11508. this._markAsDirty();
  11509. },
  11510. enumerable: true,
  11511. configurable: true
  11512. });
  11513. Slider.prototype._getTypeName = function () {
  11514. return "Slider";
  11515. };
  11516. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11517. context.save();
  11518. this._applyStates(context);
  11519. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11520. var left = this._renderLeft;
  11521. var top = this._renderTop;
  11522. var width = this._renderWidth;
  11523. var height = this._renderHeight;
  11524. var radius = 0;
  11525. if (this.isThumbClamped && this.isThumbCircle) {
  11526. if (this.isVertical) {
  11527. top += (this._effectiveThumbThickness / 2);
  11528. }
  11529. else {
  11530. left += (this._effectiveThumbThickness / 2);
  11531. }
  11532. radius = this._backgroundBoxThickness / 2;
  11533. }
  11534. else {
  11535. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11536. }
  11537. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11538. context.shadowColor = this.shadowColor;
  11539. context.shadowBlur = this.shadowBlur;
  11540. context.shadowOffsetX = this.shadowOffsetX;
  11541. context.shadowOffsetY = this.shadowOffsetY;
  11542. }
  11543. var thumbPosition = this._getThumbPosition();
  11544. context.fillStyle = this._background;
  11545. if (this.isVertical) {
  11546. if (this.isThumbClamped) {
  11547. if (this.isThumbCircle) {
  11548. context.beginPath();
  11549. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11550. context.fill();
  11551. context.fillRect(left, top, width, height);
  11552. }
  11553. else {
  11554. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11555. }
  11556. }
  11557. else {
  11558. context.fillRect(left, top, width, height);
  11559. }
  11560. }
  11561. else {
  11562. if (this.isThumbClamped) {
  11563. if (this.isThumbCircle) {
  11564. context.beginPath();
  11565. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11566. context.fill();
  11567. context.fillRect(left, top, width, height);
  11568. }
  11569. else {
  11570. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11571. }
  11572. }
  11573. else {
  11574. context.fillRect(left, top, width, height);
  11575. }
  11576. }
  11577. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11578. context.shadowBlur = 0;
  11579. context.shadowOffsetX = 0;
  11580. context.shadowOffsetY = 0;
  11581. }
  11582. // Value bar
  11583. context.fillStyle = this.color;
  11584. if (this._displayValueBar) {
  11585. if (this.isVertical) {
  11586. if (this.isThumbClamped) {
  11587. if (this.isThumbCircle) {
  11588. context.beginPath();
  11589. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11590. context.fill();
  11591. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11592. }
  11593. else {
  11594. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11595. }
  11596. }
  11597. else {
  11598. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11599. }
  11600. }
  11601. else {
  11602. if (this.isThumbClamped) {
  11603. if (this.isThumbCircle) {
  11604. context.beginPath();
  11605. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11606. context.fill();
  11607. context.fillRect(left, top, thumbPosition, height);
  11608. }
  11609. else {
  11610. context.fillRect(left, top, thumbPosition, height);
  11611. }
  11612. }
  11613. else {
  11614. context.fillRect(left, top, thumbPosition, height);
  11615. }
  11616. }
  11617. }
  11618. // Thumb
  11619. if (this.displayThumb) {
  11620. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11621. context.shadowColor = this.shadowColor;
  11622. context.shadowBlur = this.shadowBlur;
  11623. context.shadowOffsetX = this.shadowOffsetX;
  11624. context.shadowOffsetY = this.shadowOffsetY;
  11625. }
  11626. if (this._isThumbCircle) {
  11627. context.beginPath();
  11628. if (this.isVertical) {
  11629. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11630. }
  11631. else {
  11632. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11633. }
  11634. context.fill();
  11635. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11636. context.shadowBlur = 0;
  11637. context.shadowOffsetX = 0;
  11638. context.shadowOffsetY = 0;
  11639. }
  11640. context.strokeStyle = this._borderColor;
  11641. context.stroke();
  11642. }
  11643. else {
  11644. if (this.isVertical) {
  11645. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11646. }
  11647. else {
  11648. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11649. }
  11650. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11651. context.shadowBlur = 0;
  11652. context.shadowOffsetX = 0;
  11653. context.shadowOffsetY = 0;
  11654. }
  11655. context.strokeStyle = this._borderColor;
  11656. if (this.isVertical) {
  11657. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11658. }
  11659. else {
  11660. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11661. }
  11662. }
  11663. }
  11664. context.restore();
  11665. };
  11666. return Slider;
  11667. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11668. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11669. /***/ }),
  11670. /***/ "./2D/controls/stackPanel.ts":
  11671. /*!***********************************!*\
  11672. !*** ./2D/controls/stackPanel.ts ***!
  11673. \***********************************/
  11674. /*! exports provided: StackPanel */
  11675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11676. "use strict";
  11677. __webpack_require__.r(__webpack_exports__);
  11678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11679. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11680. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  11681. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11682. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11683. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11684. /**
  11685. * Class used to create a 2D stack panel container
  11686. */
  11687. var StackPanel = /** @class */ (function (_super) {
  11688. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11689. /**
  11690. * Creates a new StackPanel
  11691. * @param name defines control name
  11692. */
  11693. function StackPanel(name) {
  11694. var _this = _super.call(this, name) || this;
  11695. _this.name = name;
  11696. _this._isVertical = true;
  11697. _this._manualWidth = false;
  11698. _this._manualHeight = false;
  11699. _this._doNotTrackManualChanges = false;
  11700. /**
  11701. * Gets or sets a boolean indicating that layou warnings should be ignored
  11702. */
  11703. _this.ignoreLayoutWarnings = false;
  11704. return _this;
  11705. }
  11706. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11707. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11708. get: function () {
  11709. return this._isVertical;
  11710. },
  11711. set: function (value) {
  11712. if (this._isVertical === value) {
  11713. return;
  11714. }
  11715. this._isVertical = value;
  11716. this._markAsDirty();
  11717. },
  11718. enumerable: true,
  11719. configurable: true
  11720. });
  11721. Object.defineProperty(StackPanel.prototype, "width", {
  11722. get: function () {
  11723. return this._width.toString(this._host);
  11724. },
  11725. /**
  11726. * Gets or sets panel width.
  11727. * This value should not be set when in horizontal mode as it will be computed automatically
  11728. */
  11729. set: function (value) {
  11730. if (!this._doNotTrackManualChanges) {
  11731. this._manualWidth = true;
  11732. }
  11733. if (this._width.toString(this._host) === value) {
  11734. return;
  11735. }
  11736. if (this._width.fromString(value)) {
  11737. this._markAsDirty();
  11738. }
  11739. },
  11740. enumerable: true,
  11741. configurable: true
  11742. });
  11743. Object.defineProperty(StackPanel.prototype, "height", {
  11744. get: function () {
  11745. return this._height.toString(this._host);
  11746. },
  11747. /**
  11748. * Gets or sets panel height.
  11749. * This value should not be set when in vertical mode as it will be computed automatically
  11750. */
  11751. set: function (value) {
  11752. if (!this._doNotTrackManualChanges) {
  11753. this._manualHeight = true;
  11754. }
  11755. if (this._height.toString(this._host) === value) {
  11756. return;
  11757. }
  11758. if (this._height.fromString(value)) {
  11759. this._markAsDirty();
  11760. }
  11761. },
  11762. enumerable: true,
  11763. configurable: true
  11764. });
  11765. StackPanel.prototype._getTypeName = function () {
  11766. return "StackPanel";
  11767. };
  11768. /** @hidden */
  11769. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11770. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11771. var child = _a[_i];
  11772. if (this._isVertical) {
  11773. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11774. }
  11775. else {
  11776. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11777. }
  11778. }
  11779. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11780. };
  11781. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11782. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11783. this._measureForChildren.copyFrom(parentMeasure);
  11784. this._measureForChildren.left = this._currentMeasure.left;
  11785. this._measureForChildren.top = this._currentMeasure.top;
  11786. if (!this.isVertical || this._manualWidth) {
  11787. this._measureForChildren.width = this._currentMeasure.width;
  11788. }
  11789. if (this.isVertical || this._manualHeight) {
  11790. this._measureForChildren.height = this._currentMeasure.height;
  11791. }
  11792. };
  11793. StackPanel.prototype._postMeasure = function () {
  11794. var stackWidth = 0;
  11795. var stackHeight = 0;
  11796. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11797. var child = _a[_i];
  11798. if (!child.isVisible || child.notRenderable) {
  11799. continue;
  11800. }
  11801. if (this._isVertical) {
  11802. if (child.top !== stackHeight + "px") {
  11803. child.top = stackHeight + "px";
  11804. this._rebuildLayout = true;
  11805. child._top.ignoreAdaptiveScaling = true;
  11806. }
  11807. if (child._height.isPercentage && !child._automaticSize) {
  11808. if (!this.ignoreLayoutWarnings) {
  11809. 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");
  11810. }
  11811. }
  11812. else {
  11813. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11814. }
  11815. }
  11816. else {
  11817. if (child.left !== stackWidth + "px") {
  11818. child.left = stackWidth + "px";
  11819. this._rebuildLayout = true;
  11820. child._left.ignoreAdaptiveScaling = true;
  11821. }
  11822. if (child._width.isPercentage && !child._automaticSize) {
  11823. if (!this.ignoreLayoutWarnings) {
  11824. 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");
  11825. }
  11826. }
  11827. else {
  11828. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11829. }
  11830. }
  11831. }
  11832. this._doNotTrackManualChanges = true;
  11833. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11834. // User can now define their own height and width for stack panel.
  11835. var panelWidthChanged = false;
  11836. var panelHeightChanged = false;
  11837. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11838. var previousHeight = this.height;
  11839. this.height = stackHeight + "px";
  11840. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11841. }
  11842. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11843. var previousWidth = this.width;
  11844. this.width = stackWidth + "px";
  11845. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11846. }
  11847. if (panelHeightChanged) {
  11848. this._height.ignoreAdaptiveScaling = true;
  11849. }
  11850. if (panelWidthChanged) {
  11851. this._width.ignoreAdaptiveScaling = true;
  11852. }
  11853. this._doNotTrackManualChanges = false;
  11854. if (panelWidthChanged || panelHeightChanged) {
  11855. this._rebuildLayout = true;
  11856. }
  11857. _super.prototype._postMeasure.call(this);
  11858. };
  11859. return StackPanel;
  11860. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11861. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11862. /***/ }),
  11863. /***/ "./2D/controls/statics.ts":
  11864. /*!********************************!*\
  11865. !*** ./2D/controls/statics.ts ***!
  11866. \********************************/
  11867. /*! exports provided: name */
  11868. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11869. "use strict";
  11870. __webpack_require__.r(__webpack_exports__);
  11871. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11872. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11873. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11874. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11875. /**
  11876. * Forcing an export so that this code will execute
  11877. * @hidden
  11878. */
  11879. var name = "Statics";
  11880. /**
  11881. * Creates a stack panel that can be used to render headers
  11882. * @param control defines the control to associate with the header
  11883. * @param text defines the text of the header
  11884. * @param size defines the size of the header
  11885. * @param options defines options used to configure the header
  11886. * @returns a new StackPanel
  11887. */
  11888. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11889. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11890. var isHorizontal = options ? options.isHorizontal : true;
  11891. var controlFirst = options ? options.controlFirst : true;
  11892. panel.isVertical = !isHorizontal;
  11893. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11894. header.text = text;
  11895. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11896. if (isHorizontal) {
  11897. header.width = size;
  11898. }
  11899. else {
  11900. header.height = size;
  11901. }
  11902. if (controlFirst) {
  11903. panel.addControl(control);
  11904. panel.addControl(header);
  11905. header.paddingLeft = "5px";
  11906. }
  11907. else {
  11908. panel.addControl(header);
  11909. panel.addControl(control);
  11910. header.paddingRight = "5px";
  11911. }
  11912. header.shadowBlur = control.shadowBlur;
  11913. header.shadowColor = control.shadowColor;
  11914. header.shadowOffsetX = control.shadowOffsetX;
  11915. header.shadowOffsetY = control.shadowOffsetY;
  11916. return panel;
  11917. };
  11918. /***/ }),
  11919. /***/ "./2D/controls/textBlock.ts":
  11920. /*!**********************************!*\
  11921. !*** ./2D/controls/textBlock.ts ***!
  11922. \**********************************/
  11923. /*! exports provided: TextWrapping, TextBlock */
  11924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11925. "use strict";
  11926. __webpack_require__.r(__webpack_exports__);
  11927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  11928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  11929. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11930. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  11931. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11932. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  11933. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11934. /**
  11935. * Enum that determines the text-wrapping mode to use.
  11936. */
  11937. var TextWrapping;
  11938. (function (TextWrapping) {
  11939. /**
  11940. * Clip the text when it's larger than Control.width; this is the default mode.
  11941. */
  11942. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  11943. /**
  11944. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  11945. */
  11946. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  11947. /**
  11948. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  11949. */
  11950. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  11951. })(TextWrapping || (TextWrapping = {}));
  11952. /**
  11953. * Class used to create text block control
  11954. */
  11955. var TextBlock = /** @class */ (function (_super) {
  11956. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  11957. /**
  11958. * Creates a new TextBlock object
  11959. * @param name defines the name of the control
  11960. * @param text defines the text to display (emptry string by default)
  11961. */
  11962. function TextBlock(
  11963. /**
  11964. * Defines the name of the control
  11965. */
  11966. name, text) {
  11967. if (text === void 0) { text = ""; }
  11968. var _this = _super.call(this, name) || this;
  11969. _this.name = name;
  11970. _this._text = "";
  11971. _this._textWrapping = TextWrapping.Clip;
  11972. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11973. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11974. _this._resizeToFit = false;
  11975. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11976. _this._outlineWidth = 0;
  11977. _this._outlineColor = "white";
  11978. /**
  11979. * An event triggered after the text is changed
  11980. */
  11981. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11982. /**
  11983. * An event triggered after the text was broken up into lines
  11984. */
  11985. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11986. _this.text = text;
  11987. return _this;
  11988. }
  11989. Object.defineProperty(TextBlock.prototype, "lines", {
  11990. /**
  11991. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11992. */
  11993. get: function () {
  11994. return this._lines;
  11995. },
  11996. enumerable: true,
  11997. configurable: true
  11998. });
  11999. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12000. /**
  12001. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12002. */
  12003. get: function () {
  12004. return this._resizeToFit;
  12005. },
  12006. /**
  12007. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12008. */
  12009. set: function (value) {
  12010. if (this._resizeToFit === value) {
  12011. return;
  12012. }
  12013. this._resizeToFit = value;
  12014. if (this._resizeToFit) {
  12015. this._width.ignoreAdaptiveScaling = true;
  12016. this._height.ignoreAdaptiveScaling = true;
  12017. }
  12018. this._markAsDirty();
  12019. },
  12020. enumerable: true,
  12021. configurable: true
  12022. });
  12023. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12024. /**
  12025. * Gets or sets a boolean indicating if text must be wrapped
  12026. */
  12027. get: function () {
  12028. return this._textWrapping;
  12029. },
  12030. /**
  12031. * Gets or sets a boolean indicating if text must be wrapped
  12032. */
  12033. set: function (value) {
  12034. if (this._textWrapping === value) {
  12035. return;
  12036. }
  12037. this._textWrapping = +value;
  12038. this._markAsDirty();
  12039. },
  12040. enumerable: true,
  12041. configurable: true
  12042. });
  12043. Object.defineProperty(TextBlock.prototype, "text", {
  12044. /**
  12045. * Gets or sets text to display
  12046. */
  12047. get: function () {
  12048. return this._text;
  12049. },
  12050. /**
  12051. * Gets or sets text to display
  12052. */
  12053. set: function (value) {
  12054. if (this._text === value) {
  12055. return;
  12056. }
  12057. this._text = value;
  12058. this._markAsDirty();
  12059. this.onTextChangedObservable.notifyObservers(this);
  12060. },
  12061. enumerable: true,
  12062. configurable: true
  12063. });
  12064. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12065. /**
  12066. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12067. */
  12068. get: function () {
  12069. return this._textHorizontalAlignment;
  12070. },
  12071. /**
  12072. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12073. */
  12074. set: function (value) {
  12075. if (this._textHorizontalAlignment === value) {
  12076. return;
  12077. }
  12078. this._textHorizontalAlignment = value;
  12079. this._markAsDirty();
  12080. },
  12081. enumerable: true,
  12082. configurable: true
  12083. });
  12084. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12085. /**
  12086. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12087. */
  12088. get: function () {
  12089. return this._textVerticalAlignment;
  12090. },
  12091. /**
  12092. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12093. */
  12094. set: function (value) {
  12095. if (this._textVerticalAlignment === value) {
  12096. return;
  12097. }
  12098. this._textVerticalAlignment = value;
  12099. this._markAsDirty();
  12100. },
  12101. enumerable: true,
  12102. configurable: true
  12103. });
  12104. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12105. /**
  12106. * Gets or sets line spacing value
  12107. */
  12108. get: function () {
  12109. return this._lineSpacing.toString(this._host);
  12110. },
  12111. /**
  12112. * Gets or sets line spacing value
  12113. */
  12114. set: function (value) {
  12115. if (this._lineSpacing.fromString(value)) {
  12116. this._markAsDirty();
  12117. }
  12118. },
  12119. enumerable: true,
  12120. configurable: true
  12121. });
  12122. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12123. /**
  12124. * Gets or sets outlineWidth of the text to display
  12125. */
  12126. get: function () {
  12127. return this._outlineWidth;
  12128. },
  12129. /**
  12130. * Gets or sets outlineWidth of the text to display
  12131. */
  12132. set: function (value) {
  12133. if (this._outlineWidth === value) {
  12134. return;
  12135. }
  12136. this._outlineWidth = value;
  12137. this._markAsDirty();
  12138. },
  12139. enumerable: true,
  12140. configurable: true
  12141. });
  12142. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12143. /**
  12144. * Gets or sets outlineColor of the text to display
  12145. */
  12146. get: function () {
  12147. return this._outlineColor;
  12148. },
  12149. /**
  12150. * Gets or sets outlineColor of the text to display
  12151. */
  12152. set: function (value) {
  12153. if (this._outlineColor === value) {
  12154. return;
  12155. }
  12156. this._outlineColor = value;
  12157. this._markAsDirty();
  12158. },
  12159. enumerable: true,
  12160. configurable: true
  12161. });
  12162. TextBlock.prototype._getTypeName = function () {
  12163. return "TextBlock";
  12164. };
  12165. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12166. if (!this._fontOffset) {
  12167. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12168. }
  12169. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12170. // Prepare lines
  12171. this._lines = this._breakLines(this._currentMeasure.width, context);
  12172. this.onLinesReadyObservable.notifyObservers(this);
  12173. var maxLineWidth = 0;
  12174. for (var i = 0; i < this._lines.length; i++) {
  12175. var line = this._lines[i];
  12176. if (line.width > maxLineWidth) {
  12177. maxLineWidth = line.width;
  12178. }
  12179. }
  12180. if (this._resizeToFit) {
  12181. if (this._textWrapping === TextWrapping.Clip) {
  12182. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  12183. if (newWidth !== this._width.internalValue) {
  12184. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12185. this._rebuildLayout = true;
  12186. }
  12187. }
  12188. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  12189. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12190. var lineSpacing = 0;
  12191. if (this._lineSpacing.isPixel) {
  12192. lineSpacing = this._lineSpacing.getValue(this._host);
  12193. }
  12194. else {
  12195. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12196. }
  12197. newHeight += (this._lines.length - 1) * lineSpacing;
  12198. }
  12199. if (newHeight !== this._height.internalValue) {
  12200. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12201. this._rebuildLayout = true;
  12202. }
  12203. }
  12204. };
  12205. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12206. var width = this._currentMeasure.width;
  12207. var x = 0;
  12208. switch (this._textHorizontalAlignment) {
  12209. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12210. x = 0;
  12211. break;
  12212. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12213. x = width - textWidth;
  12214. break;
  12215. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12216. x = (width - textWidth) / 2;
  12217. break;
  12218. }
  12219. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12220. context.shadowColor = this.shadowColor;
  12221. context.shadowBlur = this.shadowBlur;
  12222. context.shadowOffsetX = this.shadowOffsetX;
  12223. context.shadowOffsetY = this.shadowOffsetY;
  12224. }
  12225. if (this.outlineWidth) {
  12226. context.strokeText(text, this._currentMeasure.left + x, y);
  12227. }
  12228. context.fillText(text, this._currentMeasure.left + x, y);
  12229. };
  12230. /** @hidden */
  12231. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12232. context.save();
  12233. this._applyStates(context);
  12234. // Render lines
  12235. this._renderLines(context);
  12236. context.restore();
  12237. };
  12238. TextBlock.prototype._applyStates = function (context) {
  12239. _super.prototype._applyStates.call(this, context);
  12240. if (this.outlineWidth) {
  12241. context.lineWidth = this.outlineWidth;
  12242. context.strokeStyle = this.outlineColor;
  12243. }
  12244. };
  12245. TextBlock.prototype._breakLines = function (refWidth, context) {
  12246. var lines = [];
  12247. var _lines = this.text.split("\n");
  12248. if (this._textWrapping === TextWrapping.Ellipsis) {
  12249. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12250. var _line = _lines_1[_i];
  12251. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12252. }
  12253. }
  12254. else if (this._textWrapping === TextWrapping.WordWrap) {
  12255. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12256. var _line = _lines_2[_a];
  12257. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12258. }
  12259. }
  12260. else {
  12261. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12262. var _line = _lines_3[_b];
  12263. lines.push(this._parseLine(_line, context));
  12264. }
  12265. }
  12266. return lines;
  12267. };
  12268. TextBlock.prototype._parseLine = function (line, context) {
  12269. if (line === void 0) { line = ''; }
  12270. return { text: line, width: context.measureText(line).width };
  12271. };
  12272. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12273. if (line === void 0) { line = ''; }
  12274. var lineWidth = context.measureText(line).width;
  12275. if (lineWidth > width) {
  12276. line += '…';
  12277. }
  12278. while (line.length > 2 && lineWidth > width) {
  12279. line = line.slice(0, -2) + '…';
  12280. lineWidth = context.measureText(line).width;
  12281. }
  12282. return { text: line, width: lineWidth };
  12283. };
  12284. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12285. if (line === void 0) { line = ''; }
  12286. var lines = [];
  12287. var words = line.split(' ');
  12288. var lineWidth = 0;
  12289. for (var n = 0; n < words.length; n++) {
  12290. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12291. var metrics = context.measureText(testLine);
  12292. var testWidth = metrics.width;
  12293. if (testWidth > width && n > 0) {
  12294. lines.push({ text: line, width: lineWidth });
  12295. line = words[n];
  12296. lineWidth = context.measureText(line).width;
  12297. }
  12298. else {
  12299. lineWidth = testWidth;
  12300. line = testLine;
  12301. }
  12302. }
  12303. lines.push({ text: line, width: lineWidth });
  12304. return lines;
  12305. };
  12306. TextBlock.prototype._renderLines = function (context) {
  12307. var height = this._currentMeasure.height;
  12308. var rootY = 0;
  12309. switch (this._textVerticalAlignment) {
  12310. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12311. rootY = this._fontOffset.ascent;
  12312. break;
  12313. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12314. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12315. break;
  12316. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12317. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12318. break;
  12319. }
  12320. rootY += this._currentMeasure.top;
  12321. for (var i = 0; i < this._lines.length; i++) {
  12322. var line = this._lines[i];
  12323. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12324. if (this._lineSpacing.isPixel) {
  12325. rootY += this._lineSpacing.getValue(this._host);
  12326. }
  12327. else {
  12328. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12329. }
  12330. }
  12331. this._drawText(line.text, line.width, rootY, context);
  12332. rootY += this._fontOffset.height;
  12333. }
  12334. };
  12335. /**
  12336. * Given a width constraint applied on the text block, find the expected height
  12337. * @returns expected height
  12338. */
  12339. TextBlock.prototype.computeExpectedHeight = function () {
  12340. if (this.text && this.widthInPixels) {
  12341. var context_1 = document.createElement('canvas').getContext('2d');
  12342. if (context_1) {
  12343. this._applyStates(context_1);
  12344. if (!this._fontOffset) {
  12345. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12346. }
  12347. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12348. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12349. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12350. var lineSpacing = 0;
  12351. if (this._lineSpacing.isPixel) {
  12352. lineSpacing = this._lineSpacing.getValue(this._host);
  12353. }
  12354. else {
  12355. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  12356. }
  12357. newHeight += (lines.length - 1) * lineSpacing;
  12358. }
  12359. return newHeight;
  12360. }
  12361. }
  12362. return 0;
  12363. };
  12364. TextBlock.prototype.dispose = function () {
  12365. _super.prototype.dispose.call(this);
  12366. this.onTextChangedObservable.clear();
  12367. };
  12368. return TextBlock;
  12369. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12370. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12371. /***/ }),
  12372. /***/ "./2D/controls/virtualKeyboard.ts":
  12373. /*!****************************************!*\
  12374. !*** ./2D/controls/virtualKeyboard.ts ***!
  12375. \****************************************/
  12376. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12377. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12378. "use strict";
  12379. __webpack_require__.r(__webpack_exports__);
  12380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12382. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12383. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  12384. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12385. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12386. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12387. /**
  12388. * Class used to store key control properties
  12389. */
  12390. var KeyPropertySet = /** @class */ (function () {
  12391. function KeyPropertySet() {
  12392. }
  12393. return KeyPropertySet;
  12394. }());
  12395. /**
  12396. * Class used to create virtual keyboard
  12397. */
  12398. var VirtualKeyboard = /** @class */ (function (_super) {
  12399. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12400. function VirtualKeyboard() {
  12401. var _this = _super !== null && _super.apply(this, arguments) || this;
  12402. /** Observable raised when a key is pressed */
  12403. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12404. /** Gets or sets default key button width */
  12405. _this.defaultButtonWidth = "40px";
  12406. /** Gets or sets default key button height */
  12407. _this.defaultButtonHeight = "40px";
  12408. /** Gets or sets default key button left padding */
  12409. _this.defaultButtonPaddingLeft = "2px";
  12410. /** Gets or sets default key button right padding */
  12411. _this.defaultButtonPaddingRight = "2px";
  12412. /** Gets or sets default key button top padding */
  12413. _this.defaultButtonPaddingTop = "2px";
  12414. /** Gets or sets default key button bottom padding */
  12415. _this.defaultButtonPaddingBottom = "2px";
  12416. /** Gets or sets default key button foreground color */
  12417. _this.defaultButtonColor = "#DDD";
  12418. /** Gets or sets default key button background color */
  12419. _this.defaultButtonBackground = "#070707";
  12420. /** Gets or sets shift button foreground color */
  12421. _this.shiftButtonColor = "#7799FF";
  12422. /** Gets or sets shift button thickness*/
  12423. _this.selectedShiftThickness = 1;
  12424. /** Gets shift key state */
  12425. _this.shiftState = 0;
  12426. _this._currentlyConnectedInputText = null;
  12427. _this._connectedInputTexts = [];
  12428. _this._onKeyPressObserver = null;
  12429. return _this;
  12430. }
  12431. VirtualKeyboard.prototype._getTypeName = function () {
  12432. return "VirtualKeyboard";
  12433. };
  12434. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12435. var _this = this;
  12436. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12437. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12438. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12439. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12440. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12441. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12442. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12443. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12444. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12445. button.thickness = 0;
  12446. button.isFocusInvisible = true;
  12447. button.shadowColor = this.shadowColor;
  12448. button.shadowBlur = this.shadowBlur;
  12449. button.shadowOffsetX = this.shadowOffsetX;
  12450. button.shadowOffsetY = this.shadowOffsetY;
  12451. button.onPointerUpObservable.add(function () {
  12452. _this.onKeyPressObservable.notifyObservers(key);
  12453. });
  12454. return button;
  12455. };
  12456. /**
  12457. * Adds a new row of keys
  12458. * @param keys defines the list of keys to add
  12459. * @param propertySets defines the associated property sets
  12460. */
  12461. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12462. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12463. panel.isVertical = false;
  12464. panel.isFocusInvisible = true;
  12465. var maxKey = null;
  12466. for (var i = 0; i < keys.length; i++) {
  12467. var properties = null;
  12468. if (propertySets && propertySets.length === keys.length) {
  12469. properties = propertySets[i];
  12470. }
  12471. var key = this._createKey(keys[i], properties);
  12472. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12473. maxKey = key;
  12474. }
  12475. panel.addControl(key);
  12476. }
  12477. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12478. this.addControl(panel);
  12479. };
  12480. /**
  12481. * Set the shift key to a specific state
  12482. * @param shiftState defines the new shift state
  12483. */
  12484. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12485. if (!this.children) {
  12486. return;
  12487. }
  12488. for (var i = 0; i < this.children.length; i++) {
  12489. var row = this.children[i];
  12490. if (!row || !row.children) {
  12491. continue;
  12492. }
  12493. var rowContainer = row;
  12494. for (var j = 0; j < rowContainer.children.length; j++) {
  12495. var button = rowContainer.children[j];
  12496. if (!button || !button.children[0]) {
  12497. continue;
  12498. }
  12499. var button_tblock = button.children[0];
  12500. if (button_tblock.text === "\u21E7") {
  12501. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12502. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12503. }
  12504. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12505. }
  12506. }
  12507. };
  12508. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12509. /** Gets the input text control currently attached to the keyboard */
  12510. get: function () {
  12511. return this._currentlyConnectedInputText;
  12512. },
  12513. enumerable: true,
  12514. configurable: true
  12515. });
  12516. /**
  12517. * Connects the keyboard with an input text control
  12518. *
  12519. * @param input defines the target control
  12520. */
  12521. VirtualKeyboard.prototype.connect = function (input) {
  12522. var _this = this;
  12523. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12524. if (inputTextAlreadyConnected) {
  12525. return;
  12526. }
  12527. if (this._onKeyPressObserver === null) {
  12528. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12529. if (!_this._currentlyConnectedInputText) {
  12530. return;
  12531. }
  12532. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12533. switch (key) {
  12534. case "\u21E7":
  12535. _this.shiftState++;
  12536. if (_this.shiftState > 2) {
  12537. _this.shiftState = 0;
  12538. }
  12539. _this.applyShiftState(_this.shiftState);
  12540. return;
  12541. case "\u2190":
  12542. _this._currentlyConnectedInputText.processKey(8);
  12543. return;
  12544. case "\u21B5":
  12545. _this._currentlyConnectedInputText.processKey(13);
  12546. return;
  12547. }
  12548. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12549. if (_this.shiftState === 1) {
  12550. _this.shiftState = 0;
  12551. _this.applyShiftState(_this.shiftState);
  12552. }
  12553. });
  12554. }
  12555. this.isVisible = false;
  12556. this._currentlyConnectedInputText = input;
  12557. input._connectedVirtualKeyboard = this;
  12558. // Events hooking
  12559. var onFocusObserver = input.onFocusObservable.add(function () {
  12560. _this._currentlyConnectedInputText = input;
  12561. input._connectedVirtualKeyboard = _this;
  12562. _this.isVisible = true;
  12563. });
  12564. var onBlurObserver = input.onBlurObservable.add(function () {
  12565. input._connectedVirtualKeyboard = null;
  12566. _this._currentlyConnectedInputText = null;
  12567. _this.isVisible = false;
  12568. });
  12569. this._connectedInputTexts.push({
  12570. input: input,
  12571. onBlurObserver: onBlurObserver,
  12572. onFocusObserver: onFocusObserver
  12573. });
  12574. };
  12575. /**
  12576. * Disconnects the keyboard from connected InputText controls
  12577. *
  12578. * @param input optionally defines a target control, otherwise all are disconnected
  12579. */
  12580. VirtualKeyboard.prototype.disconnect = function (input) {
  12581. var _this = this;
  12582. if (input) {
  12583. // .find not available on IE
  12584. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12585. if (filtered.length === 1) {
  12586. this._removeConnectedInputObservables(filtered[0]);
  12587. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12588. if (this._currentlyConnectedInputText === input) {
  12589. this._currentlyConnectedInputText = null;
  12590. }
  12591. }
  12592. }
  12593. else {
  12594. this._connectedInputTexts.forEach(function (connectedInputText) {
  12595. _this._removeConnectedInputObservables(connectedInputText);
  12596. });
  12597. this._connectedInputTexts = [];
  12598. }
  12599. if (this._connectedInputTexts.length === 0) {
  12600. this._currentlyConnectedInputText = null;
  12601. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12602. this._onKeyPressObserver = null;
  12603. }
  12604. };
  12605. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12606. connectedInputText.input._connectedVirtualKeyboard = null;
  12607. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12608. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12609. };
  12610. /**
  12611. * Release all resources
  12612. */
  12613. VirtualKeyboard.prototype.dispose = function () {
  12614. _super.prototype.dispose.call(this);
  12615. this.disconnect();
  12616. };
  12617. // Statics
  12618. /**
  12619. * Creates a new keyboard using a default layout
  12620. *
  12621. * @param name defines control name
  12622. * @returns a new VirtualKeyboard
  12623. */
  12624. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12625. var returnValue = new VirtualKeyboard(name);
  12626. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12627. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12628. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12629. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12630. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12631. return returnValue;
  12632. };
  12633. return VirtualKeyboard;
  12634. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12635. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12636. /***/ }),
  12637. /***/ "./2D/index.ts":
  12638. /*!*********************!*\
  12639. !*** ./2D/index.ts ***!
  12640. \*********************/
  12641. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  12642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12643. "use strict";
  12644. __webpack_require__.r(__webpack_exports__);
  12645. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12678. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12680. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12682. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12685. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12687. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12689. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12691. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12693. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12695. /***/ }),
  12696. /***/ "./2D/math2D.ts":
  12697. /*!**********************!*\
  12698. !*** ./2D/math2D.ts ***!
  12699. \**********************/
  12700. /*! exports provided: Vector2WithInfo, Matrix2D */
  12701. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12702. "use strict";
  12703. __webpack_require__.r(__webpack_exports__);
  12704. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12706. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12707. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  12708. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  12709. /**
  12710. * Class used to transport Vector2 information for pointer events
  12711. */
  12712. var Vector2WithInfo = /** @class */ (function (_super) {
  12713. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12714. /**
  12715. * Creates a new Vector2WithInfo
  12716. * @param source defines the vector2 data to transport
  12717. * @param buttonIndex defines the current mouse button index
  12718. */
  12719. function Vector2WithInfo(source,
  12720. /** defines the current mouse button index */
  12721. buttonIndex) {
  12722. if (buttonIndex === void 0) { buttonIndex = 0; }
  12723. var _this = _super.call(this, source.x, source.y) || this;
  12724. _this.buttonIndex = buttonIndex;
  12725. return _this;
  12726. }
  12727. return Vector2WithInfo;
  12728. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12729. /** Class used to provide 2D matrix features */
  12730. var Matrix2D = /** @class */ (function () {
  12731. /**
  12732. * Creates a new matrix
  12733. * @param m00 defines value for (0, 0)
  12734. * @param m01 defines value for (0, 1)
  12735. * @param m10 defines value for (1, 0)
  12736. * @param m11 defines value for (1, 1)
  12737. * @param m20 defines value for (2, 0)
  12738. * @param m21 defines value for (2, 1)
  12739. */
  12740. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12741. /** Gets the internal array of 6 floats used to store matrix data */
  12742. this.m = new Float32Array(6);
  12743. this.fromValues(m00, m01, m10, m11, m20, m21);
  12744. }
  12745. /**
  12746. * Fills the matrix from direct values
  12747. * @param m00 defines value for (0, 0)
  12748. * @param m01 defines value for (0, 1)
  12749. * @param m10 defines value for (1, 0)
  12750. * @param m11 defines value for (1, 1)
  12751. * @param m20 defines value for (2, 0)
  12752. * @param m21 defines value for (2, 1)
  12753. * @returns the current modified matrix
  12754. */
  12755. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12756. this.m[0] = m00;
  12757. this.m[1] = m01;
  12758. this.m[2] = m10;
  12759. this.m[3] = m11;
  12760. this.m[4] = m20;
  12761. this.m[5] = m21;
  12762. return this;
  12763. };
  12764. /**
  12765. * Gets matrix determinant
  12766. * @returns the determinant
  12767. */
  12768. Matrix2D.prototype.determinant = function () {
  12769. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12770. };
  12771. /**
  12772. * Inverses the matrix and stores it in a target matrix
  12773. * @param result defines the target matrix
  12774. * @returns the current matrix
  12775. */
  12776. Matrix2D.prototype.invertToRef = function (result) {
  12777. var l0 = this.m[0];
  12778. var l1 = this.m[1];
  12779. var l2 = this.m[2];
  12780. var l3 = this.m[3];
  12781. var l4 = this.m[4];
  12782. var l5 = this.m[5];
  12783. var det = this.determinant();
  12784. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12785. result.m[0] = 0;
  12786. result.m[1] = 0;
  12787. result.m[2] = 0;
  12788. result.m[3] = 0;
  12789. result.m[4] = 0;
  12790. result.m[5] = 0;
  12791. return this;
  12792. }
  12793. var detDiv = 1 / det;
  12794. var det4 = l2 * l5 - l3 * l4;
  12795. var det5 = l1 * l4 - l0 * l5;
  12796. result.m[0] = l3 * detDiv;
  12797. result.m[1] = -l1 * detDiv;
  12798. result.m[2] = -l2 * detDiv;
  12799. result.m[3] = l0 * detDiv;
  12800. result.m[4] = det4 * detDiv;
  12801. result.m[5] = det5 * detDiv;
  12802. return this;
  12803. };
  12804. /**
  12805. * Multiplies the current matrix with another one
  12806. * @param other defines the second operand
  12807. * @param result defines the target matrix
  12808. * @returns the current matrix
  12809. */
  12810. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12811. var l0 = this.m[0];
  12812. var l1 = this.m[1];
  12813. var l2 = this.m[2];
  12814. var l3 = this.m[3];
  12815. var l4 = this.m[4];
  12816. var l5 = this.m[5];
  12817. var r0 = other.m[0];
  12818. var r1 = other.m[1];
  12819. var r2 = other.m[2];
  12820. var r3 = other.m[3];
  12821. var r4 = other.m[4];
  12822. var r5 = other.m[5];
  12823. result.m[0] = l0 * r0 + l1 * r2;
  12824. result.m[1] = l0 * r1 + l1 * r3;
  12825. result.m[2] = l2 * r0 + l3 * r2;
  12826. result.m[3] = l2 * r1 + l3 * r3;
  12827. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12828. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12829. return this;
  12830. };
  12831. /**
  12832. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12833. * @param x defines the x coordinate to transform
  12834. * @param y defines the x coordinate to transform
  12835. * @param result defines the target vector2
  12836. * @returns the current matrix
  12837. */
  12838. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12839. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12840. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12841. return this;
  12842. };
  12843. // Statics
  12844. /**
  12845. * Creates an identity matrix
  12846. * @returns a new matrix
  12847. */
  12848. Matrix2D.Identity = function () {
  12849. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12850. };
  12851. /**
  12852. * Creates a translation matrix and stores it in a target matrix
  12853. * @param x defines the x coordinate of the translation
  12854. * @param y defines the y coordinate of the translation
  12855. * @param result defines the target matrix
  12856. */
  12857. Matrix2D.TranslationToRef = function (x, y, result) {
  12858. result.fromValues(1, 0, 0, 1, x, y);
  12859. };
  12860. /**
  12861. * Creates a scaling matrix and stores it in a target matrix
  12862. * @param x defines the x coordinate of the scaling
  12863. * @param y defines the y coordinate of the scaling
  12864. * @param result defines the target matrix
  12865. */
  12866. Matrix2D.ScalingToRef = function (x, y, result) {
  12867. result.fromValues(x, 0, 0, y, 0, 0);
  12868. };
  12869. /**
  12870. * Creates a rotation matrix and stores it in a target matrix
  12871. * @param angle defines the rotation angle
  12872. * @param result defines the target matrix
  12873. */
  12874. Matrix2D.RotationToRef = function (angle, result) {
  12875. var s = Math.sin(angle);
  12876. var c = Math.cos(angle);
  12877. result.fromValues(c, s, -s, c, 0, 0);
  12878. };
  12879. /**
  12880. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12881. * @param tx defines the x coordinate of the translation
  12882. * @param ty defines the y coordinate of the translation
  12883. * @param angle defines the rotation angle
  12884. * @param scaleX defines the x coordinate of the scaling
  12885. * @param scaleY defines the y coordinate of the scaling
  12886. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12887. * @param result defines the target matrix
  12888. */
  12889. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12890. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12891. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12892. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12893. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12894. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12895. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12896. if (parentMatrix) {
  12897. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12898. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12899. }
  12900. else {
  12901. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12902. }
  12903. };
  12904. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12905. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12906. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12907. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12908. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12909. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12910. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12911. return Matrix2D;
  12912. }());
  12913. /***/ }),
  12914. /***/ "./2D/measure.ts":
  12915. /*!***********************!*\
  12916. !*** ./2D/measure.ts ***!
  12917. \***********************/
  12918. /*! exports provided: Measure */
  12919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12920. "use strict";
  12921. __webpack_require__.r(__webpack_exports__);
  12922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12923. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  12924. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  12925. var tmpRect = [
  12926. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12927. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12928. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12929. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12930. ];
  12931. var tmpRect2 = [
  12932. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12933. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12934. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12935. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  12936. ];
  12937. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12938. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12939. /**
  12940. * Class used to store 2D control sizes
  12941. */
  12942. var Measure = /** @class */ (function () {
  12943. /**
  12944. * Creates a new measure
  12945. * @param left defines left coordinate
  12946. * @param top defines top coordinate
  12947. * @param width defines width dimension
  12948. * @param height defines height dimension
  12949. */
  12950. function Measure(
  12951. /** defines left coordinate */
  12952. left,
  12953. /** defines top coordinate */
  12954. top,
  12955. /** defines width dimension */
  12956. width,
  12957. /** defines height dimension */
  12958. height) {
  12959. this.left = left;
  12960. this.top = top;
  12961. this.width = width;
  12962. this.height = height;
  12963. }
  12964. /**
  12965. * Copy from another measure
  12966. * @param other defines the other measure to copy from
  12967. */
  12968. Measure.prototype.copyFrom = function (other) {
  12969. this.left = other.left;
  12970. this.top = other.top;
  12971. this.width = other.width;
  12972. this.height = other.height;
  12973. };
  12974. /**
  12975. * Copy from a group of 4 floats
  12976. * @param left defines left coordinate
  12977. * @param top defines top coordinate
  12978. * @param width defines width dimension
  12979. * @param height defines height dimension
  12980. */
  12981. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12982. this.left = left;
  12983. this.top = top;
  12984. this.width = width;
  12985. this.height = height;
  12986. };
  12987. /**
  12988. * Computes the axis aligned bounding box measure for two given measures
  12989. * @param a Input measure
  12990. * @param b Input measure
  12991. * @param result the resulting bounding measure
  12992. */
  12993. Measure.CombineToRef = function (a, b, result) {
  12994. var left = Math.min(a.left, b.left);
  12995. var top = Math.min(a.top, b.top);
  12996. var right = Math.max(a.left + a.width, b.left + b.width);
  12997. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12998. result.left = left;
  12999. result.top = top;
  13000. result.width = right - left;
  13001. result.height = bottom - top;
  13002. };
  13003. /**
  13004. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13005. * @param transform the matrix to transform the measure before computing the AABB
  13006. * @param result the resulting AABB
  13007. */
  13008. Measure.prototype.transformToRef = function (transform, result) {
  13009. tmpRect[0].copyFromFloats(this.left, this.top);
  13010. tmpRect[1].copyFromFloats(this.left + this.width, this.top);
  13011. tmpRect[2].copyFromFloats(this.left + this.width, this.top + this.height);
  13012. tmpRect[3].copyFromFloats(this.left, this.top + this.height);
  13013. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  13014. tmpV2.copyFromFloats(0, 0);
  13015. for (var i = 0; i < 4; i++) {
  13016. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  13017. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  13018. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  13019. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  13020. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  13021. }
  13022. result.left = tmpV1.x;
  13023. result.top = tmpV1.y;
  13024. result.width = tmpV2.x - tmpV1.x;
  13025. result.height = tmpV2.y - tmpV1.y;
  13026. };
  13027. /**
  13028. * Check equality between this measure and another one
  13029. * @param other defines the other measures
  13030. * @returns true if both measures are equals
  13031. */
  13032. Measure.prototype.isEqualsTo = function (other) {
  13033. if (this.left !== other.left) {
  13034. return false;
  13035. }
  13036. if (this.top !== other.top) {
  13037. return false;
  13038. }
  13039. if (this.width !== other.width) {
  13040. return false;
  13041. }
  13042. if (this.height !== other.height) {
  13043. return false;
  13044. }
  13045. return true;
  13046. };
  13047. /**
  13048. * Creates an empty measure
  13049. * @returns a new measure
  13050. */
  13051. Measure.Empty = function () {
  13052. return new Measure(0, 0, 0, 0);
  13053. };
  13054. return Measure;
  13055. }());
  13056. /***/ }),
  13057. /***/ "./2D/multiLinePoint.ts":
  13058. /*!******************************!*\
  13059. !*** ./2D/multiLinePoint.ts ***!
  13060. \******************************/
  13061. /*! exports provided: MultiLinePoint */
  13062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13063. "use strict";
  13064. __webpack_require__.r(__webpack_exports__);
  13065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13066. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  13067. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13068. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13069. /**
  13070. * Class used to store a point for a MultiLine object.
  13071. * The point can be pure 2D coordinates, a mesh or a control
  13072. */
  13073. var MultiLinePoint = /** @class */ (function () {
  13074. /**
  13075. * Creates a new MultiLinePoint
  13076. * @param multiLine defines the source MultiLine object
  13077. */
  13078. function MultiLinePoint(multiLine) {
  13079. this._multiLine = multiLine;
  13080. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13081. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13082. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13083. }
  13084. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13085. /** Gets or sets x coordinate */
  13086. get: function () {
  13087. return this._x.toString(this._multiLine._host);
  13088. },
  13089. set: function (value) {
  13090. if (this._x.toString(this._multiLine._host) === value) {
  13091. return;
  13092. }
  13093. if (this._x.fromString(value)) {
  13094. this._multiLine._markAsDirty();
  13095. }
  13096. },
  13097. enumerable: true,
  13098. configurable: true
  13099. });
  13100. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13101. /** Gets or sets y coordinate */
  13102. get: function () {
  13103. return this._y.toString(this._multiLine._host);
  13104. },
  13105. set: function (value) {
  13106. if (this._y.toString(this._multiLine._host) === value) {
  13107. return;
  13108. }
  13109. if (this._y.fromString(value)) {
  13110. this._multiLine._markAsDirty();
  13111. }
  13112. },
  13113. enumerable: true,
  13114. configurable: true
  13115. });
  13116. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13117. /** Gets or sets the control associated with this point */
  13118. get: function () {
  13119. return this._control;
  13120. },
  13121. set: function (value) {
  13122. if (this._control === value) {
  13123. return;
  13124. }
  13125. if (this._control && this._controlObserver) {
  13126. this._control.onDirtyObservable.remove(this._controlObserver);
  13127. this._controlObserver = null;
  13128. }
  13129. this._control = value;
  13130. if (this._control) {
  13131. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13132. }
  13133. this._multiLine._markAsDirty();
  13134. },
  13135. enumerable: true,
  13136. configurable: true
  13137. });
  13138. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13139. /** Gets or sets the mesh associated with this point */
  13140. get: function () {
  13141. return this._mesh;
  13142. },
  13143. set: function (value) {
  13144. if (this._mesh === value) {
  13145. return;
  13146. }
  13147. if (this._mesh && this._meshObserver) {
  13148. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13149. }
  13150. this._mesh = value;
  13151. if (this._mesh) {
  13152. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13153. }
  13154. this._multiLine._markAsDirty();
  13155. },
  13156. enumerable: true,
  13157. configurable: true
  13158. });
  13159. /** Resets links */
  13160. MultiLinePoint.prototype.resetLinks = function () {
  13161. this.control = null;
  13162. this.mesh = null;
  13163. };
  13164. /**
  13165. * Gets a translation vector
  13166. * @returns the translation vector
  13167. */
  13168. MultiLinePoint.prototype.translate = function () {
  13169. this._point = this._translatePoint();
  13170. return this._point;
  13171. };
  13172. MultiLinePoint.prototype._translatePoint = function () {
  13173. if (this._mesh != null) {
  13174. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13175. }
  13176. else if (this._control != null) {
  13177. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  13178. }
  13179. else {
  13180. var host = this._multiLine._host;
  13181. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13182. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13183. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  13184. }
  13185. };
  13186. /** Release associated resources */
  13187. MultiLinePoint.prototype.dispose = function () {
  13188. this.resetLinks();
  13189. };
  13190. return MultiLinePoint;
  13191. }());
  13192. /***/ }),
  13193. /***/ "./2D/style.ts":
  13194. /*!*********************!*\
  13195. !*** ./2D/style.ts ***!
  13196. \*********************/
  13197. /*! exports provided: Style */
  13198. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13199. "use strict";
  13200. __webpack_require__.r(__webpack_exports__);
  13201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13202. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  13203. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13204. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13205. /**
  13206. * Define a style used by control to automatically setup properties based on a template.
  13207. * Only support font related properties so far
  13208. */
  13209. var Style = /** @class */ (function () {
  13210. /**
  13211. * Creates a new style object
  13212. * @param host defines the AdvancedDynamicTexture which hosts this style
  13213. */
  13214. function Style(host) {
  13215. this._fontFamily = "Arial";
  13216. this._fontStyle = "";
  13217. this._fontWeight = "";
  13218. /** @hidden */
  13219. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13220. /**
  13221. * Observable raised when the style values are changed
  13222. */
  13223. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13224. this._host = host;
  13225. }
  13226. Object.defineProperty(Style.prototype, "fontSize", {
  13227. /**
  13228. * Gets or sets the font size
  13229. */
  13230. get: function () {
  13231. return this._fontSize.toString(this._host);
  13232. },
  13233. set: function (value) {
  13234. if (this._fontSize.toString(this._host) === value) {
  13235. return;
  13236. }
  13237. if (this._fontSize.fromString(value)) {
  13238. this.onChangedObservable.notifyObservers(this);
  13239. }
  13240. },
  13241. enumerable: true,
  13242. configurable: true
  13243. });
  13244. Object.defineProperty(Style.prototype, "fontFamily", {
  13245. /**
  13246. * Gets or sets the font family
  13247. */
  13248. get: function () {
  13249. return this._fontFamily;
  13250. },
  13251. set: function (value) {
  13252. if (this._fontFamily === value) {
  13253. return;
  13254. }
  13255. this._fontFamily = value;
  13256. this.onChangedObservable.notifyObservers(this);
  13257. },
  13258. enumerable: true,
  13259. configurable: true
  13260. });
  13261. Object.defineProperty(Style.prototype, "fontStyle", {
  13262. /**
  13263. * Gets or sets the font style
  13264. */
  13265. get: function () {
  13266. return this._fontStyle;
  13267. },
  13268. set: function (value) {
  13269. if (this._fontStyle === value) {
  13270. return;
  13271. }
  13272. this._fontStyle = value;
  13273. this.onChangedObservable.notifyObservers(this);
  13274. },
  13275. enumerable: true,
  13276. configurable: true
  13277. });
  13278. Object.defineProperty(Style.prototype, "fontWeight", {
  13279. /** Gets or sets font weight */
  13280. get: function () {
  13281. return this._fontWeight;
  13282. },
  13283. set: function (value) {
  13284. if (this._fontWeight === value) {
  13285. return;
  13286. }
  13287. this._fontWeight = value;
  13288. this.onChangedObservable.notifyObservers(this);
  13289. },
  13290. enumerable: true,
  13291. configurable: true
  13292. });
  13293. /** Dispose all associated resources */
  13294. Style.prototype.dispose = function () {
  13295. this.onChangedObservable.clear();
  13296. };
  13297. return Style;
  13298. }());
  13299. /***/ }),
  13300. /***/ "./2D/valueAndUnit.ts":
  13301. /*!****************************!*\
  13302. !*** ./2D/valueAndUnit.ts ***!
  13303. \****************************/
  13304. /*! exports provided: ValueAndUnit */
  13305. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13306. "use strict";
  13307. __webpack_require__.r(__webpack_exports__);
  13308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13309. /**
  13310. * Class used to specific a value and its associated unit
  13311. */
  13312. var ValueAndUnit = /** @class */ (function () {
  13313. /**
  13314. * Creates a new ValueAndUnit
  13315. * @param value defines the value to store
  13316. * @param unit defines the unit to store
  13317. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13318. */
  13319. function ValueAndUnit(value,
  13320. /** defines the unit to store */
  13321. unit,
  13322. /** defines a boolean indicating if the value can be negative */
  13323. negativeValueAllowed) {
  13324. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13325. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13326. this.unit = unit;
  13327. this.negativeValueAllowed = negativeValueAllowed;
  13328. this._value = 1;
  13329. /**
  13330. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13331. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13332. */
  13333. this.ignoreAdaptiveScaling = false;
  13334. this._value = value;
  13335. this._originalUnit = unit;
  13336. }
  13337. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13338. /** Gets a boolean indicating if the value is a percentage */
  13339. get: function () {
  13340. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13341. },
  13342. enumerable: true,
  13343. configurable: true
  13344. });
  13345. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13346. /** Gets a boolean indicating if the value is store as pixel */
  13347. get: function () {
  13348. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13349. },
  13350. enumerable: true,
  13351. configurable: true
  13352. });
  13353. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13354. /** Gets direct internal value */
  13355. get: function () {
  13356. return this._value;
  13357. },
  13358. enumerable: true,
  13359. configurable: true
  13360. });
  13361. /**
  13362. * Gets value as pixel
  13363. * @param host defines the root host
  13364. * @param refValue defines the reference value for percentages
  13365. * @returns the value as pixel
  13366. */
  13367. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13368. if (this.isPixel) {
  13369. return this.getValue(host);
  13370. }
  13371. return this.getValue(host) * refValue;
  13372. };
  13373. /**
  13374. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13375. * @param value defines the value to store
  13376. * @param unit defines the unit to store
  13377. * @returns the current ValueAndUnit
  13378. */
  13379. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13380. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13381. this._value = value;
  13382. this.unit = unit;
  13383. return this;
  13384. };
  13385. /**
  13386. * Gets the value accordingly to its unit
  13387. * @param host defines the root host
  13388. * @returns the value
  13389. */
  13390. ValueAndUnit.prototype.getValue = function (host) {
  13391. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13392. var width = 0;
  13393. var height = 0;
  13394. if (host.idealWidth) {
  13395. width = (this._value * host.getSize().width) / host.idealWidth;
  13396. }
  13397. if (host.idealHeight) {
  13398. height = (this._value * host.getSize().height) / host.idealHeight;
  13399. }
  13400. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13401. return window.innerWidth < window.innerHeight ? width : height;
  13402. }
  13403. if (host.idealWidth) { // horizontal
  13404. return width;
  13405. }
  13406. if (host.idealHeight) { // vertical
  13407. return height;
  13408. }
  13409. }
  13410. return this._value;
  13411. };
  13412. /**
  13413. * Gets a string representation of the value
  13414. * @param host defines the root host
  13415. * @param decimals defines an optional number of decimals to display
  13416. * @returns a string
  13417. */
  13418. ValueAndUnit.prototype.toString = function (host, decimals) {
  13419. switch (this.unit) {
  13420. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13421. var percentage = this.getValue(host) * 100;
  13422. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13423. case ValueAndUnit.UNITMODE_PIXEL:
  13424. var pixels = this.getValue(host);
  13425. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13426. }
  13427. return this.unit.toString();
  13428. };
  13429. /**
  13430. * Store a value parsed from a string
  13431. * @param source defines the source string
  13432. * @returns true if the value was successfully parsed
  13433. */
  13434. ValueAndUnit.prototype.fromString = function (source) {
  13435. var match = ValueAndUnit._Regex.exec(source.toString());
  13436. if (!match || match.length === 0) {
  13437. return false;
  13438. }
  13439. var sourceValue = parseFloat(match[1]);
  13440. var sourceUnit = this._originalUnit;
  13441. if (!this.negativeValueAllowed) {
  13442. if (sourceValue < 0) {
  13443. sourceValue = 0;
  13444. }
  13445. }
  13446. if (match.length === 4) {
  13447. switch (match[3]) {
  13448. case "px":
  13449. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13450. break;
  13451. case "%":
  13452. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13453. sourceValue /= 100.0;
  13454. break;
  13455. }
  13456. }
  13457. if (sourceValue === this._value && sourceUnit === this.unit) {
  13458. return false;
  13459. }
  13460. this._value = sourceValue;
  13461. this.unit = sourceUnit;
  13462. return true;
  13463. };
  13464. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13465. /** UNITMODE_PERCENTAGE */
  13466. get: function () {
  13467. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13468. },
  13469. enumerable: true,
  13470. configurable: true
  13471. });
  13472. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13473. /** UNITMODE_PIXEL */
  13474. get: function () {
  13475. return ValueAndUnit._UNITMODE_PIXEL;
  13476. },
  13477. enumerable: true,
  13478. configurable: true
  13479. });
  13480. // Static
  13481. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13482. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13483. ValueAndUnit._UNITMODE_PIXEL = 1;
  13484. return ValueAndUnit;
  13485. }());
  13486. /***/ }),
  13487. /***/ "./2D/xmlLoader.ts":
  13488. /*!*************************!*\
  13489. !*** ./2D/xmlLoader.ts ***!
  13490. \*************************/
  13491. /*! exports provided: XmlLoader */
  13492. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13493. "use strict";
  13494. __webpack_require__.r(__webpack_exports__);
  13495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13496. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math.vector");
  13497. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13498. /**
  13499. * Class used to load GUI via XML.
  13500. */
  13501. var XmlLoader = /** @class */ (function () {
  13502. /**
  13503. * Create a new xml loader
  13504. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13505. */
  13506. function XmlLoader(parentClass) {
  13507. if (parentClass === void 0) { parentClass = null; }
  13508. this._nodes = {};
  13509. this._nodeTypes = {
  13510. element: 1,
  13511. attribute: 2,
  13512. text: 3
  13513. };
  13514. this._isLoaded = false;
  13515. this._objectAttributes = {
  13516. "textHorizontalAlignment": 1,
  13517. "textVerticalAlignment": 2,
  13518. "horizontalAlignment": 3,
  13519. "verticalAlignment": 4,
  13520. "stretch": 5,
  13521. };
  13522. if (parentClass) {
  13523. this._parentClass = parentClass;
  13524. }
  13525. }
  13526. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13527. var element = window;
  13528. if (this._parentClass) {
  13529. element = this._parentClass;
  13530. }
  13531. var value = attributeValue;
  13532. value = value.split(".");
  13533. for (var i = 0; i < value.length; i++) {
  13534. element = element[value[i]];
  13535. }
  13536. return element;
  13537. };
  13538. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13539. var attribute = attributeName.split(".");
  13540. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13541. return className[attribute[1]];
  13542. };
  13543. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13544. if (linkParent === void 0) { linkParent = true; }
  13545. try {
  13546. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13547. var guiNode = new className();
  13548. if (parent && linkParent) {
  13549. parent.addControl(guiNode);
  13550. }
  13551. for (var i = 0; i < node.attributes.length; i++) {
  13552. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13553. continue;
  13554. }
  13555. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13556. var element = this._getChainElement(node.attributes[i].value);
  13557. guiNode[node.attributes[i].name].add(element);
  13558. continue;
  13559. }
  13560. else if (node.attributes[i].name == "linkWithMesh") {
  13561. if (this._parentClass) {
  13562. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13563. }
  13564. else {
  13565. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13566. }
  13567. }
  13568. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13569. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13570. guiNode[node.attributes[i].name] = element;
  13571. }
  13572. else if (!this._objectAttributes[node.attributes[i].name]) {
  13573. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13574. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13575. }
  13576. else {
  13577. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13578. }
  13579. }
  13580. else {
  13581. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13582. }
  13583. }
  13584. if (!node.attributes.getNamedItem("id")) {
  13585. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13586. return guiNode;
  13587. }
  13588. var id = node.attributes.getNamedItem("id").value;
  13589. if (id.startsWith("{{") && id.endsWith("}}")) {
  13590. id = this._getChainElement(id.substring(2, id.length - 2));
  13591. }
  13592. if (!this._nodes[id]) {
  13593. this._nodes[id] = guiNode;
  13594. }
  13595. else {
  13596. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13597. }
  13598. return guiNode;
  13599. }
  13600. catch (e) {
  13601. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13602. }
  13603. };
  13604. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13605. var width;
  13606. var height;
  13607. var columns;
  13608. var rows = node.children;
  13609. var cells;
  13610. var isPixel = false;
  13611. var cellNode;
  13612. var rowNumber = -1;
  13613. var columnNumber = -1;
  13614. var totalColumnsNumber = 0;
  13615. for (var i = 0; i < rows.length; i++) {
  13616. if (rows[i].nodeType != this._nodeTypes.element) {
  13617. continue;
  13618. }
  13619. if (rows[i].nodeName != "Row") {
  13620. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13621. }
  13622. rowNumber += 1;
  13623. columns = rows[i].children;
  13624. if (!rows[i].attributes.getNamedItem("height")) {
  13625. throw "XmlLoader Exception : Height must be defined for grid rows";
  13626. }
  13627. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13628. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13629. guiNode.addRowDefinition(height, isPixel);
  13630. for (var j = 0; j < columns.length; j++) {
  13631. if (columns[j].nodeType != this._nodeTypes.element) {
  13632. continue;
  13633. }
  13634. if (columns[j].nodeName != "Column") {
  13635. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13636. }
  13637. columnNumber += 1;
  13638. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13639. 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.";
  13640. }
  13641. if (rowNumber == 0) {
  13642. if (!columns[j].attributes.getNamedItem("width")) {
  13643. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13644. }
  13645. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13646. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13647. guiNode.addColumnDefinition(width, isPixel);
  13648. }
  13649. cells = columns[j].children;
  13650. for (var k = 0; k < cells.length; k++) {
  13651. if (cells[k].nodeType != this._nodeTypes.element) {
  13652. continue;
  13653. }
  13654. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13655. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13656. if (cells[k].firstChild) {
  13657. this._parseXml(cells[k].firstChild, cellNode);
  13658. }
  13659. }
  13660. }
  13661. if (rowNumber == 0) {
  13662. totalColumnsNumber = columnNumber;
  13663. }
  13664. columnNumber = -1;
  13665. }
  13666. if (node.nextSibling) {
  13667. this._parseXml(node.nextSibling, parent);
  13668. }
  13669. };
  13670. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13671. if (node.firstChild) {
  13672. this._parseXml(node.firstChild, guiNode);
  13673. }
  13674. if (node.nextSibling) {
  13675. this._parseXml(node.nextSibling, parent);
  13676. }
  13677. };
  13678. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13679. if (this._parentClass) {
  13680. this._parentClass[variable] = source[iterator];
  13681. }
  13682. else {
  13683. window[variable] = source[iterator];
  13684. }
  13685. if (node.firstChild) {
  13686. this._parseXml(node.firstChild, guiNode, true);
  13687. }
  13688. };
  13689. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13690. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13691. if (!dataSource.includes(" in ")) {
  13692. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13693. }
  13694. else {
  13695. var isArray = true;
  13696. var splittedSource = dataSource.split(" in ");
  13697. if (splittedSource.length < 2) {
  13698. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13699. }
  13700. var source = splittedSource[1];
  13701. if (source.startsWith("{") && source.endsWith("}")) {
  13702. isArray = false;
  13703. }
  13704. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13705. source = source.substring(1, source.length - 1);
  13706. }
  13707. if (this._parentClass) {
  13708. source = this._parentClass[source];
  13709. }
  13710. else {
  13711. source = window[source];
  13712. }
  13713. if (isArray) {
  13714. for (var i = 0; i < source.length; i++) {
  13715. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13716. }
  13717. }
  13718. else {
  13719. for (var i in source) {
  13720. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13721. }
  13722. }
  13723. if (node.nextSibling) {
  13724. this._parseXml(node.nextSibling, parent);
  13725. }
  13726. }
  13727. };
  13728. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13729. if (generated === void 0) { generated = false; }
  13730. if (node.nodeType != this._nodeTypes.element) {
  13731. if (node.nextSibling) {
  13732. this._parseXml(node.nextSibling, parent, generated);
  13733. }
  13734. return;
  13735. }
  13736. if (generated) {
  13737. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13738. }
  13739. var guiNode = this._createGuiElement(node, parent);
  13740. if (node.nodeName == "Grid") {
  13741. this._parseGrid(node, guiNode, parent);
  13742. }
  13743. else if (!node.attributes.getNamedItem("dataSource")) {
  13744. this._parseElement(node, guiNode, parent);
  13745. }
  13746. else {
  13747. this._parseElementsFromSource(node, guiNode, parent);
  13748. }
  13749. };
  13750. /**
  13751. * Gets if the loading has finished.
  13752. * @returns whether the loading has finished or not
  13753. */
  13754. XmlLoader.prototype.isLoaded = function () {
  13755. return this._isLoaded;
  13756. };
  13757. /**
  13758. * Gets a loaded node / control by id.
  13759. * @param id the Controls id set in the xml
  13760. * @returns element of type Control
  13761. */
  13762. XmlLoader.prototype.getNodeById = function (id) {
  13763. return this._nodes[id];
  13764. };
  13765. /**
  13766. * Gets all loaded nodes / controls
  13767. * @returns Array of controls
  13768. */
  13769. XmlLoader.prototype.getNodes = function () {
  13770. return this._nodes;
  13771. };
  13772. /**
  13773. * Initiates the xml layout loading
  13774. * @param xmlFile defines the xml layout to load
  13775. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13776. * @param callback defines the callback called on layout load.
  13777. */
  13778. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13779. var xhttp = new XMLHttpRequest();
  13780. xhttp.onreadystatechange = function () {
  13781. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13782. if (!xhttp.responseXML) {
  13783. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13784. }
  13785. var xmlDoc = xhttp.responseXML.documentElement;
  13786. this._parseXml(xmlDoc.firstChild, rootNode);
  13787. this._isLoaded = true;
  13788. if (callback) {
  13789. callback();
  13790. }
  13791. }
  13792. }.bind(this);
  13793. xhttp.open("GET", xmlFile, true);
  13794. xhttp.send();
  13795. };
  13796. return XmlLoader;
  13797. }());
  13798. /***/ }),
  13799. /***/ "./3D/controls/abstractButton3D.ts":
  13800. /*!*****************************************!*\
  13801. !*** ./3D/controls/abstractButton3D.ts ***!
  13802. \*****************************************/
  13803. /*! exports provided: AbstractButton3D */
  13804. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13805. "use strict";
  13806. __webpack_require__.r(__webpack_exports__);
  13807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13808. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13809. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math.vector");
  13810. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13811. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13812. /**
  13813. * Class used as a root to all buttons
  13814. */
  13815. var AbstractButton3D = /** @class */ (function (_super) {
  13816. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13817. /**
  13818. * Creates a new button
  13819. * @param name defines the control name
  13820. */
  13821. function AbstractButton3D(name) {
  13822. return _super.call(this, name) || this;
  13823. }
  13824. AbstractButton3D.prototype._getTypeName = function () {
  13825. return "AbstractButton3D";
  13826. };
  13827. // Mesh association
  13828. AbstractButton3D.prototype._createNode = function (scene) {
  13829. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13830. };
  13831. return AbstractButton3D;
  13832. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13833. /***/ }),
  13834. /***/ "./3D/controls/button3D.ts":
  13835. /*!*********************************!*\
  13836. !*** ./3D/controls/button3D.ts ***!
  13837. \*********************************/
  13838. /*! exports provided: Button3D */
  13839. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13840. "use strict";
  13841. __webpack_require__.r(__webpack_exports__);
  13842. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13843. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13844. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  13845. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  13846. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13847. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13848. /**
  13849. * Class used to create a button in 3D
  13850. */
  13851. var Button3D = /** @class */ (function (_super) {
  13852. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13853. /**
  13854. * Creates a new button
  13855. * @param name defines the control name
  13856. */
  13857. function Button3D(name) {
  13858. var _this = _super.call(this, name) || this;
  13859. _this._contentResolution = 512;
  13860. _this._contentScaleRatio = 2;
  13861. // Default animations
  13862. _this.pointerEnterAnimation = function () {
  13863. if (!_this.mesh) {
  13864. return;
  13865. }
  13866. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13867. };
  13868. _this.pointerOutAnimation = function () {
  13869. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13870. };
  13871. _this.pointerDownAnimation = function () {
  13872. if (!_this.mesh) {
  13873. return;
  13874. }
  13875. _this.mesh.scaling.scaleInPlace(0.95);
  13876. };
  13877. _this.pointerUpAnimation = function () {
  13878. if (!_this.mesh) {
  13879. return;
  13880. }
  13881. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13882. };
  13883. return _this;
  13884. }
  13885. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13886. /**
  13887. * Gets or sets the texture resolution used to render content (512 by default)
  13888. */
  13889. get: function () {
  13890. return this._contentResolution;
  13891. },
  13892. set: function (value) {
  13893. if (this._contentResolution === value) {
  13894. return;
  13895. }
  13896. this._contentResolution = value;
  13897. this._resetContent();
  13898. },
  13899. enumerable: true,
  13900. configurable: true
  13901. });
  13902. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13903. /**
  13904. * Gets or sets the texture scale ratio used to render content (2 by default)
  13905. */
  13906. get: function () {
  13907. return this._contentScaleRatio;
  13908. },
  13909. set: function (value) {
  13910. if (this._contentScaleRatio === value) {
  13911. return;
  13912. }
  13913. this._contentScaleRatio = value;
  13914. this._resetContent();
  13915. },
  13916. enumerable: true,
  13917. configurable: true
  13918. });
  13919. Button3D.prototype._disposeFacadeTexture = function () {
  13920. if (this._facadeTexture) {
  13921. this._facadeTexture.dispose();
  13922. this._facadeTexture = null;
  13923. }
  13924. };
  13925. Button3D.prototype._resetContent = function () {
  13926. this._disposeFacadeTexture();
  13927. this.content = this._content;
  13928. };
  13929. Object.defineProperty(Button3D.prototype, "content", {
  13930. /**
  13931. * Gets or sets the GUI 2D content used to display the button's facade
  13932. */
  13933. get: function () {
  13934. return this._content;
  13935. },
  13936. set: function (value) {
  13937. this._content = value;
  13938. if (!this._host || !this._host.utilityLayer) {
  13939. return;
  13940. }
  13941. if (!this._facadeTexture) {
  13942. 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);
  13943. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  13944. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  13945. this._facadeTexture.premulAlpha = true;
  13946. }
  13947. else {
  13948. this._facadeTexture.rootContainer.clearControls();
  13949. }
  13950. this._facadeTexture.addControl(value);
  13951. this._applyFacade(this._facadeTexture);
  13952. },
  13953. enumerable: true,
  13954. configurable: true
  13955. });
  13956. /**
  13957. * Apply the facade texture (created from the content property).
  13958. * This function can be overloaded by child classes
  13959. * @param facadeTexture defines the AdvancedDynamicTexture to use
  13960. */
  13961. Button3D.prototype._applyFacade = function (facadeTexture) {
  13962. this._currentMaterial.emissiveTexture = facadeTexture;
  13963. };
  13964. Button3D.prototype._getTypeName = function () {
  13965. return "Button3D";
  13966. };
  13967. // Mesh association
  13968. Button3D.prototype._createNode = function (scene) {
  13969. var faceUV = new Array(6);
  13970. for (var i = 0; i < 6; i++) {
  13971. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  13972. }
  13973. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  13974. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  13975. width: 1.0,
  13976. height: 1.0,
  13977. depth: 0.08,
  13978. faceUV: faceUV
  13979. }, scene);
  13980. return mesh;
  13981. };
  13982. Button3D.prototype._affectMaterial = function (mesh) {
  13983. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  13984. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13985. mesh.material = material;
  13986. this._currentMaterial = material;
  13987. this._resetContent();
  13988. };
  13989. /**
  13990. * Releases all associated resources
  13991. */
  13992. Button3D.prototype.dispose = function () {
  13993. _super.prototype.dispose.call(this);
  13994. this._disposeFacadeTexture();
  13995. if (this._currentMaterial) {
  13996. this._currentMaterial.dispose();
  13997. }
  13998. };
  13999. return Button3D;
  14000. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  14001. /***/ }),
  14002. /***/ "./3D/controls/container3D.ts":
  14003. /*!************************************!*\
  14004. !*** ./3D/controls/container3D.ts ***!
  14005. \************************************/
  14006. /*! exports provided: Container3D */
  14007. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14008. "use strict";
  14009. __webpack_require__.r(__webpack_exports__);
  14010. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  14011. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14012. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math.vector");
  14013. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14014. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14015. /**
  14016. * Class used to create containers for controls
  14017. */
  14018. var Container3D = /** @class */ (function (_super) {
  14019. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  14020. /**
  14021. * Creates a new container
  14022. * @param name defines the container name
  14023. */
  14024. function Container3D(name) {
  14025. var _this = _super.call(this, name) || this;
  14026. _this._blockLayout = false;
  14027. /**
  14028. * Gets the list of child controls
  14029. */
  14030. _this._children = new Array();
  14031. return _this;
  14032. }
  14033. Object.defineProperty(Container3D.prototype, "children", {
  14034. /**
  14035. * Gets the list of child controls
  14036. */
  14037. get: function () {
  14038. return this._children;
  14039. },
  14040. enumerable: true,
  14041. configurable: true
  14042. });
  14043. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14044. /**
  14045. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14046. * This is helpful to optimize layout operation when adding multiple children in a row
  14047. */
  14048. get: function () {
  14049. return this._blockLayout;
  14050. },
  14051. set: function (value) {
  14052. if (this._blockLayout === value) {
  14053. return;
  14054. }
  14055. this._blockLayout = value;
  14056. if (!this._blockLayout) {
  14057. this._arrangeChildren();
  14058. }
  14059. },
  14060. enumerable: true,
  14061. configurable: true
  14062. });
  14063. /**
  14064. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14065. * @returns the current container
  14066. */
  14067. Container3D.prototype.updateLayout = function () {
  14068. this._arrangeChildren();
  14069. return this;
  14070. };
  14071. /**
  14072. * Gets a boolean indicating if the given control is in the children of this control
  14073. * @param control defines the control to check
  14074. * @returns true if the control is in the child list
  14075. */
  14076. Container3D.prototype.containsControl = function (control) {
  14077. return this._children.indexOf(control) !== -1;
  14078. };
  14079. /**
  14080. * Adds a control to the children of this control
  14081. * @param control defines the control to add
  14082. * @returns the current container
  14083. */
  14084. Container3D.prototype.addControl = function (control) {
  14085. var index = this._children.indexOf(control);
  14086. if (index !== -1) {
  14087. return this;
  14088. }
  14089. control.parent = this;
  14090. control._host = this._host;
  14091. this._children.push(control);
  14092. if (this._host.utilityLayer) {
  14093. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14094. if (control.node) {
  14095. control.node.parent = this.node;
  14096. }
  14097. if (!this.blockLayout) {
  14098. this._arrangeChildren();
  14099. }
  14100. }
  14101. return this;
  14102. };
  14103. /**
  14104. * This function will be called everytime a new control is added
  14105. */
  14106. Container3D.prototype._arrangeChildren = function () {
  14107. };
  14108. Container3D.prototype._createNode = function (scene) {
  14109. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14110. };
  14111. /**
  14112. * Removes a control from the children of this control
  14113. * @param control defines the control to remove
  14114. * @returns the current container
  14115. */
  14116. Container3D.prototype.removeControl = function (control) {
  14117. var index = this._children.indexOf(control);
  14118. if (index !== -1) {
  14119. this._children.splice(index, 1);
  14120. control.parent = null;
  14121. control._disposeNode();
  14122. }
  14123. return this;
  14124. };
  14125. Container3D.prototype._getTypeName = function () {
  14126. return "Container3D";
  14127. };
  14128. /**
  14129. * Releases all associated resources
  14130. */
  14131. Container3D.prototype.dispose = function () {
  14132. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14133. var control = _a[_i];
  14134. control.dispose();
  14135. }
  14136. this._children = [];
  14137. _super.prototype.dispose.call(this);
  14138. };
  14139. /** Control rotation will remain unchanged */
  14140. Container3D.UNSET_ORIENTATION = 0;
  14141. /** Control will rotate to make it look at sphere central axis */
  14142. Container3D.FACEORIGIN_ORIENTATION = 1;
  14143. /** Control will rotate to make it look back at sphere central axis */
  14144. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14145. /** Control will rotate to look at z axis (0, 0, 1) */
  14146. Container3D.FACEFORWARD_ORIENTATION = 3;
  14147. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14148. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14149. return Container3D;
  14150. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14151. /***/ }),
  14152. /***/ "./3D/controls/control3D.ts":
  14153. /*!**********************************!*\
  14154. !*** ./3D/controls/control3D.ts ***!
  14155. \**********************************/
  14156. /*! exports provided: Control3D */
  14157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14158. "use strict";
  14159. __webpack_require__.r(__webpack_exports__);
  14160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14161. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  14162. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14163. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14164. /**
  14165. * Class used as base class for controls
  14166. */
  14167. var Control3D = /** @class */ (function () {
  14168. /**
  14169. * Creates a new control
  14170. * @param name defines the control name
  14171. */
  14172. function Control3D(
  14173. /** Defines the control name */
  14174. name) {
  14175. this.name = name;
  14176. this._downCount = 0;
  14177. this._enterCount = -1;
  14178. this._downPointerIds = {};
  14179. this._isVisible = true;
  14180. /**
  14181. * An event triggered when the pointer move over the control
  14182. */
  14183. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14184. /**
  14185. * An event triggered when the pointer move out of the control
  14186. */
  14187. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14188. /**
  14189. * An event triggered when the pointer taps the control
  14190. */
  14191. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14192. /**
  14193. * An event triggered when pointer is up
  14194. */
  14195. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14196. /**
  14197. * An event triggered when a control is clicked on (with a mouse)
  14198. */
  14199. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14200. /**
  14201. * An event triggered when pointer enters the control
  14202. */
  14203. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14204. // Behaviors
  14205. this._behaviors = new Array();
  14206. }
  14207. Object.defineProperty(Control3D.prototype, "position", {
  14208. /** Gets or sets the control position in world space */
  14209. get: function () {
  14210. if (!this._node) {
  14211. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14212. }
  14213. return this._node.position;
  14214. },
  14215. set: function (value) {
  14216. if (!this._node) {
  14217. return;
  14218. }
  14219. this._node.position = value;
  14220. },
  14221. enumerable: true,
  14222. configurable: true
  14223. });
  14224. Object.defineProperty(Control3D.prototype, "scaling", {
  14225. /** Gets or sets the control scaling in world space */
  14226. get: function () {
  14227. if (!this._node) {
  14228. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14229. }
  14230. return this._node.scaling;
  14231. },
  14232. set: function (value) {
  14233. if (!this._node) {
  14234. return;
  14235. }
  14236. this._node.scaling = value;
  14237. },
  14238. enumerable: true,
  14239. configurable: true
  14240. });
  14241. Object.defineProperty(Control3D.prototype, "behaviors", {
  14242. /**
  14243. * Gets the list of attached behaviors
  14244. * @see http://doc.babylonjs.com/features/behaviour
  14245. */
  14246. get: function () {
  14247. return this._behaviors;
  14248. },
  14249. enumerable: true,
  14250. configurable: true
  14251. });
  14252. /**
  14253. * Attach a behavior to the control
  14254. * @see http://doc.babylonjs.com/features/behaviour
  14255. * @param behavior defines the behavior to attach
  14256. * @returns the current control
  14257. */
  14258. Control3D.prototype.addBehavior = function (behavior) {
  14259. var _this = this;
  14260. var index = this._behaviors.indexOf(behavior);
  14261. if (index !== -1) {
  14262. return this;
  14263. }
  14264. behavior.init();
  14265. var scene = this._host.scene;
  14266. if (scene.isLoading) {
  14267. // We defer the attach when the scene will be loaded
  14268. scene.onDataLoadedObservable.addOnce(function () {
  14269. behavior.attach(_this);
  14270. });
  14271. }
  14272. else {
  14273. behavior.attach(this);
  14274. }
  14275. this._behaviors.push(behavior);
  14276. return this;
  14277. };
  14278. /**
  14279. * Remove an attached behavior
  14280. * @see http://doc.babylonjs.com/features/behaviour
  14281. * @param behavior defines the behavior to attach
  14282. * @returns the current control
  14283. */
  14284. Control3D.prototype.removeBehavior = function (behavior) {
  14285. var index = this._behaviors.indexOf(behavior);
  14286. if (index === -1) {
  14287. return this;
  14288. }
  14289. this._behaviors[index].detach();
  14290. this._behaviors.splice(index, 1);
  14291. return this;
  14292. };
  14293. /**
  14294. * Gets an attached behavior by name
  14295. * @param name defines the name of the behavior to look for
  14296. * @see http://doc.babylonjs.com/features/behaviour
  14297. * @returns null if behavior was not found else the requested behavior
  14298. */
  14299. Control3D.prototype.getBehaviorByName = function (name) {
  14300. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14301. var behavior = _a[_i];
  14302. if (behavior.name === name) {
  14303. return behavior;
  14304. }
  14305. }
  14306. return null;
  14307. };
  14308. Object.defineProperty(Control3D.prototype, "isVisible", {
  14309. /** Gets or sets a boolean indicating if the control is visible */
  14310. get: function () {
  14311. return this._isVisible;
  14312. },
  14313. set: function (value) {
  14314. if (this._isVisible === value) {
  14315. return;
  14316. }
  14317. this._isVisible = value;
  14318. var mesh = this.mesh;
  14319. if (mesh) {
  14320. mesh.setEnabled(value);
  14321. }
  14322. },
  14323. enumerable: true,
  14324. configurable: true
  14325. });
  14326. Object.defineProperty(Control3D.prototype, "typeName", {
  14327. /**
  14328. * Gets a string representing the class name
  14329. */
  14330. get: function () {
  14331. return this._getTypeName();
  14332. },
  14333. enumerable: true,
  14334. configurable: true
  14335. });
  14336. /**
  14337. * Get the current class name of the control.
  14338. * @returns current class name
  14339. */
  14340. Control3D.prototype.getClassName = function () {
  14341. return this._getTypeName();
  14342. };
  14343. Control3D.prototype._getTypeName = function () {
  14344. return "Control3D";
  14345. };
  14346. Object.defineProperty(Control3D.prototype, "node", {
  14347. /**
  14348. * Gets the transform node used by this control
  14349. */
  14350. get: function () {
  14351. return this._node;
  14352. },
  14353. enumerable: true,
  14354. configurable: true
  14355. });
  14356. Object.defineProperty(Control3D.prototype, "mesh", {
  14357. /**
  14358. * Gets the mesh used to render this control
  14359. */
  14360. get: function () {
  14361. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14362. return this._node;
  14363. }
  14364. return null;
  14365. },
  14366. enumerable: true,
  14367. configurable: true
  14368. });
  14369. /**
  14370. * Link the control as child of the given node
  14371. * @param node defines the node to link to. Use null to unlink the control
  14372. * @returns the current control
  14373. */
  14374. Control3D.prototype.linkToTransformNode = function (node) {
  14375. if (this._node) {
  14376. this._node.parent = node;
  14377. }
  14378. return this;
  14379. };
  14380. /** @hidden **/
  14381. Control3D.prototype._prepareNode = function (scene) {
  14382. if (!this._node) {
  14383. this._node = this._createNode(scene);
  14384. if (!this.node) {
  14385. return;
  14386. }
  14387. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14388. this._node.position = this.position;
  14389. this._node.scaling = this.scaling;
  14390. var mesh = this.mesh;
  14391. if (mesh) {
  14392. mesh.isPickable = true;
  14393. this._affectMaterial(mesh);
  14394. }
  14395. }
  14396. };
  14397. /**
  14398. * Node creation.
  14399. * Can be overriden by children
  14400. * @param scene defines the scene where the node must be attached
  14401. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14402. */
  14403. Control3D.prototype._createNode = function (scene) {
  14404. // Do nothing by default
  14405. return null;
  14406. };
  14407. /**
  14408. * Affect a material to the given mesh
  14409. * @param mesh defines the mesh which will represent the control
  14410. */
  14411. Control3D.prototype._affectMaterial = function (mesh) {
  14412. mesh.material = null;
  14413. };
  14414. // Pointers
  14415. /** @hidden */
  14416. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14417. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14418. };
  14419. /** @hidden */
  14420. Control3D.prototype._onPointerEnter = function (target) {
  14421. if (this._enterCount > 0) {
  14422. return false;
  14423. }
  14424. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14425. this._enterCount = 0;
  14426. }
  14427. this._enterCount++;
  14428. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14429. if (this.pointerEnterAnimation) {
  14430. this.pointerEnterAnimation();
  14431. }
  14432. return true;
  14433. };
  14434. /** @hidden */
  14435. Control3D.prototype._onPointerOut = function (target) {
  14436. this._enterCount = 0;
  14437. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14438. if (this.pointerOutAnimation) {
  14439. this.pointerOutAnimation();
  14440. }
  14441. };
  14442. /** @hidden */
  14443. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14444. if (this._downCount !== 0) {
  14445. this._downCount++;
  14446. return false;
  14447. }
  14448. this._downCount++;
  14449. this._downPointerIds[pointerId] = true;
  14450. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14451. if (this.pointerDownAnimation) {
  14452. this.pointerDownAnimation();
  14453. }
  14454. return true;
  14455. };
  14456. /** @hidden */
  14457. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14458. this._downCount--;
  14459. delete this._downPointerIds[pointerId];
  14460. if (this._downCount < 0) {
  14461. // Handle if forcePointerUp was called prior to this
  14462. this._downCount = 0;
  14463. return;
  14464. }
  14465. if (this._downCount == 0) {
  14466. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14467. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14468. }
  14469. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14470. if (this.pointerUpAnimation) {
  14471. this.pointerUpAnimation();
  14472. }
  14473. }
  14474. };
  14475. /** @hidden */
  14476. Control3D.prototype.forcePointerUp = function (pointerId) {
  14477. if (pointerId === void 0) { pointerId = null; }
  14478. if (pointerId !== null) {
  14479. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14480. }
  14481. else {
  14482. for (var key in this._downPointerIds) {
  14483. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14484. }
  14485. if (this._downCount > 0) {
  14486. this._downCount = 1;
  14487. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14488. }
  14489. }
  14490. };
  14491. /** @hidden */
  14492. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14493. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14494. this._onPointerMove(this, pickedPoint);
  14495. var previousControlOver = this._host._lastControlOver[pointerId];
  14496. if (previousControlOver && previousControlOver !== this) {
  14497. previousControlOver._onPointerOut(this);
  14498. }
  14499. if (previousControlOver !== this) {
  14500. this._onPointerEnter(this);
  14501. }
  14502. this._host._lastControlOver[pointerId] = this;
  14503. return true;
  14504. }
  14505. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14506. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14507. this._host._lastControlDown[pointerId] = this;
  14508. this._host._lastPickedControl = this;
  14509. return true;
  14510. }
  14511. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  14512. if (this._host._lastControlDown[pointerId]) {
  14513. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14514. }
  14515. delete this._host._lastControlDown[pointerId];
  14516. return true;
  14517. }
  14518. return false;
  14519. };
  14520. /** @hidden */
  14521. Control3D.prototype._disposeNode = function () {
  14522. if (this._node) {
  14523. this._node.dispose();
  14524. this._node = null;
  14525. }
  14526. };
  14527. /**
  14528. * Releases all associated resources
  14529. */
  14530. Control3D.prototype.dispose = function () {
  14531. this.onPointerDownObservable.clear();
  14532. this.onPointerEnterObservable.clear();
  14533. this.onPointerMoveObservable.clear();
  14534. this.onPointerOutObservable.clear();
  14535. this.onPointerUpObservable.clear();
  14536. this.onPointerClickObservable.clear();
  14537. this._disposeNode();
  14538. // Behaviors
  14539. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14540. var behavior = _a[_i];
  14541. behavior.detach();
  14542. }
  14543. };
  14544. return Control3D;
  14545. }());
  14546. /***/ }),
  14547. /***/ "./3D/controls/cylinderPanel.ts":
  14548. /*!**************************************!*\
  14549. !*** ./3D/controls/cylinderPanel.ts ***!
  14550. \**************************************/
  14551. /*! exports provided: CylinderPanel */
  14552. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14553. "use strict";
  14554. __webpack_require__.r(__webpack_exports__);
  14555. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14556. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14557. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  14558. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14559. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14560. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14561. /**
  14562. * Class used to create a container panel deployed on the surface of a cylinder
  14563. */
  14564. var CylinderPanel = /** @class */ (function (_super) {
  14565. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14566. function CylinderPanel() {
  14567. var _this = _super !== null && _super.apply(this, arguments) || this;
  14568. _this._radius = 5.0;
  14569. return _this;
  14570. }
  14571. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14572. /**
  14573. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14574. */
  14575. get: function () {
  14576. return this._radius;
  14577. },
  14578. set: function (value) {
  14579. var _this = this;
  14580. if (this._radius === value) {
  14581. return;
  14582. }
  14583. this._radius = value;
  14584. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14585. _this._arrangeChildren();
  14586. });
  14587. },
  14588. enumerable: true,
  14589. configurable: true
  14590. });
  14591. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14592. var mesh = control.mesh;
  14593. if (!mesh) {
  14594. return;
  14595. }
  14596. var newPos = this._cylindricalMapping(nodePosition);
  14597. control.position = newPos;
  14598. switch (this.orientation) {
  14599. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14600. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14601. break;
  14602. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14603. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14604. break;
  14605. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14606. break;
  14607. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14608. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14609. break;
  14610. }
  14611. };
  14612. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14613. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14614. var yAngle = (source.x / this._radius);
  14615. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14616. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14617. };
  14618. return CylinderPanel;
  14619. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14620. /***/ }),
  14621. /***/ "./3D/controls/holographicButton.ts":
  14622. /*!******************************************!*\
  14623. !*** ./3D/controls/holographicButton.ts ***!
  14624. \******************************************/
  14625. /*! exports provided: HolographicButton */
  14626. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14627. "use strict";
  14628. __webpack_require__.r(__webpack_exports__);
  14629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14630. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14631. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14632. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Maths/math.vector");
  14633. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  14634. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14635. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14636. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14637. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14638. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14639. /**
  14640. * Class used to create a holographic button in 3D
  14641. */
  14642. var HolographicButton = /** @class */ (function (_super) {
  14643. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14644. /**
  14645. * Creates a new button
  14646. * @param name defines the control name
  14647. */
  14648. function HolographicButton(name, shareMaterials) {
  14649. if (shareMaterials === void 0) { shareMaterials = true; }
  14650. var _this = _super.call(this, name) || this;
  14651. _this._shareMaterials = true;
  14652. _this._shareMaterials = shareMaterials;
  14653. // Default animations
  14654. _this.pointerEnterAnimation = function () {
  14655. if (!_this.mesh) {
  14656. return;
  14657. }
  14658. _this._frontPlate.setEnabled(true);
  14659. };
  14660. _this.pointerOutAnimation = function () {
  14661. if (!_this.mesh) {
  14662. return;
  14663. }
  14664. _this._frontPlate.setEnabled(false);
  14665. };
  14666. return _this;
  14667. }
  14668. HolographicButton.prototype._disposeTooltip = function () {
  14669. this._tooltipFade = null;
  14670. if (this._tooltipTextBlock) {
  14671. this._tooltipTextBlock.dispose();
  14672. }
  14673. if (this._tooltipTexture) {
  14674. this._tooltipTexture.dispose();
  14675. }
  14676. if (this._tooltipMesh) {
  14677. this._tooltipMesh.dispose();
  14678. }
  14679. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14680. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14681. };
  14682. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14683. get: function () {
  14684. return this._backPlate.renderingGroupId;
  14685. },
  14686. /**
  14687. * Rendering ground id of all the mesh in the button
  14688. */
  14689. set: function (id) {
  14690. this._backPlate.renderingGroupId = id;
  14691. this._textPlate.renderingGroupId = id;
  14692. this._frontPlate.renderingGroupId = id;
  14693. if (this._tooltipMesh) {
  14694. this._tooltipMesh.renderingGroupId = id;
  14695. }
  14696. },
  14697. enumerable: true,
  14698. configurable: true
  14699. });
  14700. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14701. get: function () {
  14702. if (this._tooltipTextBlock) {
  14703. return this._tooltipTextBlock.text;
  14704. }
  14705. return null;
  14706. },
  14707. /**
  14708. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14709. */
  14710. set: function (text) {
  14711. var _this = this;
  14712. if (!text) {
  14713. this._disposeTooltip();
  14714. return;
  14715. }
  14716. if (!this._tooltipFade) {
  14717. // Create tooltip with mesh and text
  14718. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14719. 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);
  14720. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14721. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14722. tooltipBackground.material = mat;
  14723. tooltipBackground.isPickable = false;
  14724. this._tooltipMesh.addChild(tooltipBackground);
  14725. tooltipBackground.position.z = 0.05;
  14726. this._tooltipMesh.scaling.y = 1 / 3;
  14727. this._tooltipMesh.position.y = 0.7;
  14728. this._tooltipMesh.position.z = -0.15;
  14729. this._tooltipMesh.isPickable = false;
  14730. this._tooltipMesh.parent = this._backPlate;
  14731. // Create text texture for the tooltip
  14732. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14733. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14734. this._tooltipTextBlock.scaleY = 3;
  14735. this._tooltipTextBlock.color = "white";
  14736. this._tooltipTextBlock.fontSize = 130;
  14737. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14738. // Add hover action to tooltip
  14739. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14740. this._tooltipFade.delay = 500;
  14741. this._tooltipMesh.addBehavior(this._tooltipFade);
  14742. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14743. if (_this._tooltipFade) {
  14744. _this._tooltipFade.fadeIn(true);
  14745. }
  14746. });
  14747. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14748. if (_this._tooltipFade) {
  14749. _this._tooltipFade.fadeIn(false);
  14750. }
  14751. });
  14752. }
  14753. if (this._tooltipTextBlock) {
  14754. this._tooltipTextBlock.text = text;
  14755. }
  14756. },
  14757. enumerable: true,
  14758. configurable: true
  14759. });
  14760. Object.defineProperty(HolographicButton.prototype, "text", {
  14761. /**
  14762. * Gets or sets text for the button
  14763. */
  14764. get: function () {
  14765. return this._text;
  14766. },
  14767. set: function (value) {
  14768. if (this._text === value) {
  14769. return;
  14770. }
  14771. this._text = value;
  14772. this._rebuildContent();
  14773. },
  14774. enumerable: true,
  14775. configurable: true
  14776. });
  14777. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14778. /**
  14779. * Gets or sets the image url for the button
  14780. */
  14781. get: function () {
  14782. return this._imageUrl;
  14783. },
  14784. set: function (value) {
  14785. if (this._imageUrl === value) {
  14786. return;
  14787. }
  14788. this._imageUrl = value;
  14789. this._rebuildContent();
  14790. },
  14791. enumerable: true,
  14792. configurable: true
  14793. });
  14794. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14795. /**
  14796. * Gets the back material used by this button
  14797. */
  14798. get: function () {
  14799. return this._backMaterial;
  14800. },
  14801. enumerable: true,
  14802. configurable: true
  14803. });
  14804. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14805. /**
  14806. * Gets the front material used by this button
  14807. */
  14808. get: function () {
  14809. return this._frontMaterial;
  14810. },
  14811. enumerable: true,
  14812. configurable: true
  14813. });
  14814. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14815. /**
  14816. * Gets the plate material used by this button
  14817. */
  14818. get: function () {
  14819. return this._plateMaterial;
  14820. },
  14821. enumerable: true,
  14822. configurable: true
  14823. });
  14824. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14825. /**
  14826. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14827. */
  14828. get: function () {
  14829. return this._shareMaterials;
  14830. },
  14831. enumerable: true,
  14832. configurable: true
  14833. });
  14834. HolographicButton.prototype._getTypeName = function () {
  14835. return "HolographicButton";
  14836. };
  14837. HolographicButton.prototype._rebuildContent = function () {
  14838. this._disposeFacadeTexture();
  14839. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14840. panel.isVertical = true;
  14841. if (this._imageUrl) {
  14842. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14843. image.source = this._imageUrl;
  14844. image.paddingTop = "40px";
  14845. image.height = "180px";
  14846. image.width = "100px";
  14847. image.paddingBottom = "40px";
  14848. panel.addControl(image);
  14849. }
  14850. if (this._text) {
  14851. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14852. text.text = this._text;
  14853. text.color = "white";
  14854. text.height = "30px";
  14855. text.fontSize = 24;
  14856. panel.addControl(text);
  14857. }
  14858. if (this._frontPlate) {
  14859. this.content = panel;
  14860. }
  14861. };
  14862. // Mesh association
  14863. HolographicButton.prototype._createNode = function (scene) {
  14864. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14865. width: 1.0,
  14866. height: 1.0,
  14867. depth: 0.08
  14868. }, scene);
  14869. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14870. width: 1.0,
  14871. height: 1.0,
  14872. depth: 0.08
  14873. }, scene);
  14874. this._frontPlate.parent = this._backPlate;
  14875. this._frontPlate.position.z = -0.08;
  14876. this._frontPlate.isPickable = false;
  14877. this._frontPlate.setEnabled(false);
  14878. this._textPlate = _super.prototype._createNode.call(this, scene);
  14879. this._textPlate.parent = this._backPlate;
  14880. this._textPlate.position.z = -0.08;
  14881. this._textPlate.isPickable = false;
  14882. return this._backPlate;
  14883. };
  14884. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14885. this._plateMaterial.emissiveTexture = facadeTexture;
  14886. this._plateMaterial.opacityTexture = facadeTexture;
  14887. };
  14888. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14889. var _this = this;
  14890. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14891. this._backMaterial.renderHoverLight = true;
  14892. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14893. if (pickedPoint) {
  14894. _this._backMaterial.hoverPosition = pickedPoint;
  14895. _this._backMaterial.hoverColor.a = 1.0;
  14896. }
  14897. else {
  14898. _this._backMaterial.hoverColor.a = 0;
  14899. }
  14900. });
  14901. };
  14902. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14903. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14904. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14905. this._frontMaterial.alpha = 0.5; // Additive
  14906. this._frontMaterial.renderBorders = true;
  14907. };
  14908. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14909. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14910. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14911. };
  14912. HolographicButton.prototype._affectMaterial = function (mesh) {
  14913. // Back
  14914. if (this._shareMaterials) {
  14915. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14916. this._createBackMaterial(mesh);
  14917. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14918. }
  14919. else {
  14920. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14921. }
  14922. // Front
  14923. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  14924. this._createFrontMaterial(mesh);
  14925. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  14926. }
  14927. else {
  14928. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  14929. }
  14930. }
  14931. else {
  14932. this._createBackMaterial(mesh);
  14933. this._createFrontMaterial(mesh);
  14934. }
  14935. this._createPlateMaterial(mesh);
  14936. this._backPlate.material = this._backMaterial;
  14937. this._frontPlate.material = this._frontMaterial;
  14938. this._textPlate.material = this._plateMaterial;
  14939. this._rebuildContent();
  14940. };
  14941. /**
  14942. * Releases all associated resources
  14943. */
  14944. HolographicButton.prototype.dispose = function () {
  14945. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  14946. this._disposeTooltip();
  14947. if (!this.shareMaterials) {
  14948. this._backMaterial.dispose();
  14949. this._frontMaterial.dispose();
  14950. this._plateMaterial.dispose();
  14951. if (this._pickedPointObserver) {
  14952. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  14953. this._pickedPointObserver = null;
  14954. }
  14955. }
  14956. };
  14957. return HolographicButton;
  14958. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14959. /***/ }),
  14960. /***/ "./3D/controls/index.ts":
  14961. /*!******************************!*\
  14962. !*** ./3D/controls/index.ts ***!
  14963. \******************************/
  14964. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  14965. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14966. "use strict";
  14967. __webpack_require__.r(__webpack_exports__);
  14968. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14969. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14970. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14971. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14972. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14973. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  14974. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14975. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  14976. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  14977. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  14978. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  14979. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  14980. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  14981. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  14982. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  14983. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  14984. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  14985. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  14986. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  14987. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  14988. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  14989. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  14990. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  14992. /***/ }),
  14993. /***/ "./3D/controls/meshButton3D.ts":
  14994. /*!*************************************!*\
  14995. !*** ./3D/controls/meshButton3D.ts ***!
  14996. \*************************************/
  14997. /*! exports provided: MeshButton3D */
  14998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14999. "use strict";
  15000. __webpack_require__.r(__webpack_exports__);
  15001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  15002. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15003. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15004. /**
  15005. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  15006. */
  15007. var MeshButton3D = /** @class */ (function (_super) {
  15008. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  15009. /**
  15010. * Creates a new 3D button based on a mesh
  15011. * @param mesh mesh to become a 3D button
  15012. * @param name defines the control name
  15013. */
  15014. function MeshButton3D(mesh, name) {
  15015. var _this = _super.call(this, name) || this;
  15016. _this._currentMesh = mesh;
  15017. /**
  15018. * Provides a default behavior on hover/out & up/down
  15019. * Override those function to create your own desired behavior specific to your mesh
  15020. */
  15021. _this.pointerEnterAnimation = function () {
  15022. if (!_this.mesh) {
  15023. return;
  15024. }
  15025. _this.mesh.scaling.scaleInPlace(1.1);
  15026. };
  15027. _this.pointerOutAnimation = function () {
  15028. if (!_this.mesh) {
  15029. return;
  15030. }
  15031. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  15032. };
  15033. _this.pointerDownAnimation = function () {
  15034. if (!_this.mesh) {
  15035. return;
  15036. }
  15037. _this.mesh.scaling.scaleInPlace(0.95);
  15038. };
  15039. _this.pointerUpAnimation = function () {
  15040. if (!_this.mesh) {
  15041. return;
  15042. }
  15043. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15044. };
  15045. return _this;
  15046. }
  15047. MeshButton3D.prototype._getTypeName = function () {
  15048. return "MeshButton3D";
  15049. };
  15050. // Mesh association
  15051. MeshButton3D.prototype._createNode = function (scene) {
  15052. var _this = this;
  15053. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15054. mesh.metadata = _this;
  15055. });
  15056. return this._currentMesh;
  15057. };
  15058. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15059. };
  15060. return MeshButton3D;
  15061. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15062. /***/ }),
  15063. /***/ "./3D/controls/planePanel.ts":
  15064. /*!***********************************!*\
  15065. !*** ./3D/controls/planePanel.ts ***!
  15066. \***********************************/
  15067. /*! exports provided: PlanePanel */
  15068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15069. "use strict";
  15070. __webpack_require__.r(__webpack_exports__);
  15071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15072. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15073. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  15074. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15075. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15076. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15077. /**
  15078. * Class used to create a container panel deployed on the surface of a plane
  15079. */
  15080. var PlanePanel = /** @class */ (function (_super) {
  15081. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15082. function PlanePanel() {
  15083. return _super !== null && _super.apply(this, arguments) || this;
  15084. }
  15085. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15086. var mesh = control.mesh;
  15087. if (!mesh) {
  15088. return;
  15089. }
  15090. control.position = nodePosition.clone();
  15091. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15092. target.copyFrom(nodePosition);
  15093. switch (this.orientation) {
  15094. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15095. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15096. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15097. mesh.lookAt(target);
  15098. break;
  15099. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15100. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15101. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15102. mesh.lookAt(target);
  15103. break;
  15104. }
  15105. };
  15106. return PlanePanel;
  15107. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15108. /***/ }),
  15109. /***/ "./3D/controls/scatterPanel.ts":
  15110. /*!*************************************!*\
  15111. !*** ./3D/controls/scatterPanel.ts ***!
  15112. \*************************************/
  15113. /*! exports provided: ScatterPanel */
  15114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15115. "use strict";
  15116. __webpack_require__.r(__webpack_exports__);
  15117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15118. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15119. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15120. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15121. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15122. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15123. /**
  15124. * Class used to create a container panel where items get randomized planar mapping
  15125. */
  15126. var ScatterPanel = /** @class */ (function (_super) {
  15127. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15128. function ScatterPanel() {
  15129. var _this = _super !== null && _super.apply(this, arguments) || this;
  15130. _this._iteration = 100.0;
  15131. return _this;
  15132. }
  15133. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15134. /**
  15135. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15136. */
  15137. get: function () {
  15138. return this._iteration;
  15139. },
  15140. set: function (value) {
  15141. var _this = this;
  15142. if (this._iteration === value) {
  15143. return;
  15144. }
  15145. this._iteration = value;
  15146. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15147. _this._arrangeChildren();
  15148. });
  15149. },
  15150. enumerable: true,
  15151. configurable: true
  15152. });
  15153. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15154. var mesh = control.mesh;
  15155. var newPos = this._scatterMapping(nodePosition);
  15156. if (!mesh) {
  15157. return;
  15158. }
  15159. switch (this.orientation) {
  15160. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15161. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15162. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15163. break;
  15164. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15165. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15166. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15167. break;
  15168. }
  15169. control.position = newPos;
  15170. };
  15171. ScatterPanel.prototype._scatterMapping = function (source) {
  15172. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15173. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15174. return source;
  15175. };
  15176. ScatterPanel.prototype._finalProcessing = function () {
  15177. var meshes = [];
  15178. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15179. var child = _a[_i];
  15180. if (!child.mesh) {
  15181. continue;
  15182. }
  15183. meshes.push(child.mesh);
  15184. }
  15185. for (var count = 0; count < this._iteration; count++) {
  15186. meshes.sort(function (a, b) {
  15187. var distance1 = a.position.lengthSquared();
  15188. var distance2 = b.position.lengthSquared();
  15189. if (distance1 < distance2) {
  15190. return 1;
  15191. }
  15192. else if (distance1 > distance2) {
  15193. return -1;
  15194. }
  15195. return 0;
  15196. });
  15197. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15198. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15199. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15200. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15201. for (var i = 0; i < meshes.length - 1; i++) {
  15202. for (var j = i + 1; j < meshes.length; j++) {
  15203. if (i != j) {
  15204. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15205. // Ignore Z axis
  15206. difference2D.x = difference.x;
  15207. difference2D.y = difference.y;
  15208. var combinedRadius = cellSize;
  15209. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15210. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15211. distance -= minSeparation;
  15212. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15213. difference2D.normalize();
  15214. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15215. meshes[j].position.addInPlace(difference);
  15216. meshes[i].position.subtractInPlace(difference);
  15217. }
  15218. }
  15219. }
  15220. }
  15221. }
  15222. };
  15223. return ScatterPanel;
  15224. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15225. /***/ }),
  15226. /***/ "./3D/controls/spherePanel.ts":
  15227. /*!************************************!*\
  15228. !*** ./3D/controls/spherePanel.ts ***!
  15229. \************************************/
  15230. /*! exports provided: SpherePanel */
  15231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15232. "use strict";
  15233. __webpack_require__.r(__webpack_exports__);
  15234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15235. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15236. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15237. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15238. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15239. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15240. /**
  15241. * Class used to create a container panel deployed on the surface of a sphere
  15242. */
  15243. var SpherePanel = /** @class */ (function (_super) {
  15244. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15245. function SpherePanel() {
  15246. var _this = _super !== null && _super.apply(this, arguments) || this;
  15247. _this._radius = 5.0;
  15248. return _this;
  15249. }
  15250. Object.defineProperty(SpherePanel.prototype, "radius", {
  15251. /**
  15252. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15253. */
  15254. get: function () {
  15255. return this._radius;
  15256. },
  15257. set: function (value) {
  15258. var _this = this;
  15259. if (this._radius === value) {
  15260. return;
  15261. }
  15262. this._radius = value;
  15263. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15264. _this._arrangeChildren();
  15265. });
  15266. },
  15267. enumerable: true,
  15268. configurable: true
  15269. });
  15270. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15271. var mesh = control.mesh;
  15272. if (!mesh) {
  15273. return;
  15274. }
  15275. var newPos = this._sphericalMapping(nodePosition);
  15276. control.position = newPos;
  15277. switch (this.orientation) {
  15278. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15279. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15280. break;
  15281. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15282. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15283. break;
  15284. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15285. break;
  15286. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15287. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15288. break;
  15289. }
  15290. };
  15291. SpherePanel.prototype._sphericalMapping = function (source) {
  15292. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15293. var xAngle = (source.y / this._radius);
  15294. var yAngle = -(source.x / this._radius);
  15295. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15296. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15297. };
  15298. return SpherePanel;
  15299. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15300. /***/ }),
  15301. /***/ "./3D/controls/stackPanel3D.ts":
  15302. /*!*************************************!*\
  15303. !*** ./3D/controls/stackPanel3D.ts ***!
  15304. \*************************************/
  15305. /*! exports provided: StackPanel3D */
  15306. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15307. "use strict";
  15308. __webpack_require__.r(__webpack_exports__);
  15309. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15310. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15311. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15312. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15313. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15314. /**
  15315. * Class used to create a stack panel in 3D on XY plane
  15316. */
  15317. var StackPanel3D = /** @class */ (function (_super) {
  15318. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15319. /**
  15320. * Creates new StackPanel
  15321. * @param isVertical
  15322. */
  15323. function StackPanel3D(isVertical) {
  15324. if (isVertical === void 0) { isVertical = false; }
  15325. var _this = _super.call(this) || this;
  15326. _this._isVertical = false;
  15327. /**
  15328. * Gets or sets the distance between elements
  15329. */
  15330. _this.margin = 0.1;
  15331. _this._isVertical = isVertical;
  15332. return _this;
  15333. }
  15334. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15335. /**
  15336. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15337. */
  15338. get: function () {
  15339. return this._isVertical;
  15340. },
  15341. set: function (value) {
  15342. var _this = this;
  15343. if (this._isVertical === value) {
  15344. return;
  15345. }
  15346. this._isVertical = value;
  15347. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15348. _this._arrangeChildren();
  15349. });
  15350. },
  15351. enumerable: true,
  15352. configurable: true
  15353. });
  15354. StackPanel3D.prototype._arrangeChildren = function () {
  15355. var width = 0;
  15356. var height = 0;
  15357. var controlCount = 0;
  15358. var extendSizes = [];
  15359. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15360. // Measure
  15361. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15362. var child = _a[_i];
  15363. if (!child.mesh) {
  15364. continue;
  15365. }
  15366. controlCount++;
  15367. child.mesh.computeWorldMatrix(true);
  15368. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15369. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15370. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15371. extendSizes.push(extendSize);
  15372. if (this._isVertical) {
  15373. height += extendSize.y;
  15374. }
  15375. else {
  15376. width += extendSize.x;
  15377. }
  15378. }
  15379. if (this._isVertical) {
  15380. height += (controlCount - 1) * this.margin / 2;
  15381. }
  15382. else {
  15383. width += (controlCount - 1) * this.margin / 2;
  15384. }
  15385. // Arrange
  15386. var offset;
  15387. if (this._isVertical) {
  15388. offset = -height;
  15389. }
  15390. else {
  15391. offset = -width;
  15392. }
  15393. var index = 0;
  15394. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15395. var child = _c[_b];
  15396. if (!child.mesh) {
  15397. continue;
  15398. }
  15399. controlCount--;
  15400. var extendSize = extendSizes[index++];
  15401. if (this._isVertical) {
  15402. child.position.y = offset + extendSize.y;
  15403. child.position.x = 0;
  15404. offset += extendSize.y * 2;
  15405. }
  15406. else {
  15407. child.position.x = offset + extendSize.x;
  15408. child.position.y = 0;
  15409. offset += extendSize.x * 2;
  15410. }
  15411. offset += (controlCount > 0 ? this.margin : 0);
  15412. }
  15413. };
  15414. return StackPanel3D;
  15415. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15416. /***/ }),
  15417. /***/ "./3D/controls/volumeBasedPanel.ts":
  15418. /*!*****************************************!*\
  15419. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15420. \*****************************************/
  15421. /*! exports provided: VolumeBasedPanel */
  15422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15423. "use strict";
  15424. __webpack_require__.r(__webpack_exports__);
  15425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15426. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15427. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector");
  15428. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15429. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15430. /**
  15431. * Abstract class used to create a container panel deployed on the surface of a volume
  15432. */
  15433. var VolumeBasedPanel = /** @class */ (function (_super) {
  15434. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15435. /**
  15436. * Creates new VolumeBasedPanel
  15437. */
  15438. function VolumeBasedPanel() {
  15439. var _this = _super.call(this) || this;
  15440. _this._columns = 10;
  15441. _this._rows = 0;
  15442. _this._rowThenColum = true;
  15443. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15444. /**
  15445. * Gets or sets the distance between elements
  15446. */
  15447. _this.margin = 0;
  15448. return _this;
  15449. }
  15450. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15451. /**
  15452. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15453. * | Value | Type | Description |
  15454. * | ----- | ----------------------------------- | ----------- |
  15455. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15456. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15457. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15458. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15459. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15460. */
  15461. get: function () {
  15462. return this._orientation;
  15463. },
  15464. set: function (value) {
  15465. var _this = this;
  15466. if (this._orientation === value) {
  15467. return;
  15468. }
  15469. this._orientation = value;
  15470. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15471. _this._arrangeChildren();
  15472. });
  15473. },
  15474. enumerable: true,
  15475. configurable: true
  15476. });
  15477. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15478. /**
  15479. * Gets or sets the number of columns requested (10 by default).
  15480. * The panel will automatically compute the number of rows based on number of child controls.
  15481. */
  15482. get: function () {
  15483. return this._columns;
  15484. },
  15485. set: function (value) {
  15486. var _this = this;
  15487. if (this._columns === value) {
  15488. return;
  15489. }
  15490. this._columns = value;
  15491. this._rowThenColum = true;
  15492. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15493. _this._arrangeChildren();
  15494. });
  15495. },
  15496. enumerable: true,
  15497. configurable: true
  15498. });
  15499. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15500. /**
  15501. * Gets or sets a the number of rows requested.
  15502. * The panel will automatically compute the number of columns based on number of child controls.
  15503. */
  15504. get: function () {
  15505. return this._rows;
  15506. },
  15507. set: function (value) {
  15508. var _this = this;
  15509. if (this._rows === value) {
  15510. return;
  15511. }
  15512. this._rows = value;
  15513. this._rowThenColum = false;
  15514. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15515. _this._arrangeChildren();
  15516. });
  15517. },
  15518. enumerable: true,
  15519. configurable: true
  15520. });
  15521. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15522. this._cellWidth = 0;
  15523. this._cellHeight = 0;
  15524. var rows = 0;
  15525. var columns = 0;
  15526. var controlCount = 0;
  15527. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15528. // Measure
  15529. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15530. var child = _a[_i];
  15531. if (!child.mesh) {
  15532. continue;
  15533. }
  15534. controlCount++;
  15535. child.mesh.computeWorldMatrix(true);
  15536. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15537. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15538. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15539. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15540. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15541. diff.scaleInPlace(0.5);
  15542. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15543. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15544. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15545. }
  15546. this._cellWidth += this.margin * 2;
  15547. this._cellHeight += this.margin * 2;
  15548. // Arrange
  15549. if (this._rowThenColum) {
  15550. columns = this._columns;
  15551. rows = Math.ceil(controlCount / this._columns);
  15552. }
  15553. else {
  15554. rows = this._rows;
  15555. columns = Math.ceil(controlCount / this._rows);
  15556. }
  15557. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15558. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15559. var nodeGrid = [];
  15560. var cellCounter = 0;
  15561. if (this._rowThenColum) {
  15562. for (var r = 0; r < rows; r++) {
  15563. for (var c = 0; c < columns; c++) {
  15564. 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));
  15565. cellCounter++;
  15566. if (cellCounter > controlCount) {
  15567. break;
  15568. }
  15569. }
  15570. }
  15571. }
  15572. else {
  15573. for (var c = 0; c < columns; c++) {
  15574. for (var r = 0; r < rows; r++) {
  15575. 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));
  15576. cellCounter++;
  15577. if (cellCounter > controlCount) {
  15578. break;
  15579. }
  15580. }
  15581. }
  15582. }
  15583. cellCounter = 0;
  15584. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15585. var child = _c[_b];
  15586. if (!child.mesh) {
  15587. continue;
  15588. }
  15589. this._mapGridNode(child, nodeGrid[cellCounter]);
  15590. cellCounter++;
  15591. }
  15592. this._finalProcessing();
  15593. };
  15594. /** Child classes can implement this function to provide additional processing */
  15595. VolumeBasedPanel.prototype._finalProcessing = function () {
  15596. };
  15597. return VolumeBasedPanel;
  15598. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15599. /***/ }),
  15600. /***/ "./3D/gui3DManager.ts":
  15601. /*!****************************!*\
  15602. !*** ./3D/gui3DManager.ts ***!
  15603. \****************************/
  15604. /*! exports provided: GUI3DManager */
  15605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15606. "use strict";
  15607. __webpack_require__.r(__webpack_exports__);
  15608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15609. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math.vector");
  15610. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15611. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15612. /**
  15613. * Class used to manage 3D user interface
  15614. * @see http://doc.babylonjs.com/how_to/gui3d
  15615. */
  15616. var GUI3DManager = /** @class */ (function () {
  15617. /**
  15618. * Creates a new GUI3DManager
  15619. * @param scene
  15620. */
  15621. function GUI3DManager(scene) {
  15622. var _this = this;
  15623. /** @hidden */
  15624. this._lastControlOver = {};
  15625. /** @hidden */
  15626. this._lastControlDown = {};
  15627. /**
  15628. * Observable raised when the point picked by the pointer events changed
  15629. */
  15630. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15631. // Shared resources
  15632. /** @hidden */
  15633. this._sharedMaterials = {};
  15634. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15635. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15636. _this._sceneDisposeObserver = null;
  15637. _this._utilityLayer = null;
  15638. _this.dispose();
  15639. });
  15640. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15641. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15642. this._utilityLayer.pickUtilitySceneFirst = false;
  15643. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15644. return mesh && mesh.metadata && mesh.metadata._node;
  15645. };
  15646. // Root
  15647. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15648. this._rootContainer._host = this;
  15649. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15650. // Events
  15651. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15652. _this._handlePointerOut(pointerId, true);
  15653. });
  15654. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15655. _this._doPicking(pi);
  15656. });
  15657. // Scene
  15658. this._utilityLayer.utilityLayerScene.autoClear = false;
  15659. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15660. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15661. }
  15662. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15663. /** Gets the hosting scene */
  15664. get: function () {
  15665. return this._scene;
  15666. },
  15667. enumerable: true,
  15668. configurable: true
  15669. });
  15670. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15671. /** Gets associated utility layer */
  15672. get: function () {
  15673. return this._utilityLayer;
  15674. },
  15675. enumerable: true,
  15676. configurable: true
  15677. });
  15678. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15679. var previousControlOver = this._lastControlOver[pointerId];
  15680. if (previousControlOver) {
  15681. previousControlOver._onPointerOut(previousControlOver);
  15682. delete this._lastControlOver[pointerId];
  15683. }
  15684. if (isPointerUp) {
  15685. if (this._lastControlDown[pointerId]) {
  15686. this._lastControlDown[pointerId].forcePointerUp();
  15687. delete this._lastControlDown[pointerId];
  15688. }
  15689. }
  15690. this.onPickedPointChangedObservable.notifyObservers(null);
  15691. };
  15692. GUI3DManager.prototype._doPicking = function (pi) {
  15693. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15694. return false;
  15695. }
  15696. var pointerEvent = (pi.event);
  15697. var pointerId = pointerEvent.pointerId || 0;
  15698. var buttonIndex = pointerEvent.button;
  15699. var pickingInfo = pi.pickInfo;
  15700. if (!pickingInfo || !pickingInfo.hit) {
  15701. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15702. return false;
  15703. }
  15704. var control = (pickingInfo.pickedMesh.metadata);
  15705. if (pickingInfo.pickedPoint) {
  15706. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15707. }
  15708. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15709. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15710. if (this._lastControlOver[pointerId]) {
  15711. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15712. }
  15713. delete this._lastControlOver[pointerId];
  15714. }
  15715. }
  15716. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15717. if (this._lastControlDown[pointerEvent.pointerId]) {
  15718. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15719. delete this._lastControlDown[pointerEvent.pointerId];
  15720. }
  15721. if (pointerEvent.pointerType === "touch") {
  15722. this._handlePointerOut(pointerId, false);
  15723. }
  15724. }
  15725. return true;
  15726. };
  15727. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15728. /**
  15729. * Gets the root container
  15730. */
  15731. get: function () {
  15732. return this._rootContainer;
  15733. },
  15734. enumerable: true,
  15735. configurable: true
  15736. });
  15737. /**
  15738. * Gets a boolean indicating if the given control is in the root child list
  15739. * @param control defines the control to check
  15740. * @returns true if the control is in the root child list
  15741. */
  15742. GUI3DManager.prototype.containsControl = function (control) {
  15743. return this._rootContainer.containsControl(control);
  15744. };
  15745. /**
  15746. * Adds a control to the root child list
  15747. * @param control defines the control to add
  15748. * @returns the current manager
  15749. */
  15750. GUI3DManager.prototype.addControl = function (control) {
  15751. this._rootContainer.addControl(control);
  15752. return this;
  15753. };
  15754. /**
  15755. * Removes a control from the root child list
  15756. * @param control defines the control to remove
  15757. * @returns the current container
  15758. */
  15759. GUI3DManager.prototype.removeControl = function (control) {
  15760. this._rootContainer.removeControl(control);
  15761. return this;
  15762. };
  15763. /**
  15764. * Releases all associated resources
  15765. */
  15766. GUI3DManager.prototype.dispose = function () {
  15767. this._rootContainer.dispose();
  15768. for (var materialName in this._sharedMaterials) {
  15769. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15770. continue;
  15771. }
  15772. this._sharedMaterials[materialName].dispose();
  15773. }
  15774. this._sharedMaterials = {};
  15775. if (this._pointerOutObserver && this._utilityLayer) {
  15776. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15777. this._pointerOutObserver = null;
  15778. }
  15779. this.onPickedPointChangedObservable.clear();
  15780. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15781. if (utilityLayerScene) {
  15782. if (this._pointerObserver) {
  15783. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15784. this._pointerObserver = null;
  15785. }
  15786. }
  15787. if (this._scene) {
  15788. if (this._sceneDisposeObserver) {
  15789. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15790. this._sceneDisposeObserver = null;
  15791. }
  15792. }
  15793. if (this._utilityLayer) {
  15794. this._utilityLayer.dispose();
  15795. }
  15796. };
  15797. return GUI3DManager;
  15798. }());
  15799. /***/ }),
  15800. /***/ "./3D/index.ts":
  15801. /*!*********************!*\
  15802. !*** ./3D/index.ts ***!
  15803. \*********************/
  15804. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15805. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15806. "use strict";
  15807. __webpack_require__.r(__webpack_exports__);
  15808. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15809. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15811. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15821. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15824. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15826. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15828. /***/ }),
  15829. /***/ "./3D/materials/fluentMaterial.ts":
  15830. /*!****************************************!*\
  15831. !*** ./3D/materials/fluentMaterial.ts ***!
  15832. \****************************************/
  15833. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15835. "use strict";
  15836. __webpack_require__.r(__webpack_exports__);
  15837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15839. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15840. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Maths/math.vector");
  15841. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15842. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15843. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15844. /** @hidden */
  15845. var FluentMaterialDefines = /** @class */ (function (_super) {
  15846. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15847. function FluentMaterialDefines() {
  15848. var _this = _super.call(this) || this;
  15849. _this.INNERGLOW = false;
  15850. _this.BORDER = false;
  15851. _this.HOVERLIGHT = false;
  15852. _this.TEXTURE = false;
  15853. _this.rebuild();
  15854. return _this;
  15855. }
  15856. return FluentMaterialDefines;
  15857. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15858. /**
  15859. * Class used to render controls with fluent desgin
  15860. */
  15861. var FluentMaterial = /** @class */ (function (_super) {
  15862. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15863. /**
  15864. * Creates a new Fluent material
  15865. * @param name defines the name of the material
  15866. * @param scene defines the hosting scene
  15867. */
  15868. function FluentMaterial(name, scene) {
  15869. var _this = _super.call(this, name, scene) || this;
  15870. /**
  15871. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15872. */
  15873. _this.innerGlowColorIntensity = 0.5;
  15874. /**
  15875. * Gets or sets the inner glow color (white by default)
  15876. */
  15877. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15878. /**
  15879. * Gets or sets alpha value (default is 1.0)
  15880. */
  15881. _this.alpha = 1.0;
  15882. /**
  15883. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15884. */
  15885. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15886. /**
  15887. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15888. */
  15889. _this.renderBorders = false;
  15890. /**
  15891. * Gets or sets border width (default is 0.5)
  15892. */
  15893. _this.borderWidth = 0.5;
  15894. /**
  15895. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15896. */
  15897. _this.edgeSmoothingValue = 0.02;
  15898. /**
  15899. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15900. */
  15901. _this.borderMinValue = 0.1;
  15902. /**
  15903. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15904. */
  15905. _this.renderHoverLight = false;
  15906. /**
  15907. * Gets or sets the radius used to render the hover light (default is 1.0)
  15908. */
  15909. _this.hoverRadius = 1.0;
  15910. /**
  15911. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15912. */
  15913. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15914. /**
  15915. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15916. */
  15917. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15918. return _this;
  15919. }
  15920. FluentMaterial.prototype.needAlphaBlending = function () {
  15921. return this.alpha !== 1.0;
  15922. };
  15923. FluentMaterial.prototype.needAlphaTesting = function () {
  15924. return false;
  15925. };
  15926. FluentMaterial.prototype.getAlphaTestTexture = function () {
  15927. return null;
  15928. };
  15929. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  15930. if (this.isFrozen) {
  15931. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  15932. return true;
  15933. }
  15934. }
  15935. if (!subMesh._materialDefines) {
  15936. subMesh._materialDefines = new FluentMaterialDefines();
  15937. }
  15938. var scene = this.getScene();
  15939. var defines = subMesh._materialDefines;
  15940. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  15941. if (defines._renderId === scene.getRenderId()) {
  15942. return true;
  15943. }
  15944. }
  15945. if (defines._areTexturesDirty) {
  15946. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  15947. defines.BORDER = this.renderBorders;
  15948. defines.HOVERLIGHT = this.renderHoverLight;
  15949. if (this._albedoTexture) {
  15950. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  15951. return false;
  15952. }
  15953. else {
  15954. defines.TEXTURE = true;
  15955. }
  15956. }
  15957. else {
  15958. defines.TEXTURE = false;
  15959. }
  15960. }
  15961. var engine = scene.getEngine();
  15962. // Get correct effect
  15963. if (defines.isDirty) {
  15964. defines.markAsProcessed();
  15965. scene.resetCachedMaterial();
  15966. //Attributes
  15967. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  15968. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  15969. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  15970. var shaderName = "fluent";
  15971. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  15972. "hoverColor", "hoverPosition", "hoverRadius"
  15973. ];
  15974. var samplers = ["albedoSampler"];
  15975. var uniformBuffers = new Array();
  15976. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  15977. uniformsNames: uniforms,
  15978. uniformBuffersNames: uniformBuffers,
  15979. samplers: samplers,
  15980. defines: defines,
  15981. maxSimultaneousLights: 4
  15982. });
  15983. var join = defines.toString();
  15984. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  15985. attributes: attribs,
  15986. uniformsNames: uniforms,
  15987. uniformBuffersNames: uniformBuffers,
  15988. samplers: samplers,
  15989. defines: join,
  15990. fallbacks: null,
  15991. onCompiled: this.onCompiled,
  15992. onError: this.onError,
  15993. indexParameters: { maxSimultaneousLights: 4 }
  15994. }, engine));
  15995. }
  15996. if (!subMesh.effect || !subMesh.effect.isReady()) {
  15997. return false;
  15998. }
  15999. defines._renderId = scene.getRenderId();
  16000. subMesh.effect._wasPreviouslyReady = true;
  16001. return true;
  16002. };
  16003. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  16004. var scene = this.getScene();
  16005. var defines = subMesh._materialDefines;
  16006. if (!defines) {
  16007. return;
  16008. }
  16009. var effect = subMesh.effect;
  16010. if (!effect) {
  16011. return;
  16012. }
  16013. this._activeEffect = effect;
  16014. // Matrices
  16015. this.bindOnlyWorldMatrix(world);
  16016. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  16017. if (this._mustRebind(scene, effect)) {
  16018. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  16019. if (defines.INNERGLOW) {
  16020. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  16021. }
  16022. if (defines.BORDER) {
  16023. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  16024. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  16025. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  16026. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16027. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16028. }
  16029. if (defines.HOVERLIGHT) {
  16030. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  16031. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  16032. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  16033. }
  16034. if (defines.TEXTURE) {
  16035. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  16036. }
  16037. }
  16038. this._afterBind(mesh, this._activeEffect);
  16039. };
  16040. FluentMaterial.prototype.getActiveTextures = function () {
  16041. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16042. return activeTextures;
  16043. };
  16044. FluentMaterial.prototype.hasTexture = function (texture) {
  16045. if (_super.prototype.hasTexture.call(this, texture)) {
  16046. return true;
  16047. }
  16048. return false;
  16049. };
  16050. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16051. _super.prototype.dispose.call(this, forceDisposeEffect);
  16052. };
  16053. FluentMaterial.prototype.clone = function (name) {
  16054. var _this = this;
  16055. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16056. };
  16057. FluentMaterial.prototype.serialize = function () {
  16058. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16059. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16060. return serializationObject;
  16061. };
  16062. FluentMaterial.prototype.getClassName = function () {
  16063. return "FluentMaterial";
  16064. };
  16065. // Statics
  16066. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16067. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16068. };
  16069. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16070. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16071. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16072. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16073. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16074. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16075. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16076. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16077. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16078. ], FluentMaterial.prototype, "alpha", void 0);
  16079. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16080. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16081. ], FluentMaterial.prototype, "albedoColor", void 0);
  16082. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16083. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16084. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16085. ], FluentMaterial.prototype, "renderBorders", void 0);
  16086. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16087. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16088. ], FluentMaterial.prototype, "borderWidth", void 0);
  16089. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16090. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16091. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16092. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16093. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16094. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16095. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16096. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16097. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16098. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16099. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16100. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16101. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16102. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16103. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16104. ], FluentMaterial.prototype, "hoverColor", void 0);
  16105. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16106. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16107. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16108. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16109. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16110. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16111. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16112. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16113. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16114. return FluentMaterial;
  16115. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16116. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16117. /***/ }),
  16118. /***/ "./3D/materials/index.ts":
  16119. /*!*******************************!*\
  16120. !*** ./3D/materials/index.ts ***!
  16121. \*******************************/
  16122. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16124. "use strict";
  16125. __webpack_require__.r(__webpack_exports__);
  16126. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16129. /***/ }),
  16130. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16131. /*!*************************************************!*\
  16132. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16133. \*************************************************/
  16134. /*! exports provided: fluentPixelShader */
  16135. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16136. "use strict";
  16137. __webpack_require__.r(__webpack_exports__);
  16138. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16139. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math.vector");
  16140. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16141. var name = 'fluentPixelShader';
  16142. 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}";
  16143. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16144. /** @hidden */
  16145. var fluentPixelShader = { name: name, shader: shader };
  16146. /***/ }),
  16147. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16148. /*!***********************************************!*\
  16149. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16150. \***********************************************/
  16151. /*! exports provided: fluentVertexShader */
  16152. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16153. "use strict";
  16154. __webpack_require__.r(__webpack_exports__);
  16155. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16156. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math.vector");
  16157. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16158. var name = 'fluentVertexShader';
  16159. 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";
  16160. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16161. /** @hidden */
  16162. var fluentVertexShader = { name: name, shader: shader };
  16163. /***/ }),
  16164. /***/ "./3D/vector3WithInfo.ts":
  16165. /*!*******************************!*\
  16166. !*** ./3D/vector3WithInfo.ts ***!
  16167. \*******************************/
  16168. /*! exports provided: Vector3WithInfo */
  16169. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16170. "use strict";
  16171. __webpack_require__.r(__webpack_exports__);
  16172. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16173. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16174. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector");
  16175. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16176. /**
  16177. * Class used to transport Vector3 information for pointer events
  16178. */
  16179. var Vector3WithInfo = /** @class */ (function (_super) {
  16180. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16181. /**
  16182. * Creates a new Vector3WithInfo
  16183. * @param source defines the vector3 data to transport
  16184. * @param buttonIndex defines the current mouse button index
  16185. */
  16186. function Vector3WithInfo(source,
  16187. /** defines the current mouse button index */
  16188. buttonIndex) {
  16189. if (buttonIndex === void 0) { buttonIndex = 0; }
  16190. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16191. _this.buttonIndex = buttonIndex;
  16192. return _this;
  16193. }
  16194. return Vector3WithInfo;
  16195. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16196. /***/ }),
  16197. /***/ "./index.ts":
  16198. /*!******************!*\
  16199. !*** ./index.ts ***!
  16200. \******************/
  16201. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  16202. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16203. "use strict";
  16204. __webpack_require__.r(__webpack_exports__);
  16205. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16247. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16264. /***/ }),
  16265. /***/ "./legacy/legacy.ts":
  16266. /*!**************************!*\
  16267. !*** ./legacy/legacy.ts ***!
  16268. \**************************/
  16269. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  16270. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16271. "use strict";
  16272. __webpack_require__.r(__webpack_exports__);
  16273. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16331. /**
  16332. * Legacy support, defining window.BABYLON.GUI (global variable).
  16333. *
  16334. * This is the entry point for the UMD module.
  16335. * The entry point for a future ESM package should be index.ts
  16336. */
  16337. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16338. if (typeof globalObject !== "undefined") {
  16339. globalObject.BABYLON = globalObject.BABYLON || {};
  16340. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16341. }
  16342. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16343. /***/ }),
  16344. /***/ "babylonjs/Maths/math.vector":
  16345. /*!****************************************************************************************************!*\
  16346. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16347. \****************************************************************************************************/
  16348. /*! no static exports found */
  16349. /***/ (function(module, exports) {
  16350. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__;
  16351. /***/ })
  16352. /******/ });
  16353. });
  16354. //# sourceMappingURL=babylon.gui.js.map