babylon.gui.js 786 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) {
  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, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__createBinding", function() { return __createBinding; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; });
  128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; });
  129. /*! *****************************************************************************
  130. Copyright (c) Microsoft Corporation.
  131. Permission to use, copy, modify, and/or distribute this software for any
  132. purpose with or without fee is hereby granted.
  133. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  134. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  135. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  136. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  137. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  138. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  139. PERFORMANCE OF THIS SOFTWARE.
  140. ***************************************************************************** */
  141. /* global Reflect, Promise */
  142. var extendStatics = function(d, b) {
  143. extendStatics = Object.setPrototypeOf ||
  144. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  145. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  146. return extendStatics(d, b);
  147. };
  148. function __extends(d, b) {
  149. extendStatics(d, b);
  150. function __() { this.constructor = d; }
  151. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  152. }
  153. var __assign = function() {
  154. __assign = Object.assign || function __assign(t) {
  155. for (var s, i = 1, n = arguments.length; i < n; i++) {
  156. s = arguments[i];
  157. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  158. }
  159. return t;
  160. }
  161. return __assign.apply(this, arguments);
  162. }
  163. function __rest(s, e) {
  164. var t = {};
  165. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  166. t[p] = s[p];
  167. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  168. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  169. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  170. t[p[i]] = s[p[i]];
  171. }
  172. return t;
  173. }
  174. function __decorate(decorators, target, key, desc) {
  175. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  176. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  177. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  178. return c > 3 && r && Object.defineProperty(target, key, r), r;
  179. }
  180. function __param(paramIndex, decorator) {
  181. return function (target, key) { decorator(target, key, paramIndex); }
  182. }
  183. function __metadata(metadataKey, metadataValue) {
  184. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  185. }
  186. function __awaiter(thisArg, _arguments, P, generator) {
  187. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  188. return new (P || (P = Promise))(function (resolve, reject) {
  189. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  190. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  191. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  192. step((generator = generator.apply(thisArg, _arguments || [])).next());
  193. });
  194. }
  195. function __generator(thisArg, body) {
  196. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  197. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  198. function verb(n) { return function (v) { return step([n, v]); }; }
  199. function step(op) {
  200. if (f) throw new TypeError("Generator is already executing.");
  201. while (_) try {
  202. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  203. if (y = 0, t) op = [op[0] & 2, t.value];
  204. switch (op[0]) {
  205. case 0: case 1: t = op; break;
  206. case 4: _.label++; return { value: op[1], done: false };
  207. case 5: _.label++; y = op[1]; op = [0]; continue;
  208. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  209. default:
  210. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  211. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  212. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  213. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  214. if (t[2]) _.ops.pop();
  215. _.trys.pop(); continue;
  216. }
  217. op = body.call(thisArg, _);
  218. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  219. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  220. }
  221. }
  222. var __createBinding = Object.create ? (function(o, m, k, k2) {
  223. if (k2 === undefined) k2 = k;
  224. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  225. }) : (function(o, m, k, k2) {
  226. if (k2 === undefined) k2 = k;
  227. o[k2] = m[k];
  228. });
  229. function __exportStar(m, o) {
  230. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
  231. }
  232. function __values(o) {
  233. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  234. if (m) return m.call(o);
  235. if (o && typeof o.length === "number") return {
  236. next: function () {
  237. if (o && i >= o.length) o = void 0;
  238. return { value: o && o[i++], done: !o };
  239. }
  240. };
  241. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  242. }
  243. function __read(o, n) {
  244. var m = typeof Symbol === "function" && o[Symbol.iterator];
  245. if (!m) return o;
  246. var i = m.call(o), r, ar = [], e;
  247. try {
  248. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  249. }
  250. catch (error) { e = { error: error }; }
  251. finally {
  252. try {
  253. if (r && !r.done && (m = i["return"])) m.call(i);
  254. }
  255. finally { if (e) throw e.error; }
  256. }
  257. return ar;
  258. }
  259. function __spread() {
  260. for (var ar = [], i = 0; i < arguments.length; i++)
  261. ar = ar.concat(__read(arguments[i]));
  262. return ar;
  263. }
  264. function __spreadArrays() {
  265. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  266. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  267. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  268. r[k] = a[j];
  269. return r;
  270. };
  271. function __await(v) {
  272. return this instanceof __await ? (this.v = v, this) : new __await(v);
  273. }
  274. function __asyncGenerator(thisArg, _arguments, generator) {
  275. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  276. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  277. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  278. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  279. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  280. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  281. function fulfill(value) { resume("next", value); }
  282. function reject(value) { resume("throw", value); }
  283. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  284. }
  285. function __asyncDelegator(o) {
  286. var i, p;
  287. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  288. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  289. }
  290. function __asyncValues(o) {
  291. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  292. var m = o[Symbol.asyncIterator], i;
  293. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  294. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  295. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  296. }
  297. function __makeTemplateObject(cooked, raw) {
  298. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  299. return cooked;
  300. };
  301. var __setModuleDefault = Object.create ? (function(o, v) {
  302. Object.defineProperty(o, "default", { enumerable: true, value: v });
  303. }) : function(o, v) {
  304. o["default"] = v;
  305. };
  306. function __importStar(mod) {
  307. if (mod && mod.__esModule) return mod;
  308. var result = {};
  309. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  310. __setModuleDefault(result, mod);
  311. return result;
  312. }
  313. function __importDefault(mod) {
  314. return (mod && mod.__esModule) ? mod : { default: mod };
  315. }
  316. function __classPrivateFieldGet(receiver, privateMap) {
  317. if (!privateMap.has(receiver)) {
  318. throw new TypeError("attempted to get private field on non-instance");
  319. }
  320. return privateMap.get(receiver);
  321. }
  322. function __classPrivateFieldSet(receiver, privateMap, value) {
  323. if (!privateMap.has(receiver)) {
  324. throw new TypeError("attempted to set private field on non-instance");
  325. }
  326. privateMap.set(receiver, value);
  327. return value;
  328. }
  329. /***/ }),
  330. /***/ "../../node_modules/webpack/buildin/global.js":
  331. /*!***********************************!*\
  332. !*** (webpack)/buildin/global.js ***!
  333. \***********************************/
  334. /*! no static exports found */
  335. /***/ (function(module, exports) {
  336. var g;
  337. // This works in non-strict mode
  338. g = (function() {
  339. return this;
  340. })();
  341. try {
  342. // This works if eval is allowed (see CSP)
  343. g = g || new Function("return this")();
  344. } catch (e) {
  345. // This works if the window reference is available
  346. if (typeof window === "object") g = window;
  347. }
  348. // g can still be undefined, but nothing to do about it...
  349. // We return undefined, instead of nothing here, so it's
  350. // easier to handle this case. if(!global) { ...}
  351. module.exports = g;
  352. /***/ }),
  353. /***/ "./2D/adtInstrumentation.ts":
  354. /*!**********************************!*\
  355. !*** ./2D/adtInstrumentation.ts ***!
  356. \**********************************/
  357. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  359. "use strict";
  360. __webpack_require__.r(__webpack_exports__);
  361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  362. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/observable");
  363. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  364. /**
  365. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  366. */
  367. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  368. /**
  369. * Instantiates a new advanced dynamic texture instrumentation.
  370. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  371. * @param texture Defines the AdvancedDynamicTexture to instrument
  372. */
  373. function AdvancedDynamicTextureInstrumentation(
  374. /**
  375. * Define the instrumented AdvancedDynamicTexture.
  376. */
  377. texture) {
  378. this.texture = texture;
  379. this._captureRenderTime = false;
  380. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  381. this._captureLayoutTime = false;
  382. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  383. // Observers
  384. this._onBeginRenderObserver = null;
  385. this._onEndRenderObserver = null;
  386. this._onBeginLayoutObserver = null;
  387. this._onEndLayoutObserver = null;
  388. }
  389. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  390. // Properties
  391. /**
  392. * Gets the perf counter used to capture render time
  393. */
  394. get: function () {
  395. return this._renderTime;
  396. },
  397. enumerable: false,
  398. configurable: true
  399. });
  400. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  401. /**
  402. * Gets the perf counter used to capture layout time
  403. */
  404. get: function () {
  405. return this._layoutTime;
  406. },
  407. enumerable: false,
  408. configurable: true
  409. });
  410. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  411. /**
  412. * Enable or disable the render time capture
  413. */
  414. get: function () {
  415. return this._captureRenderTime;
  416. },
  417. set: function (value) {
  418. var _this = this;
  419. if (value === this._captureRenderTime) {
  420. return;
  421. }
  422. this._captureRenderTime = value;
  423. if (value) {
  424. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  425. _this._renderTime.beginMonitoring();
  426. });
  427. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  428. _this._renderTime.endMonitoring(true);
  429. });
  430. }
  431. else {
  432. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  433. this._onBeginRenderObserver = null;
  434. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  435. this._onEndRenderObserver = null;
  436. }
  437. },
  438. enumerable: false,
  439. configurable: true
  440. });
  441. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  442. /**
  443. * Enable or disable the layout time capture
  444. */
  445. get: function () {
  446. return this._captureLayoutTime;
  447. },
  448. set: function (value) {
  449. var _this = this;
  450. if (value === this._captureLayoutTime) {
  451. return;
  452. }
  453. this._captureLayoutTime = value;
  454. if (value) {
  455. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  456. _this._layoutTime.beginMonitoring();
  457. });
  458. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  459. _this._layoutTime.endMonitoring(true);
  460. });
  461. }
  462. else {
  463. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  464. this._onBeginLayoutObserver = null;
  465. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  466. this._onEndLayoutObserver = null;
  467. }
  468. },
  469. enumerable: false,
  470. configurable: true
  471. });
  472. /**
  473. * Dispose and release associated resources.
  474. */
  475. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  476. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  477. this._onBeginRenderObserver = null;
  478. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  479. this._onEndRenderObserver = null;
  480. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  481. this._onBeginLayoutObserver = null;
  482. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  483. this._onEndLayoutObserver = null;
  484. this.texture = null;
  485. };
  486. return AdvancedDynamicTextureInstrumentation;
  487. }());
  488. /***/ }),
  489. /***/ "./2D/advancedDynamicTexture.ts":
  490. /*!**************************************!*\
  491. !*** ./2D/advancedDynamicTexture.ts ***!
  492. \**************************************/
  493. /*! exports provided: AdvancedDynamicTexture */
  494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  495. "use strict";
  496. __webpack_require__.r(__webpack_exports__);
  497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  498. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  499. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  500. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  501. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  502. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  503. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  504. /**
  505. * Class used to create texture to support 2D GUI elements
  506. * @see https://doc.babylonjs.com/how_to/gui
  507. */
  508. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  509. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  510. /**
  511. * Creates a new AdvancedDynamicTexture
  512. * @param name defines the name of the texture
  513. * @param width defines the width of the texture
  514. * @param height defines the height of the texture
  515. * @param scene defines the hosting scene
  516. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  517. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  518. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  519. */
  520. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode, invertY) {
  521. if (width === void 0) { width = 0; }
  522. if (height === void 0) { height = 0; }
  523. if (generateMipMaps === void 0) { generateMipMaps = false; }
  524. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  525. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA, invertY) || this;
  526. _this._isDirty = false;
  527. /** @hidden */
  528. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  529. /** @hidden */
  530. _this._lastControlOver = {};
  531. /** @hidden */
  532. _this._lastControlDown = {};
  533. /** @hidden */
  534. _this._capturingControl = {};
  535. /** @hidden */
  536. _this._linkedControls = new Array();
  537. _this._isFullscreen = false;
  538. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  539. _this._idealWidth = 0;
  540. _this._idealHeight = 0;
  541. _this._useSmallestIdeal = false;
  542. _this._renderAtIdealSize = false;
  543. _this._blockNextFocusCheck = false;
  544. _this._renderScale = 1;
  545. _this._cursorChanged = false;
  546. _this._defaultMousePointerId = 0;
  547. /** @hidden */
  548. _this._numLayoutCalls = 0;
  549. /** @hidden */
  550. _this._numRenderCalls = 0;
  551. /**
  552. * Define type to string to ensure compatibility across browsers
  553. * Safari doesn't support DataTransfer constructor
  554. */
  555. _this._clipboardData = "";
  556. /**
  557. * Observable event triggered each time an clipboard event is received from the rendering canvas
  558. */
  559. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  560. /**
  561. * Observable event triggered each time a pointer down is intercepted by a control
  562. */
  563. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  564. /**
  565. * Observable event triggered before layout is evaluated
  566. */
  567. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  568. /**
  569. * Observable event triggered after the layout was evaluated
  570. */
  571. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  572. /**
  573. * Observable event triggered before the texture is rendered
  574. */
  575. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  576. /**
  577. * Observable event triggered after the texture was rendered
  578. */
  579. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  580. /**
  581. * Gets or sets a boolean defining if alpha is stored as premultiplied
  582. */
  583. _this.premulAlpha = false;
  584. /**
  585. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  586. */
  587. _this.applyYInversionOnUpdate = true;
  588. _this._useInvalidateRectOptimization = true;
  589. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  590. _this._invalidatedRectangle = null;
  591. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  592. /** @hidden */
  593. _this.onClipboardCopy = function (rawEvt) {
  594. var evt = rawEvt;
  595. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  596. _this.onClipboardObservable.notifyObservers(ev);
  597. evt.preventDefault();
  598. };
  599. /** @hidden */
  600. _this.onClipboardCut = function (rawEvt) {
  601. var evt = rawEvt;
  602. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  603. _this.onClipboardObservable.notifyObservers(ev);
  604. evt.preventDefault();
  605. };
  606. /** @hidden */
  607. _this.onClipboardPaste = function (rawEvt) {
  608. var evt = rawEvt;
  609. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  610. _this.onClipboardObservable.notifyObservers(ev);
  611. evt.preventDefault();
  612. };
  613. scene = _this.getScene();
  614. if (!scene || !_this._texture) {
  615. return _this;
  616. }
  617. _this._rootElement = scene.getEngine().getInputElement();
  618. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  619. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  620. if (!_this._focusedControl) {
  621. return;
  622. }
  623. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  624. _this._focusedControl.processKeyboard(info.event);
  625. }
  626. info.skipOnPointerObservable = true;
  627. });
  628. _this._rootContainer._link(_this);
  629. _this.hasAlpha = true;
  630. if (!width || !height) {
  631. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  632. _this._onResize();
  633. }
  634. _this._texture.isReady = true;
  635. return _this;
  636. }
  637. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  638. /** Gets the number of layout calls made the last time the ADT has been rendered */
  639. get: function () {
  640. return this._numLayoutCalls;
  641. },
  642. enumerable: false,
  643. configurable: true
  644. });
  645. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  646. /** Gets the number of render calls made the last time the ADT has been rendered */
  647. get: function () {
  648. return this._numRenderCalls;
  649. },
  650. enumerable: false,
  651. configurable: true
  652. });
  653. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  654. /**
  655. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  656. * Useful when you want more antialiasing
  657. */
  658. get: function () {
  659. return this._renderScale;
  660. },
  661. set: function (value) {
  662. if (value === this._renderScale) {
  663. return;
  664. }
  665. this._renderScale = value;
  666. this._onResize();
  667. },
  668. enumerable: false,
  669. configurable: true
  670. });
  671. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  672. /** Gets or sets the background color */
  673. get: function () {
  674. return this._background;
  675. },
  676. set: function (value) {
  677. if (this._background === value) {
  678. return;
  679. }
  680. this._background = value;
  681. this.markAsDirty();
  682. },
  683. enumerable: false,
  684. configurable: true
  685. });
  686. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  687. /**
  688. * Gets or sets the ideal width used to design controls.
  689. * The GUI will then rescale everything accordingly
  690. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  691. */
  692. get: function () {
  693. return this._idealWidth;
  694. },
  695. set: function (value) {
  696. if (this._idealWidth === value) {
  697. return;
  698. }
  699. this._idealWidth = value;
  700. this.markAsDirty();
  701. this._rootContainer._markAllAsDirty();
  702. },
  703. enumerable: false,
  704. configurable: true
  705. });
  706. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  707. /**
  708. * Gets or sets the ideal height used to design controls.
  709. * The GUI will then rescale everything accordingly
  710. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  711. */
  712. get: function () {
  713. return this._idealHeight;
  714. },
  715. set: function (value) {
  716. if (this._idealHeight === value) {
  717. return;
  718. }
  719. this._idealHeight = value;
  720. this.markAsDirty();
  721. this._rootContainer._markAllAsDirty();
  722. },
  723. enumerable: false,
  724. configurable: true
  725. });
  726. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  727. /**
  728. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  729. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  730. */
  731. get: function () {
  732. return this._useSmallestIdeal;
  733. },
  734. set: function (value) {
  735. if (this._useSmallestIdeal === value) {
  736. return;
  737. }
  738. this._useSmallestIdeal = value;
  739. this.markAsDirty();
  740. this._rootContainer._markAllAsDirty();
  741. },
  742. enumerable: false,
  743. configurable: true
  744. });
  745. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  746. /**
  747. * Gets or sets a boolean indicating if adaptive scaling must be used
  748. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  749. */
  750. get: function () {
  751. return this._renderAtIdealSize;
  752. },
  753. set: function (value) {
  754. if (this._renderAtIdealSize === value) {
  755. return;
  756. }
  757. this._renderAtIdealSize = value;
  758. this._onResize();
  759. },
  760. enumerable: false,
  761. configurable: true
  762. });
  763. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  764. /**
  765. * Gets the ratio used when in "ideal mode"
  766. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  767. * */
  768. get: function () {
  769. var rwidth = 0;
  770. var rheight = 0;
  771. if (this._idealWidth) {
  772. rwidth = (this.getSize().width) / this._idealWidth;
  773. }
  774. if (this._idealHeight) {
  775. rheight = (this.getSize().height) / this._idealHeight;
  776. }
  777. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  778. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  779. }
  780. if (this._idealWidth) { // horizontal
  781. return rwidth;
  782. }
  783. if (this._idealHeight) { // vertical
  784. return rheight;
  785. }
  786. return 1;
  787. },
  788. enumerable: false,
  789. configurable: true
  790. });
  791. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  792. /**
  793. * Gets the underlying layer used to render the texture when in fullscreen mode
  794. */
  795. get: function () {
  796. return this._layerToDispose;
  797. },
  798. enumerable: false,
  799. configurable: true
  800. });
  801. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  802. /**
  803. * Gets the root container control
  804. */
  805. get: function () {
  806. return this._rootContainer;
  807. },
  808. enumerable: false,
  809. configurable: true
  810. });
  811. /**
  812. * Returns an array containing the root container.
  813. * This is mostly used to let the Inspector introspects the ADT
  814. * @returns an array containing the rootContainer
  815. */
  816. AdvancedDynamicTexture.prototype.getChildren = function () {
  817. return [this._rootContainer];
  818. };
  819. /**
  820. * Will return all controls that are inside this texture
  821. * @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
  822. * @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
  823. * @return all child controls
  824. */
  825. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  826. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  827. };
  828. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  829. /**
  830. * Gets or sets the current focused control
  831. */
  832. get: function () {
  833. return this._focusedControl;
  834. },
  835. set: function (control) {
  836. if (this._focusedControl == control) {
  837. return;
  838. }
  839. if (this._focusedControl) {
  840. this._focusedControl.onBlur();
  841. }
  842. if (control) {
  843. control.onFocus();
  844. }
  845. this._focusedControl = control;
  846. },
  847. enumerable: false,
  848. configurable: true
  849. });
  850. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  851. /**
  852. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  853. */
  854. get: function () {
  855. if (!this.layer) {
  856. return true;
  857. }
  858. return (!this.layer.isBackground);
  859. },
  860. set: function (value) {
  861. if (!this.layer) {
  862. return;
  863. }
  864. if (this.layer.isBackground === !value) {
  865. return;
  866. }
  867. this.layer.isBackground = !value;
  868. },
  869. enumerable: false,
  870. configurable: true
  871. });
  872. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  873. /**
  874. * Gets or set information about clipboardData
  875. */
  876. get: function () {
  877. return this._clipboardData;
  878. },
  879. set: function (value) {
  880. this._clipboardData = value;
  881. },
  882. enumerable: false,
  883. configurable: true
  884. });
  885. /**
  886. * Get the current class name of the texture useful for serialization or dynamic coding.
  887. * @returns "AdvancedDynamicTexture"
  888. */
  889. AdvancedDynamicTexture.prototype.getClassName = function () {
  890. return "AdvancedDynamicTexture";
  891. };
  892. /**
  893. * Function used to execute a function on all controls
  894. * @param func defines the function to execute
  895. * @param container defines the container where controls belong. If null the root container will be used
  896. */
  897. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  898. if (!container) {
  899. container = this._rootContainer;
  900. }
  901. func(container);
  902. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  903. var child = _a[_i];
  904. if (child.children) {
  905. this.executeOnAllControls(func, child);
  906. continue;
  907. }
  908. func(child);
  909. }
  910. };
  911. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  912. /**
  913. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  914. */
  915. get: function () {
  916. return this._useInvalidateRectOptimization;
  917. },
  918. set: function (value) {
  919. this._useInvalidateRectOptimization = value;
  920. },
  921. enumerable: false,
  922. configurable: true
  923. });
  924. /**
  925. * Invalidates a rectangle area on the gui texture
  926. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  927. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  928. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  929. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  930. */
  931. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  932. if (!this._useInvalidateRectOptimization) {
  933. return;
  934. }
  935. if (!this._invalidatedRectangle) {
  936. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  937. }
  938. else {
  939. // Compute intersection
  940. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  941. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  942. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  943. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  944. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  945. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  946. }
  947. };
  948. /**
  949. * Marks the texture as dirty forcing a complete update
  950. */
  951. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  952. this._isDirty = true;
  953. };
  954. /**
  955. * Helper function used to create a new style
  956. * @returns a new style
  957. * @see https://doc.babylonjs.com/how_to/gui#styles
  958. */
  959. AdvancedDynamicTexture.prototype.createStyle = function () {
  960. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  961. };
  962. /**
  963. * Adds a new control to the root container
  964. * @param control defines the control to add
  965. * @returns the current texture
  966. */
  967. AdvancedDynamicTexture.prototype.addControl = function (control) {
  968. this._rootContainer.addControl(control);
  969. return this;
  970. };
  971. /**
  972. * Removes a control from the root container
  973. * @param control defines the control to remove
  974. * @returns the current texture
  975. */
  976. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  977. this._rootContainer.removeControl(control);
  978. return this;
  979. };
  980. /**
  981. * Release all resources
  982. */
  983. AdvancedDynamicTexture.prototype.dispose = function () {
  984. var scene = this.getScene();
  985. if (!scene) {
  986. return;
  987. }
  988. this._rootElement = null;
  989. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  990. if (this._resizeObserver) {
  991. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  992. }
  993. if (this._pointerMoveObserver) {
  994. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  995. }
  996. if (this._pointerObserver) {
  997. scene.onPointerObservable.remove(this._pointerObserver);
  998. }
  999. if (this._preKeyboardObserver) {
  1000. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  1001. }
  1002. if (this._canvasPointerOutObserver) {
  1003. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  1004. }
  1005. if (this._canvasBlurObserver) {
  1006. scene.getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver);
  1007. }
  1008. if (this._layerToDispose) {
  1009. this._layerToDispose.texture = null;
  1010. this._layerToDispose.dispose();
  1011. this._layerToDispose = null;
  1012. }
  1013. this._rootContainer.dispose();
  1014. this.onClipboardObservable.clear();
  1015. this.onControlPickedObservable.clear();
  1016. this.onBeginRenderObservable.clear();
  1017. this.onEndRenderObservable.clear();
  1018. this.onBeginLayoutObservable.clear();
  1019. this.onEndLayoutObservable.clear();
  1020. _super.prototype.dispose.call(this);
  1021. };
  1022. AdvancedDynamicTexture.prototype._onResize = function () {
  1023. var scene = this.getScene();
  1024. if (!scene) {
  1025. return;
  1026. }
  1027. // Check size
  1028. var engine = scene.getEngine();
  1029. var textureSize = this.getSize();
  1030. var renderWidth = engine.getRenderWidth() * this._renderScale;
  1031. var renderHeight = engine.getRenderHeight() * this._renderScale;
  1032. if (this._renderAtIdealSize) {
  1033. if (this._idealWidth) {
  1034. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  1035. renderWidth = this._idealWidth;
  1036. }
  1037. else if (this._idealHeight) {
  1038. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1039. renderHeight = this._idealHeight;
  1040. }
  1041. }
  1042. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1043. this.scaleTo(renderWidth, renderHeight);
  1044. this.markAsDirty();
  1045. if (this._idealWidth || this._idealHeight) {
  1046. this._rootContainer._markAllAsDirty();
  1047. }
  1048. }
  1049. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1050. };
  1051. /** @hidden */
  1052. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1053. var engine = scene.getEngine();
  1054. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1055. };
  1056. /**
  1057. * Get screen coordinates for a vector3
  1058. * @param position defines the position to project
  1059. * @param worldMatrix defines the world matrix to use
  1060. * @returns the projected position
  1061. */
  1062. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1063. var scene = this.getScene();
  1064. if (!scene) {
  1065. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1066. }
  1067. var globalViewport = this._getGlobalViewport(scene);
  1068. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1069. projectedPosition.scaleInPlace(this.renderScale);
  1070. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1071. };
  1072. /**
  1073. * Get screen coordinates for a vector3
  1074. * @param position defines the position to project
  1075. * @param worldMatrix defines the world matrix to use
  1076. * @returns the projected position with Z
  1077. */
  1078. AdvancedDynamicTexture.prototype.getProjectedPositionWithZ = function (position, worldMatrix) {
  1079. var scene = this.getScene();
  1080. if (!scene) {
  1081. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  1082. }
  1083. var globalViewport = this._getGlobalViewport(scene);
  1084. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1085. projectedPosition.scaleInPlace(this.renderScale);
  1086. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"](projectedPosition.x, projectedPosition.y, projectedPosition.z);
  1087. };
  1088. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1089. if (this._layerToDispose) {
  1090. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1091. return;
  1092. }
  1093. }
  1094. if (this._isFullscreen && this._linkedControls.length) {
  1095. var scene = this.getScene();
  1096. if (!scene) {
  1097. return;
  1098. }
  1099. var globalViewport = this._getGlobalViewport(scene);
  1100. var _loop_1 = function (control) {
  1101. if (!control.isVisible) {
  1102. return "continue";
  1103. }
  1104. var mesh = control._linkedMesh;
  1105. if (!mesh || mesh.isDisposed()) {
  1106. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1107. control.linkWithMesh(null);
  1108. });
  1109. return "continue";
  1110. }
  1111. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1112. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1113. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1114. control.notRenderable = true;
  1115. return "continue";
  1116. }
  1117. control.notRenderable = false;
  1118. // Account for RenderScale.
  1119. projectedPosition.scaleInPlace(this_1.renderScale);
  1120. control._moveToProjectedPosition(projectedPosition);
  1121. };
  1122. var this_1 = this;
  1123. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1124. var control = _a[_i];
  1125. _loop_1(control);
  1126. }
  1127. }
  1128. if (!this._isDirty && !this._rootContainer.isDirty) {
  1129. return;
  1130. }
  1131. this._isDirty = false;
  1132. this._render();
  1133. this.update(this.applyYInversionOnUpdate, this.premulAlpha);
  1134. };
  1135. AdvancedDynamicTexture.prototype._render = function () {
  1136. var textureSize = this.getSize();
  1137. var renderWidth = textureSize.width;
  1138. var renderHeight = textureSize.height;
  1139. var context = this.getContext();
  1140. context.font = "18px Arial";
  1141. context.strokeStyle = "white";
  1142. // Layout
  1143. this.onBeginLayoutObservable.notifyObservers(this);
  1144. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1145. this._numLayoutCalls = 0;
  1146. this._rootContainer._layout(measure, context);
  1147. this.onEndLayoutObservable.notifyObservers(this);
  1148. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1149. // Clear
  1150. if (this._invalidatedRectangle) {
  1151. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1152. }
  1153. else {
  1154. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1155. }
  1156. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1157. if (this._background) {
  1158. context.save();
  1159. context.fillStyle = this._background;
  1160. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1161. context.restore();
  1162. }
  1163. // Render
  1164. this.onBeginRenderObservable.notifyObservers(this);
  1165. this._numRenderCalls = 0;
  1166. this._rootContainer._render(context, this._invalidatedRectangle);
  1167. this.onEndRenderObservable.notifyObservers(this);
  1168. this._invalidatedRectangle = null;
  1169. };
  1170. /** @hidden */
  1171. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1172. if (this._rootElement) {
  1173. this._rootElement.style.cursor = cursor;
  1174. this._cursorChanged = true;
  1175. }
  1176. };
  1177. /** @hidden */
  1178. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1179. this._lastControlDown[pointerId] = control;
  1180. this.onControlPickedObservable.notifyObservers(control);
  1181. };
  1182. AdvancedDynamicTexture.prototype._doPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  1183. var scene = this.getScene();
  1184. if (!scene) {
  1185. return;
  1186. }
  1187. var engine = scene.getEngine();
  1188. var textureSize = this.getSize();
  1189. if (this._isFullscreen) {
  1190. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1191. var viewport = camera.viewport;
  1192. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1193. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1194. }
  1195. if (this._capturingControl[pointerId]) {
  1196. this._capturingControl[pointerId]._processObservables(type, x, y, pi, pointerId, buttonIndex);
  1197. return;
  1198. }
  1199. this._cursorChanged = false;
  1200. if (!this._rootContainer._processPicking(x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY)) {
  1201. this._changeCursor("");
  1202. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1203. if (this._lastControlOver[pointerId]) {
  1204. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId], pi);
  1205. delete this._lastControlOver[pointerId];
  1206. }
  1207. }
  1208. }
  1209. if (!this._cursorChanged) {
  1210. this._changeCursor("");
  1211. }
  1212. this._manageFocus();
  1213. };
  1214. /** @hidden */
  1215. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1216. for (var pointerId in list) {
  1217. if (!list.hasOwnProperty(pointerId)) {
  1218. continue;
  1219. }
  1220. var lastControlOver = list[pointerId];
  1221. if (lastControlOver === control) {
  1222. delete list[pointerId];
  1223. }
  1224. }
  1225. };
  1226. /** @hidden */
  1227. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1228. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1229. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1230. };
  1231. /** Attach to all scene events required to support pointer events */
  1232. AdvancedDynamicTexture.prototype.attach = function () {
  1233. var _this = this;
  1234. var scene = this.getScene();
  1235. if (!scene) {
  1236. return;
  1237. }
  1238. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1239. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1240. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1241. return;
  1242. }
  1243. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1244. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1245. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN
  1246. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  1247. return;
  1248. }
  1249. if (!scene) {
  1250. return;
  1251. }
  1252. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE && pi.event.pointerId) {
  1253. _this._defaultMousePointerId = pi.event.pointerId; // This is required to make sure we have the correct pointer ID for wheel
  1254. }
  1255. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1256. var engine = scene.getEngine();
  1257. if (!camera) {
  1258. tempViewport.x = 0;
  1259. tempViewport.y = 0;
  1260. tempViewport.width = engine.getRenderWidth();
  1261. tempViewport.height = engine.getRenderHeight();
  1262. }
  1263. else {
  1264. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1265. }
  1266. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1267. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1268. _this._shouldBlockPointer = false;
  1269. // Do picking modifies _shouldBlockPointer
  1270. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1271. _this._doPicking(x, y, pi, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
  1272. // Avoid overwriting a true skipOnPointerObservable to false
  1273. if (_this._shouldBlockPointer) {
  1274. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1275. }
  1276. });
  1277. this._attachToOnPointerOut(scene);
  1278. this._attachToOnBlur(scene);
  1279. };
  1280. /**
  1281. * Register the clipboard Events onto the canvas
  1282. */
  1283. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1284. self.addEventListener("copy", this.onClipboardCopy, false);
  1285. self.addEventListener("cut", this.onClipboardCut, false);
  1286. self.addEventListener("paste", this.onClipboardPaste, false);
  1287. };
  1288. /**
  1289. * Unregister the clipboard Events from the canvas
  1290. */
  1291. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1292. self.removeEventListener("copy", this.onClipboardCopy);
  1293. self.removeEventListener("cut", this.onClipboardCut);
  1294. self.removeEventListener("paste", this.onClipboardPaste);
  1295. };
  1296. /**
  1297. * Connect the texture to a hosting mesh to enable interactions
  1298. * @param mesh defines the mesh to attach to
  1299. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1300. */
  1301. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1302. var _this = this;
  1303. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1304. var scene = this.getScene();
  1305. if (!scene) {
  1306. return;
  1307. }
  1308. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1309. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1310. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1311. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1312. return;
  1313. }
  1314. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1315. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1316. var uv = pi.pickInfo.getTextureCoordinates();
  1317. if (uv) {
  1318. var size = _this.getSize();
  1319. _this._doPicking(uv.x * size.width, (_this.applyYInversionOnUpdate ? (1.0 - uv.y) : uv.y) * size.height, pi, pi.type, pointerId, pi.event.button);
  1320. }
  1321. }
  1322. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1323. if (_this._lastControlDown[pointerId]) {
  1324. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1325. }
  1326. delete _this._lastControlDown[pointerId];
  1327. if (_this.focusedControl) {
  1328. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1329. var canMoveFocus = true;
  1330. if (friendlyControls) {
  1331. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1332. var control = friendlyControls_1[_i];
  1333. // Same host, no need to keep the focus
  1334. if (_this === control._host) {
  1335. continue;
  1336. }
  1337. // Different hosts
  1338. var otherHost = control._host;
  1339. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1340. canMoveFocus = false;
  1341. break;
  1342. }
  1343. }
  1344. }
  1345. if (canMoveFocus) {
  1346. _this.focusedControl = null;
  1347. }
  1348. }
  1349. }
  1350. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1351. if (_this._lastControlOver[pointerId]) {
  1352. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], pi, true);
  1353. }
  1354. delete _this._lastControlOver[pointerId];
  1355. }
  1356. });
  1357. mesh.enablePointerMoveEvents = supportPointerMove;
  1358. this._attachToOnPointerOut(scene);
  1359. this._attachToOnBlur(scene);
  1360. };
  1361. /**
  1362. * Move the focus to a specific control
  1363. * @param control defines the control which will receive the focus
  1364. */
  1365. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1366. this.focusedControl = control;
  1367. this._lastPickedControl = control;
  1368. this._blockNextFocusCheck = true;
  1369. };
  1370. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1371. if (this._blockNextFocusCheck) {
  1372. this._blockNextFocusCheck = false;
  1373. this._lastPickedControl = this._focusedControl;
  1374. return;
  1375. }
  1376. // Focus management
  1377. if (this._focusedControl) {
  1378. if (this._focusedControl !== this._lastPickedControl) {
  1379. if (this._lastPickedControl.isFocusInvisible) {
  1380. return;
  1381. }
  1382. this.focusedControl = null;
  1383. }
  1384. }
  1385. };
  1386. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1387. var _this = this;
  1388. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1389. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1390. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId], null);
  1391. }
  1392. delete _this._lastControlOver[pointerEvent.pointerId];
  1393. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1394. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1395. delete _this._lastControlDown[pointerEvent.pointerId];
  1396. }
  1397. });
  1398. };
  1399. AdvancedDynamicTexture.prototype._attachToOnBlur = function (scene) {
  1400. var _this = this;
  1401. this._canvasBlurObserver = scene.getEngine().onCanvasBlurObservable.add(function (pointerEvent) {
  1402. Object.entries(_this._lastControlDown).forEach(function (_a) {
  1403. var key = _a[0], value = _a[1];
  1404. value._onCanvasBlur();
  1405. });
  1406. _this._lastControlDown = {};
  1407. });
  1408. };
  1409. // Statics
  1410. /**
  1411. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1412. * @param mesh defines the mesh which will receive the texture
  1413. * @param width defines the texture width (1024 by default)
  1414. * @param height defines the texture height (1024 by default)
  1415. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1416. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1417. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  1418. * @returns a new AdvancedDynamicTexture
  1419. */
  1420. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting, invertY) {
  1421. if (width === void 0) { width = 1024; }
  1422. if (height === void 0) { height = 1024; }
  1423. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1424. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1425. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, invertY);
  1426. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1427. material.backFaceCulling = false;
  1428. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1429. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1430. if (onlyAlphaTesting) {
  1431. material.diffuseTexture = result;
  1432. material.emissiveTexture = result;
  1433. result.hasAlpha = true;
  1434. }
  1435. else {
  1436. material.emissiveTexture = result;
  1437. material.opacityTexture = result;
  1438. }
  1439. mesh.material = material;
  1440. result.attachToMesh(mesh, supportPointerMove);
  1441. return result;
  1442. };
  1443. /**
  1444. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh) BUT do not create a new material for the mesh. You will be responsible for connecting the texture
  1445. * @param mesh defines the mesh which will receive the texture
  1446. * @param width defines the texture width (1024 by default)
  1447. * @param height defines the texture height (1024 by default)
  1448. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1449. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  1450. * @returns a new AdvancedDynamicTexture
  1451. */
  1452. AdvancedDynamicTexture.CreateForMeshTexture = function (mesh, width, height, supportPointerMove, invertY) {
  1453. if (width === void 0) { width = 1024; }
  1454. if (height === void 0) { height = 1024; }
  1455. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1456. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, invertY);
  1457. result.attachToMesh(mesh, supportPointerMove);
  1458. return result;
  1459. };
  1460. /**
  1461. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1462. * In this mode the texture will rely on a layer for its rendering.
  1463. * This allows it to be treated like any other layer.
  1464. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1465. * LayerMask is set through advancedTexture.layer.layerMask
  1466. * @param name defines name for the texture
  1467. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1468. * @param scene defines the hsoting scene
  1469. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1470. * @returns a new AdvancedDynamicTexture
  1471. */
  1472. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1473. if (foreground === void 0) { foreground = true; }
  1474. if (scene === void 0) { scene = null; }
  1475. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1476. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1477. // Display
  1478. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1479. layer.texture = result;
  1480. result._layerToDispose = layer;
  1481. result._isFullscreen = true;
  1482. // Attach
  1483. result.attach();
  1484. return result;
  1485. };
  1486. return AdvancedDynamicTexture;
  1487. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1488. /***/ }),
  1489. /***/ "./2D/controls/button.ts":
  1490. /*!*******************************!*\
  1491. !*** ./2D/controls/button.ts ***!
  1492. \*******************************/
  1493. /*! exports provided: Button */
  1494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1495. "use strict";
  1496. __webpack_require__.r(__webpack_exports__);
  1497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1498. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1499. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1500. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1501. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1502. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1503. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  1504. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1505. /**
  1506. * Class used to create 2D buttons
  1507. */
  1508. var Button = /** @class */ (function (_super) {
  1509. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1510. /**
  1511. * Creates a new Button
  1512. * @param name defines the name of the button
  1513. */
  1514. function Button(name) {
  1515. var _this = _super.call(this, name) || this;
  1516. _this.name = name;
  1517. /**
  1518. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1519. */
  1520. _this.delegatePickingToChildren = false;
  1521. _this.thickness = 1;
  1522. _this.isPointerBlocker = true;
  1523. var alphaStore = null;
  1524. _this.pointerEnterAnimation = function () {
  1525. alphaStore = _this.alpha;
  1526. _this.alpha -= 0.1;
  1527. };
  1528. _this.pointerOutAnimation = function () {
  1529. if (alphaStore !== null) {
  1530. _this.alpha = alphaStore;
  1531. }
  1532. };
  1533. _this.pointerDownAnimation = function () {
  1534. _this.scaleX -= 0.05;
  1535. _this.scaleY -= 0.05;
  1536. };
  1537. _this.pointerUpAnimation = function () {
  1538. _this.scaleX += 0.05;
  1539. _this.scaleY += 0.05;
  1540. };
  1541. return _this;
  1542. }
  1543. Object.defineProperty(Button.prototype, "image", {
  1544. /**
  1545. * Returns the image part of the button (if any)
  1546. */
  1547. get: function () {
  1548. return this._image;
  1549. },
  1550. enumerable: false,
  1551. configurable: true
  1552. });
  1553. Object.defineProperty(Button.prototype, "textBlock", {
  1554. /**
  1555. * Returns the image part of the button (if any)
  1556. */
  1557. get: function () {
  1558. return this._textBlock;
  1559. },
  1560. enumerable: false,
  1561. configurable: true
  1562. });
  1563. Button.prototype._getTypeName = function () {
  1564. return "Button";
  1565. };
  1566. // While being a container, the button behaves like a control.
  1567. /** @hidden */
  1568. Button.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  1569. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1570. return false;
  1571. }
  1572. if (!_super.prototype.contains.call(this, x, y)) {
  1573. return false;
  1574. }
  1575. if (this.delegatePickingToChildren) {
  1576. var contains = false;
  1577. for (var index = this._children.length - 1; index >= 0; index--) {
  1578. var child = this._children[index];
  1579. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1580. contains = true;
  1581. break;
  1582. }
  1583. }
  1584. if (!contains) {
  1585. return false;
  1586. }
  1587. }
  1588. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  1589. return true;
  1590. };
  1591. /** @hidden */
  1592. Button.prototype._onPointerEnter = function (target, pi) {
  1593. if (!_super.prototype._onPointerEnter.call(this, target, pi)) {
  1594. return false;
  1595. }
  1596. if (this.pointerEnterAnimation) {
  1597. this.pointerEnterAnimation();
  1598. }
  1599. return true;
  1600. };
  1601. /** @hidden */
  1602. Button.prototype._onPointerOut = function (target, pi, force) {
  1603. if (force === void 0) { force = false; }
  1604. if (this.pointerOutAnimation) {
  1605. this.pointerOutAnimation();
  1606. }
  1607. _super.prototype._onPointerOut.call(this, target, pi, force);
  1608. };
  1609. /** @hidden */
  1610. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  1611. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  1612. return false;
  1613. }
  1614. if (this.pointerDownAnimation) {
  1615. this.pointerDownAnimation();
  1616. }
  1617. return true;
  1618. };
  1619. /** @hidden */
  1620. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  1621. if (this.pointerUpAnimation) {
  1622. this.pointerUpAnimation();
  1623. }
  1624. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  1625. };
  1626. // Statics
  1627. /**
  1628. * Creates a new button made with an image and a text
  1629. * @param name defines the name of the button
  1630. * @param text defines the text of the button
  1631. * @param imageUrl defines the url of the image
  1632. * @returns a new Button
  1633. */
  1634. Button.CreateImageButton = function (name, text, imageUrl) {
  1635. var result = new this(name);
  1636. // Adding text
  1637. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1638. textBlock.textWrapping = true;
  1639. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1640. textBlock.paddingLeft = "20%";
  1641. result.addControl(textBlock);
  1642. // Adding image
  1643. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1644. iconImage.width = "20%";
  1645. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1646. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1647. result.addControl(iconImage);
  1648. // Store
  1649. result._image = iconImage;
  1650. result._textBlock = textBlock;
  1651. return result;
  1652. };
  1653. /**
  1654. * Creates a new button made with an image
  1655. * @param name defines the name of the button
  1656. * @param imageUrl defines the url of the image
  1657. * @returns a new Button
  1658. */
  1659. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1660. var result = new this(name);
  1661. // Adding image
  1662. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1663. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1664. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1665. result.addControl(iconImage);
  1666. // Store
  1667. result._image = iconImage;
  1668. return result;
  1669. };
  1670. /**
  1671. * Creates a new button made with a text
  1672. * @param name defines the name of the button
  1673. * @param text defines the text of the button
  1674. * @returns a new Button
  1675. */
  1676. Button.CreateSimpleButton = function (name, text) {
  1677. var result = new this(name);
  1678. // Adding text
  1679. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1680. textBlock.textWrapping = true;
  1681. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1682. result.addControl(textBlock);
  1683. // Store
  1684. result._textBlock = textBlock;
  1685. return result;
  1686. };
  1687. /**
  1688. * Creates a new button made with an image and a centered text
  1689. * @param name defines the name of the button
  1690. * @param text defines the text of the button
  1691. * @param imageUrl defines the url of the image
  1692. * @returns a new Button
  1693. */
  1694. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1695. var result = new this(name);
  1696. // Adding image
  1697. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1698. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1699. result.addControl(iconImage);
  1700. // Adding text
  1701. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1702. textBlock.textWrapping = true;
  1703. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1704. result.addControl(textBlock);
  1705. // Store
  1706. result._image = iconImage;
  1707. result._textBlock = textBlock;
  1708. return result;
  1709. };
  1710. return Button;
  1711. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1712. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1713. /***/ }),
  1714. /***/ "./2D/controls/checkbox.ts":
  1715. /*!*********************************!*\
  1716. !*** ./2D/controls/checkbox.ts ***!
  1717. \*********************************/
  1718. /*! exports provided: Checkbox */
  1719. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1720. "use strict";
  1721. __webpack_require__.r(__webpack_exports__);
  1722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1723. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1724. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1725. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1726. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1727. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1728. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1729. /**
  1730. * Class used to represent a 2D checkbox
  1731. */
  1732. var Checkbox = /** @class */ (function (_super) {
  1733. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1734. /**
  1735. * Creates a new CheckBox
  1736. * @param name defines the control name
  1737. */
  1738. function Checkbox(name) {
  1739. var _this = _super.call(this, name) || this;
  1740. _this.name = name;
  1741. _this._isChecked = false;
  1742. _this._background = "black";
  1743. _this._checkSizeRatio = 0.8;
  1744. _this._thickness = 1;
  1745. /**
  1746. * Observable raised when isChecked property changes
  1747. */
  1748. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1749. _this.isPointerBlocker = true;
  1750. return _this;
  1751. }
  1752. Object.defineProperty(Checkbox.prototype, "thickness", {
  1753. /** Gets or sets border thickness */
  1754. get: function () {
  1755. return this._thickness;
  1756. },
  1757. set: function (value) {
  1758. if (this._thickness === value) {
  1759. return;
  1760. }
  1761. this._thickness = value;
  1762. this._markAsDirty();
  1763. },
  1764. enumerable: false,
  1765. configurable: true
  1766. });
  1767. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1768. /** Gets or sets a value indicating the ratio between overall size and check size */
  1769. get: function () {
  1770. return this._checkSizeRatio;
  1771. },
  1772. set: function (value) {
  1773. value = Math.max(Math.min(1, value), 0);
  1774. if (this._checkSizeRatio === value) {
  1775. return;
  1776. }
  1777. this._checkSizeRatio = value;
  1778. this._markAsDirty();
  1779. },
  1780. enumerable: false,
  1781. configurable: true
  1782. });
  1783. Object.defineProperty(Checkbox.prototype, "background", {
  1784. /** Gets or sets background color */
  1785. get: function () {
  1786. return this._background;
  1787. },
  1788. set: function (value) {
  1789. if (this._background === value) {
  1790. return;
  1791. }
  1792. this._background = value;
  1793. this._markAsDirty();
  1794. },
  1795. enumerable: false,
  1796. configurable: true
  1797. });
  1798. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1799. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1800. get: function () {
  1801. return this._isChecked;
  1802. },
  1803. set: function (value) {
  1804. if (this._isChecked === value) {
  1805. return;
  1806. }
  1807. this._isChecked = value;
  1808. this._markAsDirty();
  1809. this.onIsCheckedChangedObservable.notifyObservers(value);
  1810. },
  1811. enumerable: false,
  1812. configurable: true
  1813. });
  1814. Checkbox.prototype._getTypeName = function () {
  1815. return "Checkbox";
  1816. };
  1817. /** @hidden */
  1818. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1819. context.save();
  1820. this._applyStates(context);
  1821. var actualWidth = this._currentMeasure.width - this._thickness;
  1822. var actualHeight = this._currentMeasure.height - this._thickness;
  1823. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1824. context.shadowColor = this.shadowColor;
  1825. context.shadowBlur = this.shadowBlur;
  1826. context.shadowOffsetX = this.shadowOffsetX;
  1827. context.shadowOffsetY = this.shadowOffsetY;
  1828. }
  1829. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1830. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1831. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1832. context.shadowBlur = 0;
  1833. context.shadowOffsetX = 0;
  1834. context.shadowOffsetY = 0;
  1835. }
  1836. if (this._isChecked) {
  1837. context.fillStyle = this._isEnabled ? this.color : this._disabledColorItem;
  1838. var offsetWidth = actualWidth * this._checkSizeRatio;
  1839. var offseHeight = actualHeight * this._checkSizeRatio;
  1840. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1841. }
  1842. context.strokeStyle = this.color;
  1843. context.lineWidth = this._thickness;
  1844. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1845. context.restore();
  1846. };
  1847. // Events
  1848. /** @hidden */
  1849. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  1850. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  1851. return false;
  1852. }
  1853. this.isChecked = !this.isChecked;
  1854. return true;
  1855. };
  1856. /**
  1857. * Utility function to easily create a checkbox with a header
  1858. * @param title defines the label to use for the header
  1859. * @param onValueChanged defines the callback to call when value changes
  1860. * @returns a StackPanel containing the checkbox and a textBlock
  1861. */
  1862. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1863. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1864. panel.isVertical = false;
  1865. panel.height = "30px";
  1866. var checkbox = new Checkbox();
  1867. checkbox.width = "20px";
  1868. checkbox.height = "20px";
  1869. checkbox.isChecked = true;
  1870. checkbox.color = "green";
  1871. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1872. panel.addControl(checkbox);
  1873. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1874. header.text = title;
  1875. header.width = "180px";
  1876. header.paddingLeft = "5px";
  1877. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1878. header.color = "white";
  1879. panel.addControl(header);
  1880. return panel;
  1881. };
  1882. return Checkbox;
  1883. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1884. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1885. /***/ }),
  1886. /***/ "./2D/controls/colorpicker.ts":
  1887. /*!************************************!*\
  1888. !*** ./2D/controls/colorpicker.ts ***!
  1889. \************************************/
  1890. /*! exports provided: ColorPicker */
  1891. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1892. "use strict";
  1893. __webpack_require__.r(__webpack_exports__);
  1894. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1895. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1896. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1897. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1898. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1899. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1900. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1901. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1902. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1903. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1904. /** Class used to create color pickers */
  1905. var ColorPicker = /** @class */ (function (_super) {
  1906. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1907. /**
  1908. * Creates a new ColorPicker
  1909. * @param name defines the control name
  1910. */
  1911. function ColorPicker(name) {
  1912. var _this = _super.call(this, name) || this;
  1913. _this.name = name;
  1914. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1915. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1916. _this._pointerStartedOnSquare = false;
  1917. _this._pointerStartedOnWheel = false;
  1918. _this._squareLeft = 0;
  1919. _this._squareTop = 0;
  1920. _this._squareSize = 0;
  1921. _this._h = 360;
  1922. _this._s = 1;
  1923. _this._v = 1;
  1924. _this._lastPointerDownID = -1;
  1925. /**
  1926. * Observable raised when the value changes
  1927. */
  1928. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1929. // Events
  1930. _this._pointerIsDown = false;
  1931. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1932. _this.size = "200px";
  1933. _this.isPointerBlocker = true;
  1934. return _this;
  1935. }
  1936. Object.defineProperty(ColorPicker.prototype, "value", {
  1937. /** Gets or sets the color of the color picker */
  1938. get: function () {
  1939. return this._value;
  1940. },
  1941. set: function (value) {
  1942. if (this._value.equals(value)) {
  1943. return;
  1944. }
  1945. this._value.copyFrom(value);
  1946. this._value.toHSVToRef(this._tmpColor);
  1947. this._h = this._tmpColor.r;
  1948. this._s = Math.max(this._tmpColor.g, 0.00001);
  1949. this._v = Math.max(this._tmpColor.b, 0.00001);
  1950. this._markAsDirty();
  1951. if (this._value.r <= ColorPicker._Epsilon) {
  1952. this._value.r = 0;
  1953. }
  1954. if (this._value.g <= ColorPicker._Epsilon) {
  1955. this._value.g = 0;
  1956. }
  1957. if (this._value.b <= ColorPicker._Epsilon) {
  1958. this._value.b = 0;
  1959. }
  1960. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1961. this._value.r = 1.0;
  1962. }
  1963. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1964. this._value.g = 1.0;
  1965. }
  1966. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1967. this._value.b = 1.0;
  1968. }
  1969. this.onValueChangedObservable.notifyObservers(this._value);
  1970. },
  1971. enumerable: false,
  1972. configurable: true
  1973. });
  1974. Object.defineProperty(ColorPicker.prototype, "width", {
  1975. /**
  1976. * Gets or sets control width
  1977. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1978. */
  1979. get: function () {
  1980. return this._width.toString(this._host);
  1981. },
  1982. set: function (value) {
  1983. if (this._width.toString(this._host) === value) {
  1984. return;
  1985. }
  1986. if (this._width.fromString(value)) {
  1987. this._height.fromString(value);
  1988. this._markAsDirty();
  1989. }
  1990. },
  1991. enumerable: false,
  1992. configurable: true
  1993. });
  1994. Object.defineProperty(ColorPicker.prototype, "height", {
  1995. /**
  1996. * Gets or sets control height
  1997. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1998. */
  1999. get: function () {
  2000. return this._height.toString(this._host);
  2001. },
  2002. /** Gets or sets control height */
  2003. set: function (value) {
  2004. if (this._height.toString(this._host) === value) {
  2005. return;
  2006. }
  2007. if (this._height.fromString(value)) {
  2008. this._width.fromString(value);
  2009. this._markAsDirty();
  2010. }
  2011. },
  2012. enumerable: false,
  2013. configurable: true
  2014. });
  2015. Object.defineProperty(ColorPicker.prototype, "size", {
  2016. /** Gets or sets control size */
  2017. get: function () {
  2018. return this.width;
  2019. },
  2020. set: function (value) {
  2021. this.width = value;
  2022. },
  2023. enumerable: false,
  2024. configurable: true
  2025. });
  2026. ColorPicker.prototype._getTypeName = function () {
  2027. return "ColorPicker";
  2028. };
  2029. /** @hidden */
  2030. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  2031. if (parentMeasure.width < parentMeasure.height) {
  2032. this._currentMeasure.height = parentMeasure.width;
  2033. }
  2034. else {
  2035. this._currentMeasure.width = parentMeasure.height;
  2036. }
  2037. };
  2038. ColorPicker.prototype._updateSquareProps = function () {
  2039. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2040. var wheelThickness = radius * .2;
  2041. var innerDiameter = (radius - wheelThickness) * 2;
  2042. var squareSize = innerDiameter / (Math.sqrt(2));
  2043. var offset = radius - squareSize * .5;
  2044. this._squareLeft = this._currentMeasure.left + offset;
  2045. this._squareTop = this._currentMeasure.top + offset;
  2046. this._squareSize = squareSize;
  2047. };
  2048. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  2049. var lgh = context.createLinearGradient(left, top, width + left, top);
  2050. lgh.addColorStop(0, '#fff');
  2051. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  2052. context.fillStyle = lgh;
  2053. context.fillRect(left, top, width, height);
  2054. var lgv = context.createLinearGradient(left, top, left, height + top);
  2055. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  2056. lgv.addColorStop(1, '#000');
  2057. context.fillStyle = lgv;
  2058. context.fillRect(left, top, width, height);
  2059. };
  2060. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  2061. context.beginPath();
  2062. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  2063. context.lineWidth = 3;
  2064. context.strokeStyle = '#333333';
  2065. context.stroke();
  2066. context.beginPath();
  2067. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  2068. context.lineWidth = 3;
  2069. context.strokeStyle = '#ffffff';
  2070. context.stroke();
  2071. };
  2072. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  2073. var canvas = document.createElement("canvas");
  2074. canvas.width = radius * 2;
  2075. canvas.height = radius * 2;
  2076. var context = canvas.getContext("2d");
  2077. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  2078. var data = image.data;
  2079. var color = this._tmpColor;
  2080. var maxDistSq = radius * radius;
  2081. var innerRadius = radius - thickness;
  2082. var minDistSq = innerRadius * innerRadius;
  2083. for (var x = -radius; x < radius; x++) {
  2084. for (var y = -radius; y < radius; y++) {
  2085. var distSq = x * x + y * y;
  2086. if (distSq > maxDistSq || distSq < minDistSq) {
  2087. continue;
  2088. }
  2089. var dist = Math.sqrt(distSq);
  2090. var ang = Math.atan2(y, x);
  2091. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  2092. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  2093. data[index] = color.r * 255;
  2094. data[index + 1] = color.g * 255;
  2095. data[index + 2] = color.b * 255;
  2096. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2097. //apply less alpha to bigger color pickers
  2098. var alphaAmount = .2;
  2099. var maxAlpha = .2;
  2100. var minAlpha = .04;
  2101. var lowerRadius = 50;
  2102. var upperRadius = 150;
  2103. if (radius < lowerRadius) {
  2104. alphaAmount = maxAlpha;
  2105. }
  2106. else if (radius > upperRadius) {
  2107. alphaAmount = minAlpha;
  2108. }
  2109. else {
  2110. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2111. }
  2112. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2113. if (alphaRatio < alphaAmount) {
  2114. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2115. }
  2116. else if (alphaRatio > 1 - alphaAmount) {
  2117. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2118. }
  2119. else {
  2120. data[index + 3] = 255;
  2121. }
  2122. }
  2123. }
  2124. context.putImageData(image, 0, 0);
  2125. return canvas;
  2126. };
  2127. /** @hidden */
  2128. ColorPicker.prototype._draw = function (context) {
  2129. context.save();
  2130. this._applyStates(context);
  2131. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2132. var wheelThickness = radius * .2;
  2133. var left = this._currentMeasure.left;
  2134. var top = this._currentMeasure.top;
  2135. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2136. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2137. }
  2138. this._updateSquareProps();
  2139. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2140. context.shadowColor = this.shadowColor;
  2141. context.shadowBlur = this.shadowBlur;
  2142. context.shadowOffsetX = this.shadowOffsetX;
  2143. context.shadowOffsetY = this.shadowOffsetY;
  2144. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2145. }
  2146. context.drawImage(this._colorWheelCanvas, left, top);
  2147. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2148. context.shadowBlur = 0;
  2149. context.shadowOffsetX = 0;
  2150. context.shadowOffsetY = 0;
  2151. }
  2152. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2153. var cx = this._squareLeft + this._squareSize * this._s;
  2154. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2155. this._drawCircle(cx, cy, radius * .04, context);
  2156. var dist = radius - wheelThickness * .5;
  2157. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2158. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2159. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2160. context.restore();
  2161. };
  2162. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2163. if (this._pointerStartedOnWheel) {
  2164. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2165. var centerX = radius + this._currentMeasure.left;
  2166. var centerY = radius + this._currentMeasure.top;
  2167. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2168. }
  2169. else if (this._pointerStartedOnSquare) {
  2170. this._updateSquareProps();
  2171. this._s = (x - this._squareLeft) / this._squareSize;
  2172. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2173. this._s = Math.min(this._s, 1);
  2174. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2175. this._v = Math.min(this._v, 1);
  2176. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2177. }
  2178. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2179. this.value = this._tmpColor;
  2180. };
  2181. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2182. this._updateSquareProps();
  2183. var left = this._squareLeft;
  2184. var top = this._squareTop;
  2185. var size = this._squareSize;
  2186. if (x >= left && x <= left + size &&
  2187. y >= top && y <= top + size) {
  2188. return true;
  2189. }
  2190. return false;
  2191. };
  2192. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2193. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2194. var centerX = radius + this._currentMeasure.left;
  2195. var centerY = radius + this._currentMeasure.top;
  2196. var wheelThickness = radius * .2;
  2197. var innerRadius = radius - wheelThickness;
  2198. var radiusSq = radius * radius;
  2199. var innerRadiusSq = innerRadius * innerRadius;
  2200. var dx = x - centerX;
  2201. var dy = y - centerY;
  2202. var distSq = dx * dx + dy * dy;
  2203. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2204. return true;
  2205. }
  2206. return false;
  2207. };
  2208. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  2209. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  2210. return false;
  2211. }
  2212. this._pointerIsDown = true;
  2213. this._pointerStartedOnSquare = false;
  2214. this._pointerStartedOnWheel = false;
  2215. // Invert transform
  2216. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2217. var x = this._transformedPosition.x;
  2218. var y = this._transformedPosition.y;
  2219. if (this._isPointOnSquare(x, y)) {
  2220. this._pointerStartedOnSquare = true;
  2221. }
  2222. else if (this._isPointOnWheel(x, y)) {
  2223. this._pointerStartedOnWheel = true;
  2224. }
  2225. this._updateValueFromPointer(x, y);
  2226. this._host._capturingControl[pointerId] = this;
  2227. this._lastPointerDownID = pointerId;
  2228. return true;
  2229. };
  2230. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  2231. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2232. if (pointerId != this._lastPointerDownID) {
  2233. return;
  2234. }
  2235. // Invert transform
  2236. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2237. var x = this._transformedPosition.x;
  2238. var y = this._transformedPosition.y;
  2239. if (this._pointerIsDown) {
  2240. this._updateValueFromPointer(x, y);
  2241. }
  2242. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  2243. };
  2244. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  2245. this._pointerIsDown = false;
  2246. delete this._host._capturingControl[pointerId];
  2247. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  2248. };
  2249. ColorPicker.prototype._onCanvasBlur = function () {
  2250. this._forcePointerUp();
  2251. _super.prototype._onCanvasBlur.call(this);
  2252. };
  2253. /**
  2254. * This function expands the color picker by creating a color picker dialog with manual
  2255. * color value input and the ability to save colors into an array to be used later in
  2256. * subsequent launches of the dialogue.
  2257. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2258. * @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.
  2259. * @returns picked color as a hex string and the saved colors array as hex strings.
  2260. */
  2261. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2262. return new Promise(function (resolve, reject) {
  2263. // Default options
  2264. options.pickerWidth = options.pickerWidth || "640px";
  2265. options.pickerHeight = options.pickerHeight || "400px";
  2266. options.headerHeight = options.headerHeight || "35px";
  2267. options.lastColor = options.lastColor || "#000000";
  2268. options.swatchLimit = options.swatchLimit || 20;
  2269. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2270. // Window size settings
  2271. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2272. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2273. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2274. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2275. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2276. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2277. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2278. // Button Colors
  2279. var buttonColor = "#c0c0c0";
  2280. var buttonBackgroundColor = "#535353";
  2281. var buttonBackgroundHoverColor = "#414141";
  2282. var buttonBackgroundClickColor = "515151";
  2283. var buttonDisabledColor = "#555555";
  2284. var buttonDisabledBackgroundColor = "#454545";
  2285. var currentSwatchesOutlineColor = "#404040";
  2286. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2287. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2288. var iconColorDark = "#aaaaaa";
  2289. var iconColorLight = "#ffffff";
  2290. var closeIconColor;
  2291. // Button settings
  2292. var buttonFontSize;
  2293. var butEdit;
  2294. var buttonWidth;
  2295. var buttonHeight;
  2296. // Input Text Colors
  2297. var inputFieldLabels = ["R", "G", "B"];
  2298. var inputTextBackgroundColor = "#454545";
  2299. var inputTextColor = "#f0f0f0";
  2300. // This is the current color as set by either the picker or by entering a value
  2301. var currentColor;
  2302. // This int is used for naming swatches and serves as the index for calling them from the list
  2303. var swatchNumber;
  2304. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2305. var swatchDrawer;
  2306. var editSwatchMode = false;
  2307. // Color InputText fields that will be updated upon value change
  2308. var picker;
  2309. var rValInt;
  2310. var gValInt;
  2311. var bValInt;
  2312. var rValDec;
  2313. var gValDec;
  2314. var bValDec;
  2315. var hexVal;
  2316. var newSwatch;
  2317. var lastVal;
  2318. var activeField;
  2319. /**
  2320. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2321. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2322. * are will receive no update. This is to prevent the input from the user being overwritten.
  2323. */
  2324. function updateValues(value, inputField) {
  2325. activeField = inputField;
  2326. var pickedColor = value.toHexString();
  2327. newSwatch.background = pickedColor;
  2328. if (rValInt.name != activeField) {
  2329. rValInt.text = Math.floor(value.r * 255).toString();
  2330. }
  2331. if (gValInt.name != activeField) {
  2332. gValInt.text = Math.floor(value.g * 255).toString();
  2333. }
  2334. if (bValInt.name != activeField) {
  2335. bValInt.text = Math.floor(value.b * 255).toString();
  2336. }
  2337. if (rValDec.name != activeField) {
  2338. rValDec.text = value.r.toString();
  2339. }
  2340. if (gValDec.name != activeField) {
  2341. gValDec.text = value.g.toString();
  2342. }
  2343. if (bValDec.name != activeField) {
  2344. bValDec.text = value.b.toString();
  2345. }
  2346. if (hexVal.name != activeField) {
  2347. var minusPound = pickedColor.split("#");
  2348. hexVal.text = minusPound[1];
  2349. }
  2350. if (picker.name != activeField) {
  2351. picker.value = value;
  2352. }
  2353. }
  2354. // 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.
  2355. function updateInt(field, channel) {
  2356. var newValue = field.text;
  2357. var checkVal = /[^0-9]/g.test(newValue);
  2358. if (checkVal) {
  2359. field.text = lastVal;
  2360. return;
  2361. }
  2362. else {
  2363. if (newValue != "") {
  2364. if (Math.floor(parseInt(newValue)) < 0) {
  2365. newValue = "0";
  2366. }
  2367. else if (Math.floor(parseInt(newValue)) > 255) {
  2368. newValue = "255";
  2369. }
  2370. else if (isNaN(parseInt(newValue))) {
  2371. newValue = "0";
  2372. }
  2373. }
  2374. if (activeField == field.name) {
  2375. lastVal = newValue;
  2376. }
  2377. }
  2378. if (newValue != "") {
  2379. newValue = parseInt(newValue).toString();
  2380. field.text = newValue;
  2381. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2382. if (activeField == field.name) {
  2383. if (channel == "r") {
  2384. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2385. }
  2386. else if (channel == "g") {
  2387. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2388. }
  2389. else {
  2390. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2391. }
  2392. }
  2393. }
  2394. }
  2395. // 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.
  2396. function updateFloat(field, channel) {
  2397. var newValue = field.text;
  2398. var checkVal = /[^0-9\.]/g.test(newValue);
  2399. if (checkVal) {
  2400. field.text = lastVal;
  2401. return;
  2402. }
  2403. else {
  2404. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2405. if (parseFloat(newValue) < 0.0) {
  2406. newValue = "0.0";
  2407. }
  2408. else if (parseFloat(newValue) > 1.0) {
  2409. newValue = "1.0";
  2410. }
  2411. else if (isNaN(parseFloat(newValue))) {
  2412. newValue = "0.0";
  2413. }
  2414. }
  2415. if (activeField == field.name) {
  2416. lastVal = newValue;
  2417. }
  2418. }
  2419. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2420. newValue = parseFloat(newValue).toString();
  2421. field.text = newValue;
  2422. }
  2423. else {
  2424. newValue = "0.0";
  2425. }
  2426. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2427. if (activeField == field.name) {
  2428. if (channel == "r") {
  2429. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2430. }
  2431. else if (channel == "g") {
  2432. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2433. }
  2434. else {
  2435. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2436. }
  2437. }
  2438. }
  2439. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2440. function deleteSwatch(index) {
  2441. if (options.savedColors) {
  2442. options.savedColors.splice(index, 1);
  2443. }
  2444. if (options.savedColors && options.savedColors.length == 0) {
  2445. setEditButtonVisibility(false);
  2446. editSwatchMode = false;
  2447. }
  2448. }
  2449. // Creates and styles an individual swatch when updateSwatches is called.
  2450. function createSwatch() {
  2451. if (options.savedColors && options.savedColors[swatchNumber]) {
  2452. if (editSwatchMode) {
  2453. var icon = "b";
  2454. }
  2455. else {
  2456. var icon = "";
  2457. }
  2458. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2459. swatch.fontFamily = "BabylonJSglyphs";
  2460. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2461. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2462. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2463. if (swatchLuminence > luminanceLimit) {
  2464. swatch.color = iconColorDark;
  2465. }
  2466. else {
  2467. swatch.color = iconColorLight;
  2468. }
  2469. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2470. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2471. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2472. swatch.background = options.savedColors[swatchNumber];
  2473. swatch.thickness = 2;
  2474. var metadata_1 = swatchNumber;
  2475. swatch.pointerDownAnimation = function () {
  2476. swatch.thickness = 4;
  2477. };
  2478. swatch.pointerUpAnimation = function () {
  2479. swatch.thickness = 3;
  2480. };
  2481. swatch.pointerEnterAnimation = function () {
  2482. swatch.thickness = 3;
  2483. };
  2484. swatch.pointerOutAnimation = function () {
  2485. swatch.thickness = 2;
  2486. };
  2487. swatch.onPointerClickObservable.add(function () {
  2488. if (!editSwatchMode) {
  2489. if (options.savedColors) {
  2490. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2491. }
  2492. }
  2493. else {
  2494. deleteSwatch(metadata_1);
  2495. updateSwatches("", butSave);
  2496. }
  2497. });
  2498. return swatch;
  2499. }
  2500. else {
  2501. return null;
  2502. }
  2503. }
  2504. // Mode switch to render button text and close symbols on swatch controls
  2505. function editSwatches(mode) {
  2506. if (mode !== undefined) {
  2507. editSwatchMode = mode;
  2508. }
  2509. if (editSwatchMode) {
  2510. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2511. var thisButton = swatchDrawer.children[i];
  2512. thisButton.textBlock.text = "b";
  2513. }
  2514. if (butEdit !== undefined) {
  2515. butEdit.textBlock.text = "Done";
  2516. }
  2517. }
  2518. else {
  2519. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2520. var thisButton = swatchDrawer.children[i];
  2521. thisButton.textBlock.text = "";
  2522. }
  2523. if (butEdit !== undefined) {
  2524. butEdit.textBlock.text = "Edit";
  2525. }
  2526. }
  2527. }
  2528. /**
  2529. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2530. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2531. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2532. * saved colors there are and how many can be stored per row.
  2533. */
  2534. function updateSwatches(color, button) {
  2535. if (options.savedColors) {
  2536. if (color != "") {
  2537. options.savedColors.push(color);
  2538. }
  2539. swatchNumber = 0;
  2540. swatchDrawer.clearControls();
  2541. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2542. if (rowCount == 0) {
  2543. var gutterCount = 0;
  2544. }
  2545. else {
  2546. var gutterCount = rowCount + 1;
  2547. }
  2548. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2549. var currentRows = swatchDrawer.rowCount;
  2550. for (var i = 0; i < currentRows; i++) {
  2551. swatchDrawer.removeRowDefinition(0);
  2552. }
  2553. for (var i = 0; i < rowCount + gutterCount; i++) {
  2554. if (i % 2) {
  2555. swatchDrawer.addRowDefinition(swatchSize, true);
  2556. }
  2557. else {
  2558. swatchDrawer.addRowDefinition(gutterSize, true);
  2559. }
  2560. }
  2561. }
  2562. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2563. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2564. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2565. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2566. var totalButtonsThisRow = options.numSwatchesPerLine;
  2567. }
  2568. else {
  2569. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2570. }
  2571. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2572. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2573. if (x > options.numSwatchesPerLine) {
  2574. continue;
  2575. }
  2576. var swatch = createSwatch();
  2577. if (swatch != null) {
  2578. swatchDrawer.addControl(swatch, y, w);
  2579. w += 2;
  2580. swatchNumber++;
  2581. }
  2582. else {
  2583. continue;
  2584. }
  2585. }
  2586. }
  2587. if (options.savedColors.length >= options.swatchLimit) {
  2588. disableButton(button, true);
  2589. }
  2590. else {
  2591. disableButton(button, false);
  2592. }
  2593. }
  2594. }
  2595. // Shows or hides edit swatches button depending on if there are saved swatches
  2596. function setEditButtonVisibility(enableButton) {
  2597. if (enableButton) {
  2598. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2599. butEdit.width = buttonWidth;
  2600. butEdit.height = buttonHeight;
  2601. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2602. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2603. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2604. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2605. butEdit.thickness = 2;
  2606. butEdit.color = buttonColor;
  2607. butEdit.fontSize = buttonFontSize;
  2608. butEdit.background = buttonBackgroundColor;
  2609. butEdit.onPointerEnterObservable.add(function () {
  2610. butEdit.background = buttonBackgroundHoverColor;
  2611. });
  2612. butEdit.onPointerOutObservable.add(function () {
  2613. butEdit.background = buttonBackgroundColor;
  2614. });
  2615. butEdit.pointerDownAnimation = function () {
  2616. butEdit.background = buttonBackgroundClickColor;
  2617. };
  2618. butEdit.pointerUpAnimation = function () {
  2619. butEdit.background = buttonBackgroundHoverColor;
  2620. };
  2621. butEdit.onPointerClickObservable.add(function () {
  2622. if (editSwatchMode) {
  2623. editSwatchMode = false;
  2624. }
  2625. else {
  2626. editSwatchMode = true;
  2627. }
  2628. editSwatches();
  2629. });
  2630. pickerGrid.addControl(butEdit, 1, 0);
  2631. }
  2632. else {
  2633. pickerGrid.removeControl(butEdit);
  2634. }
  2635. }
  2636. // Called when the user hits the limit of saved colors in the drawer.
  2637. function disableButton(button, disabled) {
  2638. if (disabled) {
  2639. button.color = buttonDisabledColor;
  2640. button.background = buttonDisabledBackgroundColor;
  2641. }
  2642. else {
  2643. button.color = buttonColor;
  2644. button.background = buttonBackgroundColor;
  2645. }
  2646. }
  2647. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2648. function closePicker(color) {
  2649. if (options.savedColors && options.savedColors.length > 0) {
  2650. resolve({
  2651. savedColors: options.savedColors,
  2652. pickedColor: color
  2653. });
  2654. }
  2655. else {
  2656. resolve({
  2657. pickedColor: color
  2658. });
  2659. }
  2660. advancedTexture.removeControl(dialogContainer);
  2661. }
  2662. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2663. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2664. dialogContainer.name = "Dialog Container";
  2665. dialogContainer.width = options.pickerWidth;
  2666. if (options.savedColors) {
  2667. dialogContainer.height = containerSize;
  2668. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2669. dialogContainer.addRowDefinition(topRow, false);
  2670. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2671. }
  2672. else {
  2673. dialogContainer.height = options.pickerHeight;
  2674. dialogContainer.addRowDefinition(1.0, false);
  2675. }
  2676. advancedTexture.addControl(dialogContainer);
  2677. // Swatch drawer which contains all saved color buttons
  2678. if (options.savedColors) {
  2679. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2680. swatchDrawer.name = "Swatch Drawer";
  2681. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2682. swatchDrawer.background = buttonBackgroundColor;
  2683. swatchDrawer.width = options.pickerWidth;
  2684. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2685. if (initialRows == 0) {
  2686. var gutterCount = 0;
  2687. }
  2688. else {
  2689. var gutterCount = initialRows + 1;
  2690. }
  2691. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2692. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2693. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2694. if (i % 2 != 0) {
  2695. swatchDrawer.addRowDefinition(swatchSize, true);
  2696. }
  2697. else {
  2698. swatchDrawer.addRowDefinition(gutterSize, true);
  2699. }
  2700. }
  2701. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2702. if (i % 2 != 0) {
  2703. swatchDrawer.addColumnDefinition(swatchSize, true);
  2704. }
  2705. else {
  2706. swatchDrawer.addColumnDefinition(gutterSize, true);
  2707. }
  2708. }
  2709. dialogContainer.addControl(swatchDrawer, 1, 0);
  2710. }
  2711. // Picker container
  2712. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2713. pickerPanel.name = "Picker Panel";
  2714. pickerPanel.height = options.pickerHeight;
  2715. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2716. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2717. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2718. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2719. dialogContainer.addControl(pickerPanel, 0, 0);
  2720. // Picker container header
  2721. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2722. header.name = "Dialogue Header Bar";
  2723. header.background = "#cccccc";
  2724. header.thickness = 0;
  2725. pickerPanel.addControl(header, 0, 0);
  2726. // Header close button
  2727. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2728. closeButton.fontFamily = "BabylonJSglyphs";
  2729. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2730. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2731. closeButton.color = closeIconColor.toHexString();
  2732. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2733. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2734. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2735. closeButton.height = closeButton.width = options.headerHeight;
  2736. closeButton.background = header.background;
  2737. closeButton.thickness = 0;
  2738. closeButton.pointerDownAnimation = function () {
  2739. };
  2740. closeButton.pointerUpAnimation = function () {
  2741. closeButton.background = header.background;
  2742. };
  2743. closeButton.pointerEnterAnimation = function () {
  2744. closeButton.color = header.background;
  2745. closeButton.background = "red";
  2746. };
  2747. closeButton.pointerOutAnimation = function () {
  2748. closeButton.color = closeIconColor.toHexString();
  2749. closeButton.background = header.background;
  2750. };
  2751. closeButton.onPointerClickObservable.add(function () {
  2752. closePicker(currentSwatch.background);
  2753. });
  2754. pickerPanel.addControl(closeButton, 0, 0);
  2755. // Dialog container body
  2756. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2757. dialogBody.name = "Dialogue Body";
  2758. dialogBody.background = buttonBackgroundColor;
  2759. var dialogBodyCols = [0.4375, 0.5625];
  2760. dialogBody.addRowDefinition(1.0, false);
  2761. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2762. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2763. pickerPanel.addControl(dialogBody, 1, 0);
  2764. // Picker grid
  2765. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2766. pickerGrid.name = "Picker Grid";
  2767. pickerGrid.addRowDefinition(0.85, false);
  2768. pickerGrid.addRowDefinition(0.15, false);
  2769. dialogBody.addControl(pickerGrid, 0, 0);
  2770. // Picker control
  2771. picker = new ColorPicker();
  2772. picker.name = "GUI Color Picker";
  2773. if (options.pickerHeight < options.pickerWidth) {
  2774. picker.width = 0.89;
  2775. }
  2776. else {
  2777. picker.height = 0.89;
  2778. }
  2779. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2780. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2781. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2782. picker.onPointerDownObservable.add(function () {
  2783. activeField = picker.name;
  2784. lastVal = "";
  2785. editSwatches(false);
  2786. });
  2787. picker.onValueChangedObservable.add(function (value) {
  2788. if (activeField == picker.name) {
  2789. updateValues(value, picker.name);
  2790. }
  2791. });
  2792. pickerGrid.addControl(picker, 0, 0);
  2793. // Picker body right quarant
  2794. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2795. pickerBodyRight.name = "Dialogue Right Half";
  2796. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2797. var pickerBodyRightRows = [0.514, 0.486];
  2798. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2799. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2800. dialogBody.addControl(pickerBodyRight, 1, 1);
  2801. // Picker container swatches and buttons
  2802. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2803. pickerSwatchesButtons.name = "Swatches and Buttons";
  2804. var pickerButtonsCol = [0.417, 0.583];
  2805. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2806. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2807. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2808. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2809. // Picker Swatches quadrant
  2810. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2811. pickerSwatches.name = "New and Current Swatches";
  2812. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2813. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2814. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2815. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2816. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2817. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2818. // Active swatches
  2819. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2820. activeSwatches.name = "Active Swatches";
  2821. activeSwatches.width = 0.67;
  2822. activeSwatches.addRowDefinition(0.5, false);
  2823. activeSwatches.addRowDefinition(0.5, false);
  2824. pickerSwatches.addControl(activeSwatches, 2, 0);
  2825. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2826. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2827. if (options.pickerWidth > options.pickerHeight) {
  2828. var labelTextSize = labelHeight;
  2829. }
  2830. else {
  2831. var labelTextSize = labelWidth;
  2832. }
  2833. // New color swatch and previous color button
  2834. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2835. newText.text = "new";
  2836. newText.name = "New Color Label";
  2837. newText.color = buttonColor;
  2838. newText.fontSize = labelTextSize;
  2839. pickerSwatches.addControl(newText, 1, 0);
  2840. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2841. newSwatch.name = "New Color Swatch";
  2842. newSwatch.background = options.lastColor;
  2843. newSwatch.thickness = 0;
  2844. activeSwatches.addControl(newSwatch, 0, 0);
  2845. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2846. currentSwatch.background = options.lastColor;
  2847. currentSwatch.thickness = 0;
  2848. currentSwatch.onPointerClickObservable.add(function () {
  2849. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2850. updateValues(revertColor, currentSwatch.name);
  2851. editSwatches(false);
  2852. });
  2853. currentSwatch.pointerDownAnimation = function () { };
  2854. currentSwatch.pointerUpAnimation = function () { };
  2855. currentSwatch.pointerEnterAnimation = function () { };
  2856. currentSwatch.pointerOutAnimation = function () { };
  2857. activeSwatches.addControl(currentSwatch, 1, 0);
  2858. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2859. swatchOutline.name = "Swatch Outline";
  2860. swatchOutline.width = 0.67;
  2861. swatchOutline.thickness = 2;
  2862. swatchOutline.color = currentSwatchesOutlineColor;
  2863. swatchOutline.isHitTestVisible = false;
  2864. pickerSwatches.addControl(swatchOutline, 2, 0);
  2865. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2866. currentText.name = "Current Color Label";
  2867. currentText.text = "current";
  2868. currentText.color = buttonColor;
  2869. currentText.fontSize = labelTextSize;
  2870. pickerSwatches.addControl(currentText, 3, 0);
  2871. // Buttons grid
  2872. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2873. buttonGrid.name = "Button Grid";
  2874. buttonGrid.height = 0.8;
  2875. var buttonGridRows = 1 / 3;
  2876. buttonGrid.addRowDefinition(buttonGridRows, false);
  2877. buttonGrid.addRowDefinition(buttonGridRows, false);
  2878. buttonGrid.addRowDefinition(buttonGridRows, false);
  2879. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2880. // Determine pixel width and height for all buttons from overall panel dimensions
  2881. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2882. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2883. // Determine button type size
  2884. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2885. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2886. }
  2887. else {
  2888. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2889. }
  2890. // Panel Buttons
  2891. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2892. butOK.width = buttonWidth;
  2893. butOK.height = buttonHeight;
  2894. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2895. butOK.thickness = 2;
  2896. butOK.color = buttonColor;
  2897. butOK.fontSize = buttonFontSize;
  2898. butOK.background = buttonBackgroundColor;
  2899. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2900. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2901. butOK.pointerDownAnimation = function () {
  2902. butOK.background = buttonBackgroundClickColor;
  2903. };
  2904. butOK.pointerUpAnimation = function () {
  2905. butOK.background = buttonBackgroundHoverColor;
  2906. };
  2907. butOK.onPointerClickObservable.add(function () {
  2908. editSwatches(false);
  2909. closePicker(newSwatch.background);
  2910. });
  2911. buttonGrid.addControl(butOK, 0, 0);
  2912. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2913. butCancel.width = buttonWidth;
  2914. butCancel.height = buttonHeight;
  2915. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2916. butCancel.thickness = 2;
  2917. butCancel.color = buttonColor;
  2918. butCancel.fontSize = buttonFontSize;
  2919. butCancel.background = buttonBackgroundColor;
  2920. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2921. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2922. butCancel.pointerDownAnimation = function () {
  2923. butCancel.background = buttonBackgroundClickColor;
  2924. };
  2925. butCancel.pointerUpAnimation = function () {
  2926. butCancel.background = buttonBackgroundHoverColor;
  2927. };
  2928. butCancel.onPointerClickObservable.add(function () {
  2929. editSwatches(false);
  2930. closePicker(currentSwatch.background);
  2931. });
  2932. buttonGrid.addControl(butCancel, 1, 0);
  2933. if (options.savedColors) {
  2934. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2935. butSave.width = buttonWidth;
  2936. butSave.height = buttonHeight;
  2937. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2938. butSave.thickness = 2;
  2939. butSave.fontSize = buttonFontSize;
  2940. if (options.savedColors.length < options.swatchLimit) {
  2941. butSave.color = buttonColor;
  2942. butSave.background = buttonBackgroundColor;
  2943. }
  2944. else {
  2945. disableButton(butSave, true);
  2946. }
  2947. butSave.onPointerEnterObservable.add(function () {
  2948. if (options.savedColors) {
  2949. if (options.savedColors.length < options.swatchLimit) {
  2950. butSave.background = buttonBackgroundHoverColor;
  2951. }
  2952. }
  2953. });
  2954. butSave.onPointerOutObservable.add(function () {
  2955. if (options.savedColors) {
  2956. if (options.savedColors.length < options.swatchLimit) {
  2957. butSave.background = buttonBackgroundColor;
  2958. }
  2959. }
  2960. });
  2961. butSave.pointerDownAnimation = function () {
  2962. if (options.savedColors) {
  2963. if (options.savedColors.length < options.swatchLimit) {
  2964. butSave.background = buttonBackgroundClickColor;
  2965. }
  2966. }
  2967. };
  2968. butSave.pointerUpAnimation = function () {
  2969. if (options.savedColors) {
  2970. if (options.savedColors.length < options.swatchLimit) {
  2971. butSave.background = buttonBackgroundHoverColor;
  2972. }
  2973. }
  2974. };
  2975. butSave.onPointerClickObservable.add(function () {
  2976. if (options.savedColors) {
  2977. if (options.savedColors.length == 0) {
  2978. setEditButtonVisibility(true);
  2979. }
  2980. if (options.savedColors.length < options.swatchLimit) {
  2981. updateSwatches(newSwatch.background, butSave);
  2982. }
  2983. editSwatches(false);
  2984. }
  2985. });
  2986. if (options.savedColors.length > 0) {
  2987. setEditButtonVisibility(true);
  2988. }
  2989. buttonGrid.addControl(butSave, 2, 0);
  2990. }
  2991. // Picker color values input
  2992. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2993. pickerColorValues.name = "Dialog Lower Right";
  2994. pickerColorValues.addRowDefinition(0.02, false);
  2995. pickerColorValues.addRowDefinition(0.63, false);
  2996. pickerColorValues.addRowDefinition(0.21, false);
  2997. pickerColorValues.addRowDefinition(0.14, false);
  2998. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2999. // RGB values text boxes
  3000. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  3001. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3002. rgbValuesQuadrant.name = "RGB Values";
  3003. rgbValuesQuadrant.width = 0.82;
  3004. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  3005. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  3006. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  3007. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  3008. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  3009. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  3010. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  3011. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  3012. for (var i = 0; i < inputFieldLabels.length; i++) {
  3013. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3014. labelText.text = inputFieldLabels[i];
  3015. labelText.color = buttonColor;
  3016. labelText.fontSize = buttonFontSize;
  3017. rgbValuesQuadrant.addControl(labelText, i, 0);
  3018. }
  3019. // Input fields for RGB values
  3020. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3021. rValInt.width = 0.83;
  3022. rValInt.height = 0.72;
  3023. rValInt.name = "rIntField";
  3024. rValInt.fontSize = buttonFontSize;
  3025. rValInt.text = (currentColor.r * 255).toString();
  3026. rValInt.color = inputTextColor;
  3027. rValInt.background = inputTextBackgroundColor;
  3028. rValInt.onFocusObservable.add(function () {
  3029. activeField = rValInt.name;
  3030. lastVal = rValInt.text;
  3031. editSwatches(false);
  3032. });
  3033. rValInt.onBlurObservable.add(function () {
  3034. if (rValInt.text == "") {
  3035. rValInt.text = "0";
  3036. }
  3037. updateInt(rValInt, "r");
  3038. if (activeField == rValInt.name) {
  3039. activeField = "";
  3040. }
  3041. });
  3042. rValInt.onTextChangedObservable.add(function () {
  3043. if (activeField == rValInt.name) {
  3044. updateInt(rValInt, "r");
  3045. }
  3046. });
  3047. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  3048. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3049. gValInt.width = 0.83;
  3050. gValInt.height = 0.72;
  3051. gValInt.name = "gIntField";
  3052. gValInt.fontSize = buttonFontSize;
  3053. gValInt.text = (currentColor.g * 255).toString();
  3054. gValInt.color = inputTextColor;
  3055. gValInt.background = inputTextBackgroundColor;
  3056. gValInt.onFocusObservable.add(function () {
  3057. activeField = gValInt.name;
  3058. lastVal = gValInt.text;
  3059. editSwatches(false);
  3060. });
  3061. gValInt.onBlurObservable.add(function () {
  3062. if (gValInt.text == "") {
  3063. gValInt.text = "0";
  3064. }
  3065. updateInt(gValInt, "g");
  3066. if (activeField == gValInt.name) {
  3067. activeField = "";
  3068. }
  3069. });
  3070. gValInt.onTextChangedObservable.add(function () {
  3071. if (activeField == gValInt.name) {
  3072. updateInt(gValInt, "g");
  3073. }
  3074. });
  3075. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  3076. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3077. bValInt.width = 0.83;
  3078. bValInt.height = 0.72;
  3079. bValInt.name = "bIntField";
  3080. bValInt.fontSize = buttonFontSize;
  3081. bValInt.text = (currentColor.b * 255).toString();
  3082. bValInt.color = inputTextColor;
  3083. bValInt.background = inputTextBackgroundColor;
  3084. bValInt.onFocusObservable.add(function () {
  3085. activeField = bValInt.name;
  3086. lastVal = bValInt.text;
  3087. editSwatches(false);
  3088. });
  3089. bValInt.onBlurObservable.add(function () {
  3090. if (bValInt.text == "") {
  3091. bValInt.text = "0";
  3092. }
  3093. updateInt(bValInt, "b");
  3094. if (activeField == bValInt.name) {
  3095. activeField = "";
  3096. }
  3097. });
  3098. bValInt.onTextChangedObservable.add(function () {
  3099. if (activeField == bValInt.name) {
  3100. updateInt(bValInt, "b");
  3101. }
  3102. });
  3103. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3104. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3105. rValDec.width = 0.95;
  3106. rValDec.height = 0.72;
  3107. rValDec.name = "rDecField";
  3108. rValDec.fontSize = buttonFontSize;
  3109. rValDec.text = currentColor.r.toString();
  3110. rValDec.color = inputTextColor;
  3111. rValDec.background = inputTextBackgroundColor;
  3112. rValDec.onFocusObservable.add(function () {
  3113. activeField = rValDec.name;
  3114. lastVal = rValDec.text;
  3115. editSwatches(false);
  3116. });
  3117. rValDec.onBlurObservable.add(function () {
  3118. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3119. rValDec.text = "0";
  3120. updateFloat(rValDec, "r");
  3121. }
  3122. if (activeField == rValDec.name) {
  3123. activeField = "";
  3124. }
  3125. });
  3126. rValDec.onTextChangedObservable.add(function () {
  3127. if (activeField == rValDec.name) {
  3128. updateFloat(rValDec, "r");
  3129. }
  3130. });
  3131. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3132. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3133. gValDec.width = 0.95;
  3134. gValDec.height = 0.72;
  3135. gValDec.name = "gDecField";
  3136. gValDec.fontSize = buttonFontSize;
  3137. gValDec.text = currentColor.g.toString();
  3138. gValDec.color = inputTextColor;
  3139. gValDec.background = inputTextBackgroundColor;
  3140. gValDec.onFocusObservable.add(function () {
  3141. activeField = gValDec.name;
  3142. lastVal = gValDec.text;
  3143. editSwatches(false);
  3144. });
  3145. gValDec.onBlurObservable.add(function () {
  3146. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3147. gValDec.text = "0";
  3148. updateFloat(gValDec, "g");
  3149. }
  3150. if (activeField == gValDec.name) {
  3151. activeField = "";
  3152. }
  3153. });
  3154. gValDec.onTextChangedObservable.add(function () {
  3155. if (activeField == gValDec.name) {
  3156. updateFloat(gValDec, "g");
  3157. }
  3158. });
  3159. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3160. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3161. bValDec.width = 0.95;
  3162. bValDec.height = 0.72;
  3163. bValDec.name = "bDecField";
  3164. bValDec.fontSize = buttonFontSize;
  3165. bValDec.text = currentColor.b.toString();
  3166. bValDec.color = inputTextColor;
  3167. bValDec.background = inputTextBackgroundColor;
  3168. bValDec.onFocusObservable.add(function () {
  3169. activeField = bValDec.name;
  3170. lastVal = bValDec.text;
  3171. editSwatches(false);
  3172. });
  3173. bValDec.onBlurObservable.add(function () {
  3174. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3175. bValDec.text = "0";
  3176. updateFloat(bValDec, "b");
  3177. }
  3178. if (activeField == bValDec.name) {
  3179. activeField = "";
  3180. }
  3181. });
  3182. bValDec.onTextChangedObservable.add(function () {
  3183. if (activeField == bValDec.name) {
  3184. updateFloat(bValDec, "b");
  3185. }
  3186. });
  3187. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3188. // Hex value input
  3189. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3190. hexValueQuadrant.name = "Hex Value";
  3191. hexValueQuadrant.width = 0.82;
  3192. hexValueQuadrant.addRowDefinition(1.0, false);
  3193. hexValueQuadrant.addColumnDefinition(0.1, false);
  3194. hexValueQuadrant.addColumnDefinition(0.9, false);
  3195. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3196. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3197. labelText.text = "#";
  3198. labelText.color = buttonColor;
  3199. labelText.fontSize = buttonFontSize;
  3200. hexValueQuadrant.addControl(labelText, 0, 0);
  3201. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3202. hexVal.width = 0.96;
  3203. hexVal.height = 0.72;
  3204. hexVal.name = "hexField";
  3205. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3206. hexVal.fontSize = buttonFontSize;
  3207. var minusPound = options.lastColor.split("#");
  3208. hexVal.text = minusPound[1];
  3209. hexVal.color = inputTextColor;
  3210. hexVal.background = inputTextBackgroundColor;
  3211. hexVal.onFocusObservable.add(function () {
  3212. activeField = hexVal.name;
  3213. lastVal = hexVal.text;
  3214. editSwatches(false);
  3215. });
  3216. hexVal.onBlurObservable.add(function () {
  3217. if (hexVal.text.length == 3) {
  3218. var val = hexVal.text.split("");
  3219. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3220. }
  3221. if (hexVal.text == "") {
  3222. hexVal.text = "000000";
  3223. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3224. }
  3225. if (activeField == hexVal.name) {
  3226. activeField = "";
  3227. }
  3228. });
  3229. hexVal.onTextChangedObservable.add(function () {
  3230. var newHexValue = hexVal.text;
  3231. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3232. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3233. hexVal.text = lastVal;
  3234. }
  3235. else {
  3236. if (hexVal.text.length < 6) {
  3237. var leadingZero = 6 - hexVal.text.length;
  3238. for (var i = 0; i < leadingZero; i++) {
  3239. newHexValue = "0" + newHexValue;
  3240. }
  3241. }
  3242. if (hexVal.text.length == 3) {
  3243. var val = hexVal.text.split("");
  3244. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3245. }
  3246. newHexValue = "#" + newHexValue;
  3247. if (activeField == hexVal.name) {
  3248. lastVal = hexVal.text;
  3249. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3250. }
  3251. }
  3252. });
  3253. hexValueQuadrant.addControl(hexVal, 0, 1);
  3254. if (options.savedColors && options.savedColors.length > 0) {
  3255. updateSwatches("", butSave);
  3256. }
  3257. });
  3258. };
  3259. ColorPicker._Epsilon = 0.000001;
  3260. return ColorPicker;
  3261. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3262. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3263. /***/ }),
  3264. /***/ "./2D/controls/container.ts":
  3265. /*!**********************************!*\
  3266. !*** ./2D/controls/container.ts ***!
  3267. \**********************************/
  3268. /*! exports provided: Container */
  3269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3270. "use strict";
  3271. __webpack_require__.r(__webpack_exports__);
  3272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3273. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3274. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable");
  3275. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3276. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3277. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3278. /**
  3279. * Root class for 2D containers
  3280. * @see https://doc.babylonjs.com/how_to/gui#containers
  3281. */
  3282. var Container = /** @class */ (function (_super) {
  3283. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3284. /**
  3285. * Creates a new Container
  3286. * @param name defines the name of the container
  3287. */
  3288. function Container(name) {
  3289. var _this = _super.call(this, name) || this;
  3290. _this.name = name;
  3291. /** @hidden */
  3292. _this._children = new Array();
  3293. /** @hidden */
  3294. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3295. /** @hidden */
  3296. _this._background = "";
  3297. /** @hidden */
  3298. _this._adaptWidthToChildren = false;
  3299. /** @hidden */
  3300. _this._adaptHeightToChildren = false;
  3301. /**
  3302. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3303. */
  3304. _this.logLayoutCycleErrors = false;
  3305. /**
  3306. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3307. */
  3308. _this.maxLayoutCycle = 3;
  3309. return _this;
  3310. }
  3311. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3312. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3313. get: function () {
  3314. return this._adaptHeightToChildren;
  3315. },
  3316. set: function (value) {
  3317. if (this._adaptHeightToChildren === value) {
  3318. return;
  3319. }
  3320. this._adaptHeightToChildren = value;
  3321. if (value) {
  3322. this.height = "100%";
  3323. }
  3324. this._markAsDirty();
  3325. },
  3326. enumerable: false,
  3327. configurable: true
  3328. });
  3329. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3330. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3331. get: function () {
  3332. return this._adaptWidthToChildren;
  3333. },
  3334. set: function (value) {
  3335. if (this._adaptWidthToChildren === value) {
  3336. return;
  3337. }
  3338. this._adaptWidthToChildren = value;
  3339. if (value) {
  3340. this.width = "100%";
  3341. }
  3342. this._markAsDirty();
  3343. },
  3344. enumerable: false,
  3345. configurable: true
  3346. });
  3347. Object.defineProperty(Container.prototype, "background", {
  3348. /** Gets or sets background color */
  3349. get: function () {
  3350. return this._background;
  3351. },
  3352. set: function (value) {
  3353. if (this._background === value) {
  3354. return;
  3355. }
  3356. this._background = value;
  3357. this._markAsDirty();
  3358. },
  3359. enumerable: false,
  3360. configurable: true
  3361. });
  3362. Object.defineProperty(Container.prototype, "children", {
  3363. /** Gets the list of children */
  3364. get: function () {
  3365. return this._children;
  3366. },
  3367. enumerable: false,
  3368. configurable: true
  3369. });
  3370. Container.prototype._getTypeName = function () {
  3371. return "Container";
  3372. };
  3373. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3374. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3375. var child = _a[_i];
  3376. child._markMatrixAsDirty();
  3377. }
  3378. };
  3379. /**
  3380. * Gets a child using its name
  3381. * @param name defines the child name to look for
  3382. * @returns the child control if found
  3383. */
  3384. Container.prototype.getChildByName = function (name) {
  3385. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3386. var child = _a[_i];
  3387. if (child.name === name) {
  3388. return child;
  3389. }
  3390. }
  3391. return null;
  3392. };
  3393. /**
  3394. * Gets a child using its type and its name
  3395. * @param name defines the child name to look for
  3396. * @param type defines the child type to look for
  3397. * @returns the child control if found
  3398. */
  3399. Container.prototype.getChildByType = function (name, type) {
  3400. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3401. var child = _a[_i];
  3402. if (child.typeName === type) {
  3403. return child;
  3404. }
  3405. }
  3406. return null;
  3407. };
  3408. /**
  3409. * Search for a specific control in children
  3410. * @param control defines the control to look for
  3411. * @returns true if the control is in child list
  3412. */
  3413. Container.prototype.containsControl = function (control) {
  3414. return this.children.indexOf(control) !== -1;
  3415. };
  3416. /**
  3417. * Adds a new control to the current container
  3418. * @param control defines the control to add
  3419. * @returns the current container
  3420. */
  3421. Container.prototype.addControl = function (control) {
  3422. if (!control) {
  3423. return this;
  3424. }
  3425. var index = this._children.indexOf(control);
  3426. if (index !== -1) {
  3427. return this;
  3428. }
  3429. control._link(this._host);
  3430. control._markAllAsDirty();
  3431. this._reOrderControl(control);
  3432. this._markAsDirty();
  3433. return this;
  3434. };
  3435. /**
  3436. * Removes all controls from the current container
  3437. * @returns the current container
  3438. */
  3439. Container.prototype.clearControls = function () {
  3440. var children = this.children.slice();
  3441. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3442. var child = children_1[_i];
  3443. this.removeControl(child);
  3444. }
  3445. return this;
  3446. };
  3447. /**
  3448. * Removes a control from the current container
  3449. * @param control defines the control to remove
  3450. * @returns the current container
  3451. */
  3452. Container.prototype.removeControl = function (control) {
  3453. var index = this._children.indexOf(control);
  3454. if (index !== -1) {
  3455. this._children.splice(index, 1);
  3456. control.parent = null;
  3457. }
  3458. control.linkWithMesh(null);
  3459. if (this._host) {
  3460. this._host._cleanControlAfterRemoval(control);
  3461. }
  3462. this._markAsDirty();
  3463. return this;
  3464. };
  3465. /** @hidden */
  3466. Container.prototype._reOrderControl = function (control) {
  3467. this.removeControl(control);
  3468. var wasAdded = false;
  3469. for (var index = 0; index < this._children.length; index++) {
  3470. if (this._children[index].zIndex > control.zIndex) {
  3471. this._children.splice(index, 0, control);
  3472. wasAdded = true;
  3473. break;
  3474. }
  3475. }
  3476. if (!wasAdded) {
  3477. this._children.push(control);
  3478. }
  3479. control.parent = this;
  3480. this._markAsDirty();
  3481. };
  3482. /** @hidden */
  3483. Container.prototype._offsetLeft = function (offset) {
  3484. _super.prototype._offsetLeft.call(this, offset);
  3485. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3486. var child = _a[_i];
  3487. child._offsetLeft(offset);
  3488. }
  3489. };
  3490. /** @hidden */
  3491. Container.prototype._offsetTop = function (offset) {
  3492. _super.prototype._offsetTop.call(this, offset);
  3493. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3494. var child = _a[_i];
  3495. child._offsetTop(offset);
  3496. }
  3497. };
  3498. /** @hidden */
  3499. Container.prototype._markAllAsDirty = function () {
  3500. _super.prototype._markAllAsDirty.call(this);
  3501. for (var index = 0; index < this._children.length; index++) {
  3502. this._children[index]._markAllAsDirty();
  3503. }
  3504. };
  3505. /** @hidden */
  3506. Container.prototype._localDraw = function (context) {
  3507. if (this._background) {
  3508. context.save();
  3509. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3510. context.shadowColor = this.shadowColor;
  3511. context.shadowBlur = this.shadowBlur;
  3512. context.shadowOffsetX = this.shadowOffsetX;
  3513. context.shadowOffsetY = this.shadowOffsetY;
  3514. }
  3515. context.fillStyle = this._background;
  3516. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3517. context.restore();
  3518. }
  3519. };
  3520. /** @hidden */
  3521. Container.prototype._link = function (host) {
  3522. _super.prototype._link.call(this, host);
  3523. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3524. var child = _a[_i];
  3525. child._link(host);
  3526. }
  3527. };
  3528. /** @hidden */
  3529. Container.prototype._beforeLayout = function () {
  3530. // Do nothing
  3531. };
  3532. /** @hidden */
  3533. Container.prototype._processMeasures = function (parentMeasure, context) {
  3534. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3535. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3536. this._evaluateClippingState(parentMeasure);
  3537. }
  3538. };
  3539. /** @hidden */
  3540. Container.prototype._layout = function (parentMeasure, context) {
  3541. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3542. return false;
  3543. }
  3544. this.host._numLayoutCalls++;
  3545. if (this._isDirty) {
  3546. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3547. }
  3548. var rebuildCount = 0;
  3549. context.save();
  3550. this._applyStates(context);
  3551. this._beforeLayout();
  3552. do {
  3553. var computedWidth = -1;
  3554. var computedHeight = -1;
  3555. this._rebuildLayout = false;
  3556. this._processMeasures(parentMeasure, context);
  3557. if (!this._isClipped) {
  3558. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3559. var child = _a[_i];
  3560. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3561. if (child._layout(this._measureForChildren, context)) {
  3562. if (this.adaptWidthToChildren && child._width.isPixel) {
  3563. computedWidth = Math.max(computedWidth, child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels);
  3564. }
  3565. if (this.adaptHeightToChildren && child._height.isPixel) {
  3566. computedHeight = Math.max(computedHeight, child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels);
  3567. }
  3568. }
  3569. }
  3570. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3571. computedWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  3572. if (this.width !== computedWidth + "px") {
  3573. this.width = computedWidth + "px";
  3574. this._rebuildLayout = true;
  3575. }
  3576. }
  3577. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3578. computedHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  3579. if (this.height !== computedHeight + "px") {
  3580. this.height = computedHeight + "px";
  3581. this._rebuildLayout = true;
  3582. }
  3583. }
  3584. this._postMeasure();
  3585. }
  3586. rebuildCount++;
  3587. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3588. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3589. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3590. }
  3591. context.restore();
  3592. if (this._isDirty) {
  3593. this.invalidateRect();
  3594. this._isDirty = false;
  3595. }
  3596. return true;
  3597. };
  3598. Container.prototype._postMeasure = function () {
  3599. // Do nothing by default
  3600. };
  3601. /** @hidden */
  3602. Container.prototype._draw = function (context, invalidatedRectangle) {
  3603. this._localDraw(context);
  3604. if (this.clipChildren) {
  3605. this._clipForChildren(context);
  3606. }
  3607. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3608. var child = _a[_i];
  3609. // Only redraw parts of the screen that are invalidated
  3610. if (invalidatedRectangle) {
  3611. if (!child._intersectsRect(invalidatedRectangle)) {
  3612. continue;
  3613. }
  3614. }
  3615. child._render(context, invalidatedRectangle);
  3616. }
  3617. };
  3618. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3619. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3620. if (!this.children) {
  3621. return;
  3622. }
  3623. for (var index = 0; index < this.children.length; index++) {
  3624. var item = this.children[index];
  3625. if (!predicate || predicate(item)) {
  3626. results.push(item);
  3627. }
  3628. if (!directDescendantsOnly) {
  3629. item.getDescendantsToRef(results, false, predicate);
  3630. }
  3631. }
  3632. };
  3633. /** @hidden */
  3634. Container.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  3635. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3636. return false;
  3637. }
  3638. if (!_super.prototype.contains.call(this, x, y)) {
  3639. return false;
  3640. }
  3641. // Checking backwards to pick closest first
  3642. for (var index = this._children.length - 1; index >= 0; index--) {
  3643. var child = this._children[index];
  3644. if (child._processPicking(x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY)) {
  3645. if (child.hoverCursor) {
  3646. this._host._changeCursor(child.hoverCursor);
  3647. }
  3648. return true;
  3649. }
  3650. }
  3651. if (!this.isHitTestVisible) {
  3652. return false;
  3653. }
  3654. return this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  3655. };
  3656. /** @hidden */
  3657. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3658. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3659. this._measureForChildren.copyFrom(this._currentMeasure);
  3660. };
  3661. /** Releases associated resources */
  3662. Container.prototype.dispose = function () {
  3663. _super.prototype.dispose.call(this);
  3664. for (var index = this.children.length - 1; index >= 0; index--) {
  3665. this.children[index].dispose();
  3666. }
  3667. };
  3668. return Container;
  3669. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3670. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3671. /***/ }),
  3672. /***/ "./2D/controls/control.ts":
  3673. /*!********************************!*\
  3674. !*** ./2D/controls/control.ts ***!
  3675. \********************************/
  3676. /*! exports provided: Control */
  3677. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3678. "use strict";
  3679. __webpack_require__.r(__webpack_exports__);
  3680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3681. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  3682. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3683. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3684. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3685. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3686. /**
  3687. * Root class used for all 2D controls
  3688. * @see https://doc.babylonjs.com/how_to/gui#controls
  3689. */
  3690. var Control = /** @class */ (function () {
  3691. // Functions
  3692. /**
  3693. * Creates a new control
  3694. * @param name defines the name of the control
  3695. */
  3696. function Control(
  3697. /** defines the name of the control */
  3698. name) {
  3699. this.name = name;
  3700. this._alpha = 1;
  3701. this._alphaSet = false;
  3702. this._zIndex = 0;
  3703. /** @hidden */
  3704. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3705. this._fontFamily = "Arial";
  3706. this._fontStyle = "";
  3707. this._fontWeight = "";
  3708. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3709. /** @hidden */
  3710. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3711. /** @hidden */
  3712. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3713. this._color = "";
  3714. this._style = null;
  3715. /** @hidden */
  3716. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3717. /** @hidden */
  3718. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3719. /** @hidden */
  3720. this._isDirty = true;
  3721. /** @hidden */
  3722. this._wasDirty = false;
  3723. /** @hidden */
  3724. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3725. /** @hidden */
  3726. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3727. /** @hidden */
  3728. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3729. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3730. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3731. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3732. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3733. /** @hidden */
  3734. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3735. /** @hidden */
  3736. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3737. this._scaleX = 1.0;
  3738. this._scaleY = 1.0;
  3739. this._rotation = 0;
  3740. this._transformCenterX = 0.5;
  3741. this._transformCenterY = 0.5;
  3742. /** @hidden */
  3743. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3744. /** @hidden */
  3745. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3746. /** @hidden */
  3747. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3748. this._isMatrixDirty = true;
  3749. this._isVisible = true;
  3750. this._isHighlighted = false;
  3751. this._fontSet = false;
  3752. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3753. this._downCount = 0;
  3754. this._enterCount = -1;
  3755. this._doNotRender = false;
  3756. this._downPointerIds = {};
  3757. this._isEnabled = true;
  3758. this._disabledColor = "#9a9a9a";
  3759. this._disabledColorItem = "#6a6a6a";
  3760. /** @hidden */
  3761. this._rebuildLayout = false;
  3762. /** @hidden */
  3763. this._customData = {};
  3764. /** @hidden */
  3765. this._isClipped = false;
  3766. /** @hidden */
  3767. this._automaticSize = false;
  3768. /**
  3769. * Gets or sets an object used to store user defined information for the node
  3770. */
  3771. this.metadata = null;
  3772. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3773. this.isHitTestVisible = true;
  3774. /** Gets or sets a boolean indicating if the control can block pointer events */
  3775. this.isPointerBlocker = false;
  3776. /** Gets or sets a boolean indicating if the control can be focusable */
  3777. this.isFocusInvisible = false;
  3778. /**
  3779. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3780. * 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
  3781. */
  3782. this.clipChildren = true;
  3783. /**
  3784. * Gets or sets a boolean indicating that control content must be clipped
  3785. * 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
  3786. */
  3787. this.clipContent = true;
  3788. /**
  3789. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3790. */
  3791. this.useBitmapCache = false;
  3792. this._shadowOffsetX = 0;
  3793. this._shadowOffsetY = 0;
  3794. this._shadowBlur = 0;
  3795. this._shadowColor = 'black';
  3796. /** Gets or sets the cursor to use when the control is hovered */
  3797. this.hoverCursor = "";
  3798. /** @hidden */
  3799. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3800. /** @hidden */
  3801. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3802. /**
  3803. * An event triggered when pointer wheel is scrolled
  3804. */
  3805. this.onWheelObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3806. /**
  3807. * An event triggered when the pointer move over the control.
  3808. */
  3809. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3810. /**
  3811. * An event triggered when the pointer move out of the control.
  3812. */
  3813. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3814. /**
  3815. * An event triggered when the pointer taps the control
  3816. */
  3817. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3818. /**
  3819. * An event triggered when pointer up
  3820. */
  3821. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3822. /**
  3823. * An event triggered when a control is clicked on
  3824. */
  3825. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3826. /**
  3827. * An event triggered when pointer enters the control
  3828. */
  3829. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3830. /**
  3831. * An event triggered when the control is marked as dirty
  3832. */
  3833. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3834. /**
  3835. * An event triggered before drawing the control
  3836. */
  3837. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3838. /**
  3839. * An event triggered after the control was drawn
  3840. */
  3841. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3842. /**
  3843. * An event triggered when the control has been disposed
  3844. */
  3845. this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3846. /**
  3847. * Gets or sets a fixed ratio for this control.
  3848. * When different from 0, the ratio is used to compute the "second" dimension.
  3849. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  3850. * second dimension is computed as first dimension * fixedRatio
  3851. */
  3852. this.fixedRatio = 0;
  3853. this._fixedRatioMasterIsWidth = true;
  3854. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3855. }
  3856. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3857. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3858. get: function () {
  3859. return this._shadowOffsetX;
  3860. },
  3861. set: function (value) {
  3862. if (this._shadowOffsetX === value) {
  3863. return;
  3864. }
  3865. this._shadowOffsetX = value;
  3866. this._markAsDirty();
  3867. },
  3868. enumerable: false,
  3869. configurable: true
  3870. });
  3871. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3872. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3873. get: function () {
  3874. return this._shadowOffsetY;
  3875. },
  3876. set: function (value) {
  3877. if (this._shadowOffsetY === value) {
  3878. return;
  3879. }
  3880. this._shadowOffsetY = value;
  3881. this._markAsDirty();
  3882. },
  3883. enumerable: false,
  3884. configurable: true
  3885. });
  3886. Object.defineProperty(Control.prototype, "shadowBlur", {
  3887. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3888. get: function () {
  3889. return this._shadowBlur;
  3890. },
  3891. set: function (value) {
  3892. if (this._shadowBlur === value) {
  3893. return;
  3894. }
  3895. this._shadowBlur = value;
  3896. this._markAsDirty();
  3897. },
  3898. enumerable: false,
  3899. configurable: true
  3900. });
  3901. Object.defineProperty(Control.prototype, "shadowColor", {
  3902. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3903. get: function () {
  3904. return this._shadowColor;
  3905. },
  3906. set: function (value) {
  3907. if (this._shadowColor === value) {
  3908. return;
  3909. }
  3910. this._shadowColor = value;
  3911. this._markAsDirty();
  3912. },
  3913. enumerable: false,
  3914. configurable: true
  3915. });
  3916. Object.defineProperty(Control.prototype, "typeName", {
  3917. // Properties
  3918. /** Gets the control type name */
  3919. get: function () {
  3920. return this._getTypeName();
  3921. },
  3922. enumerable: false,
  3923. configurable: true
  3924. });
  3925. /**
  3926. * Get the current class name of the control.
  3927. * @returns current class name
  3928. */
  3929. Control.prototype.getClassName = function () {
  3930. return this._getTypeName();
  3931. };
  3932. Object.defineProperty(Control.prototype, "host", {
  3933. /**
  3934. * Get the hosting AdvancedDynamicTexture
  3935. */
  3936. get: function () {
  3937. return this._host;
  3938. },
  3939. enumerable: false,
  3940. configurable: true
  3941. });
  3942. Object.defineProperty(Control.prototype, "fontOffset", {
  3943. /** Gets or set information about font offsets (used to render and align text) */
  3944. get: function () {
  3945. return this._fontOffset;
  3946. },
  3947. set: function (offset) {
  3948. this._fontOffset = offset;
  3949. },
  3950. enumerable: false,
  3951. configurable: true
  3952. });
  3953. Object.defineProperty(Control.prototype, "alpha", {
  3954. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3955. get: function () {
  3956. return this._alpha;
  3957. },
  3958. set: function (value) {
  3959. if (this._alpha === value) {
  3960. return;
  3961. }
  3962. this._alphaSet = true;
  3963. this._alpha = value;
  3964. this._markAsDirty();
  3965. },
  3966. enumerable: false,
  3967. configurable: true
  3968. });
  3969. Object.defineProperty(Control.prototype, "isHighlighted", {
  3970. /**
  3971. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3972. */
  3973. get: function () {
  3974. return this._isHighlighted;
  3975. },
  3976. set: function (value) {
  3977. if (this._isHighlighted === value) {
  3978. return;
  3979. }
  3980. this._isHighlighted = value;
  3981. this._markAsDirty();
  3982. },
  3983. enumerable: false,
  3984. configurable: true
  3985. });
  3986. Object.defineProperty(Control.prototype, "scaleX", {
  3987. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3988. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3989. */
  3990. get: function () {
  3991. return this._scaleX;
  3992. },
  3993. set: function (value) {
  3994. if (this._scaleX === value) {
  3995. return;
  3996. }
  3997. this._scaleX = value;
  3998. this._markAsDirty();
  3999. this._markMatrixAsDirty();
  4000. },
  4001. enumerable: false,
  4002. configurable: true
  4003. });
  4004. Object.defineProperty(Control.prototype, "scaleY", {
  4005. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  4006. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4007. */
  4008. get: function () {
  4009. return this._scaleY;
  4010. },
  4011. set: function (value) {
  4012. if (this._scaleY === value) {
  4013. return;
  4014. }
  4015. this._scaleY = value;
  4016. this._markAsDirty();
  4017. this._markMatrixAsDirty();
  4018. },
  4019. enumerable: false,
  4020. configurable: true
  4021. });
  4022. Object.defineProperty(Control.prototype, "rotation", {
  4023. /** Gets or sets the rotation angle (0 by default)
  4024. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4025. */
  4026. get: function () {
  4027. return this._rotation;
  4028. },
  4029. set: function (value) {
  4030. if (this._rotation === value) {
  4031. return;
  4032. }
  4033. this._rotation = value;
  4034. this._markAsDirty();
  4035. this._markMatrixAsDirty();
  4036. },
  4037. enumerable: false,
  4038. configurable: true
  4039. });
  4040. Object.defineProperty(Control.prototype, "transformCenterY", {
  4041. /** Gets or sets the transformation center on Y axis (0 by default)
  4042. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4043. */
  4044. get: function () {
  4045. return this._transformCenterY;
  4046. },
  4047. set: function (value) {
  4048. if (this._transformCenterY === value) {
  4049. return;
  4050. }
  4051. this._transformCenterY = value;
  4052. this._markAsDirty();
  4053. this._markMatrixAsDirty();
  4054. },
  4055. enumerable: false,
  4056. configurable: true
  4057. });
  4058. Object.defineProperty(Control.prototype, "transformCenterX", {
  4059. /** Gets or sets the transformation center on X axis (0 by default)
  4060. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4061. */
  4062. get: function () {
  4063. return this._transformCenterX;
  4064. },
  4065. set: function (value) {
  4066. if (this._transformCenterX === value) {
  4067. return;
  4068. }
  4069. this._transformCenterX = value;
  4070. this._markAsDirty();
  4071. this._markMatrixAsDirty();
  4072. },
  4073. enumerable: false,
  4074. configurable: true
  4075. });
  4076. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  4077. /**
  4078. * Gets or sets the horizontal alignment
  4079. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4080. */
  4081. get: function () {
  4082. return this._horizontalAlignment;
  4083. },
  4084. set: function (value) {
  4085. if (this._horizontalAlignment === value) {
  4086. return;
  4087. }
  4088. this._horizontalAlignment = value;
  4089. this._markAsDirty();
  4090. },
  4091. enumerable: false,
  4092. configurable: true
  4093. });
  4094. Object.defineProperty(Control.prototype, "verticalAlignment", {
  4095. /**
  4096. * Gets or sets the vertical alignment
  4097. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4098. */
  4099. get: function () {
  4100. return this._verticalAlignment;
  4101. },
  4102. set: function (value) {
  4103. if (this._verticalAlignment === value) {
  4104. return;
  4105. }
  4106. this._verticalAlignment = value;
  4107. this._markAsDirty();
  4108. },
  4109. enumerable: false,
  4110. configurable: true
  4111. });
  4112. Object.defineProperty(Control.prototype, "width", {
  4113. /**
  4114. * Gets or sets control width
  4115. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4116. */
  4117. get: function () {
  4118. return this._width.toString(this._host);
  4119. },
  4120. set: function (value) {
  4121. this._fixedRatioMasterIsWidth = true;
  4122. if (this._width.toString(this._host) === value) {
  4123. return;
  4124. }
  4125. if (this._width.fromString(value)) {
  4126. this._markAsDirty();
  4127. }
  4128. },
  4129. enumerable: false,
  4130. configurable: true
  4131. });
  4132. Object.defineProperty(Control.prototype, "widthInPixels", {
  4133. /**
  4134. * Gets or sets the control width in pixel
  4135. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4136. */
  4137. get: function () {
  4138. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4139. },
  4140. set: function (value) {
  4141. if (isNaN(value)) {
  4142. return;
  4143. }
  4144. this._fixedRatioMasterIsWidth = true;
  4145. this.width = value + "px";
  4146. },
  4147. enumerable: false,
  4148. configurable: true
  4149. });
  4150. Object.defineProperty(Control.prototype, "height", {
  4151. /**
  4152. * Gets or sets control height
  4153. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4154. */
  4155. get: function () {
  4156. return this._height.toString(this._host);
  4157. },
  4158. set: function (value) {
  4159. this._fixedRatioMasterIsWidth = false;
  4160. if (this._height.toString(this._host) === value) {
  4161. return;
  4162. }
  4163. if (this._height.fromString(value)) {
  4164. this._markAsDirty();
  4165. }
  4166. },
  4167. enumerable: false,
  4168. configurable: true
  4169. });
  4170. Object.defineProperty(Control.prototype, "heightInPixels", {
  4171. /**
  4172. * Gets or sets control height in pixel
  4173. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4174. */
  4175. get: function () {
  4176. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4177. },
  4178. set: function (value) {
  4179. if (isNaN(value)) {
  4180. return;
  4181. }
  4182. this._fixedRatioMasterIsWidth = false;
  4183. this.height = value + "px";
  4184. },
  4185. enumerable: false,
  4186. configurable: true
  4187. });
  4188. Object.defineProperty(Control.prototype, "fontFamily", {
  4189. /** Gets or set font family */
  4190. get: function () {
  4191. if (!this._fontSet) {
  4192. return "";
  4193. }
  4194. return this._fontFamily;
  4195. },
  4196. set: function (value) {
  4197. if (this._fontFamily === value) {
  4198. return;
  4199. }
  4200. this._fontFamily = value;
  4201. this._resetFontCache();
  4202. },
  4203. enumerable: false,
  4204. configurable: true
  4205. });
  4206. Object.defineProperty(Control.prototype, "fontStyle", {
  4207. /** Gets or sets font style */
  4208. get: function () {
  4209. return this._fontStyle;
  4210. },
  4211. set: function (value) {
  4212. if (this._fontStyle === value) {
  4213. return;
  4214. }
  4215. this._fontStyle = value;
  4216. this._resetFontCache();
  4217. },
  4218. enumerable: false,
  4219. configurable: true
  4220. });
  4221. Object.defineProperty(Control.prototype, "fontWeight", {
  4222. /** Gets or sets font weight */
  4223. get: function () {
  4224. return this._fontWeight;
  4225. },
  4226. set: function (value) {
  4227. if (this._fontWeight === value) {
  4228. return;
  4229. }
  4230. this._fontWeight = value;
  4231. this._resetFontCache();
  4232. },
  4233. enumerable: false,
  4234. configurable: true
  4235. });
  4236. Object.defineProperty(Control.prototype, "style", {
  4237. /**
  4238. * Gets or sets style
  4239. * @see https://doc.babylonjs.com/how_to/gui#styles
  4240. */
  4241. get: function () {
  4242. return this._style;
  4243. },
  4244. set: function (value) {
  4245. var _this = this;
  4246. if (this._style) {
  4247. this._style.onChangedObservable.remove(this._styleObserver);
  4248. this._styleObserver = null;
  4249. }
  4250. this._style = value;
  4251. if (this._style) {
  4252. this._styleObserver = this._style.onChangedObservable.add(function () {
  4253. _this._markAsDirty();
  4254. _this._resetFontCache();
  4255. });
  4256. }
  4257. this._markAsDirty();
  4258. this._resetFontCache();
  4259. },
  4260. enumerable: false,
  4261. configurable: true
  4262. });
  4263. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4264. /** @hidden */
  4265. get: function () {
  4266. return this._fontSize.isPercentage;
  4267. },
  4268. enumerable: false,
  4269. configurable: true
  4270. });
  4271. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4272. /** Gets or sets font size in pixels */
  4273. get: function () {
  4274. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4275. if (fontSizeToUse.isPixel) {
  4276. return fontSizeToUse.getValue(this._host);
  4277. }
  4278. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4279. },
  4280. set: function (value) {
  4281. if (isNaN(value)) {
  4282. return;
  4283. }
  4284. this.fontSize = value + "px";
  4285. },
  4286. enumerable: false,
  4287. configurable: true
  4288. });
  4289. Object.defineProperty(Control.prototype, "fontSize", {
  4290. /** Gets or sets font size */
  4291. get: function () {
  4292. return this._fontSize.toString(this._host);
  4293. },
  4294. set: function (value) {
  4295. if (this._fontSize.toString(this._host) === value) {
  4296. return;
  4297. }
  4298. if (this._fontSize.fromString(value)) {
  4299. this._markAsDirty();
  4300. this._resetFontCache();
  4301. }
  4302. },
  4303. enumerable: false,
  4304. configurable: true
  4305. });
  4306. Object.defineProperty(Control.prototype, "color", {
  4307. /** Gets or sets foreground color */
  4308. get: function () {
  4309. return this._color;
  4310. },
  4311. set: function (value) {
  4312. if (this._color === value) {
  4313. return;
  4314. }
  4315. this._color = value;
  4316. this._markAsDirty();
  4317. },
  4318. enumerable: false,
  4319. configurable: true
  4320. });
  4321. Object.defineProperty(Control.prototype, "zIndex", {
  4322. /** Gets or sets z index which is used to reorder controls on the z axis */
  4323. get: function () {
  4324. return this._zIndex;
  4325. },
  4326. set: function (value) {
  4327. if (this.zIndex === value) {
  4328. return;
  4329. }
  4330. this._zIndex = value;
  4331. if (this.parent) {
  4332. this.parent._reOrderControl(this);
  4333. }
  4334. },
  4335. enumerable: false,
  4336. configurable: true
  4337. });
  4338. Object.defineProperty(Control.prototype, "notRenderable", {
  4339. /** Gets or sets a boolean indicating if the control can be rendered */
  4340. get: function () {
  4341. return this._doNotRender;
  4342. },
  4343. set: function (value) {
  4344. if (this._doNotRender === value) {
  4345. return;
  4346. }
  4347. this._doNotRender = value;
  4348. this._markAsDirty();
  4349. },
  4350. enumerable: false,
  4351. configurable: true
  4352. });
  4353. Object.defineProperty(Control.prototype, "isVisible", {
  4354. /** Gets or sets a boolean indicating if the control is visible */
  4355. get: function () {
  4356. return this._isVisible;
  4357. },
  4358. set: function (value) {
  4359. if (this._isVisible === value) {
  4360. return;
  4361. }
  4362. this._isVisible = value;
  4363. this._markAsDirty(true);
  4364. },
  4365. enumerable: false,
  4366. configurable: true
  4367. });
  4368. Object.defineProperty(Control.prototype, "isDirty", {
  4369. /** Gets a boolean indicating that the control needs to update its rendering */
  4370. get: function () {
  4371. return this._isDirty;
  4372. },
  4373. enumerable: false,
  4374. configurable: true
  4375. });
  4376. Object.defineProperty(Control.prototype, "linkedMesh", {
  4377. /**
  4378. * Gets the current linked mesh (or null if none)
  4379. */
  4380. get: function () {
  4381. return this._linkedMesh;
  4382. },
  4383. enumerable: false,
  4384. configurable: true
  4385. });
  4386. Object.defineProperty(Control.prototype, "paddingLeft", {
  4387. /**
  4388. * Gets or sets a value indicating the padding to use on the left of the control
  4389. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4390. */
  4391. get: function () {
  4392. return this._paddingLeft.toString(this._host);
  4393. },
  4394. set: function (value) {
  4395. if (this._paddingLeft.fromString(value)) {
  4396. this._markAsDirty();
  4397. }
  4398. },
  4399. enumerable: false,
  4400. configurable: true
  4401. });
  4402. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4403. /**
  4404. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4405. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4406. */
  4407. get: function () {
  4408. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4409. },
  4410. set: function (value) {
  4411. if (isNaN(value)) {
  4412. return;
  4413. }
  4414. this.paddingLeft = value + "px";
  4415. },
  4416. enumerable: false,
  4417. configurable: true
  4418. });
  4419. Object.defineProperty(Control.prototype, "paddingRight", {
  4420. /**
  4421. * Gets or sets a value indicating the padding to use on the right of the control
  4422. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4423. */
  4424. get: function () {
  4425. return this._paddingRight.toString(this._host);
  4426. },
  4427. set: function (value) {
  4428. if (this._paddingRight.fromString(value)) {
  4429. this._markAsDirty();
  4430. }
  4431. },
  4432. enumerable: false,
  4433. configurable: true
  4434. });
  4435. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4436. /**
  4437. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4438. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4439. */
  4440. get: function () {
  4441. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4442. },
  4443. set: function (value) {
  4444. if (isNaN(value)) {
  4445. return;
  4446. }
  4447. this.paddingRight = value + "px";
  4448. },
  4449. enumerable: false,
  4450. configurable: true
  4451. });
  4452. Object.defineProperty(Control.prototype, "paddingTop", {
  4453. /**
  4454. * Gets or sets a value indicating the padding to use on the top of the control
  4455. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4456. */
  4457. get: function () {
  4458. return this._paddingTop.toString(this._host);
  4459. },
  4460. set: function (value) {
  4461. if (this._paddingTop.fromString(value)) {
  4462. this._markAsDirty();
  4463. }
  4464. },
  4465. enumerable: false,
  4466. configurable: true
  4467. });
  4468. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4469. /**
  4470. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4471. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4472. */
  4473. get: function () {
  4474. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4475. },
  4476. set: function (value) {
  4477. if (isNaN(value)) {
  4478. return;
  4479. }
  4480. this.paddingTop = value + "px";
  4481. },
  4482. enumerable: false,
  4483. configurable: true
  4484. });
  4485. Object.defineProperty(Control.prototype, "paddingBottom", {
  4486. /**
  4487. * Gets or sets a value indicating the padding to use on the bottom of the control
  4488. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4489. */
  4490. get: function () {
  4491. return this._paddingBottom.toString(this._host);
  4492. },
  4493. set: function (value) {
  4494. if (this._paddingBottom.fromString(value)) {
  4495. this._markAsDirty();
  4496. }
  4497. },
  4498. enumerable: false,
  4499. configurable: true
  4500. });
  4501. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4502. /**
  4503. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4504. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4505. */
  4506. get: function () {
  4507. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4508. },
  4509. set: function (value) {
  4510. if (isNaN(value)) {
  4511. return;
  4512. }
  4513. this.paddingBottom = value + "px";
  4514. },
  4515. enumerable: false,
  4516. configurable: true
  4517. });
  4518. Object.defineProperty(Control.prototype, "left", {
  4519. /**
  4520. * Gets or sets a value indicating the left coordinate of the control
  4521. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4522. */
  4523. get: function () {
  4524. return this._left.toString(this._host);
  4525. },
  4526. set: function (value) {
  4527. if (this._left.fromString(value)) {
  4528. this._markAsDirty();
  4529. }
  4530. },
  4531. enumerable: false,
  4532. configurable: true
  4533. });
  4534. Object.defineProperty(Control.prototype, "leftInPixels", {
  4535. /**
  4536. * Gets or sets a value indicating the left coordinate in pixels of the control
  4537. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4538. */
  4539. get: function () {
  4540. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4541. },
  4542. set: function (value) {
  4543. if (isNaN(value)) {
  4544. return;
  4545. }
  4546. this.left = value + "px";
  4547. },
  4548. enumerable: false,
  4549. configurable: true
  4550. });
  4551. Object.defineProperty(Control.prototype, "top", {
  4552. /**
  4553. * Gets or sets a value indicating the top coordinate of the control
  4554. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4555. */
  4556. get: function () {
  4557. return this._top.toString(this._host);
  4558. },
  4559. set: function (value) {
  4560. if (this._top.fromString(value)) {
  4561. this._markAsDirty();
  4562. }
  4563. },
  4564. enumerable: false,
  4565. configurable: true
  4566. });
  4567. Object.defineProperty(Control.prototype, "topInPixels", {
  4568. /**
  4569. * Gets or sets a value indicating the top coordinate in pixels of the control
  4570. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4571. */
  4572. get: function () {
  4573. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4574. },
  4575. set: function (value) {
  4576. if (isNaN(value)) {
  4577. return;
  4578. }
  4579. this.top = value + "px";
  4580. },
  4581. enumerable: false,
  4582. configurable: true
  4583. });
  4584. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4585. /**
  4586. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4587. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4588. */
  4589. get: function () {
  4590. return this._linkOffsetX.toString(this._host);
  4591. },
  4592. set: function (value) {
  4593. if (this._linkOffsetX.fromString(value)) {
  4594. this._markAsDirty();
  4595. }
  4596. },
  4597. enumerable: false,
  4598. configurable: true
  4599. });
  4600. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4601. /**
  4602. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4603. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4604. */
  4605. get: function () {
  4606. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4607. },
  4608. set: function (value) {
  4609. if (isNaN(value)) {
  4610. return;
  4611. }
  4612. this.linkOffsetX = value + "px";
  4613. },
  4614. enumerable: false,
  4615. configurable: true
  4616. });
  4617. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4618. /**
  4619. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4620. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4621. */
  4622. get: function () {
  4623. return this._linkOffsetY.toString(this._host);
  4624. },
  4625. set: function (value) {
  4626. if (this._linkOffsetY.fromString(value)) {
  4627. this._markAsDirty();
  4628. }
  4629. },
  4630. enumerable: false,
  4631. configurable: true
  4632. });
  4633. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4634. /**
  4635. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4636. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4637. */
  4638. get: function () {
  4639. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4640. },
  4641. set: function (value) {
  4642. if (isNaN(value)) {
  4643. return;
  4644. }
  4645. this.linkOffsetY = value + "px";
  4646. },
  4647. enumerable: false,
  4648. configurable: true
  4649. });
  4650. Object.defineProperty(Control.prototype, "centerX", {
  4651. /** Gets the center coordinate on X axis */
  4652. get: function () {
  4653. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4654. },
  4655. enumerable: false,
  4656. configurable: true
  4657. });
  4658. Object.defineProperty(Control.prototype, "centerY", {
  4659. /** Gets the center coordinate on Y axis */
  4660. get: function () {
  4661. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4662. },
  4663. enumerable: false,
  4664. configurable: true
  4665. });
  4666. Object.defineProperty(Control.prototype, "isEnabled", {
  4667. /** Gets or sets if control is Enabled*/
  4668. get: function () {
  4669. return this._isEnabled;
  4670. },
  4671. set: function (value) {
  4672. if (this._isEnabled === value) {
  4673. return;
  4674. }
  4675. this._isEnabled = value;
  4676. this._markAsDirty();
  4677. },
  4678. enumerable: false,
  4679. configurable: true
  4680. });
  4681. Object.defineProperty(Control.prototype, "disabledColor", {
  4682. /** Gets or sets background color of control if it's disabled*/
  4683. get: function () {
  4684. return this._disabledColor;
  4685. },
  4686. set: function (value) {
  4687. if (this._disabledColor === value) {
  4688. return;
  4689. }
  4690. this._disabledColor = value;
  4691. this._markAsDirty();
  4692. },
  4693. enumerable: false,
  4694. configurable: true
  4695. });
  4696. Object.defineProperty(Control.prototype, "disabledColorItem", {
  4697. /** Gets or sets front color of control if it's disabled*/
  4698. get: function () {
  4699. return this._disabledColorItem;
  4700. },
  4701. set: function (value) {
  4702. if (this._disabledColorItem === value) {
  4703. return;
  4704. }
  4705. this._disabledColorItem = value;
  4706. this._markAsDirty();
  4707. },
  4708. enumerable: false,
  4709. configurable: true
  4710. });
  4711. /** @hidden */
  4712. Control.prototype._getTypeName = function () {
  4713. return "Control";
  4714. };
  4715. /**
  4716. * Gets the first ascendant in the hierarchy of the given type
  4717. * @param className defines the required type
  4718. * @returns the ascendant or null if not found
  4719. */
  4720. Control.prototype.getAscendantOfClass = function (className) {
  4721. if (!this.parent) {
  4722. return null;
  4723. }
  4724. if (this.parent.getClassName() === className) {
  4725. return this.parent;
  4726. }
  4727. return this.parent.getAscendantOfClass(className);
  4728. };
  4729. /** @hidden */
  4730. Control.prototype._resetFontCache = function () {
  4731. this._fontSet = true;
  4732. this._markAsDirty();
  4733. };
  4734. /**
  4735. * Determines if a container is an ascendant of the current control
  4736. * @param container defines the container to look for
  4737. * @returns true if the container is one of the ascendant of the control
  4738. */
  4739. Control.prototype.isAscendant = function (container) {
  4740. if (!this.parent) {
  4741. return false;
  4742. }
  4743. if (this.parent === container) {
  4744. return true;
  4745. }
  4746. return this.parent.isAscendant(container);
  4747. };
  4748. /**
  4749. * Gets coordinates in local control space
  4750. * @param globalCoordinates defines the coordinates to transform
  4751. * @returns the new coordinates in local space
  4752. */
  4753. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4754. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4755. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4756. return result;
  4757. };
  4758. /**
  4759. * Gets coordinates in local control space
  4760. * @param globalCoordinates defines the coordinates to transform
  4761. * @param result defines the target vector2 where to store the result
  4762. * @returns the current control
  4763. */
  4764. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4765. result.x = globalCoordinates.x - this._currentMeasure.left;
  4766. result.y = globalCoordinates.y - this._currentMeasure.top;
  4767. return this;
  4768. };
  4769. /**
  4770. * Gets coordinates in parent local control space
  4771. * @param globalCoordinates defines the coordinates to transform
  4772. * @returns the new coordinates in parent local space
  4773. */
  4774. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4775. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4776. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4777. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4778. return result;
  4779. };
  4780. /**
  4781. * Move the current control to a vector3 position projected onto the screen.
  4782. * @param position defines the target position
  4783. * @param scene defines the hosting scene
  4784. */
  4785. Control.prototype.moveToVector3 = function (position, scene) {
  4786. if (!this._host || this.parent !== this._host._rootContainer) {
  4787. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4788. return;
  4789. }
  4790. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4791. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4792. var globalViewport = this._host._getGlobalViewport(scene);
  4793. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4794. this._moveToProjectedPosition(projectedPosition);
  4795. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4796. this.notRenderable = true;
  4797. return;
  4798. }
  4799. this.notRenderable = false;
  4800. };
  4801. /**
  4802. * Will store all controls that have this control as ascendant in a given array
  4803. * @param results defines the array where to store the descendants
  4804. * @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
  4805. * @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
  4806. */
  4807. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4808. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4809. // Do nothing by default
  4810. };
  4811. /**
  4812. * Will return all controls that have this control as ascendant
  4813. * @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
  4814. * @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
  4815. * @return all child controls
  4816. */
  4817. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4818. var results = new Array();
  4819. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4820. return results;
  4821. };
  4822. /**
  4823. * Link current control with a target mesh
  4824. * @param mesh defines the mesh to link with
  4825. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4826. */
  4827. Control.prototype.linkWithMesh = function (mesh) {
  4828. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4829. if (mesh) {
  4830. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4831. }
  4832. return;
  4833. }
  4834. var index = this._host._linkedControls.indexOf(this);
  4835. if (index !== -1) {
  4836. this._linkedMesh = mesh;
  4837. if (!mesh) {
  4838. this._host._linkedControls.splice(index, 1);
  4839. }
  4840. return;
  4841. }
  4842. else if (!mesh) {
  4843. return;
  4844. }
  4845. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4846. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4847. this._linkedMesh = mesh;
  4848. this._host._linkedControls.push(this);
  4849. };
  4850. /** @hidden */
  4851. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4852. var oldLeft = this._left.getValue(this._host);
  4853. var oldTop = this._top.getValue(this._host);
  4854. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4855. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4856. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4857. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4858. newLeft = oldLeft;
  4859. }
  4860. if (Math.abs(newTop - oldTop) < 0.5) {
  4861. newTop = oldTop;
  4862. }
  4863. }
  4864. this.left = newLeft + "px";
  4865. this.top = newTop + "px";
  4866. this._left.ignoreAdaptiveScaling = true;
  4867. this._top.ignoreAdaptiveScaling = true;
  4868. this._markAsDirty();
  4869. };
  4870. /** @hidden */
  4871. Control.prototype._offsetLeft = function (offset) {
  4872. this._isDirty = true;
  4873. this._currentMeasure.left += offset;
  4874. };
  4875. /** @hidden */
  4876. Control.prototype._offsetTop = function (offset) {
  4877. this._isDirty = true;
  4878. this._currentMeasure.top += offset;
  4879. };
  4880. /** @hidden */
  4881. Control.prototype._markMatrixAsDirty = function () {
  4882. this._isMatrixDirty = true;
  4883. this._flagDescendantsAsMatrixDirty();
  4884. };
  4885. /** @hidden */
  4886. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4887. // No child
  4888. };
  4889. /** @hidden */
  4890. Control.prototype._intersectsRect = function (rect) {
  4891. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4892. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4893. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4894. return false;
  4895. }
  4896. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4897. return false;
  4898. }
  4899. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4900. return false;
  4901. }
  4902. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4903. return false;
  4904. }
  4905. return true;
  4906. };
  4907. /** @hidden */
  4908. Control.prototype.invalidateRect = function () {
  4909. this._transform();
  4910. if (this.host && this.host.useInvalidateRectOptimization) {
  4911. // Rotate by transform to get the measure transformed to global space
  4912. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4913. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4914. // the previous measure is used to properly clear a control that is scaled down
  4915. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4916. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4917. // Expand rect based on shadows
  4918. var shadowOffsetX = this.shadowOffsetX;
  4919. var shadowOffsetY = this.shadowOffsetY;
  4920. var shadowBlur = this.shadowBlur;
  4921. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4922. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4923. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4924. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4925. 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));
  4926. }
  4927. else {
  4928. 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));
  4929. }
  4930. }
  4931. };
  4932. /** @hidden */
  4933. Control.prototype._markAsDirty = function (force) {
  4934. if (force === void 0) { force = false; }
  4935. if (!this._isVisible && !force) {
  4936. return;
  4937. }
  4938. this._isDirty = true;
  4939. // Redraw only this rectangle
  4940. if (this._host) {
  4941. this._host.markAsDirty();
  4942. }
  4943. };
  4944. /** @hidden */
  4945. Control.prototype._markAllAsDirty = function () {
  4946. this._markAsDirty();
  4947. if (this._font) {
  4948. this._prepareFont();
  4949. }
  4950. };
  4951. /** @hidden */
  4952. Control.prototype._link = function (host) {
  4953. this._host = host;
  4954. if (this._host) {
  4955. this.uniqueId = this._host.getScene().getUniqueId();
  4956. }
  4957. };
  4958. /** @hidden */
  4959. Control.prototype._transform = function (context) {
  4960. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4961. return;
  4962. }
  4963. // postTranslate
  4964. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4965. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4966. if (context) {
  4967. context.translate(offsetX, offsetY);
  4968. // rotate
  4969. context.rotate(this._rotation);
  4970. // scale
  4971. context.scale(this._scaleX, this._scaleY);
  4972. // preTranslate
  4973. context.translate(-offsetX, -offsetY);
  4974. }
  4975. // Need to update matrices?
  4976. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4977. this._cachedOffsetX = offsetX;
  4978. this._cachedOffsetY = offsetY;
  4979. this._isMatrixDirty = false;
  4980. this._flagDescendantsAsMatrixDirty();
  4981. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4982. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4983. }
  4984. };
  4985. /** @hidden */
  4986. Control.prototype._renderHighlight = function (context) {
  4987. if (!this.isHighlighted) {
  4988. return;
  4989. }
  4990. context.save();
  4991. context.strokeStyle = "#4affff";
  4992. context.lineWidth = 2;
  4993. this._renderHighlightSpecific(context);
  4994. context.restore();
  4995. };
  4996. /** @hidden */
  4997. Control.prototype._renderHighlightSpecific = function (context) {
  4998. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4999. };
  5000. /** @hidden */
  5001. Control.prototype._applyStates = function (context) {
  5002. if (this._isFontSizeInPercentage) {
  5003. this._fontSet = true;
  5004. }
  5005. if (this._fontSet) {
  5006. this._prepareFont();
  5007. this._fontSet = false;
  5008. }
  5009. if (this._font) {
  5010. context.font = this._font;
  5011. }
  5012. if (this._color) {
  5013. context.fillStyle = this._color;
  5014. }
  5015. if (Control.AllowAlphaInheritance) {
  5016. context.globalAlpha *= this._alpha;
  5017. }
  5018. else if (this._alphaSet) {
  5019. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  5020. }
  5021. };
  5022. /** @hidden */
  5023. Control.prototype._layout = function (parentMeasure, context) {
  5024. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  5025. return false;
  5026. }
  5027. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  5028. this.host._numLayoutCalls++;
  5029. this._currentMeasure.addAndTransformToRef(this._transformMatrix, -this.paddingLeftInPixels | 0, -this.paddingTopInPixels | 0, this.paddingRightInPixels | 0, this.paddingBottomInPixels | 0, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  5030. context.save();
  5031. this._applyStates(context);
  5032. var rebuildCount = 0;
  5033. do {
  5034. this._rebuildLayout = false;
  5035. this._processMeasures(parentMeasure, context);
  5036. rebuildCount++;
  5037. } while (this._rebuildLayout && rebuildCount < 3);
  5038. if (rebuildCount >= 3) {
  5039. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  5040. }
  5041. context.restore();
  5042. this.invalidateRect();
  5043. this._evaluateClippingState(parentMeasure);
  5044. }
  5045. this._wasDirty = this._isDirty;
  5046. this._isDirty = false;
  5047. return true;
  5048. };
  5049. /** @hidden */
  5050. Control.prototype._processMeasures = function (parentMeasure, context) {
  5051. this._currentMeasure.copyFrom(parentMeasure);
  5052. // Let children take some pre-measurement actions
  5053. this._preMeasure(parentMeasure, context);
  5054. this._measure();
  5055. this._computeAlignment(parentMeasure, context);
  5056. // Convert to int values
  5057. this._currentMeasure.left = this._currentMeasure.left | 0;
  5058. this._currentMeasure.top = this._currentMeasure.top | 0;
  5059. this._currentMeasure.width = this._currentMeasure.width | 0;
  5060. this._currentMeasure.height = this._currentMeasure.height | 0;
  5061. // Let children add more features
  5062. this._additionalProcessing(parentMeasure, context);
  5063. this._cachedParentMeasure.copyFrom(parentMeasure);
  5064. if (this.onDirtyObservable.hasObservers()) {
  5065. this.onDirtyObservable.notifyObservers(this);
  5066. }
  5067. };
  5068. Control.prototype._evaluateClippingState = function (parentMeasure) {
  5069. if (this.parent && this.parent.clipChildren) {
  5070. // Early clip
  5071. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  5072. this._isClipped = true;
  5073. return;
  5074. }
  5075. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  5076. this._isClipped = true;
  5077. return;
  5078. }
  5079. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  5080. this._isClipped = true;
  5081. return;
  5082. }
  5083. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  5084. this._isClipped = true;
  5085. return;
  5086. }
  5087. }
  5088. this._isClipped = false;
  5089. };
  5090. /** @hidden */
  5091. Control.prototype._measure = function () {
  5092. // Width / Height
  5093. if (this._width.isPixel) {
  5094. this._currentMeasure.width = this._width.getValue(this._host);
  5095. }
  5096. else {
  5097. this._currentMeasure.width *= this._width.getValue(this._host);
  5098. }
  5099. if (this._height.isPixel) {
  5100. this._currentMeasure.height = this._height.getValue(this._host);
  5101. }
  5102. else {
  5103. this._currentMeasure.height *= this._height.getValue(this._host);
  5104. }
  5105. if (this.fixedRatio !== 0) {
  5106. if (this._fixedRatioMasterIsWidth) {
  5107. this._currentMeasure.height = this._currentMeasure.width * this.fixedRatio;
  5108. }
  5109. else {
  5110. this._currentMeasure.width = this._currentMeasure.height * this.fixedRatio;
  5111. }
  5112. }
  5113. };
  5114. /** @hidden */
  5115. Control.prototype._computeAlignment = function (parentMeasure, context) {
  5116. var width = this._currentMeasure.width;
  5117. var height = this._currentMeasure.height;
  5118. var parentWidth = parentMeasure.width;
  5119. var parentHeight = parentMeasure.height;
  5120. // Left / top
  5121. var x = 0;
  5122. var y = 0;
  5123. switch (this.horizontalAlignment) {
  5124. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  5125. x = 0;
  5126. break;
  5127. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  5128. x = parentWidth - width;
  5129. break;
  5130. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  5131. x = (parentWidth - width) / 2;
  5132. break;
  5133. }
  5134. switch (this.verticalAlignment) {
  5135. case Control.VERTICAL_ALIGNMENT_TOP:
  5136. y = 0;
  5137. break;
  5138. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5139. y = parentHeight - height;
  5140. break;
  5141. case Control.VERTICAL_ALIGNMENT_CENTER:
  5142. y = (parentHeight - height) / 2;
  5143. break;
  5144. }
  5145. if (this._paddingLeft.isPixel) {
  5146. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5147. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5148. }
  5149. else {
  5150. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5151. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5152. }
  5153. if (this._paddingRight.isPixel) {
  5154. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5155. }
  5156. else {
  5157. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5158. }
  5159. if (this._paddingTop.isPixel) {
  5160. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5161. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5162. }
  5163. else {
  5164. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5165. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5166. }
  5167. if (this._paddingBottom.isPixel) {
  5168. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5169. }
  5170. else {
  5171. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5172. }
  5173. if (this._left.isPixel) {
  5174. this._currentMeasure.left += this._left.getValue(this._host);
  5175. }
  5176. else {
  5177. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5178. }
  5179. if (this._top.isPixel) {
  5180. this._currentMeasure.top += this._top.getValue(this._host);
  5181. }
  5182. else {
  5183. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5184. }
  5185. this._currentMeasure.left += x;
  5186. this._currentMeasure.top += y;
  5187. };
  5188. /** @hidden */
  5189. Control.prototype._preMeasure = function (parentMeasure, context) {
  5190. // Do nothing
  5191. };
  5192. /** @hidden */
  5193. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5194. // Do nothing
  5195. };
  5196. /** @hidden */
  5197. Control.prototype._clipForChildren = function (context) {
  5198. // DO nothing
  5199. };
  5200. Control.prototype._clip = function (context, invalidatedRectangle) {
  5201. context.beginPath();
  5202. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5203. if (invalidatedRectangle) {
  5204. // Rotate the invalidated rect into the control's space
  5205. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5206. // Get the intersection of the rect in context space and the current context
  5207. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5208. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5209. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5210. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5211. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5212. Control._ClipMeasure.copyFrom(intersection);
  5213. }
  5214. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5215. var shadowOffsetX = this.shadowOffsetX;
  5216. var shadowOffsetY = this.shadowOffsetY;
  5217. var shadowBlur = this.shadowBlur;
  5218. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5219. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5220. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5221. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5222. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5223. }
  5224. else {
  5225. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5226. }
  5227. context.clip();
  5228. };
  5229. /** @hidden */
  5230. Control.prototype._render = function (context, invalidatedRectangle) {
  5231. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5232. this._isDirty = false;
  5233. return false;
  5234. }
  5235. this.host._numRenderCalls++;
  5236. context.save();
  5237. this._applyStates(context);
  5238. // Transform
  5239. this._transform(context);
  5240. // Clip
  5241. if (this.clipContent) {
  5242. this._clip(context, invalidatedRectangle);
  5243. }
  5244. if (this.onBeforeDrawObservable.hasObservers()) {
  5245. this.onBeforeDrawObservable.notifyObservers(this);
  5246. }
  5247. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5248. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5249. }
  5250. else {
  5251. this._draw(context, invalidatedRectangle);
  5252. }
  5253. if (this.useBitmapCache && this._wasDirty) {
  5254. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5255. }
  5256. this._renderHighlight(context);
  5257. if (this.onAfterDrawObservable.hasObservers()) {
  5258. this.onAfterDrawObservable.notifyObservers(this);
  5259. }
  5260. context.restore();
  5261. return true;
  5262. };
  5263. /** @hidden */
  5264. Control.prototype._draw = function (context, invalidatedRectangle) {
  5265. // Do nothing
  5266. };
  5267. /**
  5268. * Tests if a given coordinates belong to the current control
  5269. * @param x defines x coordinate to test
  5270. * @param y defines y coordinate to test
  5271. * @returns true if the coordinates are inside the control
  5272. */
  5273. Control.prototype.contains = function (x, y) {
  5274. // Invert transform
  5275. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5276. x = this._transformedPosition.x;
  5277. y = this._transformedPosition.y;
  5278. // Check
  5279. if (x < this._currentMeasure.left) {
  5280. return false;
  5281. }
  5282. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5283. return false;
  5284. }
  5285. if (y < this._currentMeasure.top) {
  5286. return false;
  5287. }
  5288. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5289. return false;
  5290. }
  5291. if (this.isPointerBlocker) {
  5292. this._host._shouldBlockPointer = true;
  5293. }
  5294. return true;
  5295. };
  5296. /** @hidden */
  5297. Control.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  5298. if (!this._isEnabled) {
  5299. return false;
  5300. }
  5301. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5302. return false;
  5303. }
  5304. if (!this.contains(x, y)) {
  5305. return false;
  5306. }
  5307. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  5308. return true;
  5309. };
  5310. /** @hidden */
  5311. Control.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  5312. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this, pi);
  5313. if (canNotify && this.parent != null) {
  5314. this.parent._onPointerMove(target, coordinates, pointerId, pi);
  5315. }
  5316. };
  5317. /** @hidden */
  5318. Control.prototype._onPointerEnter = function (target, pi) {
  5319. if (!this._isEnabled) {
  5320. return false;
  5321. }
  5322. if (this._enterCount > 0) {
  5323. return false;
  5324. }
  5325. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5326. this._enterCount = 0;
  5327. }
  5328. this._enterCount++;
  5329. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this, pi);
  5330. if (canNotify && this.parent != null) {
  5331. this.parent._onPointerEnter(target, pi);
  5332. }
  5333. return true;
  5334. };
  5335. /** @hidden */
  5336. Control.prototype._onPointerOut = function (target, pi, force) {
  5337. if (force === void 0) { force = false; }
  5338. if (!force && (!this._isEnabled || target === this)) {
  5339. return;
  5340. }
  5341. this._enterCount = 0;
  5342. var canNotify = true;
  5343. if (!target.isAscendant(this)) {
  5344. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this, pi);
  5345. }
  5346. if (canNotify && this.parent != null) {
  5347. this.parent._onPointerOut(target, pi, force);
  5348. }
  5349. };
  5350. /** @hidden */
  5351. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  5352. // Prevent pointerout to lose control context.
  5353. // Event redundancy is checked inside the function.
  5354. this._onPointerEnter(this, pi);
  5355. if (this._downCount !== 0) {
  5356. return false;
  5357. }
  5358. this._downCount++;
  5359. this._downPointerIds[pointerId] = true;
  5360. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5361. if (canNotify && this.parent != null) {
  5362. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);
  5363. }
  5364. return true;
  5365. };
  5366. /** @hidden */
  5367. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  5368. if (!this._isEnabled) {
  5369. return;
  5370. }
  5371. this._downCount = 0;
  5372. delete this._downPointerIds[pointerId];
  5373. var canNotifyClick = notifyClick;
  5374. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5375. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5376. }
  5377. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5378. if (canNotify && this.parent != null) {
  5379. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick, pi);
  5380. }
  5381. };
  5382. /** @hidden */
  5383. Control.prototype._forcePointerUp = function (pointerId) {
  5384. if (pointerId === void 0) { pointerId = null; }
  5385. if (pointerId !== null) {
  5386. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5387. }
  5388. else {
  5389. for (var key in this._downPointerIds) {
  5390. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5391. }
  5392. }
  5393. };
  5394. /** @hidden */
  5395. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5396. if (!this._isEnabled) {
  5397. return;
  5398. }
  5399. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"](deltaX, deltaY));
  5400. if (canNotify && this.parent != null) {
  5401. this.parent._onWheelScroll(deltaX, deltaY);
  5402. }
  5403. };
  5404. /** @hidden */
  5405. Control.prototype._onCanvasBlur = function () { };
  5406. /** @hidden */
  5407. Control.prototype._processObservables = function (type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY) {
  5408. if (!this._isEnabled) {
  5409. return false;
  5410. }
  5411. this._dummyVector2.copyFromFloats(x, y);
  5412. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5413. this._onPointerMove(this, this._dummyVector2, pointerId, pi);
  5414. var previousControlOver = this._host._lastControlOver[pointerId];
  5415. if (previousControlOver && previousControlOver !== this) {
  5416. previousControlOver._onPointerOut(this, pi);
  5417. }
  5418. if (previousControlOver !== this) {
  5419. this._onPointerEnter(this, pi);
  5420. }
  5421. this._host._lastControlOver[pointerId] = this;
  5422. return true;
  5423. }
  5424. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5425. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex, pi);
  5426. this._host._registerLastControlDown(this, pointerId);
  5427. this._host._lastPickedControl = this;
  5428. return true;
  5429. }
  5430. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5431. if (this._host._lastControlDown[pointerId]) {
  5432. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true, pi);
  5433. }
  5434. delete this._host._lastControlDown[pointerId];
  5435. return true;
  5436. }
  5437. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL) {
  5438. if (this._host._lastControlOver[pointerId]) {
  5439. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5440. return true;
  5441. }
  5442. }
  5443. return false;
  5444. };
  5445. Control.prototype._prepareFont = function () {
  5446. if (!this._font && !this._fontSet) {
  5447. return;
  5448. }
  5449. if (this._style) {
  5450. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5451. }
  5452. else {
  5453. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5454. }
  5455. this._fontOffset = Control._GetFontOffset(this._font);
  5456. };
  5457. /** Releases associated resources */
  5458. Control.prototype.dispose = function () {
  5459. this.onDirtyObservable.clear();
  5460. this.onBeforeDrawObservable.clear();
  5461. this.onAfterDrawObservable.clear();
  5462. this.onPointerDownObservable.clear();
  5463. this.onPointerEnterObservable.clear();
  5464. this.onPointerMoveObservable.clear();
  5465. this.onPointerOutObservable.clear();
  5466. this.onPointerUpObservable.clear();
  5467. this.onPointerClickObservable.clear();
  5468. this.onWheelObservable.clear();
  5469. if (this._styleObserver && this._style) {
  5470. this._style.onChangedObservable.remove(this._styleObserver);
  5471. this._styleObserver = null;
  5472. }
  5473. if (this.parent) {
  5474. this.parent.removeControl(this);
  5475. this.parent = null;
  5476. }
  5477. if (this._host) {
  5478. var index = this._host._linkedControls.indexOf(this);
  5479. if (index > -1) {
  5480. this.linkWithMesh(null);
  5481. }
  5482. }
  5483. // Callback
  5484. this.onDisposeObservable.notifyObservers(this);
  5485. this.onDisposeObservable.clear();
  5486. };
  5487. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5488. /** HORIZONTAL_ALIGNMENT_LEFT */
  5489. get: function () {
  5490. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5491. },
  5492. enumerable: false,
  5493. configurable: true
  5494. });
  5495. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5496. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5497. get: function () {
  5498. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5499. },
  5500. enumerable: false,
  5501. configurable: true
  5502. });
  5503. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5504. /** HORIZONTAL_ALIGNMENT_CENTER */
  5505. get: function () {
  5506. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5507. },
  5508. enumerable: false,
  5509. configurable: true
  5510. });
  5511. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5512. /** VERTICAL_ALIGNMENT_TOP */
  5513. get: function () {
  5514. return Control._VERTICAL_ALIGNMENT_TOP;
  5515. },
  5516. enumerable: false,
  5517. configurable: true
  5518. });
  5519. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5520. /** VERTICAL_ALIGNMENT_BOTTOM */
  5521. get: function () {
  5522. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5523. },
  5524. enumerable: false,
  5525. configurable: true
  5526. });
  5527. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5528. /** VERTICAL_ALIGNMENT_CENTER */
  5529. get: function () {
  5530. return Control._VERTICAL_ALIGNMENT_CENTER;
  5531. },
  5532. enumerable: false,
  5533. configurable: true
  5534. });
  5535. /** @hidden */
  5536. Control._GetFontOffset = function (font) {
  5537. if (Control._FontHeightSizes[font]) {
  5538. return Control._FontHeightSizes[font];
  5539. }
  5540. var text = document.createElement("span");
  5541. text.innerHTML = "Hg";
  5542. text.style.font = font;
  5543. var block = document.createElement("div");
  5544. block.style.display = "inline-block";
  5545. block.style.width = "1px";
  5546. block.style.height = "0px";
  5547. block.style.verticalAlign = "bottom";
  5548. var div = document.createElement("div");
  5549. div.style.whiteSpace = "nowrap";
  5550. div.appendChild(text);
  5551. div.appendChild(block);
  5552. document.body.appendChild(div);
  5553. var fontAscent = 0;
  5554. var fontHeight = 0;
  5555. try {
  5556. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5557. block.style.verticalAlign = "baseline";
  5558. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5559. }
  5560. finally {
  5561. document.body.removeChild(div);
  5562. }
  5563. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5564. Control._FontHeightSizes[font] = result;
  5565. return result;
  5566. };
  5567. /** @hidden */
  5568. Control.drawEllipse = function (x, y, width, height, context) {
  5569. context.translate(x, y);
  5570. context.scale(width, height);
  5571. context.beginPath();
  5572. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5573. context.closePath();
  5574. context.scale(1 / width, 1 / height);
  5575. context.translate(-x, -y);
  5576. };
  5577. /**
  5578. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5579. */
  5580. Control.AllowAlphaInheritance = false;
  5581. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5582. // Statics
  5583. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5584. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5585. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5586. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5587. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5588. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5589. Control._FontHeightSizes = {};
  5590. /**
  5591. * Creates a stack panel that can be used to render headers
  5592. * @param control defines the control to associate with the header
  5593. * @param text defines the text of the header
  5594. * @param size defines the size of the header
  5595. * @param options defines options used to configure the header
  5596. * @returns a new StackPanel
  5597. * @ignore
  5598. * @hidden
  5599. */
  5600. Control.AddHeader = function () { };
  5601. return Control;
  5602. }());
  5603. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5604. /***/ }),
  5605. /***/ "./2D/controls/displayGrid.ts":
  5606. /*!************************************!*\
  5607. !*** ./2D/controls/displayGrid.ts ***!
  5608. \************************************/
  5609. /*! exports provided: DisplayGrid */
  5610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5611. "use strict";
  5612. __webpack_require__.r(__webpack_exports__);
  5613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5614. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5615. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5616. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  5617. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5618. /** Class used to render a grid */
  5619. var DisplayGrid = /** @class */ (function (_super) {
  5620. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5621. /**
  5622. * Creates a new GridDisplayRectangle
  5623. * @param name defines the control name
  5624. */
  5625. function DisplayGrid(name) {
  5626. var _this = _super.call(this, name) || this;
  5627. _this.name = name;
  5628. _this._cellWidth = 20;
  5629. _this._cellHeight = 20;
  5630. _this._minorLineTickness = 1;
  5631. _this._minorLineColor = "DarkGray";
  5632. _this._majorLineTickness = 2;
  5633. _this._majorLineColor = "White";
  5634. _this._majorLineFrequency = 5;
  5635. _this._background = "Black";
  5636. _this._displayMajorLines = true;
  5637. _this._displayMinorLines = true;
  5638. return _this;
  5639. }
  5640. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5641. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5642. get: function () {
  5643. return this._displayMinorLines;
  5644. },
  5645. set: function (value) {
  5646. if (this._displayMinorLines === value) {
  5647. return;
  5648. }
  5649. this._displayMinorLines = value;
  5650. this._markAsDirty();
  5651. },
  5652. enumerable: false,
  5653. configurable: true
  5654. });
  5655. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5656. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5657. get: function () {
  5658. return this._displayMajorLines;
  5659. },
  5660. set: function (value) {
  5661. if (this._displayMajorLines === value) {
  5662. return;
  5663. }
  5664. this._displayMajorLines = value;
  5665. this._markAsDirty();
  5666. },
  5667. enumerable: false,
  5668. configurable: true
  5669. });
  5670. Object.defineProperty(DisplayGrid.prototype, "background", {
  5671. /** Gets or sets background color (Black by default) */
  5672. get: function () {
  5673. return this._background;
  5674. },
  5675. set: function (value) {
  5676. if (this._background === value) {
  5677. return;
  5678. }
  5679. this._background = value;
  5680. this._markAsDirty();
  5681. },
  5682. enumerable: false,
  5683. configurable: true
  5684. });
  5685. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5686. /** Gets or sets the width of each cell (20 by default) */
  5687. get: function () {
  5688. return this._cellWidth;
  5689. },
  5690. set: function (value) {
  5691. this._cellWidth = value;
  5692. this._markAsDirty();
  5693. },
  5694. enumerable: false,
  5695. configurable: true
  5696. });
  5697. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5698. /** Gets or sets the height of each cell (20 by default) */
  5699. get: function () {
  5700. return this._cellHeight;
  5701. },
  5702. set: function (value) {
  5703. this._cellHeight = value;
  5704. this._markAsDirty();
  5705. },
  5706. enumerable: false,
  5707. configurable: true
  5708. });
  5709. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5710. /** Gets or sets the tickness of minor lines (1 by default) */
  5711. get: function () {
  5712. return this._minorLineTickness;
  5713. },
  5714. set: function (value) {
  5715. this._minorLineTickness = value;
  5716. this._markAsDirty();
  5717. },
  5718. enumerable: false,
  5719. configurable: true
  5720. });
  5721. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5722. /** Gets or sets the color of minor lines (DarkGray by default) */
  5723. get: function () {
  5724. return this._minorLineColor;
  5725. },
  5726. set: function (value) {
  5727. this._minorLineColor = value;
  5728. this._markAsDirty();
  5729. },
  5730. enumerable: false,
  5731. configurable: true
  5732. });
  5733. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5734. /** Gets or sets the tickness of major lines (2 by default) */
  5735. get: function () {
  5736. return this._majorLineTickness;
  5737. },
  5738. set: function (value) {
  5739. this._majorLineTickness = value;
  5740. this._markAsDirty();
  5741. },
  5742. enumerable: false,
  5743. configurable: true
  5744. });
  5745. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5746. /** Gets or sets the color of major lines (White by default) */
  5747. get: function () {
  5748. return this._majorLineColor;
  5749. },
  5750. set: function (value) {
  5751. this._majorLineColor = value;
  5752. this._markAsDirty();
  5753. },
  5754. enumerable: false,
  5755. configurable: true
  5756. });
  5757. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5758. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5759. get: function () {
  5760. return this._majorLineFrequency;
  5761. },
  5762. set: function (value) {
  5763. this._majorLineFrequency = value;
  5764. this._markAsDirty();
  5765. },
  5766. enumerable: false,
  5767. configurable: true
  5768. });
  5769. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5770. context.save();
  5771. this._applyStates(context);
  5772. if (this._isEnabled) {
  5773. if (this._background) {
  5774. context.fillStyle = this._background;
  5775. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5776. }
  5777. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5778. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5779. // Minor lines
  5780. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5781. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5782. if (this._displayMinorLines) {
  5783. context.strokeStyle = this._minorLineColor;
  5784. context.lineWidth = this._minorLineTickness;
  5785. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5786. var cellX = left + x * this.cellWidth;
  5787. context.beginPath();
  5788. context.moveTo(cellX, this._currentMeasure.top);
  5789. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5790. context.stroke();
  5791. }
  5792. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5793. var cellY = top_1 + y * this.cellHeight;
  5794. context.beginPath();
  5795. context.moveTo(this._currentMeasure.left, cellY);
  5796. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5797. context.stroke();
  5798. }
  5799. }
  5800. // Major lines
  5801. if (this._displayMajorLines) {
  5802. context.strokeStyle = this._majorLineColor;
  5803. context.lineWidth = this._majorLineTickness;
  5804. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5805. var cellX = left + x * this.cellWidth;
  5806. context.beginPath();
  5807. context.moveTo(cellX, this._currentMeasure.top);
  5808. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5809. context.stroke();
  5810. }
  5811. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5812. var cellY = top_1 + y * this.cellHeight;
  5813. context.moveTo(this._currentMeasure.left, cellY);
  5814. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5815. context.closePath();
  5816. context.stroke();
  5817. }
  5818. }
  5819. }
  5820. context.restore();
  5821. };
  5822. DisplayGrid.prototype._getTypeName = function () {
  5823. return "DisplayGrid";
  5824. };
  5825. return DisplayGrid;
  5826. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5827. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5828. /***/ }),
  5829. /***/ "./2D/controls/ellipse.ts":
  5830. /*!********************************!*\
  5831. !*** ./2D/controls/ellipse.ts ***!
  5832. \********************************/
  5833. /*! exports provided: Ellipse */
  5834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5835. "use strict";
  5836. __webpack_require__.r(__webpack_exports__);
  5837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5838. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5839. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5840. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5841. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  5842. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5843. /** Class used to create 2D ellipse containers */
  5844. var Ellipse = /** @class */ (function (_super) {
  5845. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5846. /**
  5847. * Creates a new Ellipse
  5848. * @param name defines the control name
  5849. */
  5850. function Ellipse(name) {
  5851. var _this = _super.call(this, name) || this;
  5852. _this.name = name;
  5853. _this._thickness = 1;
  5854. return _this;
  5855. }
  5856. Object.defineProperty(Ellipse.prototype, "thickness", {
  5857. /** Gets or sets border thickness */
  5858. get: function () {
  5859. return this._thickness;
  5860. },
  5861. set: function (value) {
  5862. if (this._thickness === value) {
  5863. return;
  5864. }
  5865. this._thickness = value;
  5866. this._markAsDirty();
  5867. },
  5868. enumerable: false,
  5869. configurable: true
  5870. });
  5871. Ellipse.prototype._getTypeName = function () {
  5872. return "Ellipse";
  5873. };
  5874. Ellipse.prototype._localDraw = function (context) {
  5875. context.save();
  5876. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5877. context.shadowColor = this.shadowColor;
  5878. context.shadowBlur = this.shadowBlur;
  5879. context.shadowOffsetX = this.shadowOffsetX;
  5880. context.shadowOffsetY = this.shadowOffsetY;
  5881. }
  5882. _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);
  5883. if (this._background) {
  5884. context.fillStyle = this._background;
  5885. context.fill();
  5886. }
  5887. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5888. context.shadowBlur = 0;
  5889. context.shadowOffsetX = 0;
  5890. context.shadowOffsetY = 0;
  5891. }
  5892. if (this._thickness) {
  5893. if (this.color) {
  5894. context.strokeStyle = this.color;
  5895. }
  5896. context.lineWidth = this._thickness;
  5897. context.stroke();
  5898. }
  5899. context.restore();
  5900. };
  5901. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5902. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5903. this._measureForChildren.width -= 2 * this._thickness;
  5904. this._measureForChildren.height -= 2 * this._thickness;
  5905. this._measureForChildren.left += this._thickness;
  5906. this._measureForChildren.top += this._thickness;
  5907. };
  5908. Ellipse.prototype._clipForChildren = function (context) {
  5909. _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);
  5910. context.clip();
  5911. };
  5912. return Ellipse;
  5913. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5914. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5915. /***/ }),
  5916. /***/ "./2D/controls/focusableButton.ts":
  5917. /*!****************************************!*\
  5918. !*** ./2D/controls/focusableButton.ts ***!
  5919. \****************************************/
  5920. /*! exports provided: FocusableButton */
  5921. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5922. "use strict";
  5923. __webpack_require__.r(__webpack_exports__);
  5924. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return FocusableButton; });
  5925. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5926. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  5927. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  5928. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5929. /**
  5930. * Class used to create a focusable button that can easily handle keyboard events
  5931. */
  5932. var FocusableButton = /** @class */ (function (_super) {
  5933. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FocusableButton, _super);
  5934. function FocusableButton(name) {
  5935. var _this = _super.call(this, name) || this;
  5936. _this.name = name;
  5937. /** Highlight color when button is focused */
  5938. _this.focusedColor = null;
  5939. _this._isFocused = false;
  5940. _this._unfocusedColor = null;
  5941. /** Observable raised when the control gets the focus */
  5942. _this.onFocusObservable = new babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  5943. /** Observable raised when the control loses the focus */
  5944. _this.onBlurObservable = new babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  5945. /** Observable raised when a key event was processed */
  5946. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  5947. _this._unfocusedColor = _this.color;
  5948. return _this;
  5949. }
  5950. /** @hidden */
  5951. FocusableButton.prototype.onBlur = function () {
  5952. if (this._isFocused) {
  5953. this._isFocused = false;
  5954. if (this.focusedColor && this._unfocusedColor != null) {
  5955. // Set color back to saved unfocused color
  5956. this.color = this._unfocusedColor;
  5957. }
  5958. this.onBlurObservable.notifyObservers(this);
  5959. }
  5960. };
  5961. /** @hidden */
  5962. FocusableButton.prototype.onFocus = function () {
  5963. this._isFocused = true;
  5964. if (this.focusedColor) {
  5965. // Save the unfocused color
  5966. this._unfocusedColor = this.color;
  5967. this.color = this.focusedColor;
  5968. }
  5969. this.onFocusObservable.notifyObservers(this);
  5970. };
  5971. /**
  5972. * Function called to get the list of controls that should not steal the focus from this control
  5973. * @returns an array of controls
  5974. */
  5975. FocusableButton.prototype.keepsFocusWith = function () {
  5976. return null;
  5977. };
  5978. /**
  5979. * Function to focus a button programmatically
  5980. */
  5981. FocusableButton.prototype.focus = function () {
  5982. this._host.moveFocusToControl(this);
  5983. };
  5984. /**
  5985. * Function to unfocus a button programmatically
  5986. */
  5987. FocusableButton.prototype.blur = function () {
  5988. this._host.focusedControl = null;
  5989. };
  5990. /**
  5991. * Handles the keyboard event
  5992. * @param evt Defines the KeyboardEvent
  5993. */
  5994. FocusableButton.prototype.processKeyboard = function (evt) {
  5995. this.onKeyboardEventProcessedObservable.notifyObservers(evt, -1, this);
  5996. };
  5997. /** @hidden */
  5998. FocusableButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  5999. // Clicking on button should focus
  6000. this.focus();
  6001. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  6002. };
  6003. /** @hidden */
  6004. FocusableButton.prototype.displose = function () {
  6005. _super.prototype.dispose.call(this);
  6006. this.onBlurObservable.clear();
  6007. this.onFocusObservable.clear();
  6008. this.onKeyboardEventProcessedObservable.clear();
  6009. };
  6010. return FocusableButton;
  6011. }(_button__WEBPACK_IMPORTED_MODULE_1__["Button"]));
  6012. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FocusableButton"] = FocusableButton;
  6013. /***/ }),
  6014. /***/ "./2D/controls/grid.ts":
  6015. /*!*****************************!*\
  6016. !*** ./2D/controls/grid.ts ***!
  6017. \*****************************/
  6018. /*! exports provided: Grid */
  6019. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6020. "use strict";
  6021. __webpack_require__.r(__webpack_exports__);
  6022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  6023. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6024. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6025. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6026. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6027. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  6028. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  6029. /**
  6030. * Class used to create a 2D grid container
  6031. */
  6032. var Grid = /** @class */ (function (_super) {
  6033. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  6034. /**
  6035. * Creates a new Grid
  6036. * @param name defines control name
  6037. */
  6038. function Grid(name) {
  6039. var _this = _super.call(this, name) || this;
  6040. _this.name = name;
  6041. _this._rowDefinitions = new Array();
  6042. _this._columnDefinitions = new Array();
  6043. _this._cells = {};
  6044. _this._childControls = new Array();
  6045. return _this;
  6046. }
  6047. Object.defineProperty(Grid.prototype, "columnCount", {
  6048. /**
  6049. * Gets the number of columns
  6050. */
  6051. get: function () {
  6052. return this._columnDefinitions.length;
  6053. },
  6054. enumerable: false,
  6055. configurable: true
  6056. });
  6057. Object.defineProperty(Grid.prototype, "rowCount", {
  6058. /**
  6059. * Gets the number of rows
  6060. */
  6061. get: function () {
  6062. return this._rowDefinitions.length;
  6063. },
  6064. enumerable: false,
  6065. configurable: true
  6066. });
  6067. Object.defineProperty(Grid.prototype, "children", {
  6068. /** Gets the list of children */
  6069. get: function () {
  6070. return this._childControls;
  6071. },
  6072. enumerable: false,
  6073. configurable: true
  6074. });
  6075. Object.defineProperty(Grid.prototype, "cells", {
  6076. /** Gets the list of cells (e.g. the containers) */
  6077. get: function () {
  6078. return this._cells;
  6079. },
  6080. enumerable: false,
  6081. configurable: true
  6082. });
  6083. /**
  6084. * Gets the definition of a specific row
  6085. * @param index defines the index of the row
  6086. * @returns the row definition
  6087. */
  6088. Grid.prototype.getRowDefinition = function (index) {
  6089. if (index < 0 || index >= this._rowDefinitions.length) {
  6090. return null;
  6091. }
  6092. return this._rowDefinitions[index];
  6093. };
  6094. /**
  6095. * Gets the definition of a specific column
  6096. * @param index defines the index of the column
  6097. * @returns the column definition
  6098. */
  6099. Grid.prototype.getColumnDefinition = function (index) {
  6100. if (index < 0 || index >= this._columnDefinitions.length) {
  6101. return null;
  6102. }
  6103. return this._columnDefinitions[index];
  6104. };
  6105. /**
  6106. * Adds a new row to the grid
  6107. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  6108. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  6109. * @returns the current grid
  6110. */
  6111. Grid.prototype.addRowDefinition = function (height, isPixel) {
  6112. if (isPixel === void 0) { isPixel = false; }
  6113. 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));
  6114. this._markAsDirty();
  6115. return this;
  6116. };
  6117. /**
  6118. * Adds a new column to the grid
  6119. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6120. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6121. * @returns the current grid
  6122. */
  6123. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  6124. if (isPixel === void 0) { isPixel = false; }
  6125. 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));
  6126. this._markAsDirty();
  6127. return this;
  6128. };
  6129. /**
  6130. * Update a row definition
  6131. * @param index defines the index of the row to update
  6132. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  6133. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  6134. * @returns the current grid
  6135. */
  6136. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  6137. if (isPixel === void 0) { isPixel = false; }
  6138. if (index < 0 || index >= this._rowDefinitions.length) {
  6139. return this;
  6140. }
  6141. var current = this._rowDefinitions[index];
  6142. if (current && current.isPixel === isPixel && current.internalValue === height) {
  6143. return this;
  6144. }
  6145. 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);
  6146. this._markAsDirty();
  6147. return this;
  6148. };
  6149. /**
  6150. * Update a column definition
  6151. * @param index defines the index of the column to update
  6152. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6153. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6154. * @returns the current grid
  6155. */
  6156. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  6157. if (isPixel === void 0) { isPixel = false; }
  6158. if (index < 0 || index >= this._columnDefinitions.length) {
  6159. return this;
  6160. }
  6161. var current = this._columnDefinitions[index];
  6162. if (current && current.isPixel === isPixel && current.internalValue === width) {
  6163. return this;
  6164. }
  6165. 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);
  6166. this._markAsDirty();
  6167. return this;
  6168. };
  6169. /**
  6170. * Gets the list of children stored in a specific cell
  6171. * @param row defines the row to check
  6172. * @param column defines the column to check
  6173. * @returns the list of controls
  6174. */
  6175. Grid.prototype.getChildrenAt = function (row, column) {
  6176. var cell = this._cells[row + ":" + column];
  6177. if (!cell) {
  6178. return null;
  6179. }
  6180. return cell.children;
  6181. };
  6182. /**
  6183. * Gets a string representing the child cell info (row x column)
  6184. * @param child defines the control to get info from
  6185. * @returns a string containing the child cell info (row x column)
  6186. */
  6187. Grid.prototype.getChildCellInfo = function (child) {
  6188. return child._tag;
  6189. };
  6190. Grid.prototype._removeCell = function (cell, key) {
  6191. if (!cell) {
  6192. return;
  6193. }
  6194. _super.prototype.removeControl.call(this, cell);
  6195. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  6196. var control = _a[_i];
  6197. var childIndex = this._childControls.indexOf(control);
  6198. if (childIndex !== -1) {
  6199. this._childControls.splice(childIndex, 1);
  6200. }
  6201. }
  6202. delete this._cells[key];
  6203. };
  6204. Grid.prototype._offsetCell = function (previousKey, key) {
  6205. if (!this._cells[key]) {
  6206. return;
  6207. }
  6208. this._cells[previousKey] = this._cells[key];
  6209. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  6210. var control = _a[_i];
  6211. control._tag = previousKey;
  6212. }
  6213. delete this._cells[key];
  6214. };
  6215. /**
  6216. * Remove a column definition at specified index
  6217. * @param index defines the index of the column to remove
  6218. * @returns the current grid
  6219. */
  6220. Grid.prototype.removeColumnDefinition = function (index) {
  6221. if (index < 0 || index >= this._columnDefinitions.length) {
  6222. return this;
  6223. }
  6224. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6225. var key = x + ":" + index;
  6226. var cell = this._cells[key];
  6227. this._removeCell(cell, key);
  6228. }
  6229. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6230. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6231. var previousKey = x + ":" + (y - 1);
  6232. var key = x + ":" + y;
  6233. this._offsetCell(previousKey, key);
  6234. }
  6235. }
  6236. this._columnDefinitions.splice(index, 1);
  6237. this._markAsDirty();
  6238. return this;
  6239. };
  6240. /**
  6241. * Remove a row definition at specified index
  6242. * @param index defines the index of the row to remove
  6243. * @returns the current grid
  6244. */
  6245. Grid.prototype.removeRowDefinition = function (index) {
  6246. if (index < 0 || index >= this._rowDefinitions.length) {
  6247. return this;
  6248. }
  6249. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6250. var key = index + ":" + y;
  6251. var cell = this._cells[key];
  6252. this._removeCell(cell, key);
  6253. }
  6254. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6255. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6256. var previousKey = x - 1 + ":" + y;
  6257. var key = x + ":" + y;
  6258. this._offsetCell(previousKey, key);
  6259. }
  6260. }
  6261. this._rowDefinitions.splice(index, 1);
  6262. this._markAsDirty();
  6263. return this;
  6264. };
  6265. /**
  6266. * Adds a new control to the current grid
  6267. * @param control defines the control to add
  6268. * @param row defines the row where to add the control (0 by default)
  6269. * @param column defines the column where to add the control (0 by default)
  6270. * @returns the current grid
  6271. */
  6272. Grid.prototype.addControl = function (control, row, column) {
  6273. if (row === void 0) { row = 0; }
  6274. if (column === void 0) { column = 0; }
  6275. if (this._rowDefinitions.length === 0) {
  6276. // Add default row definition
  6277. this.addRowDefinition(1, false);
  6278. }
  6279. if (this._columnDefinitions.length === 0) {
  6280. // Add default column definition
  6281. this.addColumnDefinition(1, false);
  6282. }
  6283. if (this._childControls.indexOf(control) !== -1) {
  6284. 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");
  6285. return this;
  6286. }
  6287. var x = Math.min(row, this._rowDefinitions.length - 1);
  6288. var y = Math.min(column, this._columnDefinitions.length - 1);
  6289. var key = x + ":" + y;
  6290. var goodContainer = this._cells[key];
  6291. if (!goodContainer) {
  6292. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6293. this._cells[key] = goodContainer;
  6294. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6295. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6296. _super.prototype.addControl.call(this, goodContainer);
  6297. }
  6298. goodContainer.addControl(control);
  6299. this._childControls.push(control);
  6300. control._tag = key;
  6301. control.parent = this;
  6302. this._markAsDirty();
  6303. return this;
  6304. };
  6305. /**
  6306. * Removes a control from the current container
  6307. * @param control defines the control to remove
  6308. * @returns the current container
  6309. */
  6310. Grid.prototype.removeControl = function (control) {
  6311. var index = this._childControls.indexOf(control);
  6312. if (index !== -1) {
  6313. this._childControls.splice(index, 1);
  6314. }
  6315. var cell = this._cells[control._tag];
  6316. if (cell) {
  6317. cell.removeControl(control);
  6318. control._tag = null;
  6319. }
  6320. this._markAsDirty();
  6321. return this;
  6322. };
  6323. Grid.prototype._getTypeName = function () {
  6324. return "Grid";
  6325. };
  6326. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6327. var widths = [];
  6328. var heights = [];
  6329. var lefts = [];
  6330. var tops = [];
  6331. var availableWidth = this._currentMeasure.width;
  6332. var globalWidthPercentage = 0;
  6333. var availableHeight = this._currentMeasure.height;
  6334. var globalHeightPercentage = 0;
  6335. // Heights
  6336. var index = 0;
  6337. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6338. var value = _a[_i];
  6339. if (value.isPixel) {
  6340. var height = value.getValue(this._host);
  6341. availableHeight -= height;
  6342. heights[index] = height;
  6343. }
  6344. else {
  6345. globalHeightPercentage += value.internalValue;
  6346. }
  6347. index++;
  6348. }
  6349. var top = 0;
  6350. index = 0;
  6351. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6352. var value = _c[_b];
  6353. tops.push(top);
  6354. if (!value.isPixel) {
  6355. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6356. top += height;
  6357. heights[index] = height;
  6358. }
  6359. else {
  6360. top += value.getValue(this._host);
  6361. }
  6362. index++;
  6363. }
  6364. // Widths
  6365. index = 0;
  6366. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6367. var value = _e[_d];
  6368. if (value.isPixel) {
  6369. var width = value.getValue(this._host);
  6370. availableWidth -= width;
  6371. widths[index] = width;
  6372. }
  6373. else {
  6374. globalWidthPercentage += value.internalValue;
  6375. }
  6376. index++;
  6377. }
  6378. var left = 0;
  6379. index = 0;
  6380. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6381. var value = _g[_f];
  6382. lefts.push(left);
  6383. if (!value.isPixel) {
  6384. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6385. left += width;
  6386. widths[index] = width;
  6387. }
  6388. else {
  6389. left += value.getValue(this._host);
  6390. }
  6391. index++;
  6392. }
  6393. definitionCallback(lefts, tops, widths, heights);
  6394. };
  6395. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6396. var _this = this;
  6397. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6398. // Setting child sizes
  6399. for (var key in _this._cells) {
  6400. if (!_this._cells.hasOwnProperty(key)) {
  6401. continue;
  6402. }
  6403. var split = key.split(":");
  6404. var x = parseInt(split[0]);
  6405. var y = parseInt(split[1]);
  6406. var cell = _this._cells[key];
  6407. cell.left = lefts[y] + "px";
  6408. cell.top = tops[x] + "px";
  6409. cell.width = widths[y] + "px";
  6410. cell.height = heights[x] + "px";
  6411. cell._left.ignoreAdaptiveScaling = true;
  6412. cell._top.ignoreAdaptiveScaling = true;
  6413. cell._width.ignoreAdaptiveScaling = true;
  6414. cell._height.ignoreAdaptiveScaling = true;
  6415. }
  6416. });
  6417. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6418. };
  6419. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6420. for (var key in this._cells) {
  6421. if (!this._cells.hasOwnProperty(key)) {
  6422. continue;
  6423. }
  6424. var child = this._cells[key];
  6425. child._markMatrixAsDirty();
  6426. }
  6427. };
  6428. Grid.prototype._renderHighlightSpecific = function (context) {
  6429. var _this = this;
  6430. _super.prototype._renderHighlightSpecific.call(this, context);
  6431. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6432. // Columns
  6433. for (var index = 0; index < lefts.length; index++) {
  6434. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6435. context.beginPath();
  6436. context.moveTo(left, _this._currentMeasure.top);
  6437. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6438. context.stroke();
  6439. }
  6440. // Rows
  6441. for (var index = 0; index < tops.length; index++) {
  6442. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6443. context.beginPath();
  6444. context.moveTo(_this._currentMeasure.left, top_1);
  6445. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6446. context.stroke();
  6447. }
  6448. });
  6449. context.restore();
  6450. };
  6451. /** Releases associated resources */
  6452. Grid.prototype.dispose = function () {
  6453. _super.prototype.dispose.call(this);
  6454. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6455. var control = _a[_i];
  6456. control.dispose();
  6457. }
  6458. this._childControls = [];
  6459. };
  6460. return Grid;
  6461. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6462. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6463. /***/ }),
  6464. /***/ "./2D/controls/image.ts":
  6465. /*!******************************!*\
  6466. !*** ./2D/controls/image.ts ***!
  6467. \******************************/
  6468. /*! exports provided: Image */
  6469. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6470. "use strict";
  6471. __webpack_require__.r(__webpack_exports__);
  6472. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6473. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6474. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6475. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6476. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6477. /**
  6478. * Class used to create 2D images
  6479. */
  6480. var Image = /** @class */ (function (_super) {
  6481. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6482. /**
  6483. * Creates a new Image
  6484. * @param name defines the control name
  6485. * @param url defines the image url
  6486. */
  6487. function Image(name, url) {
  6488. if (url === void 0) { url = null; }
  6489. var _this = _super.call(this, name) || this;
  6490. _this.name = name;
  6491. _this._workingCanvas = null;
  6492. _this._loaded = false;
  6493. _this._stretch = Image.STRETCH_FILL;
  6494. _this._autoScale = false;
  6495. _this._sourceLeft = 0;
  6496. _this._sourceTop = 0;
  6497. _this._sourceWidth = 0;
  6498. _this._sourceHeight = 0;
  6499. _this._svgAttributesComputationCompleted = false;
  6500. _this._isSVG = false;
  6501. _this._cellWidth = 0;
  6502. _this._cellHeight = 0;
  6503. _this._cellId = -1;
  6504. _this._populateNinePatchSlicesFromImage = false;
  6505. _this._imageDataCache = { data: null, key: "" };
  6506. /**
  6507. * Observable notified when the content is loaded
  6508. */
  6509. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6510. /**
  6511. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6512. */
  6513. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6514. _this.source = url;
  6515. return _this;
  6516. }
  6517. Object.defineProperty(Image.prototype, "isLoaded", {
  6518. /**
  6519. * Gets a boolean indicating that the content is loaded
  6520. */
  6521. get: function () {
  6522. return this._loaded;
  6523. },
  6524. enumerable: false,
  6525. configurable: true
  6526. });
  6527. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6528. /**
  6529. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6530. */
  6531. get: function () {
  6532. return this._populateNinePatchSlicesFromImage;
  6533. },
  6534. set: function (value) {
  6535. if (this._populateNinePatchSlicesFromImage === value) {
  6536. return;
  6537. }
  6538. this._populateNinePatchSlicesFromImage = value;
  6539. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6540. this._extractNinePatchSliceDataFromImage();
  6541. }
  6542. },
  6543. enumerable: false,
  6544. configurable: true
  6545. });
  6546. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6547. /**
  6548. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6549. * Beware using this as this will comsume more memory as the image has to be stored twice
  6550. */
  6551. get: function () {
  6552. return this._detectPointerOnOpaqueOnly;
  6553. },
  6554. set: function (value) {
  6555. if (this._detectPointerOnOpaqueOnly === value) {
  6556. return;
  6557. }
  6558. this._detectPointerOnOpaqueOnly = value;
  6559. },
  6560. enumerable: false,
  6561. configurable: true
  6562. });
  6563. Object.defineProperty(Image.prototype, "sliceLeft", {
  6564. /**
  6565. * Gets or sets the left value for slicing (9-patch)
  6566. */
  6567. get: function () {
  6568. return this._sliceLeft;
  6569. },
  6570. set: function (value) {
  6571. if (this._sliceLeft === value) {
  6572. return;
  6573. }
  6574. this._sliceLeft = value;
  6575. this._markAsDirty();
  6576. },
  6577. enumerable: false,
  6578. configurable: true
  6579. });
  6580. Object.defineProperty(Image.prototype, "sliceRight", {
  6581. /**
  6582. * Gets or sets the right value for slicing (9-patch)
  6583. */
  6584. get: function () {
  6585. return this._sliceRight;
  6586. },
  6587. set: function (value) {
  6588. if (this._sliceRight === value) {
  6589. return;
  6590. }
  6591. this._sliceRight = value;
  6592. this._markAsDirty();
  6593. },
  6594. enumerable: false,
  6595. configurable: true
  6596. });
  6597. Object.defineProperty(Image.prototype, "sliceTop", {
  6598. /**
  6599. * Gets or sets the top value for slicing (9-patch)
  6600. */
  6601. get: function () {
  6602. return this._sliceTop;
  6603. },
  6604. set: function (value) {
  6605. if (this._sliceTop === value) {
  6606. return;
  6607. }
  6608. this._sliceTop = value;
  6609. this._markAsDirty();
  6610. },
  6611. enumerable: false,
  6612. configurable: true
  6613. });
  6614. Object.defineProperty(Image.prototype, "sliceBottom", {
  6615. /**
  6616. * Gets or sets the bottom value for slicing (9-patch)
  6617. */
  6618. get: function () {
  6619. return this._sliceBottom;
  6620. },
  6621. set: function (value) {
  6622. if (this._sliceBottom === value) {
  6623. return;
  6624. }
  6625. this._sliceBottom = value;
  6626. this._markAsDirty();
  6627. },
  6628. enumerable: false,
  6629. configurable: true
  6630. });
  6631. Object.defineProperty(Image.prototype, "sourceLeft", {
  6632. /**
  6633. * Gets or sets the left coordinate in the source image
  6634. */
  6635. get: function () {
  6636. return this._sourceLeft;
  6637. },
  6638. set: function (value) {
  6639. if (this._sourceLeft === value) {
  6640. return;
  6641. }
  6642. this._sourceLeft = value;
  6643. this._markAsDirty();
  6644. },
  6645. enumerable: false,
  6646. configurable: true
  6647. });
  6648. Object.defineProperty(Image.prototype, "sourceTop", {
  6649. /**
  6650. * Gets or sets the top coordinate in the source image
  6651. */
  6652. get: function () {
  6653. return this._sourceTop;
  6654. },
  6655. set: function (value) {
  6656. if (this._sourceTop === value) {
  6657. return;
  6658. }
  6659. this._sourceTop = value;
  6660. this._markAsDirty();
  6661. },
  6662. enumerable: false,
  6663. configurable: true
  6664. });
  6665. Object.defineProperty(Image.prototype, "sourceWidth", {
  6666. /**
  6667. * Gets or sets the width to capture in the source image
  6668. */
  6669. get: function () {
  6670. return this._sourceWidth;
  6671. },
  6672. set: function (value) {
  6673. if (this._sourceWidth === value) {
  6674. return;
  6675. }
  6676. this._sourceWidth = value;
  6677. this._markAsDirty();
  6678. },
  6679. enumerable: false,
  6680. configurable: true
  6681. });
  6682. Object.defineProperty(Image.prototype, "sourceHeight", {
  6683. /**
  6684. * Gets or sets the height to capture in the source image
  6685. */
  6686. get: function () {
  6687. return this._sourceHeight;
  6688. },
  6689. set: function (value) {
  6690. if (this._sourceHeight === value) {
  6691. return;
  6692. }
  6693. this._sourceHeight = value;
  6694. this._markAsDirty();
  6695. },
  6696. enumerable: false,
  6697. configurable: true
  6698. });
  6699. Object.defineProperty(Image.prototype, "isSVG", {
  6700. /** Indicates if the format of the image is SVG */
  6701. get: function () {
  6702. return this._isSVG;
  6703. },
  6704. enumerable: false,
  6705. configurable: true
  6706. });
  6707. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6708. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6709. get: function () {
  6710. return this._svgAttributesComputationCompleted;
  6711. },
  6712. enumerable: false,
  6713. configurable: true
  6714. });
  6715. Object.defineProperty(Image.prototype, "autoScale", {
  6716. /**
  6717. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6718. * @see https://doc.babylonjs.com/how_to/gui#image
  6719. */
  6720. get: function () {
  6721. return this._autoScale;
  6722. },
  6723. set: function (value) {
  6724. if (this._autoScale === value) {
  6725. return;
  6726. }
  6727. this._autoScale = value;
  6728. if (value && this._loaded) {
  6729. this.synchronizeSizeWithContent();
  6730. }
  6731. },
  6732. enumerable: false,
  6733. configurable: true
  6734. });
  6735. Object.defineProperty(Image.prototype, "stretch", {
  6736. /** Gets or sets the streching mode used by the image */
  6737. get: function () {
  6738. return this._stretch;
  6739. },
  6740. set: function (value) {
  6741. if (this._stretch === value) {
  6742. return;
  6743. }
  6744. this._stretch = value;
  6745. this._markAsDirty();
  6746. },
  6747. enumerable: false,
  6748. configurable: true
  6749. });
  6750. /** @hidden */
  6751. Image.prototype._rotate90 = function (n, preserveProperties) {
  6752. if (preserveProperties === void 0) { preserveProperties = false; }
  6753. var canvas = document.createElement('canvas');
  6754. var context = canvas.getContext('2d');
  6755. var width = this._domImage.width;
  6756. var height = this._domImage.height;
  6757. canvas.width = height;
  6758. canvas.height = width;
  6759. context.translate(canvas.width / 2, canvas.height / 2);
  6760. context.rotate(n * Math.PI / 2);
  6761. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6762. var dataUrl = canvas.toDataURL("image/jpg");
  6763. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6764. if (preserveProperties) {
  6765. rotatedImage._stretch = this._stretch;
  6766. rotatedImage._autoScale = this._autoScale;
  6767. rotatedImage._cellId = this._cellId;
  6768. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6769. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6770. }
  6771. this._handleRotationForSVGImage(this, rotatedImage, n);
  6772. this._imageDataCache.data = null;
  6773. return rotatedImage;
  6774. };
  6775. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6776. var _this = this;
  6777. if (!srcImage._isSVG) {
  6778. return;
  6779. }
  6780. if (srcImage._svgAttributesComputationCompleted) {
  6781. this._rotate90SourceProperties(srcImage, dstImage, n);
  6782. this._markAsDirty();
  6783. }
  6784. else {
  6785. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6786. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6787. _this._markAsDirty();
  6788. });
  6789. }
  6790. };
  6791. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6792. var _a, _b;
  6793. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6794. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6795. if (n != 0) {
  6796. var mult = n < 0 ? -1 : 1;
  6797. n = n % 4;
  6798. for (var i = 0; i < Math.abs(n); ++i) {
  6799. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6800. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6801. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6802. if (n < 0) {
  6803. dstTop -= dstHeight;
  6804. }
  6805. else {
  6806. dstLeft -= dstWidth;
  6807. }
  6808. srcLeft = dstLeft;
  6809. srcTop = dstTop;
  6810. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6811. }
  6812. }
  6813. dstImage.sourceLeft = dstLeft;
  6814. dstImage.sourceTop = dstTop;
  6815. dstImage.sourceWidth = dstWidth;
  6816. dstImage.sourceHeight = dstHeight;
  6817. };
  6818. Object.defineProperty(Image.prototype, "domImage", {
  6819. get: function () {
  6820. return this._domImage;
  6821. },
  6822. /**
  6823. * Gets or sets the internal DOM image used to render the control
  6824. */
  6825. set: function (value) {
  6826. var _this = this;
  6827. this._domImage = value;
  6828. this._loaded = false;
  6829. this._imageDataCache.data = null;
  6830. if (this._domImage.width) {
  6831. this._onImageLoaded();
  6832. }
  6833. else {
  6834. this._domImage.onload = function () {
  6835. _this._onImageLoaded();
  6836. };
  6837. }
  6838. },
  6839. enumerable: false,
  6840. configurable: true
  6841. });
  6842. Image.prototype._onImageLoaded = function () {
  6843. this._imageDataCache.data = null;
  6844. this._imageWidth = this._domImage.width;
  6845. this._imageHeight = this._domImage.height;
  6846. this._loaded = true;
  6847. if (this._populateNinePatchSlicesFromImage) {
  6848. this._extractNinePatchSliceDataFromImage();
  6849. }
  6850. if (this._autoScale) {
  6851. this.synchronizeSizeWithContent();
  6852. }
  6853. this.onImageLoadedObservable.notifyObservers(this);
  6854. this._markAsDirty();
  6855. };
  6856. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6857. if (!this._workingCanvas) {
  6858. this._workingCanvas = document.createElement('canvas');
  6859. }
  6860. var canvas = this._workingCanvas;
  6861. var context = canvas.getContext('2d');
  6862. var width = this._domImage.width;
  6863. var height = this._domImage.height;
  6864. canvas.width = width;
  6865. canvas.height = height;
  6866. context.drawImage(this._domImage, 0, 0, width, height);
  6867. var imageData = context.getImageData(0, 0, width, height);
  6868. // Left and right
  6869. this._sliceLeft = -1;
  6870. this._sliceRight = -1;
  6871. for (var x = 0; x < width; x++) {
  6872. var alpha = imageData.data[x * 4 + 3];
  6873. if (alpha > 127 && this._sliceLeft === -1) {
  6874. this._sliceLeft = x;
  6875. continue;
  6876. }
  6877. if (alpha < 127 && this._sliceLeft > -1) {
  6878. this._sliceRight = x;
  6879. break;
  6880. }
  6881. }
  6882. // top and bottom
  6883. this._sliceTop = -1;
  6884. this._sliceBottom = -1;
  6885. for (var y = 0; y < height; y++) {
  6886. var alpha = imageData.data[y * width * 4 + 3];
  6887. if (alpha > 127 && this._sliceTop === -1) {
  6888. this._sliceTop = y;
  6889. continue;
  6890. }
  6891. if (alpha < 127 && this._sliceTop > -1) {
  6892. this._sliceBottom = y;
  6893. break;
  6894. }
  6895. }
  6896. };
  6897. Object.defineProperty(Image.prototype, "source", {
  6898. /**
  6899. * Gets or sets image source url
  6900. */
  6901. set: function (value) {
  6902. var _this = this;
  6903. if (this._source === value) {
  6904. return;
  6905. }
  6906. this._loaded = false;
  6907. this._source = value;
  6908. this._imageDataCache.data = null;
  6909. if (value) {
  6910. value = this._svgCheck(value);
  6911. }
  6912. this._domImage = document.createElement("img");
  6913. this._domImage.onload = function () {
  6914. _this._onImageLoaded();
  6915. };
  6916. if (value) {
  6917. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6918. this._domImage.src = value;
  6919. }
  6920. },
  6921. enumerable: false,
  6922. configurable: true
  6923. });
  6924. /**
  6925. * Checks for svg document with icon id present
  6926. */
  6927. Image.prototype._svgCheck = function (value) {
  6928. var _this = this;
  6929. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6930. this._isSVG = true;
  6931. var svgsrc = value.split('#')[0];
  6932. var elemid = value.split('#')[1];
  6933. // check if object alr exist in document
  6934. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6935. if (svgExist) {
  6936. var svgDoc = svgExist.contentDocument;
  6937. // get viewbox width and height, get svg document width and height in px
  6938. if (svgDoc && svgDoc.documentElement) {
  6939. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6940. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6941. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6942. var elem = svgDoc.getElementById(elemid);
  6943. if (elem && vb && docwidth && docheight) {
  6944. this._getSVGAttribs(svgExist, elemid);
  6945. return value;
  6946. }
  6947. }
  6948. // wait for object to load
  6949. svgExist.addEventListener("load", function () {
  6950. _this._getSVGAttribs(svgExist, elemid);
  6951. });
  6952. }
  6953. else {
  6954. // create document object
  6955. var svgImage = document.createElement("object");
  6956. svgImage.data = svgsrc;
  6957. svgImage.type = "image/svg+xml";
  6958. svgImage.width = "0%";
  6959. svgImage.height = "0%";
  6960. document.body.appendChild(svgImage);
  6961. // when the object has loaded, get the element attribs
  6962. svgImage.onload = function () {
  6963. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6964. if (svgobj) {
  6965. _this._getSVGAttribs(svgobj, elemid);
  6966. }
  6967. };
  6968. }
  6969. return svgsrc;
  6970. }
  6971. else {
  6972. return value;
  6973. }
  6974. };
  6975. /**
  6976. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6977. * given external svg file and icon id
  6978. */
  6979. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6980. var svgDoc = svgsrc.contentDocument;
  6981. // get viewbox width and height, get svg document width and height in px
  6982. if (svgDoc && svgDoc.documentElement) {
  6983. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6984. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6985. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6986. // get element bbox and matrix transform
  6987. var elem = svgDoc.getElementById(elemid);
  6988. if (vb && docwidth && docheight && elem) {
  6989. var vb_width = Number(vb.split(" ")[2]);
  6990. var vb_height = Number(vb.split(" ")[3]);
  6991. var elem_bbox = elem.getBBox();
  6992. var elem_matrix_a = 1;
  6993. var elem_matrix_d = 1;
  6994. var elem_matrix_e = 0;
  6995. var elem_matrix_f = 0;
  6996. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6997. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6998. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6999. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  7000. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  7001. }
  7002. // compute source coordinates and dimensions
  7003. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  7004. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  7005. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  7006. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  7007. this._svgAttributesComputationCompleted = true;
  7008. this.onSVGAttributesComputedObservable.notifyObservers(this);
  7009. }
  7010. }
  7011. };
  7012. Object.defineProperty(Image.prototype, "cellWidth", {
  7013. /**
  7014. * Gets or sets the cell width to use when animation sheet is enabled
  7015. * @see https://doc.babylonjs.com/how_to/gui#image
  7016. */
  7017. get: function () {
  7018. return this._cellWidth;
  7019. },
  7020. set: function (value) {
  7021. if (this._cellWidth === value) {
  7022. return;
  7023. }
  7024. this._cellWidth = value;
  7025. this._markAsDirty();
  7026. },
  7027. enumerable: false,
  7028. configurable: true
  7029. });
  7030. Object.defineProperty(Image.prototype, "cellHeight", {
  7031. /**
  7032. * Gets or sets the cell height to use when animation sheet is enabled
  7033. * @see https://doc.babylonjs.com/how_to/gui#image
  7034. */
  7035. get: function () {
  7036. return this._cellHeight;
  7037. },
  7038. set: function (value) {
  7039. if (this._cellHeight === value) {
  7040. return;
  7041. }
  7042. this._cellHeight = value;
  7043. this._markAsDirty();
  7044. },
  7045. enumerable: false,
  7046. configurable: true
  7047. });
  7048. Object.defineProperty(Image.prototype, "cellId", {
  7049. /**
  7050. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  7051. * @see https://doc.babylonjs.com/how_to/gui#image
  7052. */
  7053. get: function () {
  7054. return this._cellId;
  7055. },
  7056. set: function (value) {
  7057. if (this._cellId === value) {
  7058. return;
  7059. }
  7060. this._cellId = value;
  7061. this._markAsDirty();
  7062. },
  7063. enumerable: false,
  7064. configurable: true
  7065. });
  7066. /**
  7067. * Tests if a given coordinates belong to the current control
  7068. * @param x defines x coordinate to test
  7069. * @param y defines y coordinate to test
  7070. * @returns true if the coordinates are inside the control
  7071. */
  7072. Image.prototype.contains = function (x, y) {
  7073. if (!_super.prototype.contains.call(this, x, y)) {
  7074. return false;
  7075. }
  7076. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  7077. return true;
  7078. }
  7079. var width = this._currentMeasure.width | 0;
  7080. var height = this._currentMeasure.height | 0;
  7081. var key = width + "_" + height;
  7082. var imageData = this._imageDataCache.data;
  7083. if (!imageData || this._imageDataCache.key !== key) {
  7084. var canvas = this._workingCanvas;
  7085. var context_1 = canvas.getContext("2d");
  7086. this._imageDataCache.data = imageData = context_1.getImageData(0, 0, width, height).data;
  7087. this._imageDataCache.key = key;
  7088. }
  7089. x = (x - this._currentMeasure.left) | 0;
  7090. y = (y - this._currentMeasure.top) | 0;
  7091. var pickedPixel = imageData[(x + y * width) * 4 + 3];
  7092. return pickedPixel > 0;
  7093. };
  7094. Image.prototype._getTypeName = function () {
  7095. return "Image";
  7096. };
  7097. /** Force the control to synchronize with its content */
  7098. Image.prototype.synchronizeSizeWithContent = function () {
  7099. if (!this._loaded) {
  7100. return;
  7101. }
  7102. this.width = this._domImage.width + "px";
  7103. this.height = this._domImage.height + "px";
  7104. };
  7105. Image.prototype._processMeasures = function (parentMeasure, context) {
  7106. if (this._loaded) {
  7107. switch (this._stretch) {
  7108. case Image.STRETCH_NONE:
  7109. break;
  7110. case Image.STRETCH_FILL:
  7111. break;
  7112. case Image.STRETCH_UNIFORM:
  7113. break;
  7114. case Image.STRETCH_NINE_PATCH:
  7115. break;
  7116. case Image.STRETCH_EXTEND:
  7117. if (this._autoScale) {
  7118. this.synchronizeSizeWithContent();
  7119. }
  7120. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  7121. this.parent.adaptWidthToChildren = true;
  7122. this.parent.adaptHeightToChildren = true;
  7123. }
  7124. break;
  7125. }
  7126. }
  7127. _super.prototype._processMeasures.call(this, parentMeasure, context);
  7128. };
  7129. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  7130. if (!this._detectPointerOnOpaqueOnly) {
  7131. return;
  7132. }
  7133. if (!this._workingCanvas) {
  7134. this._workingCanvas = document.createElement('canvas');
  7135. }
  7136. var canvas = this._workingCanvas;
  7137. var width = this._currentMeasure.width;
  7138. var height = this._currentMeasure.height;
  7139. var context = canvas.getContext("2d");
  7140. canvas.width = width;
  7141. canvas.height = height;
  7142. context.clearRect(0, 0, width, height);
  7143. };
  7144. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  7145. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  7146. if (!this._detectPointerOnOpaqueOnly) {
  7147. return;
  7148. }
  7149. var canvas = this._workingCanvas;
  7150. context = canvas.getContext("2d");
  7151. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  7152. };
  7153. Image.prototype._draw = function (context) {
  7154. context.save();
  7155. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7156. context.shadowColor = this.shadowColor;
  7157. context.shadowBlur = this.shadowBlur;
  7158. context.shadowOffsetX = this.shadowOffsetX;
  7159. context.shadowOffsetY = this.shadowOffsetY;
  7160. }
  7161. var x, y, width, height;
  7162. if (this.cellId == -1) {
  7163. x = this._sourceLeft;
  7164. y = this._sourceTop;
  7165. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  7166. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  7167. }
  7168. else {
  7169. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  7170. var column = (this.cellId / rowCount) >> 0;
  7171. var row = this.cellId % rowCount;
  7172. x = this.cellWidth * row;
  7173. y = this.cellHeight * column;
  7174. width = this.cellWidth;
  7175. height = this.cellHeight;
  7176. }
  7177. this._prepareWorkingCanvasForOpaqueDetection();
  7178. this._applyStates(context);
  7179. if (this._loaded) {
  7180. switch (this._stretch) {
  7181. case Image.STRETCH_NONE:
  7182. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7183. break;
  7184. case Image.STRETCH_FILL:
  7185. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7186. break;
  7187. case Image.STRETCH_UNIFORM:
  7188. var hRatio = this._currentMeasure.width / width;
  7189. var vRatio = this._currentMeasure.height / height;
  7190. var ratio = Math.min(hRatio, vRatio);
  7191. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  7192. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  7193. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  7194. break;
  7195. case Image.STRETCH_EXTEND:
  7196. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7197. break;
  7198. case Image.STRETCH_NINE_PATCH:
  7199. this._renderNinePatch(context);
  7200. break;
  7201. }
  7202. }
  7203. context.restore();
  7204. };
  7205. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  7206. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  7207. };
  7208. Image.prototype._renderNinePatch = function (context) {
  7209. var height = this._imageHeight;
  7210. var leftWidth = this._sliceLeft;
  7211. var topHeight = this._sliceTop;
  7212. var bottomHeight = this._imageHeight - this._sliceBottom;
  7213. var rightWidth = this._imageWidth - this._sliceRight;
  7214. var left = 0;
  7215. var top = 0;
  7216. if (this._populateNinePatchSlicesFromImage) {
  7217. left = 1;
  7218. top = 1;
  7219. height -= 2;
  7220. leftWidth -= 1;
  7221. topHeight -= 1;
  7222. bottomHeight -= 1;
  7223. rightWidth -= 1;
  7224. }
  7225. var centerWidth = this._sliceRight - this._sliceLeft;
  7226. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  7227. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  7228. // Corners
  7229. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  7230. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  7231. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  7232. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  7233. // Center
  7234. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  7235. // Borders
  7236. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7237. 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);
  7238. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  7239. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  7240. };
  7241. Image.prototype.dispose = function () {
  7242. _super.prototype.dispose.call(this);
  7243. this.onImageLoadedObservable.clear();
  7244. this.onSVGAttributesComputedObservable.clear();
  7245. };
  7246. // Static
  7247. /** STRETCH_NONE */
  7248. Image.STRETCH_NONE = 0;
  7249. /** STRETCH_FILL */
  7250. Image.STRETCH_FILL = 1;
  7251. /** STRETCH_UNIFORM */
  7252. Image.STRETCH_UNIFORM = 2;
  7253. /** STRETCH_EXTEND */
  7254. Image.STRETCH_EXTEND = 3;
  7255. /** NINE_PATCH */
  7256. Image.STRETCH_NINE_PATCH = 4;
  7257. return Image;
  7258. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7259. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7260. /***/ }),
  7261. /***/ "./2D/controls/index.ts":
  7262. /*!******************************!*\
  7263. !*** ./2D/controls/index.ts ***!
  7264. \******************************/
  7265. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, FocusableButton, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, ToggleButton, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  7266. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7267. "use strict";
  7268. __webpack_require__.r(__webpack_exports__);
  7269. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7271. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7273. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7275. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7277. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7279. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7281. /* harmony import */ var _focusableButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./focusableButton */ "./2D/controls/focusableButton.ts");
  7282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _focusableButton__WEBPACK_IMPORTED_MODULE_6__["FocusableButton"]; });
  7283. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_7__["Grid"]; });
  7285. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_8__["Image"]; });
  7287. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_9__["InputText"]; });
  7289. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_10__["InputPassword"]; });
  7291. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_11__["Line"]; });
  7293. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_12__["MultiLine"]; });
  7295. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_13__["RadioButton"]; });
  7297. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_14__["StackPanel"]; });
  7299. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["SelectorGroup"]; });
  7301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["CheckboxGroup"]; });
  7302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["RadioGroup"]; });
  7303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["SliderGroup"]; });
  7304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["SelectionPanel"]; });
  7305. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_16__["ScrollViewer"]; });
  7307. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_17__["TextWrapping"]; });
  7309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_17__["TextBlock"]; });
  7310. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _textWrapper__WEBPACK_IMPORTED_MODULE_18__["TextWrapper"]; });
  7312. /* harmony import */ var _toggleButton__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./toggleButton */ "./2D/controls/toggleButton.ts");
  7313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _toggleButton__WEBPACK_IMPORTED_MODULE_19__["ToggleButton"]; });
  7314. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_20__["KeyPropertySet"]; });
  7316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_20__["VirtualKeyboard"]; });
  7317. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_21__["Rectangle"]; });
  7319. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_22__["DisplayGrid"]; });
  7321. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_23__["BaseSlider"]; });
  7323. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_24__["Slider"]; });
  7325. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_25__["ImageBasedSlider"]; });
  7327. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_26__["ScrollBar"]; });
  7329. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_27__["ImageScrollBar"]; });
  7331. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_28__["name"]; });
  7333. /***/ }),
  7334. /***/ "./2D/controls/inputPassword.ts":
  7335. /*!**************************************!*\
  7336. !*** ./2D/controls/inputPassword.ts ***!
  7337. \**************************************/
  7338. /*! exports provided: InputPassword */
  7339. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7340. "use strict";
  7341. __webpack_require__.r(__webpack_exports__);
  7342. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7343. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7344. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7345. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  7346. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7347. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7348. /**
  7349. * Class used to create a password control
  7350. */
  7351. var InputPassword = /** @class */ (function (_super) {
  7352. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7353. function InputPassword() {
  7354. return _super !== null && _super.apply(this, arguments) || this;
  7355. }
  7356. InputPassword.prototype._beforeRenderText = function (textWrapper) {
  7357. var pwdTextWrapper = new _textWrapper__WEBPACK_IMPORTED_MODULE_3__["TextWrapper"]();
  7358. var txt = "";
  7359. for (var i = 0; i < textWrapper.length; i++) {
  7360. txt += "\u2022";
  7361. }
  7362. pwdTextWrapper.text = txt;
  7363. return pwdTextWrapper;
  7364. };
  7365. return InputPassword;
  7366. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7367. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7368. /***/ }),
  7369. /***/ "./2D/controls/inputText.ts":
  7370. /*!**********************************!*\
  7371. !*** ./2D/controls/inputText.ts ***!
  7372. \**********************************/
  7373. /*! exports provided: InputText */
  7374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7375. "use strict";
  7376. __webpack_require__.r(__webpack_exports__);
  7377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7378. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7379. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  7380. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7381. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7382. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7383. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7384. /**
  7385. * Class used to create input text control
  7386. */
  7387. var InputText = /** @class */ (function (_super) {
  7388. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7389. /**
  7390. * Creates a new InputText
  7391. * @param name defines the control name
  7392. * @param text defines the text of the control
  7393. */
  7394. function InputText(name, text) {
  7395. if (text === void 0) { text = ""; }
  7396. var _this = _super.call(this, name) || this;
  7397. _this.name = name;
  7398. _this._placeholderText = "";
  7399. _this._background = "#222222";
  7400. _this._focusedBackground = "#000000";
  7401. _this._focusedColor = "white";
  7402. _this._placeholderColor = "gray";
  7403. _this._thickness = 1;
  7404. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7405. _this._autoStretchWidth = true;
  7406. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7407. _this._isFocused = false;
  7408. _this._blinkIsEven = false;
  7409. _this._cursorOffset = 0;
  7410. _this._deadKey = false;
  7411. _this._addKey = true;
  7412. _this._currentKey = "";
  7413. _this._isTextHighlightOn = false;
  7414. _this._textHighlightColor = "#d5e0ff";
  7415. _this._highligherOpacity = 0.4;
  7416. _this._highlightedText = "";
  7417. _this._startHighlightIndex = 0;
  7418. _this._endHighlightIndex = 0;
  7419. _this._cursorIndex = -1;
  7420. _this._onFocusSelectAll = false;
  7421. _this._isPointerDown = false;
  7422. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7423. _this.promptMessage = "Please enter text:";
  7424. /** Force disable prompt on mobile device */
  7425. _this.disableMobilePrompt = false;
  7426. /** Observable raised when the text changes */
  7427. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7428. /** Observable raised just before an entered character is to be added */
  7429. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7430. /** Observable raised when the control gets the focus */
  7431. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7432. /** Observable raised when the control loses the focus */
  7433. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7434. /**Observable raised when the text is highlighted */
  7435. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7436. /**Observable raised when copy event is triggered */
  7437. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7438. /** Observable raised when cut event is triggered */
  7439. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7440. /** Observable raised when paste event is triggered */
  7441. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7442. /** Observable raised when a key event was processed */
  7443. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7444. _this.text = text;
  7445. _this.isPointerBlocker = true;
  7446. return _this;
  7447. }
  7448. Object.defineProperty(InputText.prototype, "maxWidth", {
  7449. /** Gets or sets the maximum width allowed by the control */
  7450. get: function () {
  7451. return this._maxWidth.toString(this._host);
  7452. },
  7453. set: function (value) {
  7454. if (this._maxWidth.toString(this._host) === value) {
  7455. return;
  7456. }
  7457. if (this._maxWidth.fromString(value)) {
  7458. this._markAsDirty();
  7459. }
  7460. },
  7461. enumerable: false,
  7462. configurable: true
  7463. });
  7464. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7465. /** Gets the maximum width allowed by the control in pixels */
  7466. get: function () {
  7467. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7468. },
  7469. enumerable: false,
  7470. configurable: true
  7471. });
  7472. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7473. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7474. get: function () {
  7475. return this._highligherOpacity;
  7476. },
  7477. set: function (value) {
  7478. if (this._highligherOpacity === value) {
  7479. return;
  7480. }
  7481. this._highligherOpacity = value;
  7482. this._markAsDirty();
  7483. },
  7484. enumerable: false,
  7485. configurable: true
  7486. });
  7487. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7488. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7489. get: function () {
  7490. return this._onFocusSelectAll;
  7491. },
  7492. set: function (value) {
  7493. if (this._onFocusSelectAll === value) {
  7494. return;
  7495. }
  7496. this._onFocusSelectAll = value;
  7497. this._markAsDirty();
  7498. },
  7499. enumerable: false,
  7500. configurable: true
  7501. });
  7502. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7503. /** Gets or sets the text hightlight color */
  7504. get: function () {
  7505. return this._textHighlightColor;
  7506. },
  7507. set: function (value) {
  7508. if (this._textHighlightColor === value) {
  7509. return;
  7510. }
  7511. this._textHighlightColor = value;
  7512. this._markAsDirty();
  7513. },
  7514. enumerable: false,
  7515. configurable: true
  7516. });
  7517. Object.defineProperty(InputText.prototype, "margin", {
  7518. /** Gets or sets control margin */
  7519. get: function () {
  7520. return this._margin.toString(this._host);
  7521. },
  7522. set: function (value) {
  7523. if (this._margin.toString(this._host) === value) {
  7524. return;
  7525. }
  7526. if (this._margin.fromString(value)) {
  7527. this._markAsDirty();
  7528. }
  7529. },
  7530. enumerable: false,
  7531. configurable: true
  7532. });
  7533. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7534. /** Gets control margin in pixels */
  7535. get: function () {
  7536. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7537. },
  7538. enumerable: false,
  7539. configurable: true
  7540. });
  7541. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7542. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7543. get: function () {
  7544. return this._autoStretchWidth;
  7545. },
  7546. set: function (value) {
  7547. if (this._autoStretchWidth === value) {
  7548. return;
  7549. }
  7550. this._autoStretchWidth = value;
  7551. this._markAsDirty();
  7552. },
  7553. enumerable: false,
  7554. configurable: true
  7555. });
  7556. Object.defineProperty(InputText.prototype, "thickness", {
  7557. /** Gets or sets border thickness */
  7558. get: function () {
  7559. return this._thickness;
  7560. },
  7561. set: function (value) {
  7562. if (this._thickness === value) {
  7563. return;
  7564. }
  7565. this._thickness = value;
  7566. this._markAsDirty();
  7567. },
  7568. enumerable: false,
  7569. configurable: true
  7570. });
  7571. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7572. /** Gets or sets the background color when focused */
  7573. get: function () {
  7574. return this._focusedBackground;
  7575. },
  7576. set: function (value) {
  7577. if (this._focusedBackground === value) {
  7578. return;
  7579. }
  7580. this._focusedBackground = value;
  7581. this._markAsDirty();
  7582. },
  7583. enumerable: false,
  7584. configurable: true
  7585. });
  7586. Object.defineProperty(InputText.prototype, "focusedColor", {
  7587. /** Gets or sets the background color when focused */
  7588. get: function () {
  7589. return this._focusedColor;
  7590. },
  7591. set: function (value) {
  7592. if (this._focusedColor === value) {
  7593. return;
  7594. }
  7595. this._focusedColor = value;
  7596. this._markAsDirty();
  7597. },
  7598. enumerable: false,
  7599. configurable: true
  7600. });
  7601. Object.defineProperty(InputText.prototype, "background", {
  7602. /** Gets or sets the background color */
  7603. get: function () {
  7604. return this._background;
  7605. },
  7606. set: function (value) {
  7607. if (this._background === value) {
  7608. return;
  7609. }
  7610. this._background = value;
  7611. this._markAsDirty();
  7612. },
  7613. enumerable: false,
  7614. configurable: true
  7615. });
  7616. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7617. /** Gets or sets the placeholder color */
  7618. get: function () {
  7619. return this._placeholderColor;
  7620. },
  7621. set: function (value) {
  7622. if (this._placeholderColor === value) {
  7623. return;
  7624. }
  7625. this._placeholderColor = value;
  7626. this._markAsDirty();
  7627. },
  7628. enumerable: false,
  7629. configurable: true
  7630. });
  7631. Object.defineProperty(InputText.prototype, "placeholderText", {
  7632. /** Gets or sets the text displayed when the control is empty */
  7633. get: function () {
  7634. return this._placeholderText;
  7635. },
  7636. set: function (value) {
  7637. if (this._placeholderText === value) {
  7638. return;
  7639. }
  7640. this._placeholderText = value;
  7641. this._markAsDirty();
  7642. },
  7643. enumerable: false,
  7644. configurable: true
  7645. });
  7646. Object.defineProperty(InputText.prototype, "deadKey", {
  7647. /** Gets or sets the dead key flag */
  7648. get: function () {
  7649. return this._deadKey;
  7650. },
  7651. set: function (flag) {
  7652. this._deadKey = flag;
  7653. },
  7654. enumerable: false,
  7655. configurable: true
  7656. });
  7657. Object.defineProperty(InputText.prototype, "highlightedText", {
  7658. /** Gets or sets the highlight text */
  7659. get: function () {
  7660. return this._highlightedText;
  7661. },
  7662. set: function (text) {
  7663. if (this._highlightedText === text) {
  7664. return;
  7665. }
  7666. this._highlightedText = text;
  7667. this._markAsDirty();
  7668. },
  7669. enumerable: false,
  7670. configurable: true
  7671. });
  7672. Object.defineProperty(InputText.prototype, "addKey", {
  7673. /** Gets or sets if the current key should be added */
  7674. get: function () {
  7675. return this._addKey;
  7676. },
  7677. set: function (flag) {
  7678. this._addKey = flag;
  7679. },
  7680. enumerable: false,
  7681. configurable: true
  7682. });
  7683. Object.defineProperty(InputText.prototype, "currentKey", {
  7684. /** Gets or sets the value of the current key being entered */
  7685. get: function () {
  7686. return this._currentKey;
  7687. },
  7688. set: function (key) {
  7689. this._currentKey = key;
  7690. },
  7691. enumerable: false,
  7692. configurable: true
  7693. });
  7694. Object.defineProperty(InputText.prototype, "text", {
  7695. /** Gets or sets the text displayed in the control */
  7696. get: function () {
  7697. return this._textWrapper.text;
  7698. },
  7699. set: function (value) {
  7700. var valueAsString = value.toString(); // Forcing convertion
  7701. if (!this._textWrapper) {
  7702. this._textWrapper = new _textWrapper__WEBPACK_IMPORTED_MODULE_4__["TextWrapper"]();
  7703. }
  7704. if (this._textWrapper.text === valueAsString) {
  7705. return;
  7706. }
  7707. this._textWrapper.text = valueAsString;
  7708. this._textHasChanged();
  7709. },
  7710. enumerable: false,
  7711. configurable: true
  7712. });
  7713. InputText.prototype._textHasChanged = function () {
  7714. this._markAsDirty();
  7715. this.onTextChangedObservable.notifyObservers(this);
  7716. };
  7717. Object.defineProperty(InputText.prototype, "width", {
  7718. /** Gets or sets control width */
  7719. get: function () {
  7720. return this._width.toString(this._host);
  7721. },
  7722. set: function (value) {
  7723. if (this._width.toString(this._host) === value) {
  7724. return;
  7725. }
  7726. if (this._width.fromString(value)) {
  7727. this._markAsDirty();
  7728. }
  7729. this.autoStretchWidth = false;
  7730. },
  7731. enumerable: false,
  7732. configurable: true
  7733. });
  7734. /** @hidden */
  7735. InputText.prototype.onBlur = function () {
  7736. this._isFocused = false;
  7737. this._scrollLeft = null;
  7738. this._cursorOffset = 0;
  7739. clearTimeout(this._blinkTimeout);
  7740. this._markAsDirty();
  7741. this.onBlurObservable.notifyObservers(this);
  7742. this._host.unRegisterClipboardEvents();
  7743. if (this._onClipboardObserver) {
  7744. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7745. }
  7746. var scene = this._host.getScene();
  7747. if (this._onPointerDblTapObserver && scene) {
  7748. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7749. }
  7750. };
  7751. /** @hidden */
  7752. InputText.prototype.onFocus = function () {
  7753. var _this = this;
  7754. if (!this._isEnabled) {
  7755. return;
  7756. }
  7757. this._scrollLeft = null;
  7758. this._isFocused = true;
  7759. this._blinkIsEven = false;
  7760. this._cursorOffset = 0;
  7761. this._markAsDirty();
  7762. this.onFocusObservable.notifyObservers(this);
  7763. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7764. var value = prompt(this.promptMessage);
  7765. if (value !== null) {
  7766. this.text = value;
  7767. }
  7768. this._host.focusedControl = null;
  7769. return;
  7770. }
  7771. this._host.registerClipboardEvents();
  7772. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7773. // process clipboard event, can be configured.
  7774. switch (clipboardInfo.type) {
  7775. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7776. _this._onCopyText(clipboardInfo.event);
  7777. _this.onTextCopyObservable.notifyObservers(_this);
  7778. break;
  7779. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7780. _this._onCutText(clipboardInfo.event);
  7781. _this.onTextCutObservable.notifyObservers(_this);
  7782. break;
  7783. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7784. _this._onPasteText(clipboardInfo.event);
  7785. _this.onTextPasteObservable.notifyObservers(_this);
  7786. break;
  7787. default: return;
  7788. }
  7789. });
  7790. var scene = this._host.getScene();
  7791. if (scene) {
  7792. //register the pointer double tap event
  7793. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7794. if (!_this._isFocused) {
  7795. return;
  7796. }
  7797. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7798. _this._processDblClick(pointerInfo);
  7799. }
  7800. });
  7801. }
  7802. if (this._onFocusSelectAll) {
  7803. this._selectAllText();
  7804. }
  7805. };
  7806. /**
  7807. * Function to focus an inputText programmatically
  7808. */
  7809. InputText.prototype.focus = function () {
  7810. this._host.moveFocusToControl(this);
  7811. };
  7812. /**
  7813. * Function to unfocus an inputText programmatically
  7814. */
  7815. InputText.prototype.blur = function () {
  7816. this._host.focusedControl = null;
  7817. };
  7818. InputText.prototype._getTypeName = function () {
  7819. return "InputText";
  7820. };
  7821. /**
  7822. * Function called to get the list of controls that should not steal the focus from this control
  7823. * @returns an array of controls
  7824. */
  7825. InputText.prototype.keepsFocusWith = function () {
  7826. if (!this._connectedVirtualKeyboard) {
  7827. return null;
  7828. }
  7829. return [this._connectedVirtualKeyboard];
  7830. };
  7831. /** @hidden */
  7832. InputText.prototype.processKey = function (keyCode, key, evt) {
  7833. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7834. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7835. return;
  7836. }
  7837. //select all
  7838. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7839. this._selectAllText();
  7840. evt.preventDefault();
  7841. return;
  7842. }
  7843. // Specific cases
  7844. switch (keyCode) {
  7845. case 32: //SPACE
  7846. key = " "; //ie11 key for space is "Spacebar"
  7847. break;
  7848. case 191: //SLASH
  7849. if (evt) {
  7850. evt.preventDefault();
  7851. }
  7852. break;
  7853. case 8: // BACKSPACE
  7854. if (this._textWrapper.text && this._textWrapper.length > 0) {
  7855. //delete the highlighted text
  7856. if (this._isTextHighlightOn) {
  7857. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  7858. this._textHasChanged();
  7859. this._isTextHighlightOn = false;
  7860. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  7861. this._blinkIsEven = false;
  7862. if (evt) {
  7863. evt.preventDefault();
  7864. }
  7865. return;
  7866. }
  7867. //delete single character
  7868. if (this._cursorOffset === 0) {
  7869. this.text = this._textWrapper.substr(0, this._textWrapper.length - 1);
  7870. }
  7871. else {
  7872. var deletePosition = this._textWrapper.length - this._cursorOffset;
  7873. if (deletePosition > 0) {
  7874. this._textWrapper.removePart(deletePosition - 1, deletePosition);
  7875. this._textHasChanged();
  7876. }
  7877. }
  7878. }
  7879. if (evt) {
  7880. evt.preventDefault();
  7881. }
  7882. return;
  7883. case 46: // DELETE
  7884. if (this._isTextHighlightOn) {
  7885. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  7886. this._textHasChanged();
  7887. this._isTextHighlightOn = false;
  7888. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  7889. if (evt) {
  7890. evt.preventDefault();
  7891. }
  7892. return;
  7893. }
  7894. if (this._textWrapper.text && this._textWrapper.length > 0 && this._cursorOffset > 0) {
  7895. var deletePosition = this._textWrapper.length - this._cursorOffset;
  7896. this._textWrapper.removePart(deletePosition, deletePosition + 1);
  7897. this._textHasChanged();
  7898. this._cursorOffset--;
  7899. }
  7900. if (evt) {
  7901. evt.preventDefault();
  7902. }
  7903. return;
  7904. case 13: // RETURN
  7905. this._host.focusedControl = null;
  7906. this._isTextHighlightOn = false;
  7907. return;
  7908. case 35: // END
  7909. this._cursorOffset = 0;
  7910. this._blinkIsEven = false;
  7911. this._isTextHighlightOn = false;
  7912. this._markAsDirty();
  7913. return;
  7914. case 36: // HOME
  7915. this._cursorOffset = this._textWrapper.length;
  7916. this._blinkIsEven = false;
  7917. this._isTextHighlightOn = false;
  7918. this._markAsDirty();
  7919. return;
  7920. case 37: // LEFT
  7921. this._cursorOffset++;
  7922. if (this._cursorOffset > this._textWrapper.length) {
  7923. this._cursorOffset = this._textWrapper.length;
  7924. }
  7925. if (evt && evt.shiftKey) {
  7926. // update the cursor
  7927. this._blinkIsEven = false;
  7928. // shift + ctrl/cmd + <-
  7929. if (evt.ctrlKey || evt.metaKey) {
  7930. if (!this._isTextHighlightOn) {
  7931. if (this._textWrapper.length === this._cursorOffset) {
  7932. return;
  7933. }
  7934. else {
  7935. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset + 1;
  7936. }
  7937. }
  7938. this._startHighlightIndex = 0;
  7939. this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
  7940. this._cursorOffset = this._textWrapper.length;
  7941. this._isTextHighlightOn = true;
  7942. this._markAsDirty();
  7943. return;
  7944. }
  7945. //store the starting point
  7946. if (!this._isTextHighlightOn) {
  7947. this._isTextHighlightOn = true;
  7948. this._cursorIndex = (this._cursorOffset >= this._textWrapper.length) ? this._textWrapper.length : this._cursorOffset - 1;
  7949. }
  7950. //if text is already highlighted
  7951. else if (this._cursorIndex === -1) {
  7952. this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
  7953. this._cursorOffset = (this._startHighlightIndex === 0) ? this._textWrapper.length : this._textWrapper.length - this._startHighlightIndex + 1;
  7954. }
  7955. //set the highlight indexes
  7956. if (this._cursorIndex < this._cursorOffset) {
  7957. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  7958. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  7959. }
  7960. else if (this._cursorIndex > this._cursorOffset) {
  7961. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  7962. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  7963. }
  7964. else {
  7965. this._isTextHighlightOn = false;
  7966. }
  7967. this._markAsDirty();
  7968. return;
  7969. }
  7970. if (this._isTextHighlightOn) {
  7971. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  7972. this._isTextHighlightOn = false;
  7973. }
  7974. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7975. this._cursorOffset = this._textWrapper.length;
  7976. evt.preventDefault();
  7977. }
  7978. this._blinkIsEven = false;
  7979. this._isTextHighlightOn = false;
  7980. this._cursorIndex = -1;
  7981. this._markAsDirty();
  7982. return;
  7983. case 39: // RIGHT
  7984. this._cursorOffset--;
  7985. if (this._cursorOffset < 0) {
  7986. this._cursorOffset = 0;
  7987. }
  7988. if (evt && evt.shiftKey) {
  7989. //update the cursor
  7990. this._blinkIsEven = false;
  7991. //shift + ctrl/cmd + ->
  7992. if (evt.ctrlKey || evt.metaKey) {
  7993. if (!this._isTextHighlightOn) {
  7994. if (this._cursorOffset === 0) {
  7995. return;
  7996. }
  7997. else {
  7998. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset - 1;
  7999. }
  8000. }
  8001. this._endHighlightIndex = this._textWrapper.length;
  8002. this._isTextHighlightOn = true;
  8003. this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
  8004. this._cursorOffset = 0;
  8005. this._markAsDirty();
  8006. return;
  8007. }
  8008. if (!this._isTextHighlightOn) {
  8009. this._isTextHighlightOn = true;
  8010. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  8011. }
  8012. //if text is already highlighted
  8013. else if (this._cursorIndex === -1) {
  8014. this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
  8015. this._cursorOffset = (this._textWrapper.length === this._endHighlightIndex) ? 0 : this._textWrapper.length - this._endHighlightIndex - 1;
  8016. }
  8017. //set the highlight indexes
  8018. if (this._cursorIndex < this._cursorOffset) {
  8019. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8020. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8021. }
  8022. else if (this._cursorIndex > this._cursorOffset) {
  8023. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8024. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8025. }
  8026. else {
  8027. this._isTextHighlightOn = false;
  8028. }
  8029. this._markAsDirty();
  8030. return;
  8031. }
  8032. if (this._isTextHighlightOn) {
  8033. this._cursorOffset = this._textWrapper.length - this._endHighlightIndex;
  8034. this._isTextHighlightOn = false;
  8035. }
  8036. //ctr + ->
  8037. if (evt && (evt.ctrlKey || evt.metaKey)) {
  8038. this._cursorOffset = 0;
  8039. evt.preventDefault();
  8040. }
  8041. this._blinkIsEven = false;
  8042. this._isTextHighlightOn = false;
  8043. this._cursorIndex = -1;
  8044. this._markAsDirty();
  8045. return;
  8046. case 222: // Dead
  8047. if (evt) {
  8048. evt.preventDefault();
  8049. }
  8050. this._cursorIndex = -1;
  8051. this.deadKey = true;
  8052. break;
  8053. }
  8054. // Printable characters
  8055. if (key &&
  8056. ((keyCode === -1) || // Direct access
  8057. (keyCode === 32) || // Space
  8058. (keyCode > 47 && keyCode < 64) || // Numbers
  8059. (keyCode > 64 && keyCode < 91) || // Letters
  8060. (keyCode > 159 && keyCode < 193) || // Special characters
  8061. (keyCode > 218 && keyCode < 223) || // Special characters
  8062. (keyCode > 95 && keyCode < 112))) { // Numpad
  8063. this._currentKey = key;
  8064. this.onBeforeKeyAddObservable.notifyObservers(this);
  8065. key = this._currentKey;
  8066. if (this._addKey) {
  8067. if (this._isTextHighlightOn) {
  8068. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex, key);
  8069. this._textHasChanged();
  8070. this._cursorOffset = this._textWrapper.length - (this._startHighlightIndex + 1);
  8071. this._isTextHighlightOn = false;
  8072. this._blinkIsEven = false;
  8073. this._markAsDirty();
  8074. }
  8075. else if (this._cursorOffset === 0) {
  8076. this.text += key;
  8077. }
  8078. else {
  8079. var insertPosition = this._textWrapper.length - this._cursorOffset;
  8080. this._textWrapper.removePart(insertPosition, insertPosition, key);
  8081. this._textHasChanged();
  8082. }
  8083. }
  8084. }
  8085. };
  8086. /** @hidden */
  8087. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  8088. //update the cursor
  8089. this._blinkIsEven = false;
  8090. if (this._cursorIndex === -1) {
  8091. this._cursorIndex = offset;
  8092. }
  8093. else {
  8094. if (this._cursorIndex < this._cursorOffset) {
  8095. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8096. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8097. }
  8098. else if (this._cursorIndex > this._cursorOffset) {
  8099. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8100. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8101. }
  8102. else {
  8103. this._isTextHighlightOn = false;
  8104. this._markAsDirty();
  8105. return;
  8106. }
  8107. }
  8108. this._isTextHighlightOn = true;
  8109. this._markAsDirty();
  8110. };
  8111. /** @hidden */
  8112. InputText.prototype._processDblClick = function (evt) {
  8113. //pre-find the start and end index of the word under cursor, speeds up the rendering
  8114. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8115. this._endHighlightIndex = this._startHighlightIndex;
  8116. var moveLeft, moveRight;
  8117. do {
  8118. moveRight = this._endHighlightIndex < this._textWrapper.length && this._textWrapper.isWord(this._endHighlightIndex) ? ++this._endHighlightIndex : 0;
  8119. moveLeft = this._startHighlightIndex > 0 && this._textWrapper.isWord(this._startHighlightIndex - 1) ? --this._startHighlightIndex : 0;
  8120. } while (moveLeft || moveRight);
  8121. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8122. this.onTextHighlightObservable.notifyObservers(this);
  8123. this._isTextHighlightOn = true;
  8124. this._clickedCoordinate = null;
  8125. this._blinkIsEven = true;
  8126. this._cursorIndex = -1;
  8127. this._markAsDirty();
  8128. };
  8129. /** @hidden */
  8130. InputText.prototype._selectAllText = function () {
  8131. this._blinkIsEven = true;
  8132. this._isTextHighlightOn = true;
  8133. this._startHighlightIndex = 0;
  8134. this._endHighlightIndex = this._textWrapper.length;
  8135. this._cursorOffset = this._textWrapper.length;
  8136. this._cursorIndex = -1;
  8137. this._markAsDirty();
  8138. };
  8139. /**
  8140. * Handles the keyboard event
  8141. * @param evt Defines the KeyboardEvent
  8142. */
  8143. InputText.prototype.processKeyboard = function (evt) {
  8144. // process pressed key
  8145. this.processKey(evt.keyCode, evt.key, evt);
  8146. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  8147. };
  8148. /** @hidden */
  8149. InputText.prototype._onCopyText = function (ev) {
  8150. this._isTextHighlightOn = false;
  8151. //when write permission to clipbaord data is denied
  8152. try {
  8153. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8154. }
  8155. catch (_a) { } //pass
  8156. this._host.clipboardData = this._highlightedText;
  8157. };
  8158. /** @hidden */
  8159. InputText.prototype._onCutText = function (ev) {
  8160. if (!this._highlightedText) {
  8161. return;
  8162. }
  8163. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  8164. this._textHasChanged();
  8165. this._isTextHighlightOn = false;
  8166. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8167. //when write permission to clipbaord data is denied
  8168. try {
  8169. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8170. }
  8171. catch (_a) { } //pass
  8172. this._host.clipboardData = this._highlightedText;
  8173. this._highlightedText = "";
  8174. };
  8175. /** @hidden */
  8176. InputText.prototype._onPasteText = function (ev) {
  8177. var data = "";
  8178. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  8179. data = ev.clipboardData.getData("text/plain");
  8180. }
  8181. else {
  8182. //get the cached data; returns blank string by default
  8183. data = this._host.clipboardData;
  8184. }
  8185. var insertPosition = this._textWrapper.length - this._cursorOffset;
  8186. this._textWrapper.removePart(insertPosition, insertPosition, data);
  8187. this._textHasChanged();
  8188. };
  8189. InputText.prototype._draw = function (context, invalidatedRectangle) {
  8190. var _this = this;
  8191. context.save();
  8192. this._applyStates(context);
  8193. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8194. context.shadowColor = this.shadowColor;
  8195. context.shadowBlur = this.shadowBlur;
  8196. context.shadowOffsetX = this.shadowOffsetX;
  8197. context.shadowOffsetY = this.shadowOffsetY;
  8198. }
  8199. // Background
  8200. if (this._isFocused) {
  8201. if (this._focusedBackground) {
  8202. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  8203. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8204. }
  8205. }
  8206. else if (this._background) {
  8207. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8208. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8209. }
  8210. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8211. context.shadowBlur = 0;
  8212. context.shadowOffsetX = 0;
  8213. context.shadowOffsetY = 0;
  8214. }
  8215. if (!this._fontOffset) {
  8216. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  8217. }
  8218. // Text
  8219. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  8220. if (this.color) {
  8221. context.fillStyle = this.color;
  8222. }
  8223. var text = this._beforeRenderText(this._textWrapper);
  8224. if (!this._isFocused && !this._textWrapper.text && this._placeholderText) {
  8225. text = new _textWrapper__WEBPACK_IMPORTED_MODULE_4__["TextWrapper"]();
  8226. text.text = this._placeholderText;
  8227. if (this._placeholderColor) {
  8228. context.fillStyle = this._placeholderColor;
  8229. }
  8230. }
  8231. this._textWidth = context.measureText(text.text).width;
  8232. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  8233. if (this._autoStretchWidth) {
  8234. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  8235. }
  8236. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  8237. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  8238. context.save();
  8239. context.beginPath();
  8240. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  8241. context.clip();
  8242. if (this._isFocused && this._textWidth > availableWidth) {
  8243. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  8244. if (!this._scrollLeft) {
  8245. this._scrollLeft = textLeft;
  8246. }
  8247. }
  8248. else {
  8249. this._scrollLeft = clipTextLeft;
  8250. }
  8251. context.fillText(text.text, this._scrollLeft, this._currentMeasure.top + rootY);
  8252. // Cursor
  8253. if (this._isFocused) {
  8254. // Need to move cursor
  8255. if (this._clickedCoordinate) {
  8256. var rightPosition = this._scrollLeft + this._textWidth;
  8257. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  8258. var currentSize = 0;
  8259. this._cursorOffset = 0;
  8260. var previousDist = 0;
  8261. do {
  8262. if (this._cursorOffset) {
  8263. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  8264. }
  8265. this._cursorOffset++;
  8266. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  8267. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  8268. // Find closest move
  8269. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8270. this._cursorOffset--;
  8271. }
  8272. this._blinkIsEven = false;
  8273. this._clickedCoordinate = null;
  8274. }
  8275. // Render cursor
  8276. if (!this._blinkIsEven) {
  8277. var cursorOffsetText = text.substr(text.length - this._cursorOffset);
  8278. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8279. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8280. if (cursorLeft < clipTextLeft) {
  8281. this._scrollLeft += (clipTextLeft - cursorLeft);
  8282. cursorLeft = clipTextLeft;
  8283. this._markAsDirty();
  8284. }
  8285. else if (cursorLeft > clipTextLeft + availableWidth) {
  8286. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8287. cursorLeft = clipTextLeft + availableWidth;
  8288. this._markAsDirty();
  8289. }
  8290. if (!this._isTextHighlightOn) {
  8291. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8292. }
  8293. }
  8294. clearTimeout(this._blinkTimeout);
  8295. this._blinkTimeout = setTimeout(function () {
  8296. _this._blinkIsEven = !_this._blinkIsEven;
  8297. _this._markAsDirty();
  8298. }, 500);
  8299. //show the highlighted text
  8300. if (this._isTextHighlightOn) {
  8301. clearTimeout(this._blinkTimeout);
  8302. var highlightCursorOffsetWidth = context.measureText(text.substring(this._startHighlightIndex)).width;
  8303. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8304. this._highlightedText = text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8305. var width = context.measureText(text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8306. if (highlightCursorLeft < clipTextLeft) {
  8307. width = width - (clipTextLeft - highlightCursorLeft);
  8308. if (!width) {
  8309. // when using left arrow on text.length > availableWidth;
  8310. // assigns the width of the first letter after clipTextLeft
  8311. width = context.measureText(text.charAt(text.length - this._cursorOffset)).width;
  8312. }
  8313. highlightCursorLeft = clipTextLeft;
  8314. }
  8315. //for transparancy
  8316. context.globalAlpha = this._highligherOpacity;
  8317. context.fillStyle = this._textHighlightColor;
  8318. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8319. context.globalAlpha = 1.0;
  8320. }
  8321. }
  8322. context.restore();
  8323. // Border
  8324. if (this._thickness) {
  8325. if (this._isFocused) {
  8326. if (this.focusedColor) {
  8327. context.strokeStyle = this.focusedColor;
  8328. }
  8329. }
  8330. else {
  8331. if (this.color) {
  8332. context.strokeStyle = this.color;
  8333. }
  8334. }
  8335. context.lineWidth = this._thickness;
  8336. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8337. }
  8338. context.restore();
  8339. };
  8340. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  8341. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  8342. return false;
  8343. }
  8344. this._clickedCoordinate = coordinates.x;
  8345. this._isTextHighlightOn = false;
  8346. this._highlightedText = "";
  8347. this._cursorIndex = -1;
  8348. this._isPointerDown = true;
  8349. this._host._capturingControl[pointerId] = this;
  8350. if (this._host.focusedControl === this) {
  8351. // Move cursor
  8352. clearTimeout(this._blinkTimeout);
  8353. this._markAsDirty();
  8354. return true;
  8355. }
  8356. if (!this._isEnabled) {
  8357. return false;
  8358. }
  8359. this._host.focusedControl = this;
  8360. return true;
  8361. };
  8362. InputText.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  8363. if (this._host.focusedControl === this && this._isPointerDown) {
  8364. this._clickedCoordinate = coordinates.x;
  8365. this._markAsDirty();
  8366. this._updateValueFromCursorIndex(this._cursorOffset);
  8367. }
  8368. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  8369. };
  8370. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8371. this._isPointerDown = false;
  8372. delete this._host._capturingControl[pointerId];
  8373. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8374. };
  8375. InputText.prototype._beforeRenderText = function (textWrapper) {
  8376. return textWrapper;
  8377. };
  8378. InputText.prototype.dispose = function () {
  8379. _super.prototype.dispose.call(this);
  8380. this.onBlurObservable.clear();
  8381. this.onFocusObservable.clear();
  8382. this.onTextChangedObservable.clear();
  8383. this.onTextCopyObservable.clear();
  8384. this.onTextCutObservable.clear();
  8385. this.onTextPasteObservable.clear();
  8386. this.onTextHighlightObservable.clear();
  8387. this.onKeyboardEventProcessedObservable.clear();
  8388. };
  8389. return InputText;
  8390. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8391. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8392. /***/ }),
  8393. /***/ "./2D/controls/line.ts":
  8394. /*!*****************************!*\
  8395. !*** ./2D/controls/line.ts ***!
  8396. \*****************************/
  8397. /*! exports provided: Line */
  8398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8399. "use strict";
  8400. __webpack_require__.r(__webpack_exports__);
  8401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8402. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8403. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  8404. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8405. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8406. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8407. /** Class used to render 2D lines */
  8408. var Line = /** @class */ (function (_super) {
  8409. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8410. /**
  8411. * Creates a new Line
  8412. * @param name defines the control name
  8413. */
  8414. function Line(name) {
  8415. var _this = _super.call(this, name) || this;
  8416. _this.name = name;
  8417. _this._lineWidth = 1;
  8418. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8419. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8420. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8421. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8422. _this._dash = new Array();
  8423. _this._automaticSize = true;
  8424. _this.isHitTestVisible = false;
  8425. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8426. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8427. return _this;
  8428. }
  8429. Object.defineProperty(Line.prototype, "dash", {
  8430. /** Gets or sets the dash pattern */
  8431. get: function () {
  8432. return this._dash;
  8433. },
  8434. set: function (value) {
  8435. if (this._dash === value) {
  8436. return;
  8437. }
  8438. this._dash = value;
  8439. this._markAsDirty();
  8440. },
  8441. enumerable: false,
  8442. configurable: true
  8443. });
  8444. Object.defineProperty(Line.prototype, "connectedControl", {
  8445. /** Gets or sets the control connected with the line end */
  8446. get: function () {
  8447. return this._connectedControl;
  8448. },
  8449. set: function (value) {
  8450. var _this = this;
  8451. if (this._connectedControl === value) {
  8452. return;
  8453. }
  8454. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8455. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8456. this._connectedControlDirtyObserver = null;
  8457. }
  8458. if (value) {
  8459. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8460. }
  8461. this._connectedControl = value;
  8462. this._markAsDirty();
  8463. },
  8464. enumerable: false,
  8465. configurable: true
  8466. });
  8467. Object.defineProperty(Line.prototype, "x1", {
  8468. /** Gets or sets start coordinates on X axis */
  8469. get: function () {
  8470. return this._x1.toString(this._host);
  8471. },
  8472. set: function (value) {
  8473. if (this._x1.toString(this._host) === value) {
  8474. return;
  8475. }
  8476. if (this._x1.fromString(value)) {
  8477. this._markAsDirty();
  8478. }
  8479. },
  8480. enumerable: false,
  8481. configurable: true
  8482. });
  8483. Object.defineProperty(Line.prototype, "y1", {
  8484. /** Gets or sets start coordinates on Y axis */
  8485. get: function () {
  8486. return this._y1.toString(this._host);
  8487. },
  8488. set: function (value) {
  8489. if (this._y1.toString(this._host) === value) {
  8490. return;
  8491. }
  8492. if (this._y1.fromString(value)) {
  8493. this._markAsDirty();
  8494. }
  8495. },
  8496. enumerable: false,
  8497. configurable: true
  8498. });
  8499. Object.defineProperty(Line.prototype, "x2", {
  8500. /** Gets or sets end coordinates on X axis */
  8501. get: function () {
  8502. return this._x2.toString(this._host);
  8503. },
  8504. set: function (value) {
  8505. if (this._x2.toString(this._host) === value) {
  8506. return;
  8507. }
  8508. if (this._x2.fromString(value)) {
  8509. this._markAsDirty();
  8510. }
  8511. },
  8512. enumerable: false,
  8513. configurable: true
  8514. });
  8515. Object.defineProperty(Line.prototype, "y2", {
  8516. /** Gets or sets end coordinates on Y axis */
  8517. get: function () {
  8518. return this._y2.toString(this._host);
  8519. },
  8520. set: function (value) {
  8521. if (this._y2.toString(this._host) === value) {
  8522. return;
  8523. }
  8524. if (this._y2.fromString(value)) {
  8525. this._markAsDirty();
  8526. }
  8527. },
  8528. enumerable: false,
  8529. configurable: true
  8530. });
  8531. Object.defineProperty(Line.prototype, "lineWidth", {
  8532. /** Gets or sets line width */
  8533. get: function () {
  8534. return this._lineWidth;
  8535. },
  8536. set: function (value) {
  8537. if (this._lineWidth === value) {
  8538. return;
  8539. }
  8540. this._lineWidth = value;
  8541. this._markAsDirty();
  8542. },
  8543. enumerable: false,
  8544. configurable: true
  8545. });
  8546. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8547. /** Gets or sets horizontal alignment */
  8548. set: function (value) {
  8549. return;
  8550. },
  8551. enumerable: false,
  8552. configurable: true
  8553. });
  8554. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8555. /** Gets or sets vertical alignment */
  8556. set: function (value) {
  8557. return;
  8558. },
  8559. enumerable: false,
  8560. configurable: true
  8561. });
  8562. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8563. get: function () {
  8564. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8565. },
  8566. enumerable: false,
  8567. configurable: true
  8568. });
  8569. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8570. get: function () {
  8571. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8572. },
  8573. enumerable: false,
  8574. configurable: true
  8575. });
  8576. Line.prototype._getTypeName = function () {
  8577. return "Line";
  8578. };
  8579. Line.prototype._draw = function (context) {
  8580. context.save();
  8581. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8582. context.shadowColor = this.shadowColor;
  8583. context.shadowBlur = this.shadowBlur;
  8584. context.shadowOffsetX = this.shadowOffsetX;
  8585. context.shadowOffsetY = this.shadowOffsetY;
  8586. }
  8587. this._applyStates(context);
  8588. context.strokeStyle = this.color;
  8589. context.lineWidth = this._lineWidth;
  8590. context.setLineDash(this._dash);
  8591. context.beginPath();
  8592. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8593. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8594. context.stroke();
  8595. context.restore();
  8596. };
  8597. Line.prototype._measure = function () {
  8598. // Width / Height
  8599. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8600. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8601. };
  8602. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8603. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8604. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8605. };
  8606. /**
  8607. * Move one end of the line given 3D cartesian coordinates.
  8608. * @param position Targeted world position
  8609. * @param scene Scene
  8610. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8611. */
  8612. Line.prototype.moveToVector3 = function (position, scene, end) {
  8613. if (end === void 0) { end = false; }
  8614. if (!this._host || this.parent !== this._host._rootContainer) {
  8615. 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");
  8616. return;
  8617. }
  8618. var globalViewport = this._host._getGlobalViewport(scene);
  8619. 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);
  8620. this._moveToProjectedPosition(projectedPosition, end);
  8621. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8622. this.notRenderable = true;
  8623. return;
  8624. }
  8625. this.notRenderable = false;
  8626. };
  8627. /**
  8628. * Move one end of the line to a position in screen absolute space.
  8629. * @param projectedPosition Position in screen absolute space (X, Y)
  8630. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8631. */
  8632. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8633. if (end === void 0) { end = false; }
  8634. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8635. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8636. if (end) {
  8637. this.x2 = x;
  8638. this.y2 = y;
  8639. this._x2.ignoreAdaptiveScaling = true;
  8640. this._y2.ignoreAdaptiveScaling = true;
  8641. }
  8642. else {
  8643. this.x1 = x;
  8644. this.y1 = y;
  8645. this._x1.ignoreAdaptiveScaling = true;
  8646. this._y1.ignoreAdaptiveScaling = true;
  8647. }
  8648. };
  8649. return Line;
  8650. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8651. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8652. /***/ }),
  8653. /***/ "./2D/controls/multiLine.ts":
  8654. /*!**********************************!*\
  8655. !*** ./2D/controls/multiLine.ts ***!
  8656. \**********************************/
  8657. /*! exports provided: MultiLine */
  8658. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8659. "use strict";
  8660. __webpack_require__.r(__webpack_exports__);
  8661. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8662. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8663. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  8664. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8665. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8666. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8667. /**
  8668. * Class used to create multi line control
  8669. */
  8670. var MultiLine = /** @class */ (function (_super) {
  8671. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8672. /**
  8673. * Creates a new MultiLine
  8674. * @param name defines the control name
  8675. */
  8676. function MultiLine(name) {
  8677. var _this = _super.call(this, name) || this;
  8678. _this.name = name;
  8679. _this._lineWidth = 1;
  8680. /** Function called when a point is updated */
  8681. _this.onPointUpdate = function () {
  8682. _this._markAsDirty();
  8683. };
  8684. _this._automaticSize = true;
  8685. _this.isHitTestVisible = false;
  8686. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8687. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8688. _this._dash = [];
  8689. _this._points = [];
  8690. return _this;
  8691. }
  8692. Object.defineProperty(MultiLine.prototype, "dash", {
  8693. /** Gets or sets dash pattern */
  8694. get: function () {
  8695. return this._dash;
  8696. },
  8697. set: function (value) {
  8698. if (this._dash === value) {
  8699. return;
  8700. }
  8701. this._dash = value;
  8702. this._markAsDirty();
  8703. },
  8704. enumerable: false,
  8705. configurable: true
  8706. });
  8707. /**
  8708. * Gets point stored at specified index
  8709. * @param index defines the index to look for
  8710. * @returns the requested point if found
  8711. */
  8712. MultiLine.prototype.getAt = function (index) {
  8713. if (!this._points[index]) {
  8714. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8715. }
  8716. return this._points[index];
  8717. };
  8718. /**
  8719. * Adds new points to the point collection
  8720. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8721. * @returns the list of created MultiLinePoint
  8722. */
  8723. MultiLine.prototype.add = function () {
  8724. var _this = this;
  8725. var items = [];
  8726. for (var _i = 0; _i < arguments.length; _i++) {
  8727. items[_i] = arguments[_i];
  8728. }
  8729. return items.map(function (item) { return _this.push(item); });
  8730. };
  8731. /**
  8732. * Adds a new point to the point collection
  8733. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8734. * @returns the created MultiLinePoint
  8735. */
  8736. MultiLine.prototype.push = function (item) {
  8737. var point = this.getAt(this._points.length);
  8738. if (item == null) {
  8739. return point;
  8740. }
  8741. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8742. point.mesh = item;
  8743. }
  8744. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8745. point.control = item;
  8746. }
  8747. else if (item.x != null && item.y != null) {
  8748. point.x = item.x;
  8749. point.y = item.y;
  8750. }
  8751. return point;
  8752. };
  8753. /**
  8754. * Remove a specific value or point from the active point collection
  8755. * @param value defines the value or point to remove
  8756. */
  8757. MultiLine.prototype.remove = function (value) {
  8758. var index;
  8759. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8760. index = this._points.indexOf(value);
  8761. if (index === -1) {
  8762. return;
  8763. }
  8764. }
  8765. else {
  8766. index = value;
  8767. }
  8768. var point = this._points[index];
  8769. if (!point) {
  8770. return;
  8771. }
  8772. point.dispose();
  8773. this._points.splice(index, 1);
  8774. };
  8775. /**
  8776. * Resets this object to initial state (no point)
  8777. */
  8778. MultiLine.prototype.reset = function () {
  8779. while (this._points.length > 0) {
  8780. this.remove(this._points.length - 1);
  8781. }
  8782. };
  8783. /**
  8784. * Resets all links
  8785. */
  8786. MultiLine.prototype.resetLinks = function () {
  8787. this._points.forEach(function (point) {
  8788. if (point != null) {
  8789. point.resetLinks();
  8790. }
  8791. });
  8792. };
  8793. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8794. /** Gets or sets line width */
  8795. get: function () {
  8796. return this._lineWidth;
  8797. },
  8798. set: function (value) {
  8799. if (this._lineWidth === value) {
  8800. return;
  8801. }
  8802. this._lineWidth = value;
  8803. this._markAsDirty();
  8804. },
  8805. enumerable: false,
  8806. configurable: true
  8807. });
  8808. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8809. set: function (value) {
  8810. return;
  8811. },
  8812. enumerable: false,
  8813. configurable: true
  8814. });
  8815. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8816. set: function (value) {
  8817. return;
  8818. },
  8819. enumerable: false,
  8820. configurable: true
  8821. });
  8822. MultiLine.prototype._getTypeName = function () {
  8823. return "MultiLine";
  8824. };
  8825. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8826. context.save();
  8827. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8828. context.shadowColor = this.shadowColor;
  8829. context.shadowBlur = this.shadowBlur;
  8830. context.shadowOffsetX = this.shadowOffsetX;
  8831. context.shadowOffsetY = this.shadowOffsetY;
  8832. }
  8833. this._applyStates(context);
  8834. context.strokeStyle = this.color;
  8835. context.lineWidth = this._lineWidth;
  8836. context.setLineDash(this._dash);
  8837. context.beginPath();
  8838. var first = true; //first index is not necessarily 0
  8839. var previousPoint;
  8840. this._points.forEach(function (point) {
  8841. if (!point) {
  8842. return;
  8843. }
  8844. if (first) {
  8845. context.moveTo(point._point.x, point._point.y);
  8846. first = false;
  8847. }
  8848. else {
  8849. if (point._point.z < 1 && previousPoint.z < 1) {
  8850. context.lineTo(point._point.x, point._point.y);
  8851. }
  8852. else {
  8853. context.moveTo(point._point.x, point._point.y);
  8854. }
  8855. }
  8856. previousPoint = point._point;
  8857. });
  8858. context.stroke();
  8859. context.restore();
  8860. };
  8861. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8862. var _this = this;
  8863. this._minX = null;
  8864. this._minY = null;
  8865. this._maxX = null;
  8866. this._maxY = null;
  8867. this._points.forEach(function (point, index) {
  8868. if (!point) {
  8869. return;
  8870. }
  8871. point.translate();
  8872. if (_this._minX == null || point._point.x < _this._minX) {
  8873. _this._minX = point._point.x;
  8874. }
  8875. if (_this._minY == null || point._point.y < _this._minY) {
  8876. _this._minY = point._point.y;
  8877. }
  8878. if (_this._maxX == null || point._point.x > _this._maxX) {
  8879. _this._maxX = point._point.x;
  8880. }
  8881. if (_this._maxY == null || point._point.y > _this._maxY) {
  8882. _this._maxY = point._point.y;
  8883. }
  8884. });
  8885. if (this._minX == null) {
  8886. this._minX = 0;
  8887. }
  8888. if (this._minY == null) {
  8889. this._minY = 0;
  8890. }
  8891. if (this._maxX == null) {
  8892. this._maxX = 0;
  8893. }
  8894. if (this._maxY == null) {
  8895. this._maxY = 0;
  8896. }
  8897. };
  8898. MultiLine.prototype._measure = function () {
  8899. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8900. return;
  8901. }
  8902. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8903. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8904. };
  8905. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8906. if (this._minX == null || this._minY == null) {
  8907. return;
  8908. }
  8909. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8910. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8911. };
  8912. MultiLine.prototype.dispose = function () {
  8913. this.reset();
  8914. _super.prototype.dispose.call(this);
  8915. };
  8916. return MultiLine;
  8917. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8918. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8919. /***/ }),
  8920. /***/ "./2D/controls/radioButton.ts":
  8921. /*!************************************!*\
  8922. !*** ./2D/controls/radioButton.ts ***!
  8923. \************************************/
  8924. /*! exports provided: RadioButton */
  8925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8926. "use strict";
  8927. __webpack_require__.r(__webpack_exports__);
  8928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8929. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8930. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  8931. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8932. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8933. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8934. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8935. /**
  8936. * Class used to create radio button controls
  8937. */
  8938. var RadioButton = /** @class */ (function (_super) {
  8939. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8940. /**
  8941. * Creates a new RadioButton
  8942. * @param name defines the control name
  8943. */
  8944. function RadioButton(name) {
  8945. var _this = _super.call(this, name) || this;
  8946. _this.name = name;
  8947. _this._isChecked = false;
  8948. _this._background = "black";
  8949. _this._checkSizeRatio = 0.8;
  8950. _this._thickness = 1;
  8951. /** Gets or sets group name */
  8952. _this.group = "";
  8953. /** Observable raised when isChecked is changed */
  8954. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8955. _this.isPointerBlocker = true;
  8956. return _this;
  8957. }
  8958. Object.defineProperty(RadioButton.prototype, "thickness", {
  8959. /** Gets or sets border thickness */
  8960. get: function () {
  8961. return this._thickness;
  8962. },
  8963. set: function (value) {
  8964. if (this._thickness === value) {
  8965. return;
  8966. }
  8967. this._thickness = value;
  8968. this._markAsDirty();
  8969. },
  8970. enumerable: false,
  8971. configurable: true
  8972. });
  8973. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8974. /** Gets or sets a value indicating the ratio between overall size and check size */
  8975. get: function () {
  8976. return this._checkSizeRatio;
  8977. },
  8978. set: function (value) {
  8979. value = Math.max(Math.min(1, value), 0);
  8980. if (this._checkSizeRatio === value) {
  8981. return;
  8982. }
  8983. this._checkSizeRatio = value;
  8984. this._markAsDirty();
  8985. },
  8986. enumerable: false,
  8987. configurable: true
  8988. });
  8989. Object.defineProperty(RadioButton.prototype, "background", {
  8990. /** Gets or sets background color */
  8991. get: function () {
  8992. return this._background;
  8993. },
  8994. set: function (value) {
  8995. if (this._background === value) {
  8996. return;
  8997. }
  8998. this._background = value;
  8999. this._markAsDirty();
  9000. },
  9001. enumerable: false,
  9002. configurable: true
  9003. });
  9004. Object.defineProperty(RadioButton.prototype, "isChecked", {
  9005. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  9006. get: function () {
  9007. return this._isChecked;
  9008. },
  9009. set: function (value) {
  9010. var _this = this;
  9011. if (this._isChecked === value) {
  9012. return;
  9013. }
  9014. this._isChecked = value;
  9015. this._markAsDirty();
  9016. this.onIsCheckedChangedObservable.notifyObservers(value);
  9017. if (this._isChecked && this._host) {
  9018. // Update all controls from same group
  9019. this._host.executeOnAllControls(function (control) {
  9020. if (control === _this) {
  9021. return;
  9022. }
  9023. if (control.group === undefined) {
  9024. return;
  9025. }
  9026. var childRadio = control;
  9027. if (childRadio.group === _this.group) {
  9028. childRadio.isChecked = false;
  9029. }
  9030. });
  9031. }
  9032. },
  9033. enumerable: false,
  9034. configurable: true
  9035. });
  9036. RadioButton.prototype._getTypeName = function () {
  9037. return "RadioButton";
  9038. };
  9039. RadioButton.prototype._draw = function (context) {
  9040. context.save();
  9041. this._applyStates(context);
  9042. var actualWidth = this._currentMeasure.width - this._thickness;
  9043. var actualHeight = this._currentMeasure.height - this._thickness;
  9044. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9045. context.shadowColor = this.shadowColor;
  9046. context.shadowBlur = this.shadowBlur;
  9047. context.shadowOffsetX = this.shadowOffsetX;
  9048. context.shadowOffsetY = this.shadowOffsetY;
  9049. }
  9050. // Outer
  9051. _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);
  9052. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  9053. context.fill();
  9054. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9055. context.shadowBlur = 0;
  9056. context.shadowOffsetX = 0;
  9057. context.shadowOffsetY = 0;
  9058. }
  9059. context.strokeStyle = this.color;
  9060. context.lineWidth = this._thickness;
  9061. context.stroke();
  9062. // Inner
  9063. if (this._isChecked) {
  9064. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  9065. var offsetWidth = actualWidth * this._checkSizeRatio;
  9066. var offseHeight = actualHeight * this._checkSizeRatio;
  9067. _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);
  9068. context.fill();
  9069. }
  9070. context.restore();
  9071. };
  9072. // Events
  9073. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  9074. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  9075. return false;
  9076. }
  9077. if (!this.isChecked) {
  9078. this.isChecked = true;
  9079. }
  9080. return true;
  9081. };
  9082. /**
  9083. * Utility function to easily create a radio button with a header
  9084. * @param title defines the label to use for the header
  9085. * @param group defines the group to use for the radio button
  9086. * @param isChecked defines the initial state of the radio button
  9087. * @param onValueChanged defines the callback to call when value changes
  9088. * @returns a StackPanel containing the radio button and a textBlock
  9089. */
  9090. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  9091. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  9092. panel.isVertical = false;
  9093. panel.height = "30px";
  9094. var radio = new RadioButton();
  9095. radio.width = "20px";
  9096. radio.height = "20px";
  9097. radio.isChecked = isChecked;
  9098. radio.color = "green";
  9099. radio.group = group;
  9100. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  9101. panel.addControl(radio);
  9102. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  9103. header.text = title;
  9104. header.width = "180px";
  9105. header.paddingLeft = "5px";
  9106. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9107. header.color = "white";
  9108. panel.addControl(header);
  9109. return panel;
  9110. };
  9111. return RadioButton;
  9112. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9113. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  9114. /***/ }),
  9115. /***/ "./2D/controls/rectangle.ts":
  9116. /*!**********************************!*\
  9117. !*** ./2D/controls/rectangle.ts ***!
  9118. \**********************************/
  9119. /*! exports provided: Rectangle */
  9120. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9121. "use strict";
  9122. __webpack_require__.r(__webpack_exports__);
  9123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  9124. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9125. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9126. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  9127. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  9128. /** Class used to create rectangle container */
  9129. var Rectangle = /** @class */ (function (_super) {
  9130. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  9131. /**
  9132. * Creates a new Rectangle
  9133. * @param name defines the control name
  9134. */
  9135. function Rectangle(name) {
  9136. var _this = _super.call(this, name) || this;
  9137. _this.name = name;
  9138. _this._thickness = 1;
  9139. _this._cornerRadius = 0;
  9140. return _this;
  9141. }
  9142. Object.defineProperty(Rectangle.prototype, "thickness", {
  9143. /** Gets or sets border thickness */
  9144. get: function () {
  9145. return this._thickness;
  9146. },
  9147. set: function (value) {
  9148. if (this._thickness === value) {
  9149. return;
  9150. }
  9151. this._thickness = value;
  9152. this._markAsDirty();
  9153. },
  9154. enumerable: false,
  9155. configurable: true
  9156. });
  9157. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  9158. /** Gets or sets the corner radius angle */
  9159. get: function () {
  9160. return this._cornerRadius;
  9161. },
  9162. set: function (value) {
  9163. if (value < 0) {
  9164. value = 0;
  9165. }
  9166. if (this._cornerRadius === value) {
  9167. return;
  9168. }
  9169. this._cornerRadius = value;
  9170. this._markAsDirty();
  9171. },
  9172. enumerable: false,
  9173. configurable: true
  9174. });
  9175. Rectangle.prototype._getTypeName = function () {
  9176. return "Rectangle";
  9177. };
  9178. Rectangle.prototype._localDraw = function (context) {
  9179. context.save();
  9180. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9181. context.shadowColor = this.shadowColor;
  9182. context.shadowBlur = this.shadowBlur;
  9183. context.shadowOffsetX = this.shadowOffsetX;
  9184. context.shadowOffsetY = this.shadowOffsetY;
  9185. }
  9186. if (this._background) {
  9187. context.fillStyle = this._background;
  9188. if (this._cornerRadius) {
  9189. this._drawRoundedRect(context, this._thickness / 2);
  9190. context.fill();
  9191. }
  9192. else {
  9193. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  9194. }
  9195. }
  9196. if (this._thickness) {
  9197. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9198. context.shadowBlur = 0;
  9199. context.shadowOffsetX = 0;
  9200. context.shadowOffsetY = 0;
  9201. }
  9202. if (this.color) {
  9203. context.strokeStyle = this.color;
  9204. }
  9205. context.lineWidth = this._thickness;
  9206. if (this._cornerRadius) {
  9207. this._drawRoundedRect(context, this._thickness / 2);
  9208. context.stroke();
  9209. }
  9210. else {
  9211. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  9212. }
  9213. }
  9214. context.restore();
  9215. };
  9216. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  9217. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9218. this._measureForChildren.width -= 2 * this._thickness;
  9219. this._measureForChildren.height -= 2 * this._thickness;
  9220. this._measureForChildren.left += this._thickness;
  9221. this._measureForChildren.top += this._thickness;
  9222. };
  9223. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  9224. if (offset === void 0) { offset = 0; }
  9225. var x = this._currentMeasure.left + offset;
  9226. var y = this._currentMeasure.top + offset;
  9227. var width = this._currentMeasure.width - offset * 2;
  9228. var height = this._currentMeasure.height - offset * 2;
  9229. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  9230. context.beginPath();
  9231. context.moveTo(x + radius, y);
  9232. context.lineTo(x + width - radius, y);
  9233. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  9234. context.lineTo(x + width, y + height - radius);
  9235. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  9236. context.lineTo(x + radius, y + height);
  9237. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  9238. context.lineTo(x, y + radius);
  9239. context.quadraticCurveTo(x, y, x + radius, y);
  9240. context.closePath();
  9241. };
  9242. Rectangle.prototype._clipForChildren = function (context) {
  9243. if (this._cornerRadius) {
  9244. this._drawRoundedRect(context, this._thickness);
  9245. context.clip();
  9246. }
  9247. };
  9248. return Rectangle;
  9249. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9250. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  9251. /***/ }),
  9252. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  9253. /*!***************************************************!*\
  9254. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  9255. \***************************************************/
  9256. /*! exports provided: ScrollViewer */
  9257. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9258. "use strict";
  9259. __webpack_require__.r(__webpack_exports__);
  9260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  9261. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9262. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  9263. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  9264. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9265. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  9266. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  9267. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  9268. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  9269. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  9270. /**
  9271. * Class used to hold a viewer window and sliders in a grid
  9272. */
  9273. var ScrollViewer = /** @class */ (function (_super) {
  9274. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  9275. /**
  9276. * Creates a new ScrollViewer
  9277. * @param name of ScrollViewer
  9278. */
  9279. function ScrollViewer(name, isImageBased) {
  9280. var _this = _super.call(this, name) || this;
  9281. _this._barSize = 20;
  9282. _this._pointerIsOver = false;
  9283. _this._wheelPrecision = 0.05;
  9284. _this._thumbLength = 0.5;
  9285. _this._thumbHeight = 1;
  9286. _this._barImageHeight = 1;
  9287. _this._horizontalBarImageHeight = 1;
  9288. _this._verticalBarImageHeight = 1;
  9289. _this._oldWindowContentsWidth = 0;
  9290. _this._oldWindowContentsHeight = 0;
  9291. _this._forceHorizontalBar = false;
  9292. _this._forceVerticalBar = false;
  9293. _this._useImageBar = isImageBased ? isImageBased : false;
  9294. _this.onDirtyObservable.add(function () {
  9295. _this._horizontalBarSpace.color = _this.color;
  9296. _this._verticalBarSpace.color = _this.color;
  9297. _this._dragSpace.color = _this.color;
  9298. });
  9299. _this.onPointerEnterObservable.add(function () {
  9300. _this._pointerIsOver = true;
  9301. });
  9302. _this.onPointerOutObservable.add(function () {
  9303. _this._pointerIsOver = false;
  9304. });
  9305. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9306. if (_this._useImageBar) {
  9307. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9308. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9309. }
  9310. else {
  9311. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9312. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9313. }
  9314. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9315. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9316. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9317. _this._grid.addColumnDefinition(1);
  9318. _this._grid.addColumnDefinition(0, true);
  9319. _this._grid.addRowDefinition(1);
  9320. _this._grid.addRowDefinition(0, true);
  9321. _super.prototype.addControl.call(_this, _this._grid);
  9322. _this._grid.addControl(_this._window, 0, 0);
  9323. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9324. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9325. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9326. _this._verticalBarSpace.thickness = 1;
  9327. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9328. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9329. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9330. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9331. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9332. _this._horizontalBarSpace.thickness = 1;
  9333. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9334. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9335. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9336. _this._dragSpace.thickness = 1;
  9337. _this._grid.addControl(_this._dragSpace, 1, 1);
  9338. // Colors
  9339. if (!_this._useImageBar) {
  9340. _this.barColor = "grey";
  9341. _this.barBackground = "transparent";
  9342. }
  9343. return _this;
  9344. }
  9345. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9346. /**
  9347. * Gets the horizontal scrollbar
  9348. */
  9349. get: function () {
  9350. return this._horizontalBar;
  9351. },
  9352. enumerable: false,
  9353. configurable: true
  9354. });
  9355. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9356. /**
  9357. * Gets the vertical scrollbar
  9358. */
  9359. get: function () {
  9360. return this._verticalBar;
  9361. },
  9362. enumerable: false,
  9363. configurable: true
  9364. });
  9365. /**
  9366. * Adds a new control to the current container
  9367. * @param control defines the control to add
  9368. * @returns the current container
  9369. */
  9370. ScrollViewer.prototype.addControl = function (control) {
  9371. if (!control) {
  9372. return this;
  9373. }
  9374. this._window.addControl(control);
  9375. return this;
  9376. };
  9377. /**
  9378. * Removes a control from the current container
  9379. * @param control defines the control to remove
  9380. * @returns the current container
  9381. */
  9382. ScrollViewer.prototype.removeControl = function (control) {
  9383. this._window.removeControl(control);
  9384. return this;
  9385. };
  9386. Object.defineProperty(ScrollViewer.prototype, "children", {
  9387. /** Gets the list of children */
  9388. get: function () {
  9389. return this._window.children;
  9390. },
  9391. enumerable: false,
  9392. configurable: true
  9393. });
  9394. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9395. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9396. var child = _a[_i];
  9397. child._markMatrixAsDirty();
  9398. }
  9399. };
  9400. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9401. /**
  9402. * Freezes or unfreezes the controls in the window.
  9403. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9404. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9405. */
  9406. get: function () {
  9407. return this._window.freezeControls;
  9408. },
  9409. set: function (value) {
  9410. this._window.freezeControls = value;
  9411. },
  9412. enumerable: false,
  9413. configurable: true
  9414. });
  9415. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9416. /** Gets the bucket width */
  9417. get: function () {
  9418. return this._window.bucketWidth;
  9419. },
  9420. enumerable: false,
  9421. configurable: true
  9422. });
  9423. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9424. /** Gets the bucket height */
  9425. get: function () {
  9426. return this._window.bucketHeight;
  9427. },
  9428. enumerable: false,
  9429. configurable: true
  9430. });
  9431. /**
  9432. * Sets the bucket sizes.
  9433. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9434. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9435. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9436. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9437. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9438. * used), that's why it is not enabled by default.
  9439. * @param width width of the bucket
  9440. * @param height height of the bucket
  9441. */
  9442. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9443. this._window.setBucketSizes(width, height);
  9444. };
  9445. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9446. /**
  9447. * Forces the horizontal scroll bar to be displayed
  9448. */
  9449. get: function () {
  9450. return this._forceHorizontalBar;
  9451. },
  9452. set: function (value) {
  9453. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9454. this._horizontalBar.isVisible = value;
  9455. this._forceHorizontalBar = value;
  9456. },
  9457. enumerable: false,
  9458. configurable: true
  9459. });
  9460. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9461. /**
  9462. * Forces the vertical scroll bar to be displayed
  9463. */
  9464. get: function () {
  9465. return this._forceVerticalBar;
  9466. },
  9467. set: function (value) {
  9468. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9469. this._verticalBar.isVisible = value;
  9470. this._forceVerticalBar = value;
  9471. },
  9472. enumerable: false,
  9473. configurable: true
  9474. });
  9475. /** Reset the scroll viewer window to initial size */
  9476. ScrollViewer.prototype.resetWindow = function () {
  9477. this._window.width = "100%";
  9478. this._window.height = "100%";
  9479. };
  9480. ScrollViewer.prototype._getTypeName = function () {
  9481. return "ScrollViewer";
  9482. };
  9483. ScrollViewer.prototype._buildClientSizes = function () {
  9484. var ratio = this.host.idealRatio;
  9485. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9486. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9487. this._clientWidth = this._window.parentClientWidth;
  9488. this._clientHeight = this._window.parentClientHeight;
  9489. };
  9490. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9491. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9492. this._buildClientSizes();
  9493. };
  9494. ScrollViewer.prototype._postMeasure = function () {
  9495. _super.prototype._postMeasure.call(this);
  9496. this._updateScroller();
  9497. this._setWindowPosition(false);
  9498. };
  9499. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9500. /**
  9501. * Gets or sets the mouse wheel precision
  9502. * from 0 to 1 with a default value of 0.05
  9503. * */
  9504. get: function () {
  9505. return this._wheelPrecision;
  9506. },
  9507. set: function (value) {
  9508. if (this._wheelPrecision === value) {
  9509. return;
  9510. }
  9511. if (value < 0) {
  9512. value = 0;
  9513. }
  9514. if (value > 1) {
  9515. value = 1;
  9516. }
  9517. this._wheelPrecision = value;
  9518. },
  9519. enumerable: false,
  9520. configurable: true
  9521. });
  9522. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9523. /** Gets or sets the scroll bar container background color */
  9524. get: function () {
  9525. return this._horizontalBarSpace.background;
  9526. },
  9527. set: function (color) {
  9528. if (this._horizontalBarSpace.background === color) {
  9529. return;
  9530. }
  9531. this._horizontalBarSpace.background = color;
  9532. this._verticalBarSpace.background = color;
  9533. },
  9534. enumerable: false,
  9535. configurable: true
  9536. });
  9537. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9538. /** Gets or sets the bar color */
  9539. get: function () {
  9540. return this._barColor;
  9541. },
  9542. set: function (color) {
  9543. if (this._barColor === color) {
  9544. return;
  9545. }
  9546. this._barColor = color;
  9547. this._horizontalBar.color = color;
  9548. this._verticalBar.color = color;
  9549. },
  9550. enumerable: false,
  9551. configurable: true
  9552. });
  9553. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9554. /** Gets or sets the bar image */
  9555. get: function () {
  9556. return this._barImage;
  9557. },
  9558. set: function (value) {
  9559. if (this._barImage === value) {
  9560. return;
  9561. }
  9562. this._barImage = value;
  9563. var hb = this._horizontalBar;
  9564. var vb = this._verticalBar;
  9565. hb.thumbImage = value;
  9566. vb.thumbImage = value;
  9567. },
  9568. enumerable: false,
  9569. configurable: true
  9570. });
  9571. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9572. /** Gets or sets the horizontal bar image */
  9573. get: function () {
  9574. return this._horizontalBarImage;
  9575. },
  9576. set: function (value) {
  9577. if (this._horizontalBarImage === value) {
  9578. return;
  9579. }
  9580. this._horizontalBarImage = value;
  9581. var hb = this._horizontalBar;
  9582. hb.thumbImage = value;
  9583. },
  9584. enumerable: false,
  9585. configurable: true
  9586. });
  9587. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9588. /** Gets or sets the vertical bar image */
  9589. get: function () {
  9590. return this._verticalBarImage;
  9591. },
  9592. set: function (value) {
  9593. if (this._verticalBarImage === value) {
  9594. return;
  9595. }
  9596. this._verticalBarImage = value;
  9597. var vb = this._verticalBar;
  9598. vb.thumbImage = value;
  9599. },
  9600. enumerable: false,
  9601. configurable: true
  9602. });
  9603. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9604. /** Gets or sets the size of the bar */
  9605. get: function () {
  9606. return this._barSize;
  9607. },
  9608. set: function (value) {
  9609. if (this._barSize === value) {
  9610. return;
  9611. }
  9612. this._barSize = value;
  9613. this._markAsDirty();
  9614. if (this._horizontalBar.isVisible) {
  9615. this._grid.setRowDefinition(1, this._barSize, true);
  9616. }
  9617. if (this._verticalBar.isVisible) {
  9618. this._grid.setColumnDefinition(1, this._barSize, true);
  9619. }
  9620. },
  9621. enumerable: false,
  9622. configurable: true
  9623. });
  9624. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9625. /** Gets or sets the length of the thumb */
  9626. get: function () {
  9627. return this._thumbLength;
  9628. },
  9629. set: function (value) {
  9630. if (this._thumbLength === value) {
  9631. return;
  9632. }
  9633. if (value <= 0) {
  9634. value = 0.1;
  9635. }
  9636. if (value > 1) {
  9637. value = 1;
  9638. }
  9639. this._thumbLength = value;
  9640. var hb = this._horizontalBar;
  9641. var vb = this._verticalBar;
  9642. hb.thumbLength = value;
  9643. vb.thumbLength = value;
  9644. this._markAsDirty();
  9645. },
  9646. enumerable: false,
  9647. configurable: true
  9648. });
  9649. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9650. /** Gets or sets the height of the thumb */
  9651. get: function () {
  9652. return this._thumbHeight;
  9653. },
  9654. set: function (value) {
  9655. if (this._thumbHeight === value) {
  9656. return;
  9657. }
  9658. if (value <= 0) {
  9659. value = 0.1;
  9660. }
  9661. if (value > 1) {
  9662. value = 1;
  9663. }
  9664. this._thumbHeight = value;
  9665. var hb = this._horizontalBar;
  9666. var vb = this._verticalBar;
  9667. hb.thumbHeight = value;
  9668. vb.thumbHeight = value;
  9669. this._markAsDirty();
  9670. },
  9671. enumerable: false,
  9672. configurable: true
  9673. });
  9674. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9675. /** Gets or sets the height of the bar image */
  9676. get: function () {
  9677. return this._barImageHeight;
  9678. },
  9679. set: function (value) {
  9680. if (this._barImageHeight === value) {
  9681. return;
  9682. }
  9683. if (value <= 0) {
  9684. value = 0.1;
  9685. }
  9686. if (value > 1) {
  9687. value = 1;
  9688. }
  9689. this._barImageHeight = value;
  9690. var hb = this._horizontalBar;
  9691. var vb = this._verticalBar;
  9692. hb.barImageHeight = value;
  9693. vb.barImageHeight = value;
  9694. this._markAsDirty();
  9695. },
  9696. enumerable: false,
  9697. configurable: true
  9698. });
  9699. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9700. /** Gets or sets the height of the horizontal bar image */
  9701. get: function () {
  9702. return this._horizontalBarImageHeight;
  9703. },
  9704. set: function (value) {
  9705. if (this._horizontalBarImageHeight === value) {
  9706. return;
  9707. }
  9708. if (value <= 0) {
  9709. value = 0.1;
  9710. }
  9711. if (value > 1) {
  9712. value = 1;
  9713. }
  9714. this._horizontalBarImageHeight = value;
  9715. var hb = this._horizontalBar;
  9716. hb.barImageHeight = value;
  9717. this._markAsDirty();
  9718. },
  9719. enumerable: false,
  9720. configurable: true
  9721. });
  9722. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9723. /** Gets or sets the height of the vertical bar image */
  9724. get: function () {
  9725. return this._verticalBarImageHeight;
  9726. },
  9727. set: function (value) {
  9728. if (this._verticalBarImageHeight === value) {
  9729. return;
  9730. }
  9731. if (value <= 0) {
  9732. value = 0.1;
  9733. }
  9734. if (value > 1) {
  9735. value = 1;
  9736. }
  9737. this._verticalBarImageHeight = value;
  9738. var vb = this._verticalBar;
  9739. vb.barImageHeight = value;
  9740. this._markAsDirty();
  9741. },
  9742. enumerable: false,
  9743. configurable: true
  9744. });
  9745. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9746. /** Gets or sets the bar background */
  9747. get: function () {
  9748. return this._barBackground;
  9749. },
  9750. set: function (color) {
  9751. if (this._barBackground === color) {
  9752. return;
  9753. }
  9754. this._barBackground = color;
  9755. var hb = this._horizontalBar;
  9756. var vb = this._verticalBar;
  9757. hb.background = color;
  9758. vb.background = color;
  9759. this._dragSpace.background = color;
  9760. },
  9761. enumerable: false,
  9762. configurable: true
  9763. });
  9764. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9765. /** Gets or sets the bar background image */
  9766. get: function () {
  9767. return this._barBackgroundImage;
  9768. },
  9769. set: function (value) {
  9770. if (this._barBackgroundImage === value) {
  9771. }
  9772. this._barBackgroundImage = value;
  9773. var hb = this._horizontalBar;
  9774. var vb = this._verticalBar;
  9775. hb.backgroundImage = value;
  9776. vb.backgroundImage = value;
  9777. },
  9778. enumerable: false,
  9779. configurable: true
  9780. });
  9781. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9782. /** Gets or sets the horizontal bar background image */
  9783. get: function () {
  9784. return this._horizontalBarBackgroundImage;
  9785. },
  9786. set: function (value) {
  9787. if (this._horizontalBarBackgroundImage === value) {
  9788. }
  9789. this._horizontalBarBackgroundImage = value;
  9790. var hb = this._horizontalBar;
  9791. hb.backgroundImage = value;
  9792. },
  9793. enumerable: false,
  9794. configurable: true
  9795. });
  9796. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9797. /** Gets or sets the vertical bar background image */
  9798. get: function () {
  9799. return this._verticalBarBackgroundImage;
  9800. },
  9801. set: function (value) {
  9802. if (this._verticalBarBackgroundImage === value) {
  9803. }
  9804. this._verticalBarBackgroundImage = value;
  9805. var vb = this._verticalBar;
  9806. vb.backgroundImage = value;
  9807. },
  9808. enumerable: false,
  9809. configurable: true
  9810. });
  9811. ScrollViewer.prototype._setWindowPosition = function (force) {
  9812. if (force === void 0) { force = true; }
  9813. var ratio = this.host.idealRatio;
  9814. var windowContentsWidth = this._window._currentMeasure.width;
  9815. var windowContentsHeight = this._window._currentMeasure.height;
  9816. if (!force && this._oldWindowContentsWidth === windowContentsWidth && this._oldWindowContentsHeight === windowContentsHeight) {
  9817. return;
  9818. }
  9819. this._oldWindowContentsWidth = windowContentsWidth;
  9820. this._oldWindowContentsHeight = windowContentsHeight;
  9821. var _endLeft = this._clientWidth - windowContentsWidth;
  9822. var _endTop = this._clientHeight - windowContentsHeight;
  9823. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9824. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9825. if (newLeft !== this._window.left) {
  9826. this._window.left = newLeft;
  9827. if (!this.freezeControls) {
  9828. this._rebuildLayout = true;
  9829. }
  9830. }
  9831. if (newTop !== this._window.top) {
  9832. this._window.top = newTop;
  9833. if (!this.freezeControls) {
  9834. this._rebuildLayout = true;
  9835. }
  9836. }
  9837. };
  9838. /** @hidden */
  9839. ScrollViewer.prototype._updateScroller = function () {
  9840. var windowContentsWidth = this._window._currentMeasure.width;
  9841. var windowContentsHeight = this._window._currentMeasure.height;
  9842. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9843. this._grid.setRowDefinition(1, 0, true);
  9844. this._horizontalBar.isVisible = false;
  9845. this._horizontalBar.value = 0;
  9846. this._rebuildLayout = true;
  9847. }
  9848. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9849. this._grid.setRowDefinition(1, this._barSize, true);
  9850. this._horizontalBar.isVisible = true;
  9851. this._rebuildLayout = true;
  9852. }
  9853. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9854. this._grid.setColumnDefinition(1, 0, true);
  9855. this._verticalBar.isVisible = false;
  9856. this._verticalBar.value = 0;
  9857. this._rebuildLayout = true;
  9858. }
  9859. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9860. this._grid.setColumnDefinition(1, this._barSize, true);
  9861. this._verticalBar.isVisible = true;
  9862. this._rebuildLayout = true;
  9863. }
  9864. this._buildClientSizes();
  9865. var ratio = this.host.idealRatio;
  9866. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9867. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9868. };
  9869. ScrollViewer.prototype._link = function (host) {
  9870. _super.prototype._link.call(this, host);
  9871. this._attachWheel();
  9872. };
  9873. /** @hidden */
  9874. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9875. var _this = this;
  9876. barControl.paddingLeft = 0;
  9877. barControl.width = "100%";
  9878. barControl.height = "100%";
  9879. barControl.barOffset = 0;
  9880. barControl.value = 0;
  9881. barControl.maximum = 1;
  9882. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9883. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9884. barControl.isVertical = isVertical;
  9885. barControl.rotation = rotation;
  9886. barControl.isVisible = false;
  9887. barContainer.addControl(barControl);
  9888. barControl.onValueChangedObservable.add(function (value) {
  9889. _this._setWindowPosition();
  9890. });
  9891. };
  9892. /** @hidden */
  9893. ScrollViewer.prototype._attachWheel = function () {
  9894. var _this = this;
  9895. if (!this._host || this._onWheelObserver) {
  9896. return;
  9897. }
  9898. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  9899. if (!_this._pointerIsOver) {
  9900. return;
  9901. }
  9902. if (_this._verticalBar.isVisible == true) {
  9903. if (pi.y < 0 && _this._verticalBar.value > 0) {
  9904. _this._verticalBar.value -= _this._wheelPrecision;
  9905. }
  9906. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9907. _this._verticalBar.value += _this._wheelPrecision;
  9908. }
  9909. }
  9910. if (_this._horizontalBar.isVisible == true) {
  9911. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9912. _this._horizontalBar.value += _this._wheelPrecision;
  9913. }
  9914. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  9915. _this._horizontalBar.value -= _this._wheelPrecision;
  9916. }
  9917. }
  9918. });
  9919. };
  9920. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9921. if (!this.isHighlighted) {
  9922. return;
  9923. }
  9924. _super.prototype._renderHighlightSpecific.call(this, context);
  9925. this._grid._renderHighlightSpecific(context);
  9926. context.restore();
  9927. };
  9928. /** Releases associated resources */
  9929. ScrollViewer.prototype.dispose = function () {
  9930. this.onWheelObservable.remove(this._onWheelObserver);
  9931. this._onWheelObserver = null;
  9932. _super.prototype.dispose.call(this);
  9933. };
  9934. return ScrollViewer;
  9935. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9936. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9937. /***/ }),
  9938. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9939. /*!*********************************************************!*\
  9940. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9941. \*********************************************************/
  9942. /*! exports provided: _ScrollViewerWindow */
  9943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9944. "use strict";
  9945. __webpack_require__.r(__webpack_exports__);
  9946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9947. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9948. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9949. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9950. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9951. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9952. /**
  9953. * Class used to hold a the container for ScrollViewer
  9954. * @hidden
  9955. */
  9956. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9957. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9958. /**
  9959. * Creates a new ScrollViewerWindow
  9960. * @param name of ScrollViewerWindow
  9961. */
  9962. function _ScrollViewerWindow(name) {
  9963. var _this = _super.call(this, name) || this;
  9964. _this._freezeControls = false;
  9965. _this._bucketWidth = 0;
  9966. _this._bucketHeight = 0;
  9967. _this._buckets = {};
  9968. return _this;
  9969. }
  9970. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9971. get: function () {
  9972. return this._freezeControls;
  9973. },
  9974. set: function (value) {
  9975. if (this._freezeControls === value) {
  9976. return;
  9977. }
  9978. if (!value) {
  9979. this._restoreMeasures();
  9980. }
  9981. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9982. this._freezeControls = false;
  9983. var textureSize = this.host.getSize();
  9984. var renderWidth = textureSize.width;
  9985. var renderHeight = textureSize.height;
  9986. var context = this.host.getContext();
  9987. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9988. this.host._numLayoutCalls = 0;
  9989. this.host._rootContainer._layout(measure, context);
  9990. // in freeze mode, prepare children measures accordingly
  9991. if (value) {
  9992. this._updateMeasures();
  9993. if (this._useBuckets()) {
  9994. this._makeBuckets();
  9995. }
  9996. }
  9997. this._freezeControls = value;
  9998. this.host.markAsDirty(); // redraw with the (new) current settings
  9999. },
  10000. enumerable: false,
  10001. configurable: true
  10002. });
  10003. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  10004. get: function () {
  10005. return this._bucketWidth;
  10006. },
  10007. enumerable: false,
  10008. configurable: true
  10009. });
  10010. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  10011. get: function () {
  10012. return this._bucketHeight;
  10013. },
  10014. enumerable: false,
  10015. configurable: true
  10016. });
  10017. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  10018. this._bucketWidth = width;
  10019. this._bucketHeight = height;
  10020. if (this._useBuckets()) {
  10021. if (this._freezeControls) {
  10022. this._makeBuckets();
  10023. }
  10024. }
  10025. else {
  10026. this._buckets = {};
  10027. }
  10028. };
  10029. _ScrollViewerWindow.prototype._useBuckets = function () {
  10030. return this._bucketWidth > 0 && this._bucketHeight > 0;
  10031. };
  10032. _ScrollViewerWindow.prototype._makeBuckets = function () {
  10033. this._buckets = {};
  10034. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  10035. this._dispatchInBuckets(this._children);
  10036. this._oldLeft = null;
  10037. this._oldTop = null;
  10038. };
  10039. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  10040. for (var i = 0; i < children.length; ++i) {
  10041. var child = children[i];
  10042. var bStartX = Math.max(0, Math.floor((child._customData._origLeft - this._customData.origLeft) / this._bucketWidth)), bEndX = Math.floor((child._customData._origLeft - this._customData.origLeft + child._currentMeasure.width - 1) / this._bucketWidth), bStartY = Math.max(0, Math.floor((child._customData._origTop - this._customData.origTop) / this._bucketHeight)), bEndY = Math.floor((child._customData._origTop - this._customData.origTop + child._currentMeasure.height - 1) / this._bucketHeight);
  10043. while (bStartY <= bEndY) {
  10044. for (var x = bStartX; x <= bEndX; ++x) {
  10045. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  10046. if (!lstc) {
  10047. lstc = [];
  10048. this._buckets[bucket] = lstc;
  10049. }
  10050. lstc.push(child);
  10051. }
  10052. bStartY++;
  10053. }
  10054. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10055. this._dispatchInBuckets(child._children);
  10056. }
  10057. }
  10058. };
  10059. // reset left and top measures for the window and all its children
  10060. _ScrollViewerWindow.prototype._updateMeasures = function () {
  10061. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10062. this._measureForChildren.left -= left;
  10063. this._measureForChildren.top -= top;
  10064. this._currentMeasure.left -= left;
  10065. this._currentMeasure.top -= top;
  10066. this._customData.origLeftForChildren = this._measureForChildren.left;
  10067. this._customData.origTopForChildren = this._measureForChildren.top;
  10068. this._customData.origLeft = this._currentMeasure.left;
  10069. this._customData.origTop = this._currentMeasure.top;
  10070. this._updateChildrenMeasures(this._children, left, top);
  10071. };
  10072. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  10073. for (var i = 0; i < children.length; ++i) {
  10074. var child = children[i];
  10075. child._currentMeasure.left -= left;
  10076. child._currentMeasure.top -= top;
  10077. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  10078. child._customData._origTop = child._currentMeasure.top;
  10079. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10080. this._updateChildrenMeasures(child._children, left, top);
  10081. }
  10082. }
  10083. };
  10084. _ScrollViewerWindow.prototype._restoreMeasures = function () {
  10085. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10086. this._measureForChildren.left = this._customData.origLeftForChildren + left;
  10087. this._measureForChildren.top = this._customData.origTopForChildren + top;
  10088. this._currentMeasure.left = this._customData.origLeft + left;
  10089. this._currentMeasure.top = this._customData.origTop + top;
  10090. };
  10091. _ScrollViewerWindow.prototype._getTypeName = function () {
  10092. return "ScrollViewerWindow";
  10093. };
  10094. /** @hidden */
  10095. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  10096. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10097. this._parentMeasure = parentMeasure;
  10098. this._measureForChildren.left = this._currentMeasure.left;
  10099. this._measureForChildren.top = this._currentMeasure.top;
  10100. this._measureForChildren.width = parentMeasure.width;
  10101. this._measureForChildren.height = parentMeasure.height;
  10102. };
  10103. /** @hidden */
  10104. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  10105. if (this._freezeControls) {
  10106. this.invalidateRect(); // will trigger a redraw of the window
  10107. return false;
  10108. }
  10109. return _super.prototype._layout.call(this, parentMeasure, context);
  10110. };
  10111. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  10112. for (var i = 0; i < children.length; ++i) {
  10113. var child = children[i];
  10114. child._currentMeasure.left = child._customData._origLeft + left;
  10115. child._currentMeasure.top = child._customData._origTop + top;
  10116. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  10117. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10118. this._scrollChildren(child._children, left, top);
  10119. }
  10120. }
  10121. };
  10122. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  10123. 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);
  10124. while (bStartY <= bEndY) {
  10125. for (var x = bStartX; x <= bEndX; ++x) {
  10126. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  10127. if (lstc) {
  10128. for (var i = 0; i < lstc.length; ++i) {
  10129. var child = lstc[i];
  10130. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  10131. child._currentMeasure.top = child._customData._origTop + scrollTop;
  10132. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  10133. }
  10134. }
  10135. }
  10136. bStartY++;
  10137. }
  10138. };
  10139. /** @hidden */
  10140. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  10141. if (!this._freezeControls) {
  10142. _super.prototype._draw.call(this, context, invalidatedRectangle);
  10143. return;
  10144. }
  10145. this._localDraw(context);
  10146. if (this.clipChildren) {
  10147. this._clipForChildren(context);
  10148. }
  10149. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10150. if (this._useBuckets()) {
  10151. if (this._oldLeft !== null && this._oldTop !== null) {
  10152. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  10153. this._scrollChildrenWithBuckets(left, top, left, top);
  10154. }
  10155. else {
  10156. this._scrollChildren(this._children, left, top);
  10157. }
  10158. }
  10159. else {
  10160. this._scrollChildren(this._children, left, top);
  10161. }
  10162. this._oldLeft = left;
  10163. this._oldTop = top;
  10164. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10165. var child = _a[_i];
  10166. if (!child._intersectsRect(this._parentMeasure)) {
  10167. continue;
  10168. }
  10169. child._render(context, this._parentMeasure);
  10170. }
  10171. };
  10172. _ScrollViewerWindow.prototype._postMeasure = function () {
  10173. if (this._freezeControls) {
  10174. _super.prototype._postMeasure.call(this);
  10175. return;
  10176. }
  10177. var maxWidth = this.parentClientWidth;
  10178. var maxHeight = this.parentClientHeight;
  10179. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10180. var child = _a[_i];
  10181. if (!child.isVisible || child.notRenderable) {
  10182. continue;
  10183. }
  10184. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  10185. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  10186. }
  10187. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  10188. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  10189. }
  10190. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width + child.paddingRightInPixels);
  10191. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height + child.paddingBottomInPixels);
  10192. }
  10193. if (this._currentMeasure.width !== maxWidth) {
  10194. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10195. this._currentMeasure.width = maxWidth;
  10196. this._rebuildLayout = true;
  10197. this._isDirty = true;
  10198. }
  10199. if (this._currentMeasure.height !== maxHeight) {
  10200. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10201. this._currentMeasure.height = maxHeight;
  10202. this._rebuildLayout = true;
  10203. this._isDirty = true;
  10204. }
  10205. _super.prototype._postMeasure.call(this);
  10206. };
  10207. return _ScrollViewerWindow;
  10208. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10209. /***/ }),
  10210. /***/ "./2D/controls/selector.ts":
  10211. /*!*********************************!*\
  10212. !*** ./2D/controls/selector.ts ***!
  10213. \*********************************/
  10214. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  10215. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10216. "use strict";
  10217. __webpack_require__.r(__webpack_exports__);
  10218. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  10219. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  10220. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  10221. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  10222. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  10223. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10224. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  10225. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10226. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10227. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10228. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  10229. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  10230. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  10231. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10232. /** Class used to create a RadioGroup
  10233. * which contains groups of radio buttons
  10234. */
  10235. var SelectorGroup = /** @class */ (function () {
  10236. /**
  10237. * Creates a new SelectorGroup
  10238. * @param name of group, used as a group heading
  10239. */
  10240. function SelectorGroup(
  10241. /** name of SelectorGroup */
  10242. name) {
  10243. this.name = name;
  10244. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10245. this._selectors = new Array();
  10246. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10247. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10248. this._groupHeader = this._addGroupHeader(name);
  10249. }
  10250. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  10251. /** Gets the groupPanel of the SelectorGroup */
  10252. get: function () {
  10253. return this._groupPanel;
  10254. },
  10255. enumerable: false,
  10256. configurable: true
  10257. });
  10258. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  10259. /** Gets the selectors array */
  10260. get: function () {
  10261. return this._selectors;
  10262. },
  10263. enumerable: false,
  10264. configurable: true
  10265. });
  10266. Object.defineProperty(SelectorGroup.prototype, "header", {
  10267. /** Gets and sets the group header */
  10268. get: function () {
  10269. return this._groupHeader.text;
  10270. },
  10271. set: function (label) {
  10272. if (this._groupHeader.text === "label") {
  10273. return;
  10274. }
  10275. this._groupHeader.text = label;
  10276. },
  10277. enumerable: false,
  10278. configurable: true
  10279. });
  10280. /** @hidden */
  10281. SelectorGroup.prototype._addGroupHeader = function (text) {
  10282. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  10283. groupHeading.width = 0.9;
  10284. groupHeading.height = "30px";
  10285. groupHeading.textWrapping = true;
  10286. groupHeading.color = "black";
  10287. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10288. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10289. groupHeading.left = "2px";
  10290. this._groupPanel.addControl(groupHeading);
  10291. return groupHeading;
  10292. };
  10293. /** @hidden*/
  10294. SelectorGroup.prototype._getSelector = function (selectorNb) {
  10295. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10296. return;
  10297. }
  10298. return this._selectors[selectorNb];
  10299. };
  10300. /** Removes the selector at the given position
  10301. * @param selectorNb the position of the selector within the group
  10302. */
  10303. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  10304. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10305. return;
  10306. }
  10307. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10308. this._selectors.splice(selectorNb, 1);
  10309. };
  10310. return SelectorGroup;
  10311. }());
  10312. /** Class used to create a CheckboxGroup
  10313. * which contains groups of checkbox buttons
  10314. */
  10315. var CheckboxGroup = /** @class */ (function (_super) {
  10316. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10317. function CheckboxGroup() {
  10318. return _super !== null && _super.apply(this, arguments) || this;
  10319. }
  10320. /** Adds a checkbox as a control
  10321. * @param text is the label for the selector
  10322. * @param func is the function called when the Selector is checked
  10323. * @param checked is true when Selector is checked
  10324. */
  10325. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10326. if (func === void 0) { func = function (s) { }; }
  10327. if (checked === void 0) { checked = false; }
  10328. var checked = checked || false;
  10329. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10330. button.width = "20px";
  10331. button.height = "20px";
  10332. button.color = "#364249";
  10333. button.background = "#CCCCCC";
  10334. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10335. button.onIsCheckedChangedObservable.add(function (state) {
  10336. func(state);
  10337. });
  10338. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10339. _selector.height = "30px";
  10340. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10341. _selector.left = "4px";
  10342. this.groupPanel.addControl(_selector);
  10343. this.selectors.push(_selector);
  10344. button.isChecked = checked;
  10345. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10346. button.color = this.groupPanel.parent.parent.buttonColor;
  10347. button.background = this.groupPanel.parent.parent.buttonBackground;
  10348. }
  10349. };
  10350. /** @hidden */
  10351. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10352. this.selectors[selectorNb].children[1].text = label;
  10353. };
  10354. /** @hidden */
  10355. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10356. this.selectors[selectorNb].children[1].color = color;
  10357. };
  10358. /** @hidden */
  10359. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10360. this.selectors[selectorNb].children[0].color = color;
  10361. };
  10362. /** @hidden */
  10363. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10364. this.selectors[selectorNb].children[0].background = color;
  10365. };
  10366. return CheckboxGroup;
  10367. }(SelectorGroup));
  10368. /** Class used to create a RadioGroup
  10369. * which contains groups of radio buttons
  10370. */
  10371. var RadioGroup = /** @class */ (function (_super) {
  10372. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10373. function RadioGroup() {
  10374. var _this = _super !== null && _super.apply(this, arguments) || this;
  10375. _this._selectNb = 0;
  10376. return _this;
  10377. }
  10378. /** Adds a radio button as a control
  10379. * @param label is the label for the selector
  10380. * @param func is the function called when the Selector is checked
  10381. * @param checked is true when Selector is checked
  10382. */
  10383. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10384. if (func === void 0) { func = function (n) { }; }
  10385. if (checked === void 0) { checked = false; }
  10386. var nb = this._selectNb++;
  10387. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10388. button.name = label;
  10389. button.width = "20px";
  10390. button.height = "20px";
  10391. button.color = "#364249";
  10392. button.background = "#CCCCCC";
  10393. button.group = this.name;
  10394. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10395. button.onIsCheckedChangedObservable.add(function (state) {
  10396. if (state) {
  10397. func(nb);
  10398. }
  10399. });
  10400. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10401. _selector.height = "30px";
  10402. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10403. _selector.left = "4px";
  10404. this.groupPanel.addControl(_selector);
  10405. this.selectors.push(_selector);
  10406. button.isChecked = checked;
  10407. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10408. button.color = this.groupPanel.parent.parent.buttonColor;
  10409. button.background = this.groupPanel.parent.parent.buttonBackground;
  10410. }
  10411. };
  10412. /** @hidden */
  10413. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10414. this.selectors[selectorNb].children[1].text = label;
  10415. };
  10416. /** @hidden */
  10417. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10418. this.selectors[selectorNb].children[1].color = color;
  10419. };
  10420. /** @hidden */
  10421. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10422. this.selectors[selectorNb].children[0].color = color;
  10423. };
  10424. /** @hidden */
  10425. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10426. this.selectors[selectorNb].children[0].background = color;
  10427. };
  10428. return RadioGroup;
  10429. }(SelectorGroup));
  10430. /** Class used to create a SliderGroup
  10431. * which contains groups of slider buttons
  10432. */
  10433. var SliderGroup = /** @class */ (function (_super) {
  10434. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10435. function SliderGroup() {
  10436. return _super !== null && _super.apply(this, arguments) || this;
  10437. }
  10438. /**
  10439. * Adds a slider to the SelectorGroup
  10440. * @param label is the label for the SliderBar
  10441. * @param func is the function called when the Slider moves
  10442. * @param unit is a string describing the units used, eg degrees or metres
  10443. * @param min is the minimum value for the Slider
  10444. * @param max is the maximum value for the Slider
  10445. * @param value is the start value for the Slider between min and max
  10446. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10447. */
  10448. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10449. if (func === void 0) { func = function (v) { }; }
  10450. if (unit === void 0) { unit = "Units"; }
  10451. if (min === void 0) { min = 0; }
  10452. if (max === void 0) { max = 0; }
  10453. if (value === void 0) { value = 0; }
  10454. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10455. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10456. button.name = unit;
  10457. button.value = value;
  10458. button.minimum = min;
  10459. button.maximum = max;
  10460. button.width = 0.9;
  10461. button.height = "20px";
  10462. button.color = "#364249";
  10463. button.background = "#CCCCCC";
  10464. button.borderColor = "black";
  10465. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10466. button.left = "4px";
  10467. button.paddingBottom = "4px";
  10468. button.onValueChangedObservable.add(function (value) {
  10469. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10470. func(value);
  10471. });
  10472. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10473. _selector.height = "60px";
  10474. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10475. _selector.left = "4px";
  10476. _selector.children[0].name = label;
  10477. this.groupPanel.addControl(_selector);
  10478. this.selectors.push(_selector);
  10479. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10480. button.color = this.groupPanel.parent.parent.buttonColor;
  10481. button.background = this.groupPanel.parent.parent.buttonBackground;
  10482. }
  10483. };
  10484. /** @hidden */
  10485. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10486. this.selectors[selectorNb].children[0].name = label;
  10487. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10488. };
  10489. /** @hidden */
  10490. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10491. this.selectors[selectorNb].children[0].color = color;
  10492. };
  10493. /** @hidden */
  10494. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10495. this.selectors[selectorNb].children[1].color = color;
  10496. };
  10497. /** @hidden */
  10498. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10499. this.selectors[selectorNb].children[1].background = color;
  10500. };
  10501. return SliderGroup;
  10502. }(SelectorGroup));
  10503. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10504. * @see https://doc.babylonjs.com/how_to/selector
  10505. */
  10506. var SelectionPanel = /** @class */ (function (_super) {
  10507. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10508. /**
  10509. * Creates a new SelectionPanel
  10510. * @param name of SelectionPanel
  10511. * @param groups is an array of SelectionGroups
  10512. */
  10513. function SelectionPanel(
  10514. /** name of SelectionPanel */
  10515. name,
  10516. /** an array of SelectionGroups */
  10517. groups) {
  10518. if (groups === void 0) { groups = []; }
  10519. var _this = _super.call(this, name) || this;
  10520. _this.name = name;
  10521. _this.groups = groups;
  10522. _this._buttonColor = "#364249";
  10523. _this._buttonBackground = "#CCCCCC";
  10524. _this._headerColor = "black";
  10525. _this._barColor = "white";
  10526. _this._barHeight = "2px";
  10527. _this._spacerHeight = "20px";
  10528. _this._bars = new Array();
  10529. _this._groups = groups;
  10530. _this.thickness = 2;
  10531. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10532. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10533. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10534. _this._panel.top = 5;
  10535. _this._panel.left = 5;
  10536. _this._panel.width = 0.95;
  10537. if (groups.length > 0) {
  10538. for (var i = 0; i < groups.length - 1; i++) {
  10539. _this._panel.addControl(groups[i].groupPanel);
  10540. _this._addSpacer();
  10541. }
  10542. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10543. }
  10544. _this.addControl(_this._panel);
  10545. return _this;
  10546. }
  10547. SelectionPanel.prototype._getTypeName = function () {
  10548. return "SelectionPanel";
  10549. };
  10550. Object.defineProperty(SelectionPanel.prototype, "panel", {
  10551. /** Gets the (stack) panel of the SelectionPanel */
  10552. get: function () {
  10553. return this._panel;
  10554. },
  10555. enumerable: false,
  10556. configurable: true
  10557. });
  10558. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10559. /** Gets or sets the headerColor */
  10560. get: function () {
  10561. return this._headerColor;
  10562. },
  10563. set: function (color) {
  10564. if (this._headerColor === color) {
  10565. return;
  10566. }
  10567. this._headerColor = color;
  10568. this._setHeaderColor();
  10569. },
  10570. enumerable: false,
  10571. configurable: true
  10572. });
  10573. SelectionPanel.prototype._setHeaderColor = function () {
  10574. for (var i = 0; i < this._groups.length; i++) {
  10575. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10576. }
  10577. };
  10578. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10579. /** Gets or sets the button color */
  10580. get: function () {
  10581. return this._buttonColor;
  10582. },
  10583. set: function (color) {
  10584. if (this._buttonColor === color) {
  10585. return;
  10586. }
  10587. this._buttonColor = color;
  10588. this._setbuttonColor();
  10589. },
  10590. enumerable: false,
  10591. configurable: true
  10592. });
  10593. SelectionPanel.prototype._setbuttonColor = function () {
  10594. for (var i = 0; i < this._groups.length; i++) {
  10595. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10596. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10597. }
  10598. }
  10599. };
  10600. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10601. /** Gets or sets the label color */
  10602. get: function () {
  10603. return this._labelColor;
  10604. },
  10605. set: function (color) {
  10606. if (this._labelColor === color) {
  10607. return;
  10608. }
  10609. this._labelColor = color;
  10610. this._setLabelColor();
  10611. },
  10612. enumerable: false,
  10613. configurable: true
  10614. });
  10615. SelectionPanel.prototype._setLabelColor = function () {
  10616. for (var i = 0; i < this._groups.length; i++) {
  10617. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10618. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10619. }
  10620. }
  10621. };
  10622. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10623. /** Gets or sets the button background */
  10624. get: function () {
  10625. return this._buttonBackground;
  10626. },
  10627. set: function (color) {
  10628. if (this._buttonBackground === color) {
  10629. return;
  10630. }
  10631. this._buttonBackground = color;
  10632. this._setButtonBackground();
  10633. },
  10634. enumerable: false,
  10635. configurable: true
  10636. });
  10637. SelectionPanel.prototype._setButtonBackground = function () {
  10638. for (var i = 0; i < this._groups.length; i++) {
  10639. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10640. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10641. }
  10642. }
  10643. };
  10644. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10645. /** Gets or sets the color of separator bar */
  10646. get: function () {
  10647. return this._barColor;
  10648. },
  10649. set: function (color) {
  10650. if (this._barColor === color) {
  10651. return;
  10652. }
  10653. this._barColor = color;
  10654. this._setBarColor();
  10655. },
  10656. enumerable: false,
  10657. configurable: true
  10658. });
  10659. SelectionPanel.prototype._setBarColor = function () {
  10660. for (var i = 0; i < this._bars.length; i++) {
  10661. this._bars[i].children[0].background = this._barColor;
  10662. }
  10663. };
  10664. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10665. /** Gets or sets the height of separator bar */
  10666. get: function () {
  10667. return this._barHeight;
  10668. },
  10669. set: function (value) {
  10670. if (this._barHeight === value) {
  10671. return;
  10672. }
  10673. this._barHeight = value;
  10674. this._setBarHeight();
  10675. },
  10676. enumerable: false,
  10677. configurable: true
  10678. });
  10679. SelectionPanel.prototype._setBarHeight = function () {
  10680. for (var i = 0; i < this._bars.length; i++) {
  10681. this._bars[i].children[0].height = this._barHeight;
  10682. }
  10683. };
  10684. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10685. /** Gets or sets the height of spacers*/
  10686. get: function () {
  10687. return this._spacerHeight;
  10688. },
  10689. set: function (value) {
  10690. if (this._spacerHeight === value) {
  10691. return;
  10692. }
  10693. this._spacerHeight = value;
  10694. this._setSpacerHeight();
  10695. },
  10696. enumerable: false,
  10697. configurable: true
  10698. });
  10699. SelectionPanel.prototype._setSpacerHeight = function () {
  10700. for (var i = 0; i < this._bars.length; i++) {
  10701. this._bars[i].height = this._spacerHeight;
  10702. }
  10703. };
  10704. /** Adds a bar between groups */
  10705. SelectionPanel.prototype._addSpacer = function () {
  10706. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10707. separator.width = 1;
  10708. separator.height = this._spacerHeight;
  10709. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10710. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10711. bar.width = 1;
  10712. bar.height = this._barHeight;
  10713. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10714. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10715. bar.background = this._barColor;
  10716. bar.color = "transparent";
  10717. separator.addControl(bar);
  10718. this._panel.addControl(separator);
  10719. this._bars.push(separator);
  10720. };
  10721. /** Add a group to the selection panel
  10722. * @param group is the selector group to add
  10723. */
  10724. SelectionPanel.prototype.addGroup = function (group) {
  10725. if (this._groups.length > 0) {
  10726. this._addSpacer();
  10727. }
  10728. this._panel.addControl(group.groupPanel);
  10729. this._groups.push(group);
  10730. group.groupPanel.children[0].color = this._headerColor;
  10731. for (var j = 0; j < group.selectors.length; j++) {
  10732. group._setSelectorButtonColor(j, this._buttonColor);
  10733. group._setSelectorButtonBackground(j, this._buttonBackground);
  10734. }
  10735. };
  10736. /** Remove the group from the given position
  10737. * @param groupNb is the position of the group in the list
  10738. */
  10739. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10740. if (groupNb < 0 || groupNb >= this._groups.length) {
  10741. return;
  10742. }
  10743. var group = this._groups[groupNb];
  10744. this._panel.removeControl(group.groupPanel);
  10745. this._groups.splice(groupNb, 1);
  10746. if (groupNb < this._bars.length) {
  10747. this._panel.removeControl(this._bars[groupNb]);
  10748. this._bars.splice(groupNb, 1);
  10749. }
  10750. };
  10751. /** Change a group header label
  10752. * @param label is the new group header label
  10753. * @param groupNb is the number of the group to relabel
  10754. * */
  10755. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10756. if (groupNb < 0 || groupNb >= this._groups.length) {
  10757. return;
  10758. }
  10759. var group = this._groups[groupNb];
  10760. group.groupPanel.children[0].text = label;
  10761. };
  10762. /** Change selector label to the one given
  10763. * @param label is the new selector label
  10764. * @param groupNb is the number of the groupcontaining the selector
  10765. * @param selectorNb is the number of the selector within a group to relabel
  10766. * */
  10767. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10768. if (groupNb < 0 || groupNb >= this._groups.length) {
  10769. return;
  10770. }
  10771. var group = this._groups[groupNb];
  10772. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10773. return;
  10774. }
  10775. group._setSelectorLabel(selectorNb, label);
  10776. };
  10777. /** For a given group position remove the selector at the given position
  10778. * @param groupNb is the number of the group to remove the selector from
  10779. * @param selectorNb is the number of the selector within the group
  10780. */
  10781. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10782. if (groupNb < 0 || groupNb >= this._groups.length) {
  10783. return;
  10784. }
  10785. var group = this._groups[groupNb];
  10786. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10787. return;
  10788. }
  10789. group.removeSelector(selectorNb);
  10790. };
  10791. /** For a given group position of correct type add a checkbox button
  10792. * @param groupNb is the number of the group to remove the selector from
  10793. * @param label is the label for the selector
  10794. * @param func is the function called when the Selector is checked
  10795. * @param checked is true when Selector is checked
  10796. */
  10797. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10798. if (func === void 0) { func = function () { }; }
  10799. if (checked === void 0) { checked = false; }
  10800. if (groupNb < 0 || groupNb >= this._groups.length) {
  10801. return;
  10802. }
  10803. var group = this._groups[groupNb];
  10804. group.addCheckbox(label, func, checked);
  10805. };
  10806. /** For a given group position of correct type add a radio button
  10807. * @param groupNb is the number of the group to remove the selector from
  10808. * @param label is the label for the selector
  10809. * @param func is the function called when the Selector is checked
  10810. * @param checked is true when Selector is checked
  10811. */
  10812. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10813. if (func === void 0) { func = function () { }; }
  10814. if (checked === void 0) { checked = false; }
  10815. if (groupNb < 0 || groupNb >= this._groups.length) {
  10816. return;
  10817. }
  10818. var group = this._groups[groupNb];
  10819. group.addRadio(label, func, checked);
  10820. };
  10821. /**
  10822. * For a given slider group add a slider
  10823. * @param groupNb is the number of the group to add the slider to
  10824. * @param label is the label for the Slider
  10825. * @param func is the function called when the Slider moves
  10826. * @param unit is a string describing the units used, eg degrees or metres
  10827. * @param min is the minimum value for the Slider
  10828. * @param max is the maximum value for the Slider
  10829. * @param value is the start value for the Slider between min and max
  10830. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10831. */
  10832. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10833. if (func === void 0) { func = function () { }; }
  10834. if (unit === void 0) { unit = "Units"; }
  10835. if (min === void 0) { min = 0; }
  10836. if (max === void 0) { max = 0; }
  10837. if (value === void 0) { value = 0; }
  10838. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10839. if (groupNb < 0 || groupNb >= this._groups.length) {
  10840. return;
  10841. }
  10842. var group = this._groups[groupNb];
  10843. group.addSlider(label, func, unit, min, max, value, onVal);
  10844. };
  10845. return SelectionPanel;
  10846. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10847. /***/ }),
  10848. /***/ "./2D/controls/sliders/baseSlider.ts":
  10849. /*!*******************************************!*\
  10850. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10851. \*******************************************/
  10852. /*! exports provided: BaseSlider */
  10853. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10854. "use strict";
  10855. __webpack_require__.r(__webpack_exports__);
  10856. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10857. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10858. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  10859. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10860. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10861. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10862. /**
  10863. * Class used to create slider controls
  10864. */
  10865. var BaseSlider = /** @class */ (function (_super) {
  10866. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10867. /**
  10868. * Creates a new BaseSlider
  10869. * @param name defines the control name
  10870. */
  10871. function BaseSlider(name) {
  10872. var _this = _super.call(this, name) || this;
  10873. _this.name = name;
  10874. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10875. _this._minimum = 0;
  10876. _this._maximum = 100;
  10877. _this._value = 50;
  10878. _this._isVertical = false;
  10879. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10880. _this._isThumbClamped = false;
  10881. _this._displayThumb = true;
  10882. _this._step = 0;
  10883. _this._lastPointerDownID = -1;
  10884. // Shared rendering info
  10885. _this._effectiveBarOffset = 0;
  10886. /** Observable raised when the sldier value changes */
  10887. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10888. // Events
  10889. _this._pointerIsDown = false;
  10890. _this.isPointerBlocker = true;
  10891. return _this;
  10892. }
  10893. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10894. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10895. get: function () {
  10896. return this._displayThumb;
  10897. },
  10898. set: function (value) {
  10899. if (this._displayThumb === value) {
  10900. return;
  10901. }
  10902. this._displayThumb = value;
  10903. this._markAsDirty();
  10904. },
  10905. enumerable: false,
  10906. configurable: true
  10907. });
  10908. Object.defineProperty(BaseSlider.prototype, "step", {
  10909. /** Gets or sets a step to apply to values (0 by default) */
  10910. get: function () {
  10911. return this._step;
  10912. },
  10913. set: function (value) {
  10914. if (this._step === value) {
  10915. return;
  10916. }
  10917. this._step = value;
  10918. this._markAsDirty();
  10919. },
  10920. enumerable: false,
  10921. configurable: true
  10922. });
  10923. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10924. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10925. get: function () {
  10926. return this._barOffset.toString(this._host);
  10927. },
  10928. set: function (value) {
  10929. if (this._barOffset.toString(this._host) === value) {
  10930. return;
  10931. }
  10932. if (this._barOffset.fromString(value)) {
  10933. this._markAsDirty();
  10934. }
  10935. },
  10936. enumerable: false,
  10937. configurable: true
  10938. });
  10939. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10940. /** Gets main bar offset in pixels*/
  10941. get: function () {
  10942. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10943. },
  10944. enumerable: false,
  10945. configurable: true
  10946. });
  10947. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10948. /** Gets or sets thumb width */
  10949. get: function () {
  10950. return this._thumbWidth.toString(this._host);
  10951. },
  10952. set: function (value) {
  10953. if (this._thumbWidth.toString(this._host) === value) {
  10954. return;
  10955. }
  10956. if (this._thumbWidth.fromString(value)) {
  10957. this._markAsDirty();
  10958. }
  10959. },
  10960. enumerable: false,
  10961. configurable: true
  10962. });
  10963. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10964. /** Gets thumb width in pixels */
  10965. get: function () {
  10966. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10967. },
  10968. enumerable: false,
  10969. configurable: true
  10970. });
  10971. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10972. /** Gets or sets minimum value */
  10973. get: function () {
  10974. return this._minimum;
  10975. },
  10976. set: function (value) {
  10977. if (this._minimum === value) {
  10978. return;
  10979. }
  10980. this._minimum = value;
  10981. this._markAsDirty();
  10982. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10983. },
  10984. enumerable: false,
  10985. configurable: true
  10986. });
  10987. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10988. /** Gets or sets maximum value */
  10989. get: function () {
  10990. return this._maximum;
  10991. },
  10992. set: function (value) {
  10993. if (this._maximum === value) {
  10994. return;
  10995. }
  10996. this._maximum = value;
  10997. this._markAsDirty();
  10998. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10999. },
  11000. enumerable: false,
  11001. configurable: true
  11002. });
  11003. Object.defineProperty(BaseSlider.prototype, "value", {
  11004. /** Gets or sets current value */
  11005. get: function () {
  11006. return this._value;
  11007. },
  11008. set: function (value) {
  11009. value = Math.max(Math.min(value, this._maximum), this._minimum);
  11010. if (this._value === value) {
  11011. return;
  11012. }
  11013. this._value = value;
  11014. this._markAsDirty();
  11015. this.onValueChangedObservable.notifyObservers(this._value);
  11016. },
  11017. enumerable: false,
  11018. configurable: true
  11019. });
  11020. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  11021. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  11022. get: function () {
  11023. return this._isVertical;
  11024. },
  11025. set: function (value) {
  11026. if (this._isVertical === value) {
  11027. return;
  11028. }
  11029. this._isVertical = value;
  11030. this._markAsDirty();
  11031. },
  11032. enumerable: false,
  11033. configurable: true
  11034. });
  11035. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  11036. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  11037. get: function () {
  11038. return this._isThumbClamped;
  11039. },
  11040. set: function (value) {
  11041. if (this._isThumbClamped === value) {
  11042. return;
  11043. }
  11044. this._isThumbClamped = value;
  11045. this._markAsDirty();
  11046. },
  11047. enumerable: false,
  11048. configurable: true
  11049. });
  11050. BaseSlider.prototype._getTypeName = function () {
  11051. return "BaseSlider";
  11052. };
  11053. BaseSlider.prototype._getThumbPosition = function () {
  11054. if (this.isVertical) {
  11055. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  11056. }
  11057. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  11058. };
  11059. BaseSlider.prototype._getThumbThickness = function (type) {
  11060. var thumbThickness = 0;
  11061. switch (type) {
  11062. case "circle":
  11063. if (this._thumbWidth.isPixel) {
  11064. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  11065. }
  11066. else {
  11067. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11068. }
  11069. break;
  11070. case "rectangle":
  11071. if (this._thumbWidth.isPixel) {
  11072. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  11073. }
  11074. else {
  11075. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11076. }
  11077. }
  11078. return thumbThickness;
  11079. };
  11080. BaseSlider.prototype._prepareRenderingData = function (type) {
  11081. // Main bar
  11082. this._effectiveBarOffset = 0;
  11083. this._renderLeft = this._currentMeasure.left;
  11084. this._renderTop = this._currentMeasure.top;
  11085. this._renderWidth = this._currentMeasure.width;
  11086. this._renderHeight = this._currentMeasure.height;
  11087. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  11088. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  11089. this._effectiveThumbThickness = this._getThumbThickness(type);
  11090. if (this.displayThumb) {
  11091. this._backgroundBoxLength -= this._effectiveThumbThickness;
  11092. }
  11093. //throw error when height is less than width for vertical slider
  11094. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  11095. console.error("Height should be greater than width");
  11096. return;
  11097. }
  11098. if (this._barOffset.isPixel) {
  11099. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  11100. }
  11101. else {
  11102. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  11103. }
  11104. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  11105. if (this.isVertical) {
  11106. this._renderLeft += this._effectiveBarOffset;
  11107. if (!this.isThumbClamped && this.displayThumb) {
  11108. this._renderTop += (this._effectiveThumbThickness / 2);
  11109. }
  11110. this._renderHeight = this._backgroundBoxLength;
  11111. this._renderWidth = this._backgroundBoxThickness;
  11112. }
  11113. else {
  11114. this._renderTop += this._effectiveBarOffset;
  11115. if (!this.isThumbClamped && this.displayThumb) {
  11116. this._renderLeft += (this._effectiveThumbThickness / 2);
  11117. }
  11118. this._renderHeight = this._backgroundBoxThickness;
  11119. this._renderWidth = this._backgroundBoxLength;
  11120. }
  11121. };
  11122. /** @hidden */
  11123. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  11124. if (this.rotation != 0) {
  11125. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11126. x = this._transformedPosition.x;
  11127. y = this._transformedPosition.y;
  11128. }
  11129. var value;
  11130. if (this._isVertical) {
  11131. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  11132. }
  11133. else {
  11134. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  11135. }
  11136. var mult = (1 / this._step) | 0;
  11137. this.value = this._step ? ((value * mult) | 0) / mult : value;
  11138. };
  11139. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  11140. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  11141. return false;
  11142. }
  11143. this._pointerIsDown = true;
  11144. this._updateValueFromPointer(coordinates.x, coordinates.y);
  11145. this._host._capturingControl[pointerId] = this;
  11146. this._lastPointerDownID = pointerId;
  11147. return true;
  11148. };
  11149. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  11150. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  11151. if (pointerId != this._lastPointerDownID) {
  11152. return;
  11153. }
  11154. if (this._pointerIsDown) {
  11155. this._updateValueFromPointer(coordinates.x, coordinates.y);
  11156. }
  11157. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  11158. };
  11159. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  11160. this._pointerIsDown = false;
  11161. delete this._host._capturingControl[pointerId];
  11162. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  11163. };
  11164. BaseSlider.prototype._onCanvasBlur = function () {
  11165. this._forcePointerUp();
  11166. _super.prototype._onCanvasBlur.call(this);
  11167. };
  11168. return BaseSlider;
  11169. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  11170. /***/ }),
  11171. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  11172. /*!*************************************************!*\
  11173. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  11174. \*************************************************/
  11175. /*! exports provided: ImageBasedSlider */
  11176. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11177. "use strict";
  11178. __webpack_require__.r(__webpack_exports__);
  11179. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  11180. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11181. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11182. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11183. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  11184. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  11185. /**
  11186. * Class used to create slider controls based on images
  11187. */
  11188. var ImageBasedSlider = /** @class */ (function (_super) {
  11189. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  11190. /**
  11191. * Creates a new ImageBasedSlider
  11192. * @param name defines the control name
  11193. */
  11194. function ImageBasedSlider(name) {
  11195. var _this = _super.call(this, name) || this;
  11196. _this.name = name;
  11197. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11198. return _this;
  11199. }
  11200. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  11201. get: function () {
  11202. return this._displayThumb && this.thumbImage != null;
  11203. },
  11204. set: function (value) {
  11205. if (this._displayThumb === value) {
  11206. return;
  11207. }
  11208. this._displayThumb = value;
  11209. this._markAsDirty();
  11210. },
  11211. enumerable: false,
  11212. configurable: true
  11213. });
  11214. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  11215. /**
  11216. * Gets or sets the image used to render the background
  11217. */
  11218. get: function () {
  11219. return this._backgroundImage;
  11220. },
  11221. set: function (value) {
  11222. var _this = this;
  11223. if (this._backgroundImage === value) {
  11224. return;
  11225. }
  11226. this._backgroundImage = value;
  11227. if (value && !value.isLoaded) {
  11228. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11229. }
  11230. this._markAsDirty();
  11231. },
  11232. enumerable: false,
  11233. configurable: true
  11234. });
  11235. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  11236. /**
  11237. * Gets or sets the image used to render the value bar
  11238. */
  11239. get: function () {
  11240. return this._valueBarImage;
  11241. },
  11242. set: function (value) {
  11243. var _this = this;
  11244. if (this._valueBarImage === value) {
  11245. return;
  11246. }
  11247. this._valueBarImage = value;
  11248. if (value && !value.isLoaded) {
  11249. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11250. }
  11251. this._markAsDirty();
  11252. },
  11253. enumerable: false,
  11254. configurable: true
  11255. });
  11256. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  11257. /**
  11258. * Gets or sets the image used to render the thumb
  11259. */
  11260. get: function () {
  11261. return this._thumbImage;
  11262. },
  11263. set: function (value) {
  11264. var _this = this;
  11265. if (this._thumbImage === value) {
  11266. return;
  11267. }
  11268. this._thumbImage = value;
  11269. if (value && !value.isLoaded) {
  11270. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11271. }
  11272. this._markAsDirty();
  11273. },
  11274. enumerable: false,
  11275. configurable: true
  11276. });
  11277. ImageBasedSlider.prototype._getTypeName = function () {
  11278. return "ImageBasedSlider";
  11279. };
  11280. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  11281. context.save();
  11282. this._applyStates(context);
  11283. this._prepareRenderingData("rectangle");
  11284. var thumbPosition = this._getThumbPosition();
  11285. var left = this._renderLeft;
  11286. var top = this._renderTop;
  11287. var width = this._renderWidth;
  11288. var height = this._renderHeight;
  11289. // Background
  11290. if (this._backgroundImage) {
  11291. this._tempMeasure.copyFromFloats(left, top, width, height);
  11292. if (this.isThumbClamped && this.displayThumb) {
  11293. if (this.isVertical) {
  11294. this._tempMeasure.height += this._effectiveThumbThickness;
  11295. }
  11296. else {
  11297. this._tempMeasure.width += this._effectiveThumbThickness;
  11298. }
  11299. }
  11300. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11301. this._backgroundImage._draw(context);
  11302. }
  11303. // Bar
  11304. if (this._valueBarImage) {
  11305. if (this.isVertical) {
  11306. if (this.isThumbClamped && this.displayThumb) {
  11307. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11308. }
  11309. else {
  11310. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  11311. }
  11312. }
  11313. else {
  11314. if (this.isThumbClamped && this.displayThumb) {
  11315. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  11316. }
  11317. else {
  11318. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11319. }
  11320. }
  11321. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11322. this._valueBarImage._draw(context);
  11323. }
  11324. // Thumb
  11325. if (this.displayThumb) {
  11326. if (this.isVertical) {
  11327. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11328. }
  11329. else {
  11330. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11331. }
  11332. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11333. this._thumbImage._draw(context);
  11334. }
  11335. context.restore();
  11336. };
  11337. return ImageBasedSlider;
  11338. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11339. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11340. /***/ }),
  11341. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11342. /*!***********************************************!*\
  11343. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11344. \***********************************************/
  11345. /*! exports provided: ImageScrollBar */
  11346. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11347. "use strict";
  11348. __webpack_require__.r(__webpack_exports__);
  11349. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11350. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11351. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11352. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11353. /**
  11354. * Class used to create slider controls
  11355. */
  11356. var ImageScrollBar = /** @class */ (function (_super) {
  11357. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11358. /**
  11359. * Creates a new ImageScrollBar
  11360. * @param name defines the control name
  11361. */
  11362. function ImageScrollBar(name) {
  11363. var _this = _super.call(this, name) || this;
  11364. _this.name = name;
  11365. _this._thumbLength = 0.5;
  11366. _this._thumbHeight = 1;
  11367. _this._barImageHeight = 1;
  11368. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11369. /** Number of 90° rotation to apply on the images when in vertical mode */
  11370. _this.num90RotationInVerticalMode = 1;
  11371. return _this;
  11372. }
  11373. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11374. /**
  11375. * Gets or sets the image used to render the background for horizontal bar
  11376. */
  11377. get: function () {
  11378. return this._backgroundBaseImage;
  11379. },
  11380. set: function (value) {
  11381. var _this = this;
  11382. if (this._backgroundBaseImage === value) {
  11383. return;
  11384. }
  11385. this._backgroundBaseImage = value;
  11386. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11387. if (!value.isLoaded) {
  11388. value.onImageLoadedObservable.addOnce(function () {
  11389. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11390. _this._backgroundImage = rotatedValue;
  11391. if (!rotatedValue.isLoaded) {
  11392. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11393. _this._markAsDirty();
  11394. });
  11395. }
  11396. _this._markAsDirty();
  11397. });
  11398. }
  11399. else {
  11400. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11401. this._markAsDirty();
  11402. }
  11403. }
  11404. else {
  11405. this._backgroundImage = value;
  11406. if (value && !value.isLoaded) {
  11407. value.onImageLoadedObservable.addOnce(function () {
  11408. _this._markAsDirty();
  11409. });
  11410. }
  11411. this._markAsDirty();
  11412. }
  11413. },
  11414. enumerable: false,
  11415. configurable: true
  11416. });
  11417. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11418. /**
  11419. * Gets or sets the image used to render the thumb
  11420. */
  11421. get: function () {
  11422. return this._thumbBaseImage;
  11423. },
  11424. set: function (value) {
  11425. var _this = this;
  11426. if (this._thumbBaseImage === value) {
  11427. return;
  11428. }
  11429. this._thumbBaseImage = value;
  11430. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11431. if (!value.isLoaded) {
  11432. value.onImageLoadedObservable.addOnce(function () {
  11433. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11434. _this._thumbImage = rotatedValue;
  11435. if (!rotatedValue.isLoaded) {
  11436. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11437. _this._markAsDirty();
  11438. });
  11439. }
  11440. _this._markAsDirty();
  11441. });
  11442. }
  11443. else {
  11444. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11445. this._markAsDirty();
  11446. }
  11447. }
  11448. else {
  11449. this._thumbImage = value;
  11450. if (value && !value.isLoaded) {
  11451. value.onImageLoadedObservable.addOnce(function () {
  11452. _this._markAsDirty();
  11453. });
  11454. }
  11455. this._markAsDirty();
  11456. }
  11457. },
  11458. enumerable: false,
  11459. configurable: true
  11460. });
  11461. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11462. /**
  11463. * Gets or sets the length of the thumb
  11464. */
  11465. get: function () {
  11466. return this._thumbLength;
  11467. },
  11468. set: function (value) {
  11469. if (this._thumbLength === value) {
  11470. return;
  11471. }
  11472. this._thumbLength = value;
  11473. this._markAsDirty();
  11474. },
  11475. enumerable: false,
  11476. configurable: true
  11477. });
  11478. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11479. /**
  11480. * Gets or sets the height of the thumb
  11481. */
  11482. get: function () {
  11483. return this._thumbHeight;
  11484. },
  11485. set: function (value) {
  11486. if (this._thumbLength === value) {
  11487. return;
  11488. }
  11489. this._thumbHeight = value;
  11490. this._markAsDirty();
  11491. },
  11492. enumerable: false,
  11493. configurable: true
  11494. });
  11495. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11496. /**
  11497. * Gets or sets the height of the bar image
  11498. */
  11499. get: function () {
  11500. return this._barImageHeight;
  11501. },
  11502. set: function (value) {
  11503. if (this._barImageHeight === value) {
  11504. return;
  11505. }
  11506. this._barImageHeight = value;
  11507. this._markAsDirty();
  11508. },
  11509. enumerable: false,
  11510. configurable: true
  11511. });
  11512. ImageScrollBar.prototype._getTypeName = function () {
  11513. return "ImageScrollBar";
  11514. };
  11515. ImageScrollBar.prototype._getThumbThickness = function () {
  11516. var thumbThickness = 0;
  11517. if (this._thumbWidth.isPixel) {
  11518. thumbThickness = this._thumbWidth.getValue(this._host);
  11519. }
  11520. else {
  11521. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11522. }
  11523. return thumbThickness;
  11524. };
  11525. ImageScrollBar.prototype._draw = function (context) {
  11526. context.save();
  11527. this._applyStates(context);
  11528. this._prepareRenderingData("rectangle");
  11529. var thumbPosition = this._getThumbPosition();
  11530. var left = this._renderLeft;
  11531. var top = this._renderTop;
  11532. var width = this._renderWidth;
  11533. var height = this._renderHeight;
  11534. // Background
  11535. if (this._backgroundImage) {
  11536. this._tempMeasure.copyFromFloats(left, top, width, height);
  11537. if (this.isVertical) {
  11538. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11539. this._tempMeasure.height += this._effectiveThumbThickness;
  11540. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11541. }
  11542. else {
  11543. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11544. this._tempMeasure.width += this._effectiveThumbThickness;
  11545. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11546. }
  11547. this._backgroundImage._draw(context);
  11548. }
  11549. // Thumb
  11550. if (this.isVertical) {
  11551. 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);
  11552. }
  11553. else {
  11554. 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);
  11555. }
  11556. if (this._thumbImage) {
  11557. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11558. this._thumbImage._draw(context);
  11559. }
  11560. context.restore();
  11561. };
  11562. /** @hidden */
  11563. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11564. if (this.rotation != 0) {
  11565. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11566. x = this._transformedPosition.x;
  11567. y = this._transformedPosition.y;
  11568. }
  11569. if (this._first) {
  11570. this._first = false;
  11571. this._originX = x;
  11572. this._originY = y;
  11573. // Check if move is required
  11574. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11575. if (this.isVertical) {
  11576. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11577. }
  11578. else {
  11579. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11580. }
  11581. }
  11582. }
  11583. // Delta mode
  11584. var delta = 0;
  11585. if (this.isVertical) {
  11586. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11587. }
  11588. else {
  11589. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11590. }
  11591. this.value += delta * (this.maximum - this.minimum);
  11592. this._originX = x;
  11593. this._originY = y;
  11594. };
  11595. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  11596. this._first = true;
  11597. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  11598. };
  11599. return ImageScrollBar;
  11600. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11601. /***/ }),
  11602. /***/ "./2D/controls/sliders/scrollBar.ts":
  11603. /*!******************************************!*\
  11604. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11605. \******************************************/
  11606. /*! exports provided: ScrollBar */
  11607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11608. "use strict";
  11609. __webpack_require__.r(__webpack_exports__);
  11610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11611. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11612. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11613. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11614. /**
  11615. * Class used to create slider controls
  11616. */
  11617. var ScrollBar = /** @class */ (function (_super) {
  11618. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11619. /**
  11620. * Creates a new Slider
  11621. * @param name defines the control name
  11622. */
  11623. function ScrollBar(name) {
  11624. var _this = _super.call(this, name) || this;
  11625. _this.name = name;
  11626. _this._background = "black";
  11627. _this._borderColor = "white";
  11628. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11629. return _this;
  11630. }
  11631. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11632. /** Gets or sets border color */
  11633. get: function () {
  11634. return this._borderColor;
  11635. },
  11636. set: function (value) {
  11637. if (this._borderColor === value) {
  11638. return;
  11639. }
  11640. this._borderColor = value;
  11641. this._markAsDirty();
  11642. },
  11643. enumerable: false,
  11644. configurable: true
  11645. });
  11646. Object.defineProperty(ScrollBar.prototype, "background", {
  11647. /** Gets or sets background color */
  11648. get: function () {
  11649. return this._background;
  11650. },
  11651. set: function (value) {
  11652. if (this._background === value) {
  11653. return;
  11654. }
  11655. this._background = value;
  11656. this._markAsDirty();
  11657. },
  11658. enumerable: false,
  11659. configurable: true
  11660. });
  11661. ScrollBar.prototype._getTypeName = function () {
  11662. return "Scrollbar";
  11663. };
  11664. ScrollBar.prototype._getThumbThickness = function () {
  11665. var thumbThickness = 0;
  11666. if (this._thumbWidth.isPixel) {
  11667. thumbThickness = this._thumbWidth.getValue(this._host);
  11668. }
  11669. else {
  11670. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11671. }
  11672. return thumbThickness;
  11673. };
  11674. ScrollBar.prototype._draw = function (context) {
  11675. context.save();
  11676. this._applyStates(context);
  11677. this._prepareRenderingData("rectangle");
  11678. var left = this._renderLeft;
  11679. var thumbPosition = this._getThumbPosition();
  11680. context.fillStyle = this._background;
  11681. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11682. // Value bar
  11683. context.fillStyle = this.color;
  11684. // Thumb
  11685. if (this.isVertical) {
  11686. this._tempMeasure.left = left - this._effectiveBarOffset;
  11687. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11688. this._tempMeasure.width = this._currentMeasure.width;
  11689. this._tempMeasure.height = this._effectiveThumbThickness;
  11690. }
  11691. else {
  11692. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11693. this._tempMeasure.top = this._currentMeasure.top;
  11694. this._tempMeasure.width = this._effectiveThumbThickness;
  11695. this._tempMeasure.height = this._currentMeasure.height;
  11696. }
  11697. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11698. context.restore();
  11699. };
  11700. /** @hidden */
  11701. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11702. if (this.rotation != 0) {
  11703. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11704. x = this._transformedPosition.x;
  11705. y = this._transformedPosition.y;
  11706. }
  11707. if (this._first) {
  11708. this._first = false;
  11709. this._originX = x;
  11710. this._originY = y;
  11711. // Check if move is required
  11712. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11713. if (this.isVertical) {
  11714. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11715. }
  11716. else {
  11717. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11718. }
  11719. }
  11720. }
  11721. // Delta mode
  11722. var delta = 0;
  11723. if (this.isVertical) {
  11724. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11725. }
  11726. else {
  11727. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11728. }
  11729. this.value += delta * (this.maximum - this.minimum);
  11730. this._originX = x;
  11731. this._originY = y;
  11732. };
  11733. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  11734. this._first = true;
  11735. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  11736. };
  11737. return ScrollBar;
  11738. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11739. /***/ }),
  11740. /***/ "./2D/controls/sliders/slider.ts":
  11741. /*!***************************************!*\
  11742. !*** ./2D/controls/sliders/slider.ts ***!
  11743. \***************************************/
  11744. /*! exports provided: Slider */
  11745. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11746. "use strict";
  11747. __webpack_require__.r(__webpack_exports__);
  11748. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11749. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11750. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11751. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  11752. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11753. /**
  11754. * Class used to create slider controls
  11755. */
  11756. var Slider = /** @class */ (function (_super) {
  11757. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11758. /**
  11759. * Creates a new Slider
  11760. * @param name defines the control name
  11761. */
  11762. function Slider(name) {
  11763. var _this = _super.call(this, name) || this;
  11764. _this.name = name;
  11765. _this._background = "black";
  11766. _this._borderColor = "white";
  11767. _this._thumbColor = "";
  11768. _this._isThumbCircle = false;
  11769. _this._displayValueBar = true;
  11770. return _this;
  11771. }
  11772. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11773. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11774. get: function () {
  11775. return this._displayValueBar;
  11776. },
  11777. set: function (value) {
  11778. if (this._displayValueBar === value) {
  11779. return;
  11780. }
  11781. this._displayValueBar = value;
  11782. this._markAsDirty();
  11783. },
  11784. enumerable: false,
  11785. configurable: true
  11786. });
  11787. Object.defineProperty(Slider.prototype, "borderColor", {
  11788. /** Gets or sets border color */
  11789. get: function () {
  11790. return this._borderColor;
  11791. },
  11792. set: function (value) {
  11793. if (this._borderColor === value) {
  11794. return;
  11795. }
  11796. this._borderColor = value;
  11797. this._markAsDirty();
  11798. },
  11799. enumerable: false,
  11800. configurable: true
  11801. });
  11802. Object.defineProperty(Slider.prototype, "background", {
  11803. /** Gets or sets background color */
  11804. get: function () {
  11805. return this._background;
  11806. },
  11807. set: function (value) {
  11808. if (this._background === value) {
  11809. return;
  11810. }
  11811. this._background = value;
  11812. this._markAsDirty();
  11813. },
  11814. enumerable: false,
  11815. configurable: true
  11816. });
  11817. Object.defineProperty(Slider.prototype, "thumbColor", {
  11818. /** Gets or sets thumb's color */
  11819. get: function () {
  11820. return this._thumbColor;
  11821. },
  11822. set: function (value) {
  11823. if (this._thumbColor === value) {
  11824. return;
  11825. }
  11826. this._thumbColor = value;
  11827. this._markAsDirty();
  11828. },
  11829. enumerable: false,
  11830. configurable: true
  11831. });
  11832. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11833. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11834. get: function () {
  11835. return this._isThumbCircle;
  11836. },
  11837. set: function (value) {
  11838. if (this._isThumbCircle === value) {
  11839. return;
  11840. }
  11841. this._isThumbCircle = value;
  11842. this._markAsDirty();
  11843. },
  11844. enumerable: false,
  11845. configurable: true
  11846. });
  11847. Slider.prototype._getTypeName = function () {
  11848. return "Slider";
  11849. };
  11850. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11851. context.save();
  11852. this._applyStates(context);
  11853. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11854. var left = this._renderLeft;
  11855. var top = this._renderTop;
  11856. var width = this._renderWidth;
  11857. var height = this._renderHeight;
  11858. var radius = 0;
  11859. if (this.isThumbClamped && this.isThumbCircle) {
  11860. if (this.isVertical) {
  11861. top += (this._effectiveThumbThickness / 2);
  11862. }
  11863. else {
  11864. left += (this._effectiveThumbThickness / 2);
  11865. }
  11866. radius = this._backgroundBoxThickness / 2;
  11867. }
  11868. else {
  11869. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11870. }
  11871. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11872. context.shadowColor = this.shadowColor;
  11873. context.shadowBlur = this.shadowBlur;
  11874. context.shadowOffsetX = this.shadowOffsetX;
  11875. context.shadowOffsetY = this.shadowOffsetY;
  11876. }
  11877. var thumbPosition = this._getThumbPosition();
  11878. context.fillStyle = this._background;
  11879. if (this.isVertical) {
  11880. if (this.isThumbClamped) {
  11881. if (this.isThumbCircle) {
  11882. context.beginPath();
  11883. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11884. context.fill();
  11885. context.fillRect(left, top, width, height);
  11886. }
  11887. else {
  11888. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11889. }
  11890. }
  11891. else {
  11892. context.fillRect(left, top, width, height);
  11893. }
  11894. }
  11895. else {
  11896. if (this.isThumbClamped) {
  11897. if (this.isThumbCircle) {
  11898. context.beginPath();
  11899. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11900. context.fill();
  11901. context.fillRect(left, top, width, height);
  11902. }
  11903. else {
  11904. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11905. }
  11906. }
  11907. else {
  11908. context.fillRect(left, top, width, height);
  11909. }
  11910. }
  11911. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11912. context.shadowBlur = 0;
  11913. context.shadowOffsetX = 0;
  11914. context.shadowOffsetY = 0;
  11915. }
  11916. // Value bar
  11917. context.fillStyle = this.color;
  11918. if (this._displayValueBar) {
  11919. if (this.isVertical) {
  11920. if (this.isThumbClamped) {
  11921. if (this.isThumbCircle) {
  11922. context.beginPath();
  11923. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11924. context.fill();
  11925. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11926. }
  11927. else {
  11928. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11929. }
  11930. }
  11931. else {
  11932. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11933. }
  11934. }
  11935. else {
  11936. if (this.isThumbClamped) {
  11937. if (this.isThumbCircle) {
  11938. context.beginPath();
  11939. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11940. context.fill();
  11941. context.fillRect(left, top, thumbPosition, height);
  11942. }
  11943. else {
  11944. context.fillRect(left, top, thumbPosition, height);
  11945. }
  11946. }
  11947. else {
  11948. context.fillRect(left, top, thumbPosition, height);
  11949. }
  11950. }
  11951. }
  11952. // Thumb
  11953. context.fillStyle = this._thumbColor || this.color;
  11954. if (this.displayThumb) {
  11955. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11956. context.shadowColor = this.shadowColor;
  11957. context.shadowBlur = this.shadowBlur;
  11958. context.shadowOffsetX = this.shadowOffsetX;
  11959. context.shadowOffsetY = this.shadowOffsetY;
  11960. }
  11961. if (this._isThumbCircle) {
  11962. context.beginPath();
  11963. if (this.isVertical) {
  11964. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11965. }
  11966. else {
  11967. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11968. }
  11969. context.fill();
  11970. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11971. context.shadowBlur = 0;
  11972. context.shadowOffsetX = 0;
  11973. context.shadowOffsetY = 0;
  11974. }
  11975. context.strokeStyle = this._borderColor;
  11976. context.stroke();
  11977. }
  11978. else {
  11979. if (this.isVertical) {
  11980. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11981. }
  11982. else {
  11983. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11984. }
  11985. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11986. context.shadowBlur = 0;
  11987. context.shadowOffsetX = 0;
  11988. context.shadowOffsetY = 0;
  11989. }
  11990. context.strokeStyle = this._borderColor;
  11991. if (this.isVertical) {
  11992. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11993. }
  11994. else {
  11995. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11996. }
  11997. }
  11998. }
  11999. context.restore();
  12000. };
  12001. return Slider;
  12002. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  12003. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  12004. /***/ }),
  12005. /***/ "./2D/controls/stackPanel.ts":
  12006. /*!***********************************!*\
  12007. !*** ./2D/controls/stackPanel.ts ***!
  12008. \***********************************/
  12009. /*! exports provided: StackPanel */
  12010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12011. "use strict";
  12012. __webpack_require__.r(__webpack_exports__);
  12013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  12014. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12015. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  12016. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  12017. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  12018. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12019. /**
  12020. * Class used to create a 2D stack panel container
  12021. */
  12022. var StackPanel = /** @class */ (function (_super) {
  12023. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  12024. /**
  12025. * Creates a new StackPanel
  12026. * @param name defines control name
  12027. */
  12028. function StackPanel(name) {
  12029. var _this = _super.call(this, name) || this;
  12030. _this.name = name;
  12031. _this._isVertical = true;
  12032. _this._manualWidth = false;
  12033. _this._manualHeight = false;
  12034. _this._doNotTrackManualChanges = false;
  12035. /**
  12036. * Gets or sets a boolean indicating that layou warnings should be ignored
  12037. */
  12038. _this.ignoreLayoutWarnings = false;
  12039. return _this;
  12040. }
  12041. Object.defineProperty(StackPanel.prototype, "isVertical", {
  12042. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  12043. get: function () {
  12044. return this._isVertical;
  12045. },
  12046. set: function (value) {
  12047. if (this._isVertical === value) {
  12048. return;
  12049. }
  12050. this._isVertical = value;
  12051. this._markAsDirty();
  12052. },
  12053. enumerable: false,
  12054. configurable: true
  12055. });
  12056. Object.defineProperty(StackPanel.prototype, "width", {
  12057. get: function () {
  12058. return this._width.toString(this._host);
  12059. },
  12060. /**
  12061. * Gets or sets panel width.
  12062. * This value should not be set when in horizontal mode as it will be computed automatically
  12063. */
  12064. set: function (value) {
  12065. if (!this._doNotTrackManualChanges) {
  12066. this._manualWidth = true;
  12067. }
  12068. if (this._width.toString(this._host) === value) {
  12069. return;
  12070. }
  12071. if (this._width.fromString(value)) {
  12072. this._markAsDirty();
  12073. }
  12074. },
  12075. enumerable: false,
  12076. configurable: true
  12077. });
  12078. Object.defineProperty(StackPanel.prototype, "height", {
  12079. get: function () {
  12080. return this._height.toString(this._host);
  12081. },
  12082. /**
  12083. * Gets or sets panel height.
  12084. * This value should not be set when in vertical mode as it will be computed automatically
  12085. */
  12086. set: function (value) {
  12087. if (!this._doNotTrackManualChanges) {
  12088. this._manualHeight = true;
  12089. }
  12090. if (this._height.toString(this._host) === value) {
  12091. return;
  12092. }
  12093. if (this._height.fromString(value)) {
  12094. this._markAsDirty();
  12095. }
  12096. },
  12097. enumerable: false,
  12098. configurable: true
  12099. });
  12100. StackPanel.prototype._getTypeName = function () {
  12101. return "StackPanel";
  12102. };
  12103. /** @hidden */
  12104. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  12105. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12106. var child = _a[_i];
  12107. if (this._isVertical) {
  12108. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  12109. }
  12110. else {
  12111. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12112. }
  12113. }
  12114. _super.prototype._preMeasure.call(this, parentMeasure, context);
  12115. };
  12116. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  12117. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  12118. this._measureForChildren.copyFrom(parentMeasure);
  12119. this._measureForChildren.left = this._currentMeasure.left;
  12120. this._measureForChildren.top = this._currentMeasure.top;
  12121. if (!this.isVertical || this._manualWidth) {
  12122. this._measureForChildren.width = this._currentMeasure.width;
  12123. }
  12124. if (this.isVertical || this._manualHeight) {
  12125. this._measureForChildren.height = this._currentMeasure.height;
  12126. }
  12127. };
  12128. StackPanel.prototype._postMeasure = function () {
  12129. var stackWidth = 0;
  12130. var stackHeight = 0;
  12131. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12132. var child = _a[_i];
  12133. if (!child.isVisible || child.notRenderable) {
  12134. continue;
  12135. }
  12136. if (this._isVertical) {
  12137. if (child.top !== stackHeight + "px") {
  12138. child.top = stackHeight + "px";
  12139. this._rebuildLayout = true;
  12140. child._top.ignoreAdaptiveScaling = true;
  12141. }
  12142. if (child._height.isPercentage && !child._automaticSize) {
  12143. if (!this.ignoreLayoutWarnings) {
  12144. 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");
  12145. }
  12146. }
  12147. else {
  12148. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  12149. }
  12150. }
  12151. else {
  12152. if (child.left !== stackWidth + "px") {
  12153. child.left = stackWidth + "px";
  12154. this._rebuildLayout = true;
  12155. child._left.ignoreAdaptiveScaling = true;
  12156. }
  12157. if (child._width.isPercentage && !child._automaticSize) {
  12158. if (!this.ignoreLayoutWarnings) {
  12159. 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");
  12160. }
  12161. }
  12162. else {
  12163. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  12164. }
  12165. }
  12166. }
  12167. stackWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  12168. stackHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  12169. this._doNotTrackManualChanges = true;
  12170. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  12171. // User can now define their own height and width for stack panel.
  12172. var panelWidthChanged = false;
  12173. var panelHeightChanged = false;
  12174. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  12175. var previousHeight = this.height;
  12176. this.height = stackHeight + "px";
  12177. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  12178. }
  12179. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  12180. var previousWidth = this.width;
  12181. this.width = stackWidth + "px";
  12182. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  12183. }
  12184. if (panelHeightChanged) {
  12185. this._height.ignoreAdaptiveScaling = true;
  12186. }
  12187. if (panelWidthChanged) {
  12188. this._width.ignoreAdaptiveScaling = true;
  12189. }
  12190. this._doNotTrackManualChanges = false;
  12191. if (panelWidthChanged || panelHeightChanged) {
  12192. this._rebuildLayout = true;
  12193. }
  12194. _super.prototype._postMeasure.call(this);
  12195. };
  12196. return StackPanel;
  12197. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  12198. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  12199. /***/ }),
  12200. /***/ "./2D/controls/statics.ts":
  12201. /*!********************************!*\
  12202. !*** ./2D/controls/statics.ts ***!
  12203. \********************************/
  12204. /*! exports provided: name */
  12205. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12206. "use strict";
  12207. __webpack_require__.r(__webpack_exports__);
  12208. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  12209. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12210. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12211. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  12212. /**
  12213. * Forcing an export so that this code will execute
  12214. * @hidden
  12215. */
  12216. var name = "Statics";
  12217. /**
  12218. * Creates a stack panel that can be used to render headers
  12219. * @param control defines the control to associate with the header
  12220. * @param text defines the text of the header
  12221. * @param size defines the size of the header
  12222. * @param options defines options used to configure the header
  12223. * @returns a new StackPanel
  12224. */
  12225. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  12226. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  12227. var isHorizontal = options ? options.isHorizontal : true;
  12228. var controlFirst = options ? options.controlFirst : true;
  12229. panel.isVertical = !isHorizontal;
  12230. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  12231. header.text = text;
  12232. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12233. if (isHorizontal) {
  12234. header.width = size;
  12235. }
  12236. else {
  12237. header.height = size;
  12238. }
  12239. if (controlFirst) {
  12240. panel.addControl(control);
  12241. panel.addControl(header);
  12242. header.paddingLeft = "5px";
  12243. }
  12244. else {
  12245. panel.addControl(header);
  12246. panel.addControl(control);
  12247. header.paddingRight = "5px";
  12248. }
  12249. header.shadowBlur = control.shadowBlur;
  12250. header.shadowColor = control.shadowColor;
  12251. header.shadowOffsetX = control.shadowOffsetX;
  12252. header.shadowOffsetY = control.shadowOffsetY;
  12253. return panel;
  12254. };
  12255. /***/ }),
  12256. /***/ "./2D/controls/textBlock.ts":
  12257. /*!**********************************!*\
  12258. !*** ./2D/controls/textBlock.ts ***!
  12259. \**********************************/
  12260. /*! exports provided: TextWrapping, TextBlock */
  12261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12262. "use strict";
  12263. __webpack_require__.r(__webpack_exports__);
  12264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  12265. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  12266. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12267. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12268. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12269. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  12270. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12271. /**
  12272. * Enum that determines the text-wrapping mode to use.
  12273. */
  12274. var TextWrapping;
  12275. (function (TextWrapping) {
  12276. /**
  12277. * Clip the text when it's larger than Control.width; this is the default mode.
  12278. */
  12279. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  12280. /**
  12281. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  12282. */
  12283. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  12284. /**
  12285. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  12286. */
  12287. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  12288. })(TextWrapping || (TextWrapping = {}));
  12289. /**
  12290. * Class used to create text block control
  12291. */
  12292. var TextBlock = /** @class */ (function (_super) {
  12293. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  12294. /**
  12295. * Creates a new TextBlock object
  12296. * @param name defines the name of the control
  12297. * @param text defines the text to display (emptry string by default)
  12298. */
  12299. function TextBlock(
  12300. /**
  12301. * Defines the name of the control
  12302. */
  12303. name, text) {
  12304. if (text === void 0) { text = ""; }
  12305. var _this = _super.call(this, name) || this;
  12306. _this.name = name;
  12307. _this._text = "";
  12308. _this._textWrapping = TextWrapping.Clip;
  12309. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  12310. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  12311. _this._resizeToFit = false;
  12312. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  12313. _this._outlineWidth = 0;
  12314. _this._outlineColor = "white";
  12315. _this._underline = false;
  12316. _this._lineThrough = false;
  12317. /**
  12318. * An event triggered after the text is changed
  12319. */
  12320. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12321. /**
  12322. * An event triggered after the text was broken up into lines
  12323. */
  12324. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12325. _this.text = text;
  12326. return _this;
  12327. }
  12328. Object.defineProperty(TextBlock.prototype, "lines", {
  12329. /**
  12330. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  12331. */
  12332. get: function () {
  12333. return this._lines;
  12334. },
  12335. enumerable: false,
  12336. configurable: true
  12337. });
  12338. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12339. /**
  12340. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12341. */
  12342. get: function () {
  12343. return this._resizeToFit;
  12344. },
  12345. /**
  12346. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12347. */
  12348. set: function (value) {
  12349. if (this._resizeToFit === value) {
  12350. return;
  12351. }
  12352. this._resizeToFit = value;
  12353. if (this._resizeToFit) {
  12354. this._width.ignoreAdaptiveScaling = true;
  12355. this._height.ignoreAdaptiveScaling = true;
  12356. }
  12357. this._markAsDirty();
  12358. },
  12359. enumerable: false,
  12360. configurable: true
  12361. });
  12362. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12363. /**
  12364. * Gets or sets a boolean indicating if text must be wrapped
  12365. */
  12366. get: function () {
  12367. return this._textWrapping;
  12368. },
  12369. /**
  12370. * Gets or sets a boolean indicating if text must be wrapped
  12371. */
  12372. set: function (value) {
  12373. if (this._textWrapping === value) {
  12374. return;
  12375. }
  12376. this._textWrapping = +value;
  12377. this._markAsDirty();
  12378. },
  12379. enumerable: false,
  12380. configurable: true
  12381. });
  12382. Object.defineProperty(TextBlock.prototype, "text", {
  12383. /**
  12384. * Gets or sets text to display
  12385. */
  12386. get: function () {
  12387. return this._text;
  12388. },
  12389. /**
  12390. * Gets or sets text to display
  12391. */
  12392. set: function (value) {
  12393. if (this._text === value) {
  12394. return;
  12395. }
  12396. this._text = value;
  12397. this._markAsDirty();
  12398. this.onTextChangedObservable.notifyObservers(this);
  12399. },
  12400. enumerable: false,
  12401. configurable: true
  12402. });
  12403. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12404. /**
  12405. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12406. */
  12407. get: function () {
  12408. return this._textHorizontalAlignment;
  12409. },
  12410. /**
  12411. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12412. */
  12413. set: function (value) {
  12414. if (this._textHorizontalAlignment === value) {
  12415. return;
  12416. }
  12417. this._textHorizontalAlignment = value;
  12418. this._markAsDirty();
  12419. },
  12420. enumerable: false,
  12421. configurable: true
  12422. });
  12423. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12424. /**
  12425. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12426. */
  12427. get: function () {
  12428. return this._textVerticalAlignment;
  12429. },
  12430. /**
  12431. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12432. */
  12433. set: function (value) {
  12434. if (this._textVerticalAlignment === value) {
  12435. return;
  12436. }
  12437. this._textVerticalAlignment = value;
  12438. this._markAsDirty();
  12439. },
  12440. enumerable: false,
  12441. configurable: true
  12442. });
  12443. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12444. /**
  12445. * Gets or sets line spacing value
  12446. */
  12447. get: function () {
  12448. return this._lineSpacing.toString(this._host);
  12449. },
  12450. /**
  12451. * Gets or sets line spacing value
  12452. */
  12453. set: function (value) {
  12454. if (this._lineSpacing.fromString(value)) {
  12455. this._markAsDirty();
  12456. }
  12457. },
  12458. enumerable: false,
  12459. configurable: true
  12460. });
  12461. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12462. /**
  12463. * Gets or sets outlineWidth of the text to display
  12464. */
  12465. get: function () {
  12466. return this._outlineWidth;
  12467. },
  12468. /**
  12469. * Gets or sets outlineWidth of the text to display
  12470. */
  12471. set: function (value) {
  12472. if (this._outlineWidth === value) {
  12473. return;
  12474. }
  12475. this._outlineWidth = value;
  12476. this._markAsDirty();
  12477. },
  12478. enumerable: false,
  12479. configurable: true
  12480. });
  12481. Object.defineProperty(TextBlock.prototype, "underline", {
  12482. /**
  12483. * Gets or sets a boolean indicating that text must have underline
  12484. */
  12485. get: function () {
  12486. return this._underline;
  12487. },
  12488. /**
  12489. * Gets or sets a boolean indicating that text must have underline
  12490. */
  12491. set: function (value) {
  12492. if (this._underline === value) {
  12493. return;
  12494. }
  12495. this._underline = value;
  12496. this._markAsDirty();
  12497. },
  12498. enumerable: false,
  12499. configurable: true
  12500. });
  12501. Object.defineProperty(TextBlock.prototype, "lineThrough", {
  12502. /**
  12503. * Gets or sets an boolean indicating that text must be crossed out
  12504. */
  12505. get: function () {
  12506. return this._lineThrough;
  12507. },
  12508. /**
  12509. * Gets or sets an boolean indicating that text must be crossed out
  12510. */
  12511. set: function (value) {
  12512. if (this._lineThrough === value) {
  12513. return;
  12514. }
  12515. this._lineThrough = value;
  12516. this._markAsDirty();
  12517. },
  12518. enumerable: false,
  12519. configurable: true
  12520. });
  12521. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12522. /**
  12523. * Gets or sets outlineColor of the text to display
  12524. */
  12525. get: function () {
  12526. return this._outlineColor;
  12527. },
  12528. /**
  12529. * Gets or sets outlineColor of the text to display
  12530. */
  12531. set: function (value) {
  12532. if (this._outlineColor === value) {
  12533. return;
  12534. }
  12535. this._outlineColor = value;
  12536. this._markAsDirty();
  12537. },
  12538. enumerable: false,
  12539. configurable: true
  12540. });
  12541. TextBlock.prototype._getTypeName = function () {
  12542. return "TextBlock";
  12543. };
  12544. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12545. if (!this._fontOffset) {
  12546. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12547. }
  12548. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12549. // Prepare lines
  12550. this._lines = this._breakLines(this._currentMeasure.width, context);
  12551. this.onLinesReadyObservable.notifyObservers(this);
  12552. var maxLineWidth = 0;
  12553. for (var i = 0; i < this._lines.length; i++) {
  12554. var line = this._lines[i];
  12555. if (line.width > maxLineWidth) {
  12556. maxLineWidth = line.width;
  12557. }
  12558. }
  12559. if (this._resizeToFit) {
  12560. if (this._textWrapping === TextWrapping.Clip) {
  12561. var newWidth = (this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth) | 0;
  12562. if (newWidth !== this._width.internalValue) {
  12563. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12564. this._rebuildLayout = true;
  12565. }
  12566. }
  12567. var newHeight = (this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;
  12568. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12569. var lineSpacing = 0;
  12570. if (this._lineSpacing.isPixel) {
  12571. lineSpacing = this._lineSpacing.getValue(this._host);
  12572. }
  12573. else {
  12574. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12575. }
  12576. newHeight += (this._lines.length - 1) * lineSpacing;
  12577. }
  12578. if (newHeight !== this._height.internalValue) {
  12579. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12580. this._rebuildLayout = true;
  12581. }
  12582. }
  12583. };
  12584. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12585. var width = this._currentMeasure.width;
  12586. var x = 0;
  12587. switch (this._textHorizontalAlignment) {
  12588. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12589. x = 0;
  12590. break;
  12591. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12592. x = width - textWidth;
  12593. break;
  12594. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12595. x = (width - textWidth) / 2;
  12596. break;
  12597. }
  12598. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12599. context.shadowColor = this.shadowColor;
  12600. context.shadowBlur = this.shadowBlur;
  12601. context.shadowOffsetX = this.shadowOffsetX;
  12602. context.shadowOffsetY = this.shadowOffsetY;
  12603. }
  12604. if (this.outlineWidth) {
  12605. context.strokeText(text, this._currentMeasure.left + x, y);
  12606. }
  12607. context.fillText(text, this._currentMeasure.left + x, y);
  12608. if (this._underline) {
  12609. context.beginPath();
  12610. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  12611. context.moveTo(this._currentMeasure.left + x, y + 3);
  12612. context.lineTo(this._currentMeasure.left + x + textWidth, y + 3);
  12613. context.stroke();
  12614. context.closePath();
  12615. }
  12616. if (this._lineThrough) {
  12617. context.beginPath();
  12618. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  12619. context.moveTo(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3);
  12620. context.lineTo(this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3);
  12621. context.stroke();
  12622. context.closePath();
  12623. }
  12624. };
  12625. /** @hidden */
  12626. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12627. context.save();
  12628. this._applyStates(context);
  12629. // Render lines
  12630. this._renderLines(context);
  12631. context.restore();
  12632. };
  12633. TextBlock.prototype._applyStates = function (context) {
  12634. _super.prototype._applyStates.call(this, context);
  12635. if (this.outlineWidth) {
  12636. context.lineWidth = this.outlineWidth;
  12637. context.strokeStyle = this.outlineColor;
  12638. context.lineJoin = 'miter';
  12639. context.miterLimit = 2;
  12640. }
  12641. };
  12642. TextBlock.prototype._breakLines = function (refWidth, context) {
  12643. var lines = [];
  12644. var _lines = this.text.split("\n");
  12645. if (this._textWrapping === TextWrapping.Ellipsis) {
  12646. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12647. var _line = _lines_1[_i];
  12648. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12649. }
  12650. }
  12651. else if (this._textWrapping === TextWrapping.WordWrap) {
  12652. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12653. var _line = _lines_2[_a];
  12654. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12655. }
  12656. }
  12657. else {
  12658. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12659. var _line = _lines_3[_b];
  12660. lines.push(this._parseLine(_line, context));
  12661. }
  12662. }
  12663. return lines;
  12664. };
  12665. TextBlock.prototype._parseLine = function (line, context) {
  12666. if (line === void 0) { line = ""; }
  12667. return { text: line, width: context.measureText(line).width };
  12668. };
  12669. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12670. if (line === void 0) { line = ""; }
  12671. var lineWidth = context.measureText(line).width;
  12672. if (lineWidth > width) {
  12673. line += "…";
  12674. }
  12675. // unicode support. split('') does not work with unicode!
  12676. // make sure Array.from is available
  12677. var characters = Array.from && Array.from(line);
  12678. if (!characters) {
  12679. // no array.from, use the old method
  12680. while (line.length > 2 && lineWidth > width) {
  12681. line = line.slice(0, -2) + "…";
  12682. lineWidth = context.measureText(line).width;
  12683. }
  12684. }
  12685. else {
  12686. while (characters.length && lineWidth > width) {
  12687. characters.pop();
  12688. line = characters.join("") + "...";
  12689. lineWidth = context.measureText(line).width;
  12690. }
  12691. }
  12692. return { text: line, width: lineWidth };
  12693. };
  12694. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12695. if (line === void 0) { line = ""; }
  12696. var lines = [];
  12697. var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(" ");
  12698. var lineWidth = 0;
  12699. for (var n = 0; n < words.length; n++) {
  12700. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12701. var metrics = context.measureText(testLine);
  12702. var testWidth = metrics.width;
  12703. if (testWidth > width && n > 0) {
  12704. lines.push({ text: line, width: lineWidth });
  12705. line = words[n];
  12706. lineWidth = context.measureText(line).width;
  12707. }
  12708. else {
  12709. lineWidth = testWidth;
  12710. line = testLine;
  12711. }
  12712. }
  12713. lines.push({ text: line, width: lineWidth });
  12714. return lines;
  12715. };
  12716. TextBlock.prototype._renderLines = function (context) {
  12717. var height = this._currentMeasure.height;
  12718. var rootY = 0;
  12719. switch (this._textVerticalAlignment) {
  12720. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12721. rootY = this._fontOffset.ascent;
  12722. break;
  12723. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12724. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12725. break;
  12726. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12727. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12728. break;
  12729. }
  12730. rootY += this._currentMeasure.top;
  12731. for (var i = 0; i < this._lines.length; i++) {
  12732. var line = this._lines[i];
  12733. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12734. if (this._lineSpacing.isPixel) {
  12735. rootY += this._lineSpacing.getValue(this._host);
  12736. }
  12737. else {
  12738. rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12739. }
  12740. }
  12741. this._drawText(line.text, line.width, rootY, context);
  12742. rootY += this._fontOffset.height;
  12743. }
  12744. };
  12745. /**
  12746. * Given a width constraint applied on the text block, find the expected height
  12747. * @returns expected height
  12748. */
  12749. TextBlock.prototype.computeExpectedHeight = function () {
  12750. if (this.text && this.widthInPixels) {
  12751. var context_1 = document.createElement("canvas").getContext("2d");
  12752. if (context_1) {
  12753. this._applyStates(context_1);
  12754. if (!this._fontOffset) {
  12755. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12756. }
  12757. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12758. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12759. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12760. var lineSpacing = 0;
  12761. if (this._lineSpacing.isPixel) {
  12762. lineSpacing = this._lineSpacing.getValue(this._host);
  12763. }
  12764. else {
  12765. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12766. }
  12767. newHeight += (lines.length - 1) * lineSpacing;
  12768. }
  12769. return newHeight;
  12770. }
  12771. }
  12772. return 0;
  12773. };
  12774. TextBlock.prototype.dispose = function () {
  12775. _super.prototype.dispose.call(this);
  12776. this.onTextChangedObservable.clear();
  12777. };
  12778. return TextBlock;
  12779. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12780. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12781. /***/ }),
  12782. /***/ "./2D/controls/textWrapper.ts":
  12783. /*!************************************!*\
  12784. !*** ./2D/controls/textWrapper.ts ***!
  12785. \************************************/
  12786. /*! exports provided: TextWrapper */
  12787. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12788. "use strict";
  12789. __webpack_require__.r(__webpack_exports__);
  12790. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return TextWrapper; });
  12791. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12792. /** @hidden */
  12793. var TextWrapper = /** @class */ (function () {
  12794. function TextWrapper() {
  12795. }
  12796. Object.defineProperty(TextWrapper.prototype, "text", {
  12797. get: function () {
  12798. return this._characters ? this._characters.join("") : this._text;
  12799. },
  12800. set: function (txt) {
  12801. this._text = txt;
  12802. this._characters = Array.from && Array.from(txt);
  12803. },
  12804. enumerable: false,
  12805. configurable: true
  12806. });
  12807. Object.defineProperty(TextWrapper.prototype, "length", {
  12808. get: function () {
  12809. return this._characters ? this._characters.length : this._text.length;
  12810. },
  12811. enumerable: false,
  12812. configurable: true
  12813. });
  12814. TextWrapper.prototype.removePart = function (idxStart, idxEnd, insertTxt) {
  12815. var _a;
  12816. this._text = this._text.slice(0, idxStart) + (insertTxt ? insertTxt : "") + this._text.slice(idxEnd);
  12817. if (this._characters) {
  12818. var newCharacters = insertTxt ? Array.from(insertTxt) : [];
  12819. (_a = this._characters).splice.apply(_a, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spreadArrays"])([idxStart, idxEnd - idxStart], newCharacters));
  12820. }
  12821. };
  12822. TextWrapper.prototype.charAt = function (idx) {
  12823. return this._characters ? this._characters[idx] : this._text.charAt(idx);
  12824. };
  12825. TextWrapper.prototype.substr = function (from, length) {
  12826. if (this._characters) {
  12827. if (isNaN(from)) {
  12828. from = 0;
  12829. }
  12830. else if (from >= 0) {
  12831. from = Math.min(from, this._characters.length);
  12832. }
  12833. else {
  12834. from = this._characters.length + Math.max(from, -this._characters.length);
  12835. }
  12836. if (length === undefined) {
  12837. length = this._characters.length - from;
  12838. }
  12839. else if (isNaN(length)) {
  12840. length = 0;
  12841. }
  12842. else if (length < 0) {
  12843. length = 0;
  12844. }
  12845. var temp = [];
  12846. while (--length >= 0) {
  12847. temp[length] = this._characters[from + length];
  12848. }
  12849. return temp.join("");
  12850. }
  12851. return this._text.substr(from, length);
  12852. };
  12853. TextWrapper.prototype.substring = function (from, to) {
  12854. if (this._characters) {
  12855. if (isNaN(from)) {
  12856. from = 0;
  12857. }
  12858. else if (from > this._characters.length) {
  12859. from = this._characters.length;
  12860. }
  12861. else if (from < 0) {
  12862. from = 0;
  12863. }
  12864. if (to === undefined) {
  12865. to = this._characters.length;
  12866. }
  12867. else if (isNaN(to)) {
  12868. to = 0;
  12869. }
  12870. else if (to > this._characters.length) {
  12871. to = this._characters.length;
  12872. }
  12873. else if (to < 0) {
  12874. to = 0;
  12875. }
  12876. var temp = [];
  12877. var idx = 0;
  12878. while (from < to) {
  12879. temp[idx++] = this._characters[from++];
  12880. }
  12881. return temp.join("");
  12882. }
  12883. return this._text.substring(from, to);
  12884. };
  12885. TextWrapper.prototype.isWord = function (index) {
  12886. var rWord = /\w/g;
  12887. return this._characters ? this._characters[index].search(rWord) !== -1 : this._text.search(rWord) !== -1;
  12888. };
  12889. return TextWrapper;
  12890. }());
  12891. /***/ }),
  12892. /***/ "./2D/controls/toggleButton.ts":
  12893. /*!*************************************!*\
  12894. !*** ./2D/controls/toggleButton.ts ***!
  12895. \*************************************/
  12896. /*! exports provided: ToggleButton */
  12897. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12898. "use strict";
  12899. __webpack_require__.r(__webpack_exports__);
  12900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return ToggleButton; });
  12901. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12902. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12903. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12904. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  12905. /**
  12906. * Class used to create toggle buttons
  12907. */
  12908. var ToggleButton = /** @class */ (function (_super) {
  12909. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ToggleButton, _super);
  12910. /**
  12911. * Creates a new ToggleButton
  12912. * @param name defines the control name
  12913. * @param group defines the toggle group this toggle belongs to
  12914. */
  12915. function ToggleButton(name, group) {
  12916. var _this = _super.call(this, name) || this;
  12917. _this.name = name;
  12918. /** Observable raised when isActive is changed */
  12919. _this.onIsActiveChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12920. /**
  12921. * Gets or sets a boolean indicating that the toggle button will let internal controls handle picking instead of doing it directly using its bounding info
  12922. */
  12923. _this.delegatePickingToChildren = false;
  12924. _this._isActive = false;
  12925. _this.group = group !== null && group !== void 0 ? group : "";
  12926. _this.thickness = 0;
  12927. _this.isPointerBlocker = true;
  12928. var alphaStore = null;
  12929. _this.toActiveAnimation = function () {
  12930. _this.thickness = 1;
  12931. };
  12932. _this.toInactiveAnimation = function () {
  12933. _this.thickness = 0;
  12934. };
  12935. _this.pointerEnterActiveAnimation = function () {
  12936. alphaStore = _this.alpha;
  12937. _this.alpha -= 0.1;
  12938. };
  12939. _this.pointerOutActiveAnimation = function () {
  12940. if (alphaStore !== null) {
  12941. _this.alpha = alphaStore;
  12942. }
  12943. };
  12944. _this.pointerDownActiveAnimation = function () {
  12945. _this.scaleX -= 0.05;
  12946. _this.scaleY -= 0.05;
  12947. };
  12948. _this.pointerUpActiveAnimation = function () {
  12949. _this.scaleX += 0.05;
  12950. _this.scaleY += 0.05;
  12951. };
  12952. _this.pointerEnterInactiveAnimation = function () {
  12953. alphaStore = _this.alpha;
  12954. _this.alpha -= 0.1;
  12955. };
  12956. _this.pointerOutInactiveAnimation = function () {
  12957. if (alphaStore !== null) {
  12958. _this.alpha = alphaStore;
  12959. }
  12960. };
  12961. _this.pointerDownInactiveAnimation = function () {
  12962. _this.scaleX -= 0.05;
  12963. _this.scaleY -= 0.05;
  12964. };
  12965. _this.pointerUpInactiveAnimation = function () {
  12966. _this.scaleX += 0.05;
  12967. _this.scaleY += 0.05;
  12968. };
  12969. return _this;
  12970. }
  12971. Object.defineProperty(ToggleButton.prototype, "image", {
  12972. /**
  12973. * Returns the ToggleButton's image control if it exists
  12974. */
  12975. get: function () {
  12976. return this._image;
  12977. },
  12978. enumerable: false,
  12979. configurable: true
  12980. });
  12981. Object.defineProperty(ToggleButton.prototype, "textBlock", {
  12982. /**
  12983. * Returns the ToggleButton's child TextBlock control if it exists
  12984. */
  12985. get: function () {
  12986. return this._textBlock;
  12987. },
  12988. enumerable: false,
  12989. configurable: true
  12990. });
  12991. Object.defineProperty(ToggleButton.prototype, "group", {
  12992. /** Gets or sets group name this toggle button belongs to */
  12993. get: function () {
  12994. return this._group;
  12995. },
  12996. set: function (value) {
  12997. if (this._group === value) {
  12998. return;
  12999. }
  13000. this._group = value;
  13001. },
  13002. enumerable: false,
  13003. configurable: true
  13004. });
  13005. Object.defineProperty(ToggleButton.prototype, "isActive", {
  13006. /** Gets or sets a boolean indicating if the toogle button is active or not */
  13007. get: function () {
  13008. return this._isActive;
  13009. },
  13010. set: function (value) {
  13011. var _this = this;
  13012. var _a, _b;
  13013. // Function modeled after radioButton.ts
  13014. if (this._isActive === value) {
  13015. return;
  13016. }
  13017. this._isActive = value;
  13018. // Update the visual state based on the new value
  13019. if (this._isActive) {
  13020. (_a = this.toActiveAnimation) === null || _a === void 0 ? void 0 : _a.call(this);
  13021. }
  13022. else {
  13023. (_b = this.toInactiveAnimation) === null || _b === void 0 ? void 0 : _b.call(this);
  13024. }
  13025. this._markAsDirty();
  13026. this.onIsActiveChangedObservable.notifyObservers(value);
  13027. if (this._isActive && this._host && this._group) {
  13028. // A toggle button in a group can only have 1 active element at a given time.
  13029. // If this toggle button has a group, set other toggle buttons in the group to inactive.
  13030. this._host.executeOnAllControls(function (control) {
  13031. // Check for control type ToggleButton
  13032. if (control.typeName === "ToggleButton") {
  13033. // Don't do anything to this toggle button
  13034. if (control === _this) {
  13035. return;
  13036. }
  13037. var childToggle = control;
  13038. // If toggle button is in same group, set isActive to false
  13039. if (childToggle.group === _this.group) {
  13040. childToggle.isActive = false;
  13041. }
  13042. }
  13043. });
  13044. }
  13045. },
  13046. enumerable: false,
  13047. configurable: true
  13048. });
  13049. ToggleButton.prototype._getTypeName = function () {
  13050. return "ToggleButton";
  13051. };
  13052. // While being a container, the toggle button behaves like a control.
  13053. /** @hidden */
  13054. ToggleButton.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  13055. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  13056. return false;
  13057. }
  13058. if (!_super.prototype.contains.call(this, x, y)) {
  13059. return false;
  13060. }
  13061. if (this.delegatePickingToChildren) {
  13062. var contains = false;
  13063. for (var index = this._children.length - 1; index >= 0; index--) {
  13064. var child = this._children[index];
  13065. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  13066. contains = true;
  13067. break;
  13068. }
  13069. }
  13070. if (!contains) {
  13071. return false;
  13072. }
  13073. }
  13074. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  13075. return true;
  13076. };
  13077. /** @hidden */
  13078. ToggleButton.prototype._onPointerEnter = function (target, pi) {
  13079. if (!_super.prototype._onPointerEnter.call(this, target, pi)) {
  13080. return false;
  13081. }
  13082. if (this._isActive) {
  13083. if (this.pointerEnterActiveAnimation) {
  13084. this.pointerEnterActiveAnimation();
  13085. }
  13086. }
  13087. else {
  13088. if (this.pointerEnterInactiveAnimation) {
  13089. this.pointerEnterInactiveAnimation();
  13090. }
  13091. }
  13092. return true;
  13093. };
  13094. /** @hidden */
  13095. ToggleButton.prototype._onPointerOut = function (target, pi, force) {
  13096. if (force === void 0) { force = false; }
  13097. if (this._isActive) {
  13098. if (this.pointerOutActiveAnimation) {
  13099. this.pointerOutActiveAnimation();
  13100. }
  13101. }
  13102. else {
  13103. if (this.pointerOutInactiveAnimation) {
  13104. this.pointerOutInactiveAnimation();
  13105. }
  13106. }
  13107. _super.prototype._onPointerOut.call(this, target, pi, force);
  13108. };
  13109. /** @hidden */
  13110. ToggleButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  13111. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  13112. return false;
  13113. }
  13114. if (this._isActive) {
  13115. if (this.pointerDownActiveAnimation) {
  13116. this.pointerDownActiveAnimation();
  13117. }
  13118. }
  13119. else {
  13120. if (this.pointerDownInactiveAnimation) {
  13121. this.pointerDownInactiveAnimation();
  13122. }
  13123. }
  13124. return true;
  13125. };
  13126. /** @hidden */
  13127. ToggleButton.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  13128. if (this._isActive) {
  13129. if (this.pointerUpActiveAnimation) {
  13130. this.pointerUpActiveAnimation();
  13131. }
  13132. }
  13133. else {
  13134. if (this.pointerUpInactiveAnimation) {
  13135. this.pointerUpInactiveAnimation();
  13136. }
  13137. }
  13138. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  13139. };
  13140. return ToggleButton;
  13141. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  13142. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ToggleButton"] = ToggleButton;
  13143. /***/ }),
  13144. /***/ "./2D/controls/virtualKeyboard.ts":
  13145. /*!****************************************!*\
  13146. !*** ./2D/controls/virtualKeyboard.ts ***!
  13147. \****************************************/
  13148. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  13149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13150. "use strict";
  13151. __webpack_require__.r(__webpack_exports__);
  13152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  13153. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  13154. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13155. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  13156. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  13157. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  13158. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  13159. /**
  13160. * Class used to store key control properties
  13161. */
  13162. var KeyPropertySet = /** @class */ (function () {
  13163. function KeyPropertySet() {
  13164. }
  13165. return KeyPropertySet;
  13166. }());
  13167. /**
  13168. * Class used to create virtual keyboard
  13169. */
  13170. var VirtualKeyboard = /** @class */ (function (_super) {
  13171. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  13172. function VirtualKeyboard() {
  13173. var _this = _super !== null && _super.apply(this, arguments) || this;
  13174. /** Observable raised when a key is pressed */
  13175. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  13176. /** Gets or sets default key button width */
  13177. _this.defaultButtonWidth = "40px";
  13178. /** Gets or sets default key button height */
  13179. _this.defaultButtonHeight = "40px";
  13180. /** Gets or sets default key button left padding */
  13181. _this.defaultButtonPaddingLeft = "2px";
  13182. /** Gets or sets default key button right padding */
  13183. _this.defaultButtonPaddingRight = "2px";
  13184. /** Gets or sets default key button top padding */
  13185. _this.defaultButtonPaddingTop = "2px";
  13186. /** Gets or sets default key button bottom padding */
  13187. _this.defaultButtonPaddingBottom = "2px";
  13188. /** Gets or sets default key button foreground color */
  13189. _this.defaultButtonColor = "#DDD";
  13190. /** Gets or sets default key button background color */
  13191. _this.defaultButtonBackground = "#070707";
  13192. /** Gets or sets shift button foreground color */
  13193. _this.shiftButtonColor = "#7799FF";
  13194. /** Gets or sets shift button thickness*/
  13195. _this.selectedShiftThickness = 1;
  13196. /** Gets shift key state */
  13197. _this.shiftState = 0;
  13198. _this._currentlyConnectedInputText = null;
  13199. _this._connectedInputTexts = [];
  13200. _this._onKeyPressObserver = null;
  13201. return _this;
  13202. }
  13203. VirtualKeyboard.prototype._getTypeName = function () {
  13204. return "VirtualKeyboard";
  13205. };
  13206. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  13207. var _this = this;
  13208. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  13209. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  13210. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  13211. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  13212. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  13213. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  13214. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  13215. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  13216. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  13217. button.thickness = 0;
  13218. button.isFocusInvisible = true;
  13219. button.shadowColor = this.shadowColor;
  13220. button.shadowBlur = this.shadowBlur;
  13221. button.shadowOffsetX = this.shadowOffsetX;
  13222. button.shadowOffsetY = this.shadowOffsetY;
  13223. button.onPointerUpObservable.add(function () {
  13224. _this.onKeyPressObservable.notifyObservers(key);
  13225. });
  13226. return button;
  13227. };
  13228. /**
  13229. * Adds a new row of keys
  13230. * @param keys defines the list of keys to add
  13231. * @param propertySets defines the associated property sets
  13232. */
  13233. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  13234. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  13235. panel.isVertical = false;
  13236. panel.isFocusInvisible = true;
  13237. var maxKey = null;
  13238. for (var i = 0; i < keys.length; i++) {
  13239. var properties = null;
  13240. if (propertySets && propertySets.length === keys.length) {
  13241. properties = propertySets[i];
  13242. }
  13243. var key = this._createKey(keys[i], properties);
  13244. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  13245. maxKey = key;
  13246. }
  13247. panel.addControl(key);
  13248. }
  13249. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  13250. this.addControl(panel);
  13251. };
  13252. /**
  13253. * Set the shift key to a specific state
  13254. * @param shiftState defines the new shift state
  13255. */
  13256. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  13257. if (!this.children) {
  13258. return;
  13259. }
  13260. for (var i = 0; i < this.children.length; i++) {
  13261. var row = this.children[i];
  13262. if (!row || !row.children) {
  13263. continue;
  13264. }
  13265. var rowContainer = row;
  13266. for (var j = 0; j < rowContainer.children.length; j++) {
  13267. var button = rowContainer.children[j];
  13268. if (!button || !button.children[0]) {
  13269. continue;
  13270. }
  13271. var button_tblock = button.children[0];
  13272. if (button_tblock.text === "\u21E7") {
  13273. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  13274. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  13275. }
  13276. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  13277. }
  13278. }
  13279. };
  13280. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  13281. /** Gets the input text control currently attached to the keyboard */
  13282. get: function () {
  13283. return this._currentlyConnectedInputText;
  13284. },
  13285. enumerable: false,
  13286. configurable: true
  13287. });
  13288. /**
  13289. * Connects the keyboard with an input text control
  13290. *
  13291. * @param input defines the target control
  13292. */
  13293. VirtualKeyboard.prototype.connect = function (input) {
  13294. var _this = this;
  13295. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  13296. if (inputTextAlreadyConnected) {
  13297. return;
  13298. }
  13299. if (this._onKeyPressObserver === null) {
  13300. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  13301. if (!_this._currentlyConnectedInputText) {
  13302. return;
  13303. }
  13304. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  13305. switch (key) {
  13306. case "\u21E7":
  13307. _this.shiftState++;
  13308. if (_this.shiftState > 2) {
  13309. _this.shiftState = 0;
  13310. }
  13311. _this.applyShiftState(_this.shiftState);
  13312. return;
  13313. case "\u2190":
  13314. _this._currentlyConnectedInputText.processKey(8);
  13315. return;
  13316. case "\u21B5":
  13317. _this._currentlyConnectedInputText.processKey(13);
  13318. return;
  13319. }
  13320. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  13321. if (_this.shiftState === 1) {
  13322. _this.shiftState = 0;
  13323. _this.applyShiftState(_this.shiftState);
  13324. }
  13325. });
  13326. }
  13327. this.isVisible = false;
  13328. this._currentlyConnectedInputText = input;
  13329. input._connectedVirtualKeyboard = this;
  13330. // Events hooking
  13331. var onFocusObserver = input.onFocusObservable.add(function () {
  13332. _this._currentlyConnectedInputText = input;
  13333. input._connectedVirtualKeyboard = _this;
  13334. _this.isVisible = true;
  13335. });
  13336. var onBlurObserver = input.onBlurObservable.add(function () {
  13337. input._connectedVirtualKeyboard = null;
  13338. _this._currentlyConnectedInputText = null;
  13339. _this.isVisible = false;
  13340. });
  13341. this._connectedInputTexts.push({
  13342. input: input,
  13343. onBlurObserver: onBlurObserver,
  13344. onFocusObserver: onFocusObserver
  13345. });
  13346. };
  13347. /**
  13348. * Disconnects the keyboard from connected InputText controls
  13349. *
  13350. * @param input optionally defines a target control, otherwise all are disconnected
  13351. */
  13352. VirtualKeyboard.prototype.disconnect = function (input) {
  13353. var _this = this;
  13354. if (input) {
  13355. // .find not available on IE
  13356. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  13357. if (filtered.length === 1) {
  13358. this._removeConnectedInputObservables(filtered[0]);
  13359. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  13360. if (this._currentlyConnectedInputText === input) {
  13361. this._currentlyConnectedInputText = null;
  13362. }
  13363. }
  13364. }
  13365. else {
  13366. this._connectedInputTexts.forEach(function (connectedInputText) {
  13367. _this._removeConnectedInputObservables(connectedInputText);
  13368. });
  13369. this._connectedInputTexts = [];
  13370. }
  13371. if (this._connectedInputTexts.length === 0) {
  13372. this._currentlyConnectedInputText = null;
  13373. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  13374. this._onKeyPressObserver = null;
  13375. }
  13376. };
  13377. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  13378. connectedInputText.input._connectedVirtualKeyboard = null;
  13379. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  13380. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  13381. };
  13382. /**
  13383. * Release all resources
  13384. */
  13385. VirtualKeyboard.prototype.dispose = function () {
  13386. _super.prototype.dispose.call(this);
  13387. this.disconnect();
  13388. };
  13389. // Statics
  13390. /**
  13391. * Creates a new keyboard using a default layout
  13392. *
  13393. * @param name defines control name
  13394. * @returns a new VirtualKeyboard
  13395. */
  13396. VirtualKeyboard.CreateDefaultLayout = function (name) {
  13397. var returnValue = new VirtualKeyboard(name);
  13398. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  13399. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  13400. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  13401. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  13402. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  13403. return returnValue;
  13404. };
  13405. return VirtualKeyboard;
  13406. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  13407. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  13408. /***/ }),
  13409. /***/ "./2D/index.ts":
  13410. /*!*********************!*\
  13411. !*** ./2D/index.ts ***!
  13412. \*********************/
  13413. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, FocusableButton, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, ToggleButton, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader */
  13414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13415. "use strict";
  13416. __webpack_require__.r(__webpack_exports__);
  13417. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  13418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  13419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  13420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  13421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  13422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  13423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  13424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["FocusableButton"]; });
  13425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  13426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  13427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  13428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  13429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  13430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  13431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  13432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  13433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  13434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  13435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  13436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  13437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  13438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  13439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  13440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  13441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  13442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ToggleButton"]; });
  13443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  13444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  13445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  13446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  13447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  13448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  13449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  13450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  13451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  13452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  13453. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  13455. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  13456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  13457. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  13458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  13459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  13460. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  13461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  13462. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  13463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  13464. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  13465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  13466. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  13468. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  13469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  13470. /***/ }),
  13471. /***/ "./2D/math2D.ts":
  13472. /*!**********************!*\
  13473. !*** ./2D/math2D.ts ***!
  13474. \**********************/
  13475. /*! exports provided: Vector2WithInfo, Matrix2D */
  13476. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13477. "use strict";
  13478. __webpack_require__.r(__webpack_exports__);
  13479. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  13480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  13481. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13482. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  13483. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  13484. /**
  13485. * Class used to transport Vector2 information for pointer events
  13486. */
  13487. var Vector2WithInfo = /** @class */ (function (_super) {
  13488. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  13489. /**
  13490. * Creates a new Vector2WithInfo
  13491. * @param source defines the vector2 data to transport
  13492. * @param buttonIndex defines the current mouse button index
  13493. */
  13494. function Vector2WithInfo(source,
  13495. /** defines the current mouse button index */
  13496. buttonIndex) {
  13497. if (buttonIndex === void 0) { buttonIndex = 0; }
  13498. var _this = _super.call(this, source.x, source.y) || this;
  13499. _this.buttonIndex = buttonIndex;
  13500. return _this;
  13501. }
  13502. return Vector2WithInfo;
  13503. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  13504. /** Class used to provide 2D matrix features */
  13505. var Matrix2D = /** @class */ (function () {
  13506. /**
  13507. * Creates a new matrix
  13508. * @param m00 defines value for (0, 0)
  13509. * @param m01 defines value for (0, 1)
  13510. * @param m10 defines value for (1, 0)
  13511. * @param m11 defines value for (1, 1)
  13512. * @param m20 defines value for (2, 0)
  13513. * @param m21 defines value for (2, 1)
  13514. */
  13515. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  13516. /** Gets the internal array of 6 floats used to store matrix data */
  13517. this.m = new Float32Array(6);
  13518. this.fromValues(m00, m01, m10, m11, m20, m21);
  13519. }
  13520. /**
  13521. * Fills the matrix from direct values
  13522. * @param m00 defines value for (0, 0)
  13523. * @param m01 defines value for (0, 1)
  13524. * @param m10 defines value for (1, 0)
  13525. * @param m11 defines value for (1, 1)
  13526. * @param m20 defines value for (2, 0)
  13527. * @param m21 defines value for (2, 1)
  13528. * @returns the current modified matrix
  13529. */
  13530. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  13531. this.m[0] = m00;
  13532. this.m[1] = m01;
  13533. this.m[2] = m10;
  13534. this.m[3] = m11;
  13535. this.m[4] = m20;
  13536. this.m[5] = m21;
  13537. return this;
  13538. };
  13539. /**
  13540. * Gets matrix determinant
  13541. * @returns the determinant
  13542. */
  13543. Matrix2D.prototype.determinant = function () {
  13544. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  13545. };
  13546. /**
  13547. * Inverses the matrix and stores it in a target matrix
  13548. * @param result defines the target matrix
  13549. * @returns the current matrix
  13550. */
  13551. Matrix2D.prototype.invertToRef = function (result) {
  13552. var l0 = this.m[0];
  13553. var l1 = this.m[1];
  13554. var l2 = this.m[2];
  13555. var l3 = this.m[3];
  13556. var l4 = this.m[4];
  13557. var l5 = this.m[5];
  13558. var det = this.determinant();
  13559. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  13560. result.m[0] = 0;
  13561. result.m[1] = 0;
  13562. result.m[2] = 0;
  13563. result.m[3] = 0;
  13564. result.m[4] = 0;
  13565. result.m[5] = 0;
  13566. return this;
  13567. }
  13568. var detDiv = 1 / det;
  13569. var det4 = l2 * l5 - l3 * l4;
  13570. var det5 = l1 * l4 - l0 * l5;
  13571. result.m[0] = l3 * detDiv;
  13572. result.m[1] = -l1 * detDiv;
  13573. result.m[2] = -l2 * detDiv;
  13574. result.m[3] = l0 * detDiv;
  13575. result.m[4] = det4 * detDiv;
  13576. result.m[5] = det5 * detDiv;
  13577. return this;
  13578. };
  13579. /**
  13580. * Multiplies the current matrix with another one
  13581. * @param other defines the second operand
  13582. * @param result defines the target matrix
  13583. * @returns the current matrix
  13584. */
  13585. Matrix2D.prototype.multiplyToRef = function (other, result) {
  13586. var l0 = this.m[0];
  13587. var l1 = this.m[1];
  13588. var l2 = this.m[2];
  13589. var l3 = this.m[3];
  13590. var l4 = this.m[4];
  13591. var l5 = this.m[5];
  13592. var r0 = other.m[0];
  13593. var r1 = other.m[1];
  13594. var r2 = other.m[2];
  13595. var r3 = other.m[3];
  13596. var r4 = other.m[4];
  13597. var r5 = other.m[5];
  13598. result.m[0] = l0 * r0 + l1 * r2;
  13599. result.m[1] = l0 * r1 + l1 * r3;
  13600. result.m[2] = l2 * r0 + l3 * r2;
  13601. result.m[3] = l2 * r1 + l3 * r3;
  13602. result.m[4] = l4 * r0 + l5 * r2 + r4;
  13603. result.m[5] = l4 * r1 + l5 * r3 + r5;
  13604. return this;
  13605. };
  13606. /**
  13607. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  13608. * @param x defines the x coordinate to transform
  13609. * @param y defines the x coordinate to transform
  13610. * @param result defines the target vector2
  13611. * @returns the current matrix
  13612. */
  13613. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  13614. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  13615. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  13616. return this;
  13617. };
  13618. // Statics
  13619. /**
  13620. * Creates an identity matrix
  13621. * @returns a new matrix
  13622. */
  13623. Matrix2D.Identity = function () {
  13624. return new Matrix2D(1, 0, 0, 1, 0, 0);
  13625. };
  13626. /**
  13627. * Creates a translation matrix and stores it in a target matrix
  13628. * @param x defines the x coordinate of the translation
  13629. * @param y defines the y coordinate of the translation
  13630. * @param result defines the target matrix
  13631. */
  13632. Matrix2D.TranslationToRef = function (x, y, result) {
  13633. result.fromValues(1, 0, 0, 1, x, y);
  13634. };
  13635. /**
  13636. * Creates a scaling matrix and stores it in a target matrix
  13637. * @param x defines the x coordinate of the scaling
  13638. * @param y defines the y coordinate of the scaling
  13639. * @param result defines the target matrix
  13640. */
  13641. Matrix2D.ScalingToRef = function (x, y, result) {
  13642. result.fromValues(x, 0, 0, y, 0, 0);
  13643. };
  13644. /**
  13645. * Creates a rotation matrix and stores it in a target matrix
  13646. * @param angle defines the rotation angle
  13647. * @param result defines the target matrix
  13648. */
  13649. Matrix2D.RotationToRef = function (angle, result) {
  13650. var s = Math.sin(angle);
  13651. var c = Math.cos(angle);
  13652. result.fromValues(c, s, -s, c, 0, 0);
  13653. };
  13654. /**
  13655. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  13656. * @param tx defines the x coordinate of the translation
  13657. * @param ty defines the y coordinate of the translation
  13658. * @param angle defines the rotation angle
  13659. * @param scaleX defines the x coordinate of the scaling
  13660. * @param scaleY defines the y coordinate of the scaling
  13661. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  13662. * @param result defines the target matrix
  13663. */
  13664. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  13665. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  13666. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  13667. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  13668. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  13669. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  13670. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  13671. if (parentMatrix) {
  13672. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  13673. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  13674. }
  13675. else {
  13676. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  13677. }
  13678. };
  13679. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  13680. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  13681. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  13682. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  13683. Matrix2D._TempCompose0 = Matrix2D.Identity();
  13684. Matrix2D._TempCompose1 = Matrix2D.Identity();
  13685. Matrix2D._TempCompose2 = Matrix2D.Identity();
  13686. return Matrix2D;
  13687. }());
  13688. /***/ }),
  13689. /***/ "./2D/measure.ts":
  13690. /*!***********************!*\
  13691. !*** ./2D/measure.ts ***!
  13692. \***********************/
  13693. /*! exports provided: Measure */
  13694. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13695. "use strict";
  13696. __webpack_require__.r(__webpack_exports__);
  13697. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  13698. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  13699. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13700. var tmpRect = [
  13701. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13702. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13703. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13704. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13705. ];
  13706. var tmpRect2 = [
  13707. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13708. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13709. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13710. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13711. ];
  13712. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13713. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13714. /**
  13715. * Class used to store 2D control sizes
  13716. */
  13717. var Measure = /** @class */ (function () {
  13718. /**
  13719. * Creates a new measure
  13720. * @param left defines left coordinate
  13721. * @param top defines top coordinate
  13722. * @param width defines width dimension
  13723. * @param height defines height dimension
  13724. */
  13725. function Measure(
  13726. /** defines left coordinate */
  13727. left,
  13728. /** defines top coordinate */
  13729. top,
  13730. /** defines width dimension */
  13731. width,
  13732. /** defines height dimension */
  13733. height) {
  13734. this.left = left;
  13735. this.top = top;
  13736. this.width = width;
  13737. this.height = height;
  13738. }
  13739. /**
  13740. * Copy from another measure
  13741. * @param other defines the other measure to copy from
  13742. */
  13743. Measure.prototype.copyFrom = function (other) {
  13744. this.left = other.left;
  13745. this.top = other.top;
  13746. this.width = other.width;
  13747. this.height = other.height;
  13748. };
  13749. /**
  13750. * Copy from a group of 4 floats
  13751. * @param left defines left coordinate
  13752. * @param top defines top coordinate
  13753. * @param width defines width dimension
  13754. * @param height defines height dimension
  13755. */
  13756. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  13757. this.left = left;
  13758. this.top = top;
  13759. this.width = width;
  13760. this.height = height;
  13761. };
  13762. /**
  13763. * Computes the axis aligned bounding box measure for two given measures
  13764. * @param a Input measure
  13765. * @param b Input measure
  13766. * @param result the resulting bounding measure
  13767. */
  13768. Measure.CombineToRef = function (a, b, result) {
  13769. var left = Math.min(a.left, b.left);
  13770. var top = Math.min(a.top, b.top);
  13771. var right = Math.max(a.left + a.width, b.left + b.width);
  13772. var bottom = Math.max(a.top + a.height, b.top + b.height);
  13773. result.left = left;
  13774. result.top = top;
  13775. result.width = right - left;
  13776. result.height = bottom - top;
  13777. };
  13778. /**
  13779. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13780. * @param transform the matrix to transform the measure before computing the AABB
  13781. * @param addX number to add to left
  13782. * @param addY number to add to top
  13783. * @param addWidth number to add to width
  13784. * @param addHeight number to add to height
  13785. * @param result the resulting AABB
  13786. */
  13787. Measure.prototype.addAndTransformToRef = function (transform, addX, addY, addWidth, addHeight, result) {
  13788. var left = this.left + addX;
  13789. var top = this.top + addY;
  13790. var width = this.width + addWidth;
  13791. var height = this.height + addHeight;
  13792. tmpRect[0].copyFromFloats(left, top);
  13793. tmpRect[1].copyFromFloats(left + width, top);
  13794. tmpRect[2].copyFromFloats(left + width, top + height);
  13795. tmpRect[3].copyFromFloats(left, top + height);
  13796. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  13797. tmpV2.copyFromFloats(0, 0);
  13798. for (var i = 0; i < 4; i++) {
  13799. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  13800. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  13801. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  13802. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  13803. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  13804. }
  13805. result.left = tmpV1.x;
  13806. result.top = tmpV1.y;
  13807. result.width = tmpV2.x - tmpV1.x;
  13808. result.height = tmpV2.y - tmpV1.y;
  13809. };
  13810. /**
  13811. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13812. * @param transform the matrix to transform the measure before computing the AABB
  13813. * @param result the resulting AABB
  13814. */
  13815. Measure.prototype.transformToRef = function (transform, result) {
  13816. this.addAndTransformToRef(transform, 0, 0, 0, 0, result);
  13817. };
  13818. /**
  13819. * Check equality between this measure and another one
  13820. * @param other defines the other measures
  13821. * @returns true if both measures are equals
  13822. */
  13823. Measure.prototype.isEqualsTo = function (other) {
  13824. if (this.left !== other.left) {
  13825. return false;
  13826. }
  13827. if (this.top !== other.top) {
  13828. return false;
  13829. }
  13830. if (this.width !== other.width) {
  13831. return false;
  13832. }
  13833. if (this.height !== other.height) {
  13834. return false;
  13835. }
  13836. return true;
  13837. };
  13838. /**
  13839. * Creates an empty measure
  13840. * @returns a new measure
  13841. */
  13842. Measure.Empty = function () {
  13843. return new Measure(0, 0, 0, 0);
  13844. };
  13845. return Measure;
  13846. }());
  13847. /***/ }),
  13848. /***/ "./2D/multiLinePoint.ts":
  13849. /*!******************************!*\
  13850. !*** ./2D/multiLinePoint.ts ***!
  13851. \******************************/
  13852. /*! exports provided: MultiLinePoint */
  13853. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13854. "use strict";
  13855. __webpack_require__.r(__webpack_exports__);
  13856. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13857. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  13858. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13859. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13860. /**
  13861. * Class used to store a point for a MultiLine object.
  13862. * The point can be pure 2D coordinates, a mesh or a control
  13863. */
  13864. var MultiLinePoint = /** @class */ (function () {
  13865. /**
  13866. * Creates a new MultiLinePoint
  13867. * @param multiLine defines the source MultiLine object
  13868. */
  13869. function MultiLinePoint(multiLine) {
  13870. this._multiLine = multiLine;
  13871. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13872. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13873. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  13874. }
  13875. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13876. /** Gets or sets x coordinate */
  13877. get: function () {
  13878. return this._x.toString(this._multiLine._host);
  13879. },
  13880. set: function (value) {
  13881. if (this._x.toString(this._multiLine._host) === value) {
  13882. return;
  13883. }
  13884. if (this._x.fromString(value)) {
  13885. this._multiLine._markAsDirty();
  13886. }
  13887. },
  13888. enumerable: false,
  13889. configurable: true
  13890. });
  13891. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13892. /** Gets or sets y coordinate */
  13893. get: function () {
  13894. return this._y.toString(this._multiLine._host);
  13895. },
  13896. set: function (value) {
  13897. if (this._y.toString(this._multiLine._host) === value) {
  13898. return;
  13899. }
  13900. if (this._y.fromString(value)) {
  13901. this._multiLine._markAsDirty();
  13902. }
  13903. },
  13904. enumerable: false,
  13905. configurable: true
  13906. });
  13907. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13908. /** Gets or sets the control associated with this point */
  13909. get: function () {
  13910. return this._control;
  13911. },
  13912. set: function (value) {
  13913. if (this._control === value) {
  13914. return;
  13915. }
  13916. if (this._control && this._controlObserver) {
  13917. this._control.onDirtyObservable.remove(this._controlObserver);
  13918. this._controlObserver = null;
  13919. }
  13920. this._control = value;
  13921. if (this._control) {
  13922. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13923. }
  13924. this._multiLine._markAsDirty();
  13925. },
  13926. enumerable: false,
  13927. configurable: true
  13928. });
  13929. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13930. /** Gets or sets the mesh associated with this point */
  13931. get: function () {
  13932. return this._mesh;
  13933. },
  13934. set: function (value) {
  13935. if (this._mesh === value) {
  13936. return;
  13937. }
  13938. if (this._mesh && this._meshObserver) {
  13939. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13940. }
  13941. this._mesh = value;
  13942. if (this._mesh) {
  13943. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13944. }
  13945. this._multiLine._markAsDirty();
  13946. },
  13947. enumerable: false,
  13948. configurable: true
  13949. });
  13950. /** Resets links */
  13951. MultiLinePoint.prototype.resetLinks = function () {
  13952. this.control = null;
  13953. this.mesh = null;
  13954. };
  13955. /**
  13956. * Gets a translation vector with Z component
  13957. * @returns the translation vector
  13958. */
  13959. MultiLinePoint.prototype.translate = function () {
  13960. this._point = this._translatePoint();
  13961. return this._point;
  13962. };
  13963. MultiLinePoint.prototype._translatePoint = function () {
  13964. if (this._mesh != null) {
  13965. return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13966. }
  13967. else if (this._control != null) {
  13968. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](this._control.centerX, this._control.centerY, 1. - babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]);
  13969. }
  13970. else {
  13971. var host = this._multiLine._host;
  13972. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13973. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13974. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](xValue, yValue, 1. - babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]);
  13975. }
  13976. };
  13977. /** Release associated resources */
  13978. MultiLinePoint.prototype.dispose = function () {
  13979. this.resetLinks();
  13980. };
  13981. return MultiLinePoint;
  13982. }());
  13983. /***/ }),
  13984. /***/ "./2D/style.ts":
  13985. /*!*********************!*\
  13986. !*** ./2D/style.ts ***!
  13987. \*********************/
  13988. /*! exports provided: Style */
  13989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13990. "use strict";
  13991. __webpack_require__.r(__webpack_exports__);
  13992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13993. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  13994. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13995. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13996. /**
  13997. * Define a style used by control to automatically setup properties based on a template.
  13998. * Only support font related properties so far
  13999. */
  14000. var Style = /** @class */ (function () {
  14001. /**
  14002. * Creates a new style object
  14003. * @param host defines the AdvancedDynamicTexture which hosts this style
  14004. */
  14005. function Style(host) {
  14006. this._fontFamily = "Arial";
  14007. this._fontStyle = "";
  14008. this._fontWeight = "";
  14009. /** @hidden */
  14010. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  14011. /**
  14012. * Observable raised when the style values are changed
  14013. */
  14014. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14015. this._host = host;
  14016. }
  14017. Object.defineProperty(Style.prototype, "fontSize", {
  14018. /**
  14019. * Gets or sets the font size
  14020. */
  14021. get: function () {
  14022. return this._fontSize.toString(this._host);
  14023. },
  14024. set: function (value) {
  14025. if (this._fontSize.toString(this._host) === value) {
  14026. return;
  14027. }
  14028. if (this._fontSize.fromString(value)) {
  14029. this.onChangedObservable.notifyObservers(this);
  14030. }
  14031. },
  14032. enumerable: false,
  14033. configurable: true
  14034. });
  14035. Object.defineProperty(Style.prototype, "fontFamily", {
  14036. /**
  14037. * Gets or sets the font family
  14038. */
  14039. get: function () {
  14040. return this._fontFamily;
  14041. },
  14042. set: function (value) {
  14043. if (this._fontFamily === value) {
  14044. return;
  14045. }
  14046. this._fontFamily = value;
  14047. this.onChangedObservable.notifyObservers(this);
  14048. },
  14049. enumerable: false,
  14050. configurable: true
  14051. });
  14052. Object.defineProperty(Style.prototype, "fontStyle", {
  14053. /**
  14054. * Gets or sets the font style
  14055. */
  14056. get: function () {
  14057. return this._fontStyle;
  14058. },
  14059. set: function (value) {
  14060. if (this._fontStyle === value) {
  14061. return;
  14062. }
  14063. this._fontStyle = value;
  14064. this.onChangedObservable.notifyObservers(this);
  14065. },
  14066. enumerable: false,
  14067. configurable: true
  14068. });
  14069. Object.defineProperty(Style.prototype, "fontWeight", {
  14070. /** Gets or sets font weight */
  14071. get: function () {
  14072. return this._fontWeight;
  14073. },
  14074. set: function (value) {
  14075. if (this._fontWeight === value) {
  14076. return;
  14077. }
  14078. this._fontWeight = value;
  14079. this.onChangedObservable.notifyObservers(this);
  14080. },
  14081. enumerable: false,
  14082. configurable: true
  14083. });
  14084. /** Dispose all associated resources */
  14085. Style.prototype.dispose = function () {
  14086. this.onChangedObservable.clear();
  14087. };
  14088. return Style;
  14089. }());
  14090. /***/ }),
  14091. /***/ "./2D/valueAndUnit.ts":
  14092. /*!****************************!*\
  14093. !*** ./2D/valueAndUnit.ts ***!
  14094. \****************************/
  14095. /*! exports provided: ValueAndUnit */
  14096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14097. "use strict";
  14098. __webpack_require__.r(__webpack_exports__);
  14099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  14100. /**
  14101. * Class used to specific a value and its associated unit
  14102. */
  14103. var ValueAndUnit = /** @class */ (function () {
  14104. /**
  14105. * Creates a new ValueAndUnit
  14106. * @param value defines the value to store
  14107. * @param unit defines the unit to store
  14108. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  14109. */
  14110. function ValueAndUnit(value,
  14111. /** defines the unit to store */
  14112. unit,
  14113. /** defines a boolean indicating if the value can be negative */
  14114. negativeValueAllowed) {
  14115. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  14116. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  14117. this.unit = unit;
  14118. this.negativeValueAllowed = negativeValueAllowed;
  14119. this._value = 1;
  14120. /**
  14121. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  14122. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  14123. */
  14124. this.ignoreAdaptiveScaling = false;
  14125. this._value = value;
  14126. this._originalUnit = unit;
  14127. }
  14128. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  14129. /** Gets a boolean indicating if the value is a percentage */
  14130. get: function () {
  14131. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  14132. },
  14133. enumerable: false,
  14134. configurable: true
  14135. });
  14136. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  14137. /** Gets a boolean indicating if the value is store as pixel */
  14138. get: function () {
  14139. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  14140. },
  14141. enumerable: false,
  14142. configurable: true
  14143. });
  14144. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  14145. /** Gets direct internal value */
  14146. get: function () {
  14147. return this._value;
  14148. },
  14149. enumerable: false,
  14150. configurable: true
  14151. });
  14152. /**
  14153. * Gets value as pixel
  14154. * @param host defines the root host
  14155. * @param refValue defines the reference value for percentages
  14156. * @returns the value as pixel
  14157. */
  14158. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  14159. if (this.isPixel) {
  14160. return this.getValue(host);
  14161. }
  14162. return this.getValue(host) * refValue;
  14163. };
  14164. /**
  14165. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  14166. * @param value defines the value to store
  14167. * @param unit defines the unit to store
  14168. * @returns the current ValueAndUnit
  14169. */
  14170. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  14171. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  14172. this._value = value;
  14173. this.unit = unit;
  14174. return this;
  14175. };
  14176. /**
  14177. * Gets the value accordingly to its unit
  14178. * @param host defines the root host
  14179. * @returns the value
  14180. */
  14181. ValueAndUnit.prototype.getValue = function (host) {
  14182. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  14183. var width = 0;
  14184. var height = 0;
  14185. if (host.idealWidth) {
  14186. width = (this._value * host.getSize().width) / host.idealWidth;
  14187. }
  14188. if (host.idealHeight) {
  14189. height = (this._value * host.getSize().height) / host.idealHeight;
  14190. }
  14191. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  14192. return window.innerWidth < window.innerHeight ? width : height;
  14193. }
  14194. if (host.idealWidth) { // horizontal
  14195. return width;
  14196. }
  14197. if (host.idealHeight) { // vertical
  14198. return height;
  14199. }
  14200. }
  14201. return this._value;
  14202. };
  14203. /**
  14204. * Gets a string representation of the value
  14205. * @param host defines the root host
  14206. * @param decimals defines an optional number of decimals to display
  14207. * @returns a string
  14208. */
  14209. ValueAndUnit.prototype.toString = function (host, decimals) {
  14210. switch (this.unit) {
  14211. case ValueAndUnit.UNITMODE_PERCENTAGE:
  14212. var percentage = this.getValue(host) * 100;
  14213. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  14214. case ValueAndUnit.UNITMODE_PIXEL:
  14215. var pixels = this.getValue(host);
  14216. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  14217. }
  14218. return this.unit.toString();
  14219. };
  14220. /**
  14221. * Store a value parsed from a string
  14222. * @param source defines the source string
  14223. * @returns true if the value was successfully parsed
  14224. */
  14225. ValueAndUnit.prototype.fromString = function (source) {
  14226. var match = ValueAndUnit._Regex.exec(source.toString());
  14227. if (!match || match.length === 0) {
  14228. return false;
  14229. }
  14230. var sourceValue = parseFloat(match[1]);
  14231. var sourceUnit = this._originalUnit;
  14232. if (!this.negativeValueAllowed) {
  14233. if (sourceValue < 0) {
  14234. sourceValue = 0;
  14235. }
  14236. }
  14237. if (match.length === 4) {
  14238. switch (match[3]) {
  14239. case "px":
  14240. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  14241. break;
  14242. case "%":
  14243. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  14244. sourceValue /= 100.0;
  14245. break;
  14246. }
  14247. }
  14248. if (sourceValue === this._value && sourceUnit === this.unit) {
  14249. return false;
  14250. }
  14251. this._value = sourceValue;
  14252. this.unit = sourceUnit;
  14253. return true;
  14254. };
  14255. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  14256. /** UNITMODE_PERCENTAGE */
  14257. get: function () {
  14258. return ValueAndUnit._UNITMODE_PERCENTAGE;
  14259. },
  14260. enumerable: false,
  14261. configurable: true
  14262. });
  14263. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  14264. /** UNITMODE_PIXEL */
  14265. get: function () {
  14266. return ValueAndUnit._UNITMODE_PIXEL;
  14267. },
  14268. enumerable: false,
  14269. configurable: true
  14270. });
  14271. // Static
  14272. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  14273. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  14274. ValueAndUnit._UNITMODE_PIXEL = 1;
  14275. return ValueAndUnit;
  14276. }());
  14277. /***/ }),
  14278. /***/ "./2D/xmlLoader.ts":
  14279. /*!*************************!*\
  14280. !*** ./2D/xmlLoader.ts ***!
  14281. \*************************/
  14282. /*! exports provided: XmlLoader */
  14283. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14284. "use strict";
  14285. __webpack_require__.r(__webpack_exports__);
  14286. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  14287. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  14288. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  14289. /**
  14290. * Class used to load GUI via XML.
  14291. */
  14292. var XmlLoader = /** @class */ (function () {
  14293. /**
  14294. * Create a new xml loader
  14295. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  14296. */
  14297. function XmlLoader(parentClass) {
  14298. if (parentClass === void 0) { parentClass = null; }
  14299. this._nodes = {};
  14300. this._nodeTypes = {
  14301. element: 1,
  14302. attribute: 2,
  14303. text: 3
  14304. };
  14305. this._isLoaded = false;
  14306. this._objectAttributes = {
  14307. "textHorizontalAlignment": 1,
  14308. "textVerticalAlignment": 2,
  14309. "horizontalAlignment": 3,
  14310. "verticalAlignment": 4,
  14311. "stretch": 5,
  14312. };
  14313. if (parentClass) {
  14314. this._parentClass = parentClass;
  14315. }
  14316. }
  14317. XmlLoader.prototype._getChainElement = function (attributeValue) {
  14318. var element = window;
  14319. if (this._parentClass) {
  14320. element = this._parentClass;
  14321. }
  14322. var value = attributeValue;
  14323. value = value.split(".");
  14324. for (var i = 0; i < value.length; i++) {
  14325. element = element[value[i]];
  14326. }
  14327. return element;
  14328. };
  14329. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  14330. var attribute = attributeName.split(".");
  14331. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  14332. return className[attribute[1]];
  14333. };
  14334. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  14335. if (linkParent === void 0) { linkParent = true; }
  14336. try {
  14337. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  14338. var guiNode = new className();
  14339. if (parent && linkParent) {
  14340. parent.addControl(guiNode);
  14341. }
  14342. for (var i = 0; i < node.attributes.length; i++) {
  14343. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  14344. continue;
  14345. }
  14346. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  14347. var element = this._getChainElement(node.attributes[i].value);
  14348. guiNode[node.attributes[i].name].add(element);
  14349. continue;
  14350. }
  14351. else if (node.attributes[i].name == "linkWithMesh") {
  14352. if (this._parentClass) {
  14353. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  14354. }
  14355. else {
  14356. guiNode.linkWithMesh(window[node.attributes[i].value]);
  14357. }
  14358. }
  14359. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  14360. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  14361. guiNode[node.attributes[i].name] = element;
  14362. }
  14363. else if (!this._objectAttributes[node.attributes[i].name]) {
  14364. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  14365. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  14366. }
  14367. else {
  14368. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  14369. }
  14370. }
  14371. else {
  14372. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  14373. }
  14374. }
  14375. if (!node.attributes.getNamedItem("id")) {
  14376. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  14377. return guiNode;
  14378. }
  14379. var id = node.attributes.getNamedItem("id").value;
  14380. if (id.startsWith("{{") && id.endsWith("}}")) {
  14381. id = this._getChainElement(id.substring(2, id.length - 2));
  14382. }
  14383. if (!this._nodes[id]) {
  14384. this._nodes[id] = guiNode;
  14385. }
  14386. else {
  14387. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  14388. }
  14389. return guiNode;
  14390. }
  14391. catch (e) {
  14392. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  14393. }
  14394. };
  14395. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  14396. var width;
  14397. var height;
  14398. var columns;
  14399. var rows = node.children;
  14400. var cells;
  14401. var isPixel = false;
  14402. var cellNode;
  14403. var rowNumber = -1;
  14404. var columnNumber = -1;
  14405. var totalColumnsNumber = 0;
  14406. for (var i = 0; i < rows.length; i++) {
  14407. if (rows[i].nodeType != this._nodeTypes.element) {
  14408. continue;
  14409. }
  14410. if (rows[i].nodeName != "Row") {
  14411. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  14412. }
  14413. rowNumber += 1;
  14414. columns = rows[i].children;
  14415. if (!rows[i].attributes.getNamedItem("height")) {
  14416. throw "XmlLoader Exception : Height must be defined for grid rows";
  14417. }
  14418. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  14419. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  14420. guiNode.addRowDefinition(height, isPixel);
  14421. for (var j = 0; j < columns.length; j++) {
  14422. if (columns[j].nodeType != this._nodeTypes.element) {
  14423. continue;
  14424. }
  14425. if (columns[j].nodeName != "Column") {
  14426. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  14427. }
  14428. columnNumber += 1;
  14429. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  14430. 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.";
  14431. }
  14432. if (rowNumber == 0) {
  14433. if (!columns[j].attributes.getNamedItem("width")) {
  14434. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  14435. }
  14436. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  14437. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  14438. guiNode.addColumnDefinition(width, isPixel);
  14439. }
  14440. cells = columns[j].children;
  14441. for (var k = 0; k < cells.length; k++) {
  14442. if (cells[k].nodeType != this._nodeTypes.element) {
  14443. continue;
  14444. }
  14445. cellNode = this._createGuiElement(cells[k], guiNode, false);
  14446. guiNode.addControl(cellNode, rowNumber, columnNumber);
  14447. if (cells[k].firstChild) {
  14448. this._parseXml(cells[k].firstChild, cellNode);
  14449. }
  14450. }
  14451. }
  14452. if (rowNumber == 0) {
  14453. totalColumnsNumber = columnNumber;
  14454. }
  14455. columnNumber = -1;
  14456. }
  14457. if (node.nextSibling) {
  14458. this._parseXml(node.nextSibling, parent);
  14459. }
  14460. };
  14461. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  14462. if (node.firstChild) {
  14463. this._parseXml(node.firstChild, guiNode);
  14464. }
  14465. if (node.nextSibling) {
  14466. this._parseXml(node.nextSibling, parent);
  14467. }
  14468. };
  14469. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  14470. if (this._parentClass) {
  14471. this._parentClass[variable] = source[iterator];
  14472. }
  14473. else {
  14474. window[variable] = source[iterator];
  14475. }
  14476. if (node.firstChild) {
  14477. this._parseXml(node.firstChild, guiNode, true);
  14478. }
  14479. };
  14480. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  14481. var dataSource = node.attributes.getNamedItem("dataSource").value;
  14482. if (!dataSource.includes(" in ")) {
  14483. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  14484. }
  14485. else {
  14486. var isArray = true;
  14487. var splittedSource = dataSource.split(" in ");
  14488. if (splittedSource.length < 2) {
  14489. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  14490. }
  14491. var source = splittedSource[1];
  14492. if (source.startsWith("{") && source.endsWith("}")) {
  14493. isArray = false;
  14494. }
  14495. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  14496. source = source.substring(1, source.length - 1);
  14497. }
  14498. if (this._parentClass) {
  14499. source = this._parentClass[source];
  14500. }
  14501. else {
  14502. source = window[source];
  14503. }
  14504. if (isArray) {
  14505. for (var i = 0; i < source.length; i++) {
  14506. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  14507. }
  14508. }
  14509. else {
  14510. for (var i in source) {
  14511. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  14512. }
  14513. }
  14514. if (node.nextSibling) {
  14515. this._parseXml(node.nextSibling, parent);
  14516. }
  14517. }
  14518. };
  14519. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  14520. if (generated === void 0) { generated = false; }
  14521. if (node.nodeType != this._nodeTypes.element) {
  14522. if (node.nextSibling) {
  14523. this._parseXml(node.nextSibling, parent, generated);
  14524. }
  14525. return;
  14526. }
  14527. if (generated) {
  14528. node.setAttribute("id", parent.id + (parent._children.length + 1));
  14529. }
  14530. var guiNode = this._createGuiElement(node, parent);
  14531. if (node.nodeName == "Grid") {
  14532. this._parseGrid(node, guiNode, parent);
  14533. }
  14534. else if (!node.attributes.getNamedItem("dataSource")) {
  14535. this._parseElement(node, guiNode, parent);
  14536. }
  14537. else {
  14538. this._parseElementsFromSource(node, guiNode, parent);
  14539. }
  14540. };
  14541. /**
  14542. * Gets if the loading has finished.
  14543. * @returns whether the loading has finished or not
  14544. */
  14545. XmlLoader.prototype.isLoaded = function () {
  14546. return this._isLoaded;
  14547. };
  14548. /**
  14549. * Gets a loaded node / control by id.
  14550. * @param id the Controls id set in the xml
  14551. * @returns element of type Control
  14552. */
  14553. XmlLoader.prototype.getNodeById = function (id) {
  14554. return this._nodes[id];
  14555. };
  14556. /**
  14557. * Gets all loaded nodes / controls
  14558. * @returns Array of controls
  14559. */
  14560. XmlLoader.prototype.getNodes = function () {
  14561. return this._nodes;
  14562. };
  14563. /**
  14564. * Initiates the xml layout loading
  14565. * @param xmlFile defines the xml layout to load
  14566. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  14567. * @param callback defines the callback called on layout load.
  14568. */
  14569. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  14570. var xhttp = new XMLHttpRequest();
  14571. xhttp.onreadystatechange = function () {
  14572. if (xhttp.readyState == 4 && xhttp.status == 200) {
  14573. if (!xhttp.responseXML) {
  14574. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  14575. }
  14576. var xmlDoc = xhttp.responseXML.documentElement;
  14577. this._parseXml(xmlDoc.firstChild, rootNode);
  14578. this._isLoaded = true;
  14579. if (callback) {
  14580. callback();
  14581. }
  14582. }
  14583. }.bind(this);
  14584. xhttp.open("GET", xmlFile, true);
  14585. xhttp.send();
  14586. };
  14587. return XmlLoader;
  14588. }());
  14589. /***/ }),
  14590. /***/ "./3D/controls/abstractButton3D.ts":
  14591. /*!*****************************************!*\
  14592. !*** ./3D/controls/abstractButton3D.ts ***!
  14593. \*****************************************/
  14594. /*! exports provided: AbstractButton3D */
  14595. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14596. "use strict";
  14597. __webpack_require__.r(__webpack_exports__);
  14598. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  14599. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14600. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  14601. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14602. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14603. /**
  14604. * Class used as a root to all buttons
  14605. */
  14606. var AbstractButton3D = /** @class */ (function (_super) {
  14607. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  14608. /**
  14609. * Creates a new button
  14610. * @param name defines the control name
  14611. */
  14612. function AbstractButton3D(name) {
  14613. return _super.call(this, name) || this;
  14614. }
  14615. AbstractButton3D.prototype._getTypeName = function () {
  14616. return "AbstractButton3D";
  14617. };
  14618. // Mesh association
  14619. AbstractButton3D.prototype._createNode = function (scene) {
  14620. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  14621. };
  14622. return AbstractButton3D;
  14623. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14624. /***/ }),
  14625. /***/ "./3D/controls/button3D.ts":
  14626. /*!*********************************!*\
  14627. !*** ./3D/controls/button3D.ts ***!
  14628. \*********************************/
  14629. /*! exports provided: Button3D */
  14630. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14631. "use strict";
  14632. __webpack_require__.r(__webpack_exports__);
  14633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  14634. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14635. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  14636. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  14637. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14638. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14639. /**
  14640. * Class used to create a button in 3D
  14641. */
  14642. var Button3D = /** @class */ (function (_super) {
  14643. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  14644. /**
  14645. * Creates a new button
  14646. * @param name defines the control name
  14647. */
  14648. function Button3D(name) {
  14649. var _this = _super.call(this, name) || this;
  14650. _this._contentResolution = 512;
  14651. _this._contentScaleRatio = 2;
  14652. // Default animations
  14653. _this.pointerEnterAnimation = function () {
  14654. if (!_this.mesh) {
  14655. return;
  14656. }
  14657. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  14658. };
  14659. _this.pointerOutAnimation = function () {
  14660. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14661. };
  14662. _this.pointerDownAnimation = function () {
  14663. if (!_this.mesh) {
  14664. return;
  14665. }
  14666. _this.mesh.scaling.scaleInPlace(0.95);
  14667. };
  14668. _this.pointerUpAnimation = function () {
  14669. if (!_this.mesh) {
  14670. return;
  14671. }
  14672. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14673. };
  14674. return _this;
  14675. }
  14676. Object.defineProperty(Button3D.prototype, "contentResolution", {
  14677. /**
  14678. * Gets or sets the texture resolution used to render content (512 by default)
  14679. */
  14680. get: function () {
  14681. return this._contentResolution;
  14682. },
  14683. set: function (value) {
  14684. if (this._contentResolution === value) {
  14685. return;
  14686. }
  14687. this._contentResolution = value;
  14688. this._resetContent();
  14689. },
  14690. enumerable: false,
  14691. configurable: true
  14692. });
  14693. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  14694. /**
  14695. * Gets or sets the texture scale ratio used to render content (2 by default)
  14696. */
  14697. get: function () {
  14698. return this._contentScaleRatio;
  14699. },
  14700. set: function (value) {
  14701. if (this._contentScaleRatio === value) {
  14702. return;
  14703. }
  14704. this._contentScaleRatio = value;
  14705. this._resetContent();
  14706. },
  14707. enumerable: false,
  14708. configurable: true
  14709. });
  14710. Button3D.prototype._disposeFacadeTexture = function () {
  14711. if (this._facadeTexture) {
  14712. this._facadeTexture.dispose();
  14713. this._facadeTexture = null;
  14714. }
  14715. };
  14716. Button3D.prototype._resetContent = function () {
  14717. this._disposeFacadeTexture();
  14718. this.content = this._content;
  14719. };
  14720. Object.defineProperty(Button3D.prototype, "content", {
  14721. /**
  14722. * Gets or sets the GUI 2D content used to display the button's facade
  14723. */
  14724. get: function () {
  14725. return this._content;
  14726. },
  14727. set: function (value) {
  14728. this._content = value;
  14729. if (!this._host || !this._host.utilityLayer) {
  14730. return;
  14731. }
  14732. if (!this._facadeTexture) {
  14733. 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);
  14734. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  14735. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  14736. this._facadeTexture.premulAlpha = true;
  14737. }
  14738. else {
  14739. this._facadeTexture.rootContainer.clearControls();
  14740. }
  14741. this._facadeTexture.addControl(value);
  14742. this._applyFacade(this._facadeTexture);
  14743. },
  14744. enumerable: false,
  14745. configurable: true
  14746. });
  14747. /**
  14748. * Apply the facade texture (created from the content property).
  14749. * This function can be overloaded by child classes
  14750. * @param facadeTexture defines the AdvancedDynamicTexture to use
  14751. */
  14752. Button3D.prototype._applyFacade = function (facadeTexture) {
  14753. this._currentMaterial.emissiveTexture = facadeTexture;
  14754. };
  14755. Button3D.prototype._getTypeName = function () {
  14756. return "Button3D";
  14757. };
  14758. // Mesh association
  14759. Button3D.prototype._createNode = function (scene) {
  14760. var faceUV = new Array(6);
  14761. for (var i = 0; i < 6; i++) {
  14762. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  14763. }
  14764. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  14765. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  14766. width: 1.0,
  14767. height: 1.0,
  14768. depth: 0.08,
  14769. faceUV: faceUV
  14770. }, scene);
  14771. return mesh;
  14772. };
  14773. Button3D.prototype._affectMaterial = function (mesh) {
  14774. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  14775. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14776. mesh.material = material;
  14777. this._currentMaterial = material;
  14778. this._resetContent();
  14779. };
  14780. /**
  14781. * Releases all associated resources
  14782. */
  14783. Button3D.prototype.dispose = function () {
  14784. _super.prototype.dispose.call(this);
  14785. this._disposeFacadeTexture();
  14786. if (this._currentMaterial) {
  14787. this._currentMaterial.dispose();
  14788. }
  14789. };
  14790. return Button3D;
  14791. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  14792. /***/ }),
  14793. /***/ "./3D/controls/container3D.ts":
  14794. /*!************************************!*\
  14795. !*** ./3D/controls/container3D.ts ***!
  14796. \************************************/
  14797. /*! exports provided: Container3D */
  14798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14799. "use strict";
  14800. __webpack_require__.r(__webpack_exports__);
  14801. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  14802. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14803. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  14804. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14805. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14806. /**
  14807. * Class used to create containers for controls
  14808. */
  14809. var Container3D = /** @class */ (function (_super) {
  14810. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  14811. /**
  14812. * Creates a new container
  14813. * @param name defines the container name
  14814. */
  14815. function Container3D(name) {
  14816. var _this = _super.call(this, name) || this;
  14817. _this._blockLayout = false;
  14818. /**
  14819. * Gets the list of child controls
  14820. */
  14821. _this._children = new Array();
  14822. return _this;
  14823. }
  14824. Object.defineProperty(Container3D.prototype, "children", {
  14825. /**
  14826. * Gets the list of child controls
  14827. */
  14828. get: function () {
  14829. return this._children;
  14830. },
  14831. enumerable: false,
  14832. configurable: true
  14833. });
  14834. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14835. /**
  14836. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14837. * This is helpful to optimize layout operation when adding multiple children in a row
  14838. */
  14839. get: function () {
  14840. return this._blockLayout;
  14841. },
  14842. set: function (value) {
  14843. if (this._blockLayout === value) {
  14844. return;
  14845. }
  14846. this._blockLayout = value;
  14847. if (!this._blockLayout) {
  14848. this._arrangeChildren();
  14849. }
  14850. },
  14851. enumerable: false,
  14852. configurable: true
  14853. });
  14854. /**
  14855. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14856. * @returns the current container
  14857. */
  14858. Container3D.prototype.updateLayout = function () {
  14859. this._arrangeChildren();
  14860. return this;
  14861. };
  14862. /**
  14863. * Gets a boolean indicating if the given control is in the children of this control
  14864. * @param control defines the control to check
  14865. * @returns true if the control is in the child list
  14866. */
  14867. Container3D.prototype.containsControl = function (control) {
  14868. return this._children.indexOf(control) !== -1;
  14869. };
  14870. /**
  14871. * Adds a control to the children of this control
  14872. * @param control defines the control to add
  14873. * @returns the current container
  14874. */
  14875. Container3D.prototype.addControl = function (control) {
  14876. var index = this._children.indexOf(control);
  14877. if (index !== -1) {
  14878. return this;
  14879. }
  14880. control.parent = this;
  14881. control._host = this._host;
  14882. this._children.push(control);
  14883. if (this._host.utilityLayer) {
  14884. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14885. if (control.node) {
  14886. control.node.parent = this.node;
  14887. }
  14888. if (!this.blockLayout) {
  14889. this._arrangeChildren();
  14890. }
  14891. }
  14892. return this;
  14893. };
  14894. /**
  14895. * This function will be called everytime a new control is added
  14896. */
  14897. Container3D.prototype._arrangeChildren = function () {
  14898. };
  14899. Container3D.prototype._createNode = function (scene) {
  14900. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14901. };
  14902. /**
  14903. * Removes a control from the children of this control
  14904. * @param control defines the control to remove
  14905. * @returns the current container
  14906. */
  14907. Container3D.prototype.removeControl = function (control) {
  14908. var index = this._children.indexOf(control);
  14909. if (index !== -1) {
  14910. this._children.splice(index, 1);
  14911. control.parent = null;
  14912. control._disposeNode();
  14913. }
  14914. return this;
  14915. };
  14916. Container3D.prototype._getTypeName = function () {
  14917. return "Container3D";
  14918. };
  14919. /**
  14920. * Releases all associated resources
  14921. */
  14922. Container3D.prototype.dispose = function () {
  14923. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14924. var control = _a[_i];
  14925. control.dispose();
  14926. }
  14927. this._children = [];
  14928. _super.prototype.dispose.call(this);
  14929. };
  14930. /** Control rotation will remain unchanged */
  14931. Container3D.UNSET_ORIENTATION = 0;
  14932. /** Control will rotate to make it look at sphere central axis */
  14933. Container3D.FACEORIGIN_ORIENTATION = 1;
  14934. /** Control will rotate to make it look back at sphere central axis */
  14935. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14936. /** Control will rotate to look at z axis (0, 0, 1) */
  14937. Container3D.FACEFORWARD_ORIENTATION = 3;
  14938. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14939. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14940. return Container3D;
  14941. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14942. /***/ }),
  14943. /***/ "./3D/controls/control3D.ts":
  14944. /*!**********************************!*\
  14945. !*** ./3D/controls/control3D.ts ***!
  14946. \**********************************/
  14947. /*! exports provided: Control3D */
  14948. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14949. "use strict";
  14950. __webpack_require__.r(__webpack_exports__);
  14951. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14952. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  14953. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14954. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14955. /**
  14956. * Class used as base class for controls
  14957. */
  14958. var Control3D = /** @class */ (function () {
  14959. /**
  14960. * Creates a new control
  14961. * @param name defines the control name
  14962. */
  14963. function Control3D(
  14964. /** Defines the control name */
  14965. name) {
  14966. this.name = name;
  14967. this._downCount = 0;
  14968. this._enterCount = -1;
  14969. this._downPointerIds = {};
  14970. this._isVisible = true;
  14971. /**
  14972. * An event triggered when the pointer move over the control
  14973. */
  14974. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14975. /**
  14976. * An event triggered when the pointer move out of the control
  14977. */
  14978. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14979. /**
  14980. * An event triggered when the pointer taps the control
  14981. */
  14982. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14983. /**
  14984. * An event triggered when pointer is up
  14985. */
  14986. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14987. /**
  14988. * An event triggered when a control is clicked on (with a mouse)
  14989. */
  14990. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14991. /**
  14992. * An event triggered when pointer enters the control
  14993. */
  14994. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14995. // Behaviors
  14996. this._behaviors = new Array();
  14997. }
  14998. Object.defineProperty(Control3D.prototype, "position", {
  14999. /** Gets or sets the control position in world space */
  15000. get: function () {
  15001. if (!this._node) {
  15002. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  15003. }
  15004. return this._node.position;
  15005. },
  15006. set: function (value) {
  15007. if (!this._node) {
  15008. return;
  15009. }
  15010. this._node.position = value;
  15011. },
  15012. enumerable: false,
  15013. configurable: true
  15014. });
  15015. Object.defineProperty(Control3D.prototype, "scaling", {
  15016. /** Gets or sets the control scaling in world space */
  15017. get: function () {
  15018. if (!this._node) {
  15019. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  15020. }
  15021. return this._node.scaling;
  15022. },
  15023. set: function (value) {
  15024. if (!this._node) {
  15025. return;
  15026. }
  15027. this._node.scaling = value;
  15028. },
  15029. enumerable: false,
  15030. configurable: true
  15031. });
  15032. Object.defineProperty(Control3D.prototype, "behaviors", {
  15033. /**
  15034. * Gets the list of attached behaviors
  15035. * @see https://doc.babylonjs.com/features/behaviour
  15036. */
  15037. get: function () {
  15038. return this._behaviors;
  15039. },
  15040. enumerable: false,
  15041. configurable: true
  15042. });
  15043. /**
  15044. * Attach a behavior to the control
  15045. * @see https://doc.babylonjs.com/features/behaviour
  15046. * @param behavior defines the behavior to attach
  15047. * @returns the current control
  15048. */
  15049. Control3D.prototype.addBehavior = function (behavior) {
  15050. var _this = this;
  15051. var index = this._behaviors.indexOf(behavior);
  15052. if (index !== -1) {
  15053. return this;
  15054. }
  15055. behavior.init();
  15056. var scene = this._host.scene;
  15057. if (scene.isLoading) {
  15058. // We defer the attach when the scene will be loaded
  15059. scene.onDataLoadedObservable.addOnce(function () {
  15060. behavior.attach(_this);
  15061. });
  15062. }
  15063. else {
  15064. behavior.attach(this);
  15065. }
  15066. this._behaviors.push(behavior);
  15067. return this;
  15068. };
  15069. /**
  15070. * Remove an attached behavior
  15071. * @see https://doc.babylonjs.com/features/behaviour
  15072. * @param behavior defines the behavior to attach
  15073. * @returns the current control
  15074. */
  15075. Control3D.prototype.removeBehavior = function (behavior) {
  15076. var index = this._behaviors.indexOf(behavior);
  15077. if (index === -1) {
  15078. return this;
  15079. }
  15080. this._behaviors[index].detach();
  15081. this._behaviors.splice(index, 1);
  15082. return this;
  15083. };
  15084. /**
  15085. * Gets an attached behavior by name
  15086. * @param name defines the name of the behavior to look for
  15087. * @see https://doc.babylonjs.com/features/behaviour
  15088. * @returns null if behavior was not found else the requested behavior
  15089. */
  15090. Control3D.prototype.getBehaviorByName = function (name) {
  15091. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  15092. var behavior = _a[_i];
  15093. if (behavior.name === name) {
  15094. return behavior;
  15095. }
  15096. }
  15097. return null;
  15098. };
  15099. Object.defineProperty(Control3D.prototype, "isVisible", {
  15100. /** Gets or sets a boolean indicating if the control is visible */
  15101. get: function () {
  15102. return this._isVisible;
  15103. },
  15104. set: function (value) {
  15105. if (this._isVisible === value) {
  15106. return;
  15107. }
  15108. this._isVisible = value;
  15109. var mesh = this.mesh;
  15110. if (mesh) {
  15111. mesh.setEnabled(value);
  15112. }
  15113. },
  15114. enumerable: false,
  15115. configurable: true
  15116. });
  15117. Object.defineProperty(Control3D.prototype, "typeName", {
  15118. /**
  15119. * Gets a string representing the class name
  15120. */
  15121. get: function () {
  15122. return this._getTypeName();
  15123. },
  15124. enumerable: false,
  15125. configurable: true
  15126. });
  15127. /**
  15128. * Get the current class name of the control.
  15129. * @returns current class name
  15130. */
  15131. Control3D.prototype.getClassName = function () {
  15132. return this._getTypeName();
  15133. };
  15134. Control3D.prototype._getTypeName = function () {
  15135. return "Control3D";
  15136. };
  15137. Object.defineProperty(Control3D.prototype, "node", {
  15138. /**
  15139. * Gets the transform node used by this control
  15140. */
  15141. get: function () {
  15142. return this._node;
  15143. },
  15144. enumerable: false,
  15145. configurable: true
  15146. });
  15147. Object.defineProperty(Control3D.prototype, "mesh", {
  15148. /**
  15149. * Gets the mesh used to render this control
  15150. */
  15151. get: function () {
  15152. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  15153. return this._node;
  15154. }
  15155. return null;
  15156. },
  15157. enumerable: false,
  15158. configurable: true
  15159. });
  15160. /**
  15161. * Link the control as child of the given node
  15162. * @param node defines the node to link to. Use null to unlink the control
  15163. * @returns the current control
  15164. */
  15165. Control3D.prototype.linkToTransformNode = function (node) {
  15166. if (this._node) {
  15167. this._node.parent = node;
  15168. }
  15169. return this;
  15170. };
  15171. /** @hidden **/
  15172. Control3D.prototype._prepareNode = function (scene) {
  15173. if (!this._node) {
  15174. this._node = this._createNode(scene);
  15175. if (!this.node) {
  15176. return;
  15177. }
  15178. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  15179. this._node.position = this.position;
  15180. this._node.scaling = this.scaling;
  15181. var mesh = this.mesh;
  15182. if (mesh) {
  15183. mesh.isPickable = true;
  15184. this._affectMaterial(mesh);
  15185. }
  15186. }
  15187. };
  15188. /**
  15189. * Node creation.
  15190. * Can be overriden by children
  15191. * @param scene defines the scene where the node must be attached
  15192. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  15193. */
  15194. Control3D.prototype._createNode = function (scene) {
  15195. // Do nothing by default
  15196. return null;
  15197. };
  15198. /**
  15199. * Affect a material to the given mesh
  15200. * @param mesh defines the mesh which will represent the control
  15201. */
  15202. Control3D.prototype._affectMaterial = function (mesh) {
  15203. mesh.material = null;
  15204. };
  15205. // Pointers
  15206. /** @hidden */
  15207. Control3D.prototype._onPointerMove = function (target, coordinates) {
  15208. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  15209. };
  15210. /** @hidden */
  15211. Control3D.prototype._onPointerEnter = function (target) {
  15212. if (this._enterCount > 0) {
  15213. return false;
  15214. }
  15215. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  15216. this._enterCount = 0;
  15217. }
  15218. this._enterCount++;
  15219. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  15220. if (this.pointerEnterAnimation) {
  15221. this.pointerEnterAnimation();
  15222. }
  15223. return true;
  15224. };
  15225. /** @hidden */
  15226. Control3D.prototype._onPointerOut = function (target) {
  15227. this._enterCount = 0;
  15228. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  15229. if (this.pointerOutAnimation) {
  15230. this.pointerOutAnimation();
  15231. }
  15232. };
  15233. /** @hidden */
  15234. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  15235. if (this._downCount !== 0) {
  15236. this._downCount++;
  15237. return false;
  15238. }
  15239. this._downCount++;
  15240. this._downPointerIds[pointerId] = true;
  15241. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  15242. if (this.pointerDownAnimation) {
  15243. this.pointerDownAnimation();
  15244. }
  15245. return true;
  15246. };
  15247. /** @hidden */
  15248. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  15249. this._downCount--;
  15250. delete this._downPointerIds[pointerId];
  15251. if (this._downCount < 0) {
  15252. // Handle if forcePointerUp was called prior to this
  15253. this._downCount = 0;
  15254. return;
  15255. }
  15256. if (this._downCount == 0) {
  15257. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  15258. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  15259. }
  15260. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  15261. if (this.pointerUpAnimation) {
  15262. this.pointerUpAnimation();
  15263. }
  15264. }
  15265. };
  15266. /** @hidden */
  15267. Control3D.prototype.forcePointerUp = function (pointerId) {
  15268. if (pointerId === void 0) { pointerId = null; }
  15269. if (pointerId !== null) {
  15270. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  15271. }
  15272. else {
  15273. for (var key in this._downPointerIds) {
  15274. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  15275. }
  15276. if (this._downCount > 0) {
  15277. this._downCount = 1;
  15278. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  15279. }
  15280. }
  15281. };
  15282. /** @hidden */
  15283. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  15284. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15285. this._onPointerMove(this, pickedPoint);
  15286. var previousControlOver = this._host._lastControlOver[pointerId];
  15287. if (previousControlOver && previousControlOver !== this) {
  15288. previousControlOver._onPointerOut(this);
  15289. }
  15290. if (previousControlOver !== this) {
  15291. this._onPointerEnter(this);
  15292. }
  15293. this._host._lastControlOver[pointerId] = this;
  15294. return true;
  15295. }
  15296. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  15297. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  15298. this._host._lastControlDown[pointerId] = this;
  15299. this._host._lastPickedControl = this;
  15300. return true;
  15301. }
  15302. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP || type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) {
  15303. if (this._host._lastControlDown[pointerId]) {
  15304. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  15305. }
  15306. delete this._host._lastControlDown[pointerId];
  15307. return true;
  15308. }
  15309. return false;
  15310. };
  15311. /** @hidden */
  15312. Control3D.prototype._disposeNode = function () {
  15313. if (this._node) {
  15314. this._node.dispose();
  15315. this._node = null;
  15316. }
  15317. };
  15318. /**
  15319. * Releases all associated resources
  15320. */
  15321. Control3D.prototype.dispose = function () {
  15322. this.onPointerDownObservable.clear();
  15323. this.onPointerEnterObservable.clear();
  15324. this.onPointerMoveObservable.clear();
  15325. this.onPointerOutObservable.clear();
  15326. this.onPointerUpObservable.clear();
  15327. this.onPointerClickObservable.clear();
  15328. this._disposeNode();
  15329. // Behaviors
  15330. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  15331. var behavior = _a[_i];
  15332. behavior.detach();
  15333. }
  15334. };
  15335. return Control3D;
  15336. }());
  15337. /***/ }),
  15338. /***/ "./3D/controls/cylinderPanel.ts":
  15339. /*!**************************************!*\
  15340. !*** ./3D/controls/cylinderPanel.ts ***!
  15341. \**************************************/
  15342. /*! exports provided: CylinderPanel */
  15343. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15344. "use strict";
  15345. __webpack_require__.r(__webpack_exports__);
  15346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  15347. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15348. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15349. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15350. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15351. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15352. /**
  15353. * Class used to create a container panel deployed on the surface of a cylinder
  15354. */
  15355. var CylinderPanel = /** @class */ (function (_super) {
  15356. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  15357. function CylinderPanel() {
  15358. var _this = _super !== null && _super.apply(this, arguments) || this;
  15359. _this._radius = 5.0;
  15360. return _this;
  15361. }
  15362. Object.defineProperty(CylinderPanel.prototype, "radius", {
  15363. /**
  15364. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  15365. */
  15366. get: function () {
  15367. return this._radius;
  15368. },
  15369. set: function (value) {
  15370. var _this = this;
  15371. if (this._radius === value) {
  15372. return;
  15373. }
  15374. this._radius = value;
  15375. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15376. _this._arrangeChildren();
  15377. });
  15378. },
  15379. enumerable: false,
  15380. configurable: true
  15381. });
  15382. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  15383. var mesh = control.mesh;
  15384. if (!mesh) {
  15385. return;
  15386. }
  15387. var newPos = this._cylindricalMapping(nodePosition);
  15388. control.position = newPos;
  15389. switch (this.orientation) {
  15390. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15391. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  15392. break;
  15393. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15394. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  15395. break;
  15396. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15397. break;
  15398. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15399. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15400. break;
  15401. }
  15402. };
  15403. CylinderPanel.prototype._cylindricalMapping = function (source) {
  15404. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  15405. var yAngle = (source.x / this._radius);
  15406. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15407. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15408. };
  15409. return CylinderPanel;
  15410. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15411. /***/ }),
  15412. /***/ "./3D/controls/holographicButton.ts":
  15413. /*!******************************************!*\
  15414. !*** ./3D/controls/holographicButton.ts ***!
  15415. \******************************************/
  15416. /*! exports provided: HolographicButton */
  15417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15418. "use strict";
  15419. __webpack_require__.r(__webpack_exports__);
  15420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  15421. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15422. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15423. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Misc/observable");
  15424. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  15425. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  15426. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  15427. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  15428. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  15429. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  15430. /**
  15431. * Class used to create a holographic button in 3D
  15432. */
  15433. var HolographicButton = /** @class */ (function (_super) {
  15434. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  15435. /**
  15436. * Creates a new button
  15437. * @param name defines the control name
  15438. */
  15439. function HolographicButton(name, shareMaterials) {
  15440. if (shareMaterials === void 0) { shareMaterials = true; }
  15441. var _this = _super.call(this, name) || this;
  15442. _this._shareMaterials = true;
  15443. _this._shareMaterials = shareMaterials;
  15444. // Default animations
  15445. _this.pointerEnterAnimation = function () {
  15446. if (!_this.mesh) {
  15447. return;
  15448. }
  15449. _this._frontPlate.setEnabled(true);
  15450. };
  15451. _this.pointerOutAnimation = function () {
  15452. if (!_this.mesh) {
  15453. return;
  15454. }
  15455. _this._frontPlate.setEnabled(false);
  15456. };
  15457. return _this;
  15458. }
  15459. HolographicButton.prototype._disposeTooltip = function () {
  15460. this._tooltipFade = null;
  15461. if (this._tooltipTextBlock) {
  15462. this._tooltipTextBlock.dispose();
  15463. }
  15464. if (this._tooltipTexture) {
  15465. this._tooltipTexture.dispose();
  15466. }
  15467. if (this._tooltipMesh) {
  15468. this._tooltipMesh.dispose();
  15469. }
  15470. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  15471. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  15472. };
  15473. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  15474. get: function () {
  15475. return this._backPlate.renderingGroupId;
  15476. },
  15477. /**
  15478. * Rendering ground id of all the mesh in the button
  15479. */
  15480. set: function (id) {
  15481. this._backPlate.renderingGroupId = id;
  15482. this._textPlate.renderingGroupId = id;
  15483. this._frontPlate.renderingGroupId = id;
  15484. if (this._tooltipMesh) {
  15485. this._tooltipMesh.renderingGroupId = id;
  15486. }
  15487. },
  15488. enumerable: false,
  15489. configurable: true
  15490. });
  15491. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  15492. get: function () {
  15493. if (this._tooltipTextBlock) {
  15494. return this._tooltipTextBlock.text;
  15495. }
  15496. return null;
  15497. },
  15498. /**
  15499. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  15500. */
  15501. set: function (text) {
  15502. var _this = this;
  15503. if (!text) {
  15504. this._disposeTooltip();
  15505. return;
  15506. }
  15507. if (!this._tooltipFade) {
  15508. // Create tooltip with mesh and text
  15509. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  15510. 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);
  15511. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  15512. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  15513. tooltipBackground.material = mat;
  15514. tooltipBackground.isPickable = false;
  15515. this._tooltipMesh.addChild(tooltipBackground);
  15516. tooltipBackground.position.z = 0.05;
  15517. this._tooltipMesh.scaling.y = 1 / 3;
  15518. this._tooltipMesh.position.y = 0.7;
  15519. this._tooltipMesh.position.z = -0.15;
  15520. this._tooltipMesh.isPickable = false;
  15521. this._tooltipMesh.parent = this._backPlate;
  15522. // Create text texture for the tooltip
  15523. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  15524. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  15525. this._tooltipTextBlock.scaleY = 3;
  15526. this._tooltipTextBlock.color = "white";
  15527. this._tooltipTextBlock.fontSize = 130;
  15528. this._tooltipTexture.addControl(this._tooltipTextBlock);
  15529. // Add hover action to tooltip
  15530. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  15531. this._tooltipFade.delay = 500;
  15532. this._tooltipMesh.addBehavior(this._tooltipFade);
  15533. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  15534. if (_this._tooltipFade) {
  15535. _this._tooltipFade.fadeIn(true);
  15536. }
  15537. });
  15538. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  15539. if (_this._tooltipFade) {
  15540. _this._tooltipFade.fadeIn(false);
  15541. }
  15542. });
  15543. }
  15544. if (this._tooltipTextBlock) {
  15545. this._tooltipTextBlock.text = text;
  15546. }
  15547. },
  15548. enumerable: false,
  15549. configurable: true
  15550. });
  15551. Object.defineProperty(HolographicButton.prototype, "text", {
  15552. /**
  15553. * Gets or sets text for the button
  15554. */
  15555. get: function () {
  15556. return this._text;
  15557. },
  15558. set: function (value) {
  15559. if (this._text === value) {
  15560. return;
  15561. }
  15562. this._text = value;
  15563. this._rebuildContent();
  15564. },
  15565. enumerable: false,
  15566. configurable: true
  15567. });
  15568. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  15569. /**
  15570. * Gets or sets the image url for the button
  15571. */
  15572. get: function () {
  15573. return this._imageUrl;
  15574. },
  15575. set: function (value) {
  15576. if (this._imageUrl === value) {
  15577. return;
  15578. }
  15579. this._imageUrl = value;
  15580. this._rebuildContent();
  15581. },
  15582. enumerable: false,
  15583. configurable: true
  15584. });
  15585. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  15586. /**
  15587. * Gets the back material used by this button
  15588. */
  15589. get: function () {
  15590. return this._backMaterial;
  15591. },
  15592. enumerable: false,
  15593. configurable: true
  15594. });
  15595. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  15596. /**
  15597. * Gets the front material used by this button
  15598. */
  15599. get: function () {
  15600. return this._frontMaterial;
  15601. },
  15602. enumerable: false,
  15603. configurable: true
  15604. });
  15605. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  15606. /**
  15607. * Gets the plate material used by this button
  15608. */
  15609. get: function () {
  15610. return this._plateMaterial;
  15611. },
  15612. enumerable: false,
  15613. configurable: true
  15614. });
  15615. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  15616. /**
  15617. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  15618. */
  15619. get: function () {
  15620. return this._shareMaterials;
  15621. },
  15622. enumerable: false,
  15623. configurable: true
  15624. });
  15625. HolographicButton.prototype._getTypeName = function () {
  15626. return "HolographicButton";
  15627. };
  15628. HolographicButton.prototype._rebuildContent = function () {
  15629. this._disposeFacadeTexture();
  15630. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  15631. panel.isVertical = true;
  15632. if (this._imageUrl) {
  15633. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  15634. image.source = this._imageUrl;
  15635. image.paddingTop = "40px";
  15636. image.height = "180px";
  15637. image.width = "100px";
  15638. image.paddingBottom = "40px";
  15639. panel.addControl(image);
  15640. }
  15641. if (this._text) {
  15642. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  15643. text.text = this._text;
  15644. text.color = "white";
  15645. text.height = "30px";
  15646. text.fontSize = 24;
  15647. panel.addControl(text);
  15648. }
  15649. if (this._frontPlate) {
  15650. this.content = panel;
  15651. }
  15652. };
  15653. // Mesh association
  15654. HolographicButton.prototype._createNode = function (scene) {
  15655. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  15656. width: 1.0,
  15657. height: 1.0,
  15658. depth: 0.08
  15659. }, scene);
  15660. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  15661. width: 1.0,
  15662. height: 1.0,
  15663. depth: 0.08
  15664. }, scene);
  15665. this._frontPlate.parent = this._backPlate;
  15666. this._frontPlate.position.z = -0.08;
  15667. this._frontPlate.isPickable = false;
  15668. this._frontPlate.setEnabled(false);
  15669. this._textPlate = _super.prototype._createNode.call(this, scene);
  15670. this._textPlate.parent = this._backPlate;
  15671. this._textPlate.position.z = -0.08;
  15672. this._textPlate.isPickable = false;
  15673. return this._backPlate;
  15674. };
  15675. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  15676. this._plateMaterial.emissiveTexture = facadeTexture;
  15677. this._plateMaterial.opacityTexture = facadeTexture;
  15678. };
  15679. HolographicButton.prototype._createBackMaterial = function (mesh) {
  15680. var _this = this;
  15681. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  15682. this._backMaterial.renderHoverLight = true;
  15683. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  15684. if (pickedPoint) {
  15685. _this._backMaterial.hoverPosition = pickedPoint;
  15686. _this._backMaterial.hoverColor.a = 1.0;
  15687. }
  15688. else {
  15689. _this._backMaterial.hoverColor.a = 0;
  15690. }
  15691. });
  15692. };
  15693. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  15694. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  15695. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  15696. this._frontMaterial.alpha = 0.5; // Additive
  15697. this._frontMaterial.renderBorders = true;
  15698. };
  15699. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  15700. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  15701. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  15702. };
  15703. HolographicButton.prototype._affectMaterial = function (mesh) {
  15704. // Back
  15705. if (this._shareMaterials) {
  15706. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  15707. this._createBackMaterial(mesh);
  15708. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  15709. }
  15710. else {
  15711. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  15712. }
  15713. // Front
  15714. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  15715. this._createFrontMaterial(mesh);
  15716. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  15717. }
  15718. else {
  15719. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  15720. }
  15721. }
  15722. else {
  15723. this._createBackMaterial(mesh);
  15724. this._createFrontMaterial(mesh);
  15725. }
  15726. this._createPlateMaterial(mesh);
  15727. this._backPlate.material = this._backMaterial;
  15728. this._frontPlate.material = this._frontMaterial;
  15729. this._textPlate.material = this._plateMaterial;
  15730. this._rebuildContent();
  15731. };
  15732. /**
  15733. * Releases all associated resources
  15734. */
  15735. HolographicButton.prototype.dispose = function () {
  15736. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  15737. this._disposeTooltip();
  15738. if (!this.shareMaterials) {
  15739. this._backMaterial.dispose();
  15740. this._frontMaterial.dispose();
  15741. this._plateMaterial.dispose();
  15742. if (this._pickedPointObserver) {
  15743. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  15744. this._pickedPointObserver = null;
  15745. }
  15746. }
  15747. };
  15748. return HolographicButton;
  15749. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15750. /***/ }),
  15751. /***/ "./3D/controls/index.ts":
  15752. /*!******************************!*\
  15753. !*** ./3D/controls/index.ts ***!
  15754. \******************************/
  15755. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  15756. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15757. "use strict";
  15758. __webpack_require__.r(__webpack_exports__);
  15759. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  15760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15761. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15763. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  15765. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  15767. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  15768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  15769. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  15770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  15771. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  15772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  15773. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  15774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  15775. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  15776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  15777. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  15778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  15779. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  15780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  15781. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  15783. /***/ }),
  15784. /***/ "./3D/controls/meshButton3D.ts":
  15785. /*!*************************************!*\
  15786. !*** ./3D/controls/meshButton3D.ts ***!
  15787. \*************************************/
  15788. /*! exports provided: MeshButton3D */
  15789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15790. "use strict";
  15791. __webpack_require__.r(__webpack_exports__);
  15792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  15793. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15794. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15795. /**
  15796. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  15797. */
  15798. var MeshButton3D = /** @class */ (function (_super) {
  15799. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  15800. /**
  15801. * Creates a new 3D button based on a mesh
  15802. * @param mesh mesh to become a 3D button
  15803. * @param name defines the control name
  15804. */
  15805. function MeshButton3D(mesh, name) {
  15806. var _this = _super.call(this, name) || this;
  15807. _this._currentMesh = mesh;
  15808. /**
  15809. * Provides a default behavior on hover/out & up/down
  15810. * Override those function to create your own desired behavior specific to your mesh
  15811. */
  15812. _this.pointerEnterAnimation = function () {
  15813. if (!_this.mesh) {
  15814. return;
  15815. }
  15816. _this.mesh.scaling.scaleInPlace(1.1);
  15817. };
  15818. _this.pointerOutAnimation = function () {
  15819. if (!_this.mesh) {
  15820. return;
  15821. }
  15822. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  15823. };
  15824. _this.pointerDownAnimation = function () {
  15825. if (!_this.mesh) {
  15826. return;
  15827. }
  15828. _this.mesh.scaling.scaleInPlace(0.95);
  15829. };
  15830. _this.pointerUpAnimation = function () {
  15831. if (!_this.mesh) {
  15832. return;
  15833. }
  15834. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15835. };
  15836. return _this;
  15837. }
  15838. MeshButton3D.prototype._getTypeName = function () {
  15839. return "MeshButton3D";
  15840. };
  15841. // Mesh association
  15842. MeshButton3D.prototype._createNode = function (scene) {
  15843. var _this = this;
  15844. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15845. mesh.metadata = _this;
  15846. });
  15847. return this._currentMesh;
  15848. };
  15849. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15850. };
  15851. return MeshButton3D;
  15852. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15853. /***/ }),
  15854. /***/ "./3D/controls/planePanel.ts":
  15855. /*!***********************************!*\
  15856. !*** ./3D/controls/planePanel.ts ***!
  15857. \***********************************/
  15858. /*! exports provided: PlanePanel */
  15859. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15860. "use strict";
  15861. __webpack_require__.r(__webpack_exports__);
  15862. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15863. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15864. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  15865. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15866. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15867. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15868. /**
  15869. * Class used to create a container panel deployed on the surface of a plane
  15870. */
  15871. var PlanePanel = /** @class */ (function (_super) {
  15872. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15873. function PlanePanel() {
  15874. return _super !== null && _super.apply(this, arguments) || this;
  15875. }
  15876. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15877. var mesh = control.mesh;
  15878. if (!mesh) {
  15879. return;
  15880. }
  15881. control.position = nodePosition.clone();
  15882. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15883. target.copyFrom(nodePosition);
  15884. switch (this.orientation) {
  15885. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15886. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15887. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15888. mesh.lookAt(target);
  15889. break;
  15890. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15891. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15892. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15893. mesh.lookAt(target);
  15894. break;
  15895. }
  15896. };
  15897. return PlanePanel;
  15898. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15899. /***/ }),
  15900. /***/ "./3D/controls/scatterPanel.ts":
  15901. /*!*************************************!*\
  15902. !*** ./3D/controls/scatterPanel.ts ***!
  15903. \*************************************/
  15904. /*! exports provided: ScatterPanel */
  15905. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15906. "use strict";
  15907. __webpack_require__.r(__webpack_exports__);
  15908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15909. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15910. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15911. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15912. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15913. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15914. /**
  15915. * Class used to create a container panel where items get randomized planar mapping
  15916. */
  15917. var ScatterPanel = /** @class */ (function (_super) {
  15918. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15919. function ScatterPanel() {
  15920. var _this = _super !== null && _super.apply(this, arguments) || this;
  15921. _this._iteration = 100.0;
  15922. return _this;
  15923. }
  15924. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15925. /**
  15926. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15927. */
  15928. get: function () {
  15929. return this._iteration;
  15930. },
  15931. set: function (value) {
  15932. var _this = this;
  15933. if (this._iteration === value) {
  15934. return;
  15935. }
  15936. this._iteration = value;
  15937. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15938. _this._arrangeChildren();
  15939. });
  15940. },
  15941. enumerable: false,
  15942. configurable: true
  15943. });
  15944. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15945. var mesh = control.mesh;
  15946. var newPos = this._scatterMapping(nodePosition);
  15947. if (!mesh) {
  15948. return;
  15949. }
  15950. switch (this.orientation) {
  15951. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15952. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15953. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15954. break;
  15955. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15956. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15957. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15958. break;
  15959. }
  15960. control.position = newPos;
  15961. };
  15962. ScatterPanel.prototype._scatterMapping = function (source) {
  15963. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15964. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15965. return source;
  15966. };
  15967. ScatterPanel.prototype._finalProcessing = function () {
  15968. var meshes = [];
  15969. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15970. var child = _a[_i];
  15971. if (!child.mesh) {
  15972. continue;
  15973. }
  15974. meshes.push(child.mesh);
  15975. }
  15976. for (var count = 0; count < this._iteration; count++) {
  15977. meshes.sort(function (a, b) {
  15978. var distance1 = a.position.lengthSquared();
  15979. var distance2 = b.position.lengthSquared();
  15980. if (distance1 < distance2) {
  15981. return 1;
  15982. }
  15983. else if (distance1 > distance2) {
  15984. return -1;
  15985. }
  15986. return 0;
  15987. });
  15988. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15989. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15990. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15991. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15992. for (var i = 0; i < meshes.length - 1; i++) {
  15993. for (var j = i + 1; j < meshes.length; j++) {
  15994. if (i != j) {
  15995. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15996. // Ignore Z axis
  15997. difference2D.x = difference.x;
  15998. difference2D.y = difference.y;
  15999. var combinedRadius = cellSize;
  16000. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  16001. var minSeparation = Math.min(distance, radiusPaddingSquared);
  16002. distance -= minSeparation;
  16003. if (distance < (Math.pow(combinedRadius, 2.0))) {
  16004. difference2D.normalize();
  16005. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  16006. meshes[j].position.addInPlace(difference);
  16007. meshes[i].position.subtractInPlace(difference);
  16008. }
  16009. }
  16010. }
  16011. }
  16012. }
  16013. };
  16014. return ScatterPanel;
  16015. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  16016. /***/ }),
  16017. /***/ "./3D/controls/spherePanel.ts":
  16018. /*!************************************!*\
  16019. !*** ./3D/controls/spherePanel.ts ***!
  16020. \************************************/
  16021. /*! exports provided: SpherePanel */
  16022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16023. "use strict";
  16024. __webpack_require__.r(__webpack_exports__);
  16025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  16026. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16027. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  16028. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16029. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16030. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16031. /**
  16032. * Class used to create a container panel deployed on the surface of a sphere
  16033. */
  16034. var SpherePanel = /** @class */ (function (_super) {
  16035. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  16036. function SpherePanel() {
  16037. var _this = _super !== null && _super.apply(this, arguments) || this;
  16038. _this._radius = 5.0;
  16039. return _this;
  16040. }
  16041. Object.defineProperty(SpherePanel.prototype, "radius", {
  16042. /**
  16043. * Gets or sets the radius of the sphere where to project controls (5 by default)
  16044. */
  16045. get: function () {
  16046. return this._radius;
  16047. },
  16048. set: function (value) {
  16049. var _this = this;
  16050. if (this._radius === value) {
  16051. return;
  16052. }
  16053. this._radius = value;
  16054. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16055. _this._arrangeChildren();
  16056. });
  16057. },
  16058. enumerable: false,
  16059. configurable: true
  16060. });
  16061. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  16062. var mesh = control.mesh;
  16063. if (!mesh) {
  16064. return;
  16065. }
  16066. var newPos = this._sphericalMapping(nodePosition);
  16067. control.position = newPos;
  16068. switch (this.orientation) {
  16069. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  16070. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  16071. break;
  16072. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  16073. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  16074. break;
  16075. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  16076. break;
  16077. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  16078. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  16079. break;
  16080. }
  16081. };
  16082. SpherePanel.prototype._sphericalMapping = function (source) {
  16083. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  16084. var xAngle = (source.y / this._radius);
  16085. var yAngle = -(source.x / this._radius);
  16086. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16087. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16088. };
  16089. return SpherePanel;
  16090. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  16091. /***/ }),
  16092. /***/ "./3D/controls/stackPanel3D.ts":
  16093. /*!*************************************!*\
  16094. !*** ./3D/controls/stackPanel3D.ts ***!
  16095. \*************************************/
  16096. /*! exports provided: StackPanel3D */
  16097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16098. "use strict";
  16099. __webpack_require__.r(__webpack_exports__);
  16100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  16101. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16102. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  16103. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16104. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16105. /**
  16106. * Class used to create a stack panel in 3D on XY plane
  16107. */
  16108. var StackPanel3D = /** @class */ (function (_super) {
  16109. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  16110. /**
  16111. * Creates new StackPanel
  16112. * @param isVertical
  16113. */
  16114. function StackPanel3D(isVertical) {
  16115. if (isVertical === void 0) { isVertical = false; }
  16116. var _this = _super.call(this) || this;
  16117. _this._isVertical = false;
  16118. /**
  16119. * Gets or sets the distance between elements
  16120. */
  16121. _this.margin = 0.1;
  16122. _this._isVertical = isVertical;
  16123. return _this;
  16124. }
  16125. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  16126. /**
  16127. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  16128. */
  16129. get: function () {
  16130. return this._isVertical;
  16131. },
  16132. set: function (value) {
  16133. var _this = this;
  16134. if (this._isVertical === value) {
  16135. return;
  16136. }
  16137. this._isVertical = value;
  16138. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16139. _this._arrangeChildren();
  16140. });
  16141. },
  16142. enumerable: false,
  16143. configurable: true
  16144. });
  16145. StackPanel3D.prototype._arrangeChildren = function () {
  16146. var width = 0;
  16147. var height = 0;
  16148. var controlCount = 0;
  16149. var extendSizes = [];
  16150. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  16151. // Measure
  16152. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  16153. var child = _a[_i];
  16154. if (!child.mesh) {
  16155. continue;
  16156. }
  16157. controlCount++;
  16158. child.mesh.computeWorldMatrix(true);
  16159. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16160. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  16161. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16162. extendSizes.push(extendSize);
  16163. if (this._isVertical) {
  16164. height += extendSize.y;
  16165. }
  16166. else {
  16167. width += extendSize.x;
  16168. }
  16169. }
  16170. if (this._isVertical) {
  16171. height += (controlCount - 1) * this.margin / 2;
  16172. }
  16173. else {
  16174. width += (controlCount - 1) * this.margin / 2;
  16175. }
  16176. // Arrange
  16177. var offset;
  16178. if (this._isVertical) {
  16179. offset = -height;
  16180. }
  16181. else {
  16182. offset = -width;
  16183. }
  16184. var index = 0;
  16185. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  16186. var child = _c[_b];
  16187. if (!child.mesh) {
  16188. continue;
  16189. }
  16190. controlCount--;
  16191. var extendSize = extendSizes[index++];
  16192. if (this._isVertical) {
  16193. child.position.y = offset + extendSize.y;
  16194. child.position.x = 0;
  16195. offset += extendSize.y * 2;
  16196. }
  16197. else {
  16198. child.position.x = offset + extendSize.x;
  16199. child.position.y = 0;
  16200. offset += extendSize.x * 2;
  16201. }
  16202. offset += (controlCount > 0 ? this.margin : 0);
  16203. }
  16204. };
  16205. return StackPanel3D;
  16206. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  16207. /***/ }),
  16208. /***/ "./3D/controls/volumeBasedPanel.ts":
  16209. /*!*****************************************!*\
  16210. !*** ./3D/controls/volumeBasedPanel.ts ***!
  16211. \*****************************************/
  16212. /*! exports provided: VolumeBasedPanel */
  16213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16214. "use strict";
  16215. __webpack_require__.r(__webpack_exports__);
  16216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  16217. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16218. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  16219. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16220. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16221. /**
  16222. * Abstract class used to create a container panel deployed on the surface of a volume
  16223. */
  16224. var VolumeBasedPanel = /** @class */ (function (_super) {
  16225. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  16226. /**
  16227. * Creates new VolumeBasedPanel
  16228. */
  16229. function VolumeBasedPanel() {
  16230. var _this = _super.call(this) || this;
  16231. _this._columns = 10;
  16232. _this._rows = 0;
  16233. _this._rowThenColum = true;
  16234. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  16235. /**
  16236. * Gets or sets the distance between elements
  16237. */
  16238. _this.margin = 0;
  16239. return _this;
  16240. }
  16241. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  16242. /**
  16243. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  16244. * | Value | Type | Description |
  16245. * | ----- | ----------------------------------- | ----------- |
  16246. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  16247. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  16248. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  16249. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  16250. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  16251. */
  16252. get: function () {
  16253. return this._orientation;
  16254. },
  16255. set: function (value) {
  16256. var _this = this;
  16257. if (this._orientation === value) {
  16258. return;
  16259. }
  16260. this._orientation = value;
  16261. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16262. _this._arrangeChildren();
  16263. });
  16264. },
  16265. enumerable: false,
  16266. configurable: true
  16267. });
  16268. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  16269. /**
  16270. * Gets or sets the number of columns requested (10 by default).
  16271. * The panel will automatically compute the number of rows based on number of child controls.
  16272. */
  16273. get: function () {
  16274. return this._columns;
  16275. },
  16276. set: function (value) {
  16277. var _this = this;
  16278. if (this._columns === value) {
  16279. return;
  16280. }
  16281. this._columns = value;
  16282. this._rowThenColum = true;
  16283. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16284. _this._arrangeChildren();
  16285. });
  16286. },
  16287. enumerable: false,
  16288. configurable: true
  16289. });
  16290. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  16291. /**
  16292. * Gets or sets a the number of rows requested.
  16293. * The panel will automatically compute the number of columns based on number of child controls.
  16294. */
  16295. get: function () {
  16296. return this._rows;
  16297. },
  16298. set: function (value) {
  16299. var _this = this;
  16300. if (this._rows === value) {
  16301. return;
  16302. }
  16303. this._rows = value;
  16304. this._rowThenColum = false;
  16305. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16306. _this._arrangeChildren();
  16307. });
  16308. },
  16309. enumerable: false,
  16310. configurable: true
  16311. });
  16312. VolumeBasedPanel.prototype._arrangeChildren = function () {
  16313. this._cellWidth = 0;
  16314. this._cellHeight = 0;
  16315. var rows = 0;
  16316. var columns = 0;
  16317. var controlCount = 0;
  16318. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  16319. // Measure
  16320. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  16321. var child = _a[_i];
  16322. if (!child.mesh) {
  16323. continue;
  16324. }
  16325. controlCount++;
  16326. child.mesh.computeWorldMatrix(true);
  16327. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  16328. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  16329. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  16330. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  16331. boundingBox.max.subtractToRef(boundingBox.min, diff);
  16332. diff.scaleInPlace(0.5);
  16333. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  16334. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  16335. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  16336. }
  16337. this._cellWidth += this.margin * 2;
  16338. this._cellHeight += this.margin * 2;
  16339. // Arrange
  16340. if (this._rowThenColum) {
  16341. columns = this._columns;
  16342. rows = Math.ceil(controlCount / this._columns);
  16343. }
  16344. else {
  16345. rows = this._rows;
  16346. columns = Math.ceil(controlCount / this._rows);
  16347. }
  16348. var startOffsetX = (columns * 0.5) * this._cellWidth;
  16349. var startOffsetY = (rows * 0.5) * this._cellHeight;
  16350. var nodeGrid = [];
  16351. var cellCounter = 0;
  16352. if (this._rowThenColum) {
  16353. for (var r = 0; r < rows; r++) {
  16354. for (var c = 0; c < columns; c++) {
  16355. 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));
  16356. cellCounter++;
  16357. if (cellCounter > controlCount) {
  16358. break;
  16359. }
  16360. }
  16361. }
  16362. }
  16363. else {
  16364. for (var c = 0; c < columns; c++) {
  16365. for (var r = 0; r < rows; r++) {
  16366. 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));
  16367. cellCounter++;
  16368. if (cellCounter > controlCount) {
  16369. break;
  16370. }
  16371. }
  16372. }
  16373. }
  16374. cellCounter = 0;
  16375. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  16376. var child = _c[_b];
  16377. if (!child.mesh) {
  16378. continue;
  16379. }
  16380. this._mapGridNode(child, nodeGrid[cellCounter]);
  16381. cellCounter++;
  16382. }
  16383. this._finalProcessing();
  16384. };
  16385. /** Child classes can implement this function to provide additional processing */
  16386. VolumeBasedPanel.prototype._finalProcessing = function () {
  16387. };
  16388. return VolumeBasedPanel;
  16389. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  16390. /***/ }),
  16391. /***/ "./3D/gui3DManager.ts":
  16392. /*!****************************!*\
  16393. !*** ./3D/gui3DManager.ts ***!
  16394. \****************************/
  16395. /*! exports provided: GUI3DManager */
  16396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16397. "use strict";
  16398. __webpack_require__.r(__webpack_exports__);
  16399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  16400. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  16401. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  16402. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  16403. /**
  16404. * Class used to manage 3D user interface
  16405. * @see https://doc.babylonjs.com/how_to/gui3d
  16406. */
  16407. var GUI3DManager = /** @class */ (function () {
  16408. /**
  16409. * Creates a new GUI3DManager
  16410. * @param scene
  16411. */
  16412. function GUI3DManager(scene) {
  16413. var _this = this;
  16414. /** @hidden */
  16415. this._lastControlOver = {};
  16416. /** @hidden */
  16417. this._lastControlDown = {};
  16418. /**
  16419. * Observable raised when the point picked by the pointer events changed
  16420. */
  16421. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  16422. // Shared resources
  16423. /** @hidden */
  16424. this._sharedMaterials = {};
  16425. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  16426. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  16427. _this._sceneDisposeObserver = null;
  16428. _this._utilityLayer = null;
  16429. _this.dispose();
  16430. });
  16431. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  16432. this._utilityLayer.onlyCheckPointerDownEvents = false;
  16433. this._utilityLayer.pickUtilitySceneFirst = false;
  16434. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  16435. return mesh && mesh.metadata && mesh.metadata._node;
  16436. };
  16437. // Root
  16438. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  16439. this._rootContainer._host = this;
  16440. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  16441. // Events
  16442. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  16443. _this._handlePointerOut(pointerId, true);
  16444. });
  16445. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  16446. _this._doPicking(pi);
  16447. });
  16448. // Scene
  16449. this._utilityLayer.utilityLayerScene.autoClear = false;
  16450. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  16451. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  16452. }
  16453. Object.defineProperty(GUI3DManager.prototype, "scene", {
  16454. /** Gets the hosting scene */
  16455. get: function () {
  16456. return this._scene;
  16457. },
  16458. enumerable: false,
  16459. configurable: true
  16460. });
  16461. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  16462. /** Gets associated utility layer */
  16463. get: function () {
  16464. return this._utilityLayer;
  16465. },
  16466. enumerable: false,
  16467. configurable: true
  16468. });
  16469. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  16470. var previousControlOver = this._lastControlOver[pointerId];
  16471. if (previousControlOver) {
  16472. previousControlOver._onPointerOut(previousControlOver);
  16473. delete this._lastControlOver[pointerId];
  16474. }
  16475. if (isPointerUp) {
  16476. if (this._lastControlDown[pointerId]) {
  16477. this._lastControlDown[pointerId].forcePointerUp();
  16478. delete this._lastControlDown[pointerId];
  16479. }
  16480. }
  16481. this.onPickedPointChangedObservable.notifyObservers(null);
  16482. };
  16483. GUI3DManager.prototype._doPicking = function (pi) {
  16484. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  16485. return false;
  16486. }
  16487. var pointerEvent = (pi.event);
  16488. var pointerId = pointerEvent.pointerId || 0;
  16489. var buttonIndex = pointerEvent.button;
  16490. var pickingInfo = pi.pickInfo;
  16491. if (!pickingInfo || !pickingInfo.hit) {
  16492. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  16493. return false;
  16494. }
  16495. var control = (pickingInfo.pickedMesh.metadata);
  16496. if (pickingInfo.pickedPoint) {
  16497. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  16498. }
  16499. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  16500. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  16501. if (this._lastControlOver[pointerId]) {
  16502. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  16503. }
  16504. delete this._lastControlOver[pointerId];
  16505. }
  16506. }
  16507. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  16508. if (this._lastControlDown[pointerEvent.pointerId]) {
  16509. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  16510. delete this._lastControlDown[pointerEvent.pointerId];
  16511. }
  16512. if (pointerEvent.pointerType === "touch") {
  16513. this._handlePointerOut(pointerId, false);
  16514. }
  16515. }
  16516. return true;
  16517. };
  16518. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  16519. /**
  16520. * Gets the root container
  16521. */
  16522. get: function () {
  16523. return this._rootContainer;
  16524. },
  16525. enumerable: false,
  16526. configurable: true
  16527. });
  16528. /**
  16529. * Gets a boolean indicating if the given control is in the root child list
  16530. * @param control defines the control to check
  16531. * @returns true if the control is in the root child list
  16532. */
  16533. GUI3DManager.prototype.containsControl = function (control) {
  16534. return this._rootContainer.containsControl(control);
  16535. };
  16536. /**
  16537. * Adds a control to the root child list
  16538. * @param control defines the control to add
  16539. * @returns the current manager
  16540. */
  16541. GUI3DManager.prototype.addControl = function (control) {
  16542. this._rootContainer.addControl(control);
  16543. return this;
  16544. };
  16545. /**
  16546. * Removes a control from the root child list
  16547. * @param control defines the control to remove
  16548. * @returns the current container
  16549. */
  16550. GUI3DManager.prototype.removeControl = function (control) {
  16551. this._rootContainer.removeControl(control);
  16552. return this;
  16553. };
  16554. /**
  16555. * Releases all associated resources
  16556. */
  16557. GUI3DManager.prototype.dispose = function () {
  16558. this._rootContainer.dispose();
  16559. for (var materialName in this._sharedMaterials) {
  16560. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  16561. continue;
  16562. }
  16563. this._sharedMaterials[materialName].dispose();
  16564. }
  16565. this._sharedMaterials = {};
  16566. if (this._pointerOutObserver && this._utilityLayer) {
  16567. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  16568. this._pointerOutObserver = null;
  16569. }
  16570. this.onPickedPointChangedObservable.clear();
  16571. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  16572. if (utilityLayerScene) {
  16573. if (this._pointerObserver) {
  16574. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  16575. this._pointerObserver = null;
  16576. }
  16577. }
  16578. if (this._scene) {
  16579. if (this._sceneDisposeObserver) {
  16580. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  16581. this._sceneDisposeObserver = null;
  16582. }
  16583. }
  16584. if (this._utilityLayer) {
  16585. this._utilityLayer.dispose();
  16586. }
  16587. };
  16588. return GUI3DManager;
  16589. }());
  16590. /***/ }),
  16591. /***/ "./3D/index.ts":
  16592. /*!*********************!*\
  16593. !*** ./3D/index.ts ***!
  16594. \*********************/
  16595. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16597. "use strict";
  16598. __webpack_require__.r(__webpack_exports__);
  16599. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  16600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16612. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  16613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16615. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  16616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  16617. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  16618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  16619. /***/ }),
  16620. /***/ "./3D/materials/fluentMaterial.ts":
  16621. /*!****************************************!*\
  16622. !*** ./3D/materials/fluentMaterial.ts ***!
  16623. \****************************************/
  16624. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16625. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16626. "use strict";
  16627. __webpack_require__.r(__webpack_exports__);
  16628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  16629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  16630. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16631. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  16632. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  16633. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  16634. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  16635. /** @hidden */
  16636. var FluentMaterialDefines = /** @class */ (function (_super) {
  16637. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  16638. function FluentMaterialDefines() {
  16639. var _this = _super.call(this) || this;
  16640. _this.INNERGLOW = false;
  16641. _this.BORDER = false;
  16642. _this.HOVERLIGHT = false;
  16643. _this.TEXTURE = false;
  16644. _this.rebuild();
  16645. return _this;
  16646. }
  16647. return FluentMaterialDefines;
  16648. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  16649. /**
  16650. * Class used to render controls with fluent desgin
  16651. */
  16652. var FluentMaterial = /** @class */ (function (_super) {
  16653. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  16654. /**
  16655. * Creates a new Fluent material
  16656. * @param name defines the name of the material
  16657. * @param scene defines the hosting scene
  16658. */
  16659. function FluentMaterial(name, scene) {
  16660. var _this = _super.call(this, name, scene) || this;
  16661. /**
  16662. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  16663. */
  16664. _this.innerGlowColorIntensity = 0.5;
  16665. /**
  16666. * Gets or sets the inner glow color (white by default)
  16667. */
  16668. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  16669. /**
  16670. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  16671. */
  16672. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  16673. /**
  16674. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  16675. */
  16676. _this.renderBorders = false;
  16677. /**
  16678. * Gets or sets border width (default is 0.5)
  16679. */
  16680. _this.borderWidth = 0.5;
  16681. /**
  16682. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  16683. */
  16684. _this.edgeSmoothingValue = 0.02;
  16685. /**
  16686. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  16687. */
  16688. _this.borderMinValue = 0.1;
  16689. /**
  16690. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  16691. */
  16692. _this.renderHoverLight = false;
  16693. /**
  16694. * Gets or sets the radius used to render the hover light (default is 1.0)
  16695. */
  16696. _this.hoverRadius = 1.0;
  16697. /**
  16698. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  16699. */
  16700. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  16701. /**
  16702. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  16703. */
  16704. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  16705. return _this;
  16706. }
  16707. FluentMaterial.prototype.needAlphaBlending = function () {
  16708. return this.alpha !== 1.0;
  16709. };
  16710. FluentMaterial.prototype.needAlphaTesting = function () {
  16711. return false;
  16712. };
  16713. FluentMaterial.prototype.getAlphaTestTexture = function () {
  16714. return null;
  16715. };
  16716. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  16717. if (this.isFrozen) {
  16718. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  16719. return true;
  16720. }
  16721. }
  16722. if (!subMesh._materialDefines) {
  16723. subMesh._materialDefines = new FluentMaterialDefines();
  16724. }
  16725. var scene = this.getScene();
  16726. var defines = subMesh._materialDefines;
  16727. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  16728. if (defines._renderId === scene.getRenderId()) {
  16729. return true;
  16730. }
  16731. }
  16732. if (defines._areTexturesDirty) {
  16733. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  16734. defines.BORDER = this.renderBorders;
  16735. defines.HOVERLIGHT = this.renderHoverLight;
  16736. if (this._albedoTexture) {
  16737. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  16738. return false;
  16739. }
  16740. else {
  16741. defines.TEXTURE = true;
  16742. }
  16743. }
  16744. else {
  16745. defines.TEXTURE = false;
  16746. }
  16747. }
  16748. var engine = scene.getEngine();
  16749. // Get correct effect
  16750. if (defines.isDirty) {
  16751. defines.markAsProcessed();
  16752. scene.resetCachedMaterial();
  16753. //Attributes
  16754. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  16755. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  16756. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  16757. var shaderName = "fluent";
  16758. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  16759. "hoverColor", "hoverPosition", "hoverRadius"
  16760. ];
  16761. var samplers = ["albedoSampler"];
  16762. var uniformBuffers = new Array();
  16763. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  16764. uniformsNames: uniforms,
  16765. uniformBuffersNames: uniformBuffers,
  16766. samplers: samplers,
  16767. defines: defines,
  16768. maxSimultaneousLights: 4
  16769. });
  16770. var join = defines.toString();
  16771. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  16772. attributes: attribs,
  16773. uniformsNames: uniforms,
  16774. uniformBuffersNames: uniformBuffers,
  16775. samplers: samplers,
  16776. defines: join,
  16777. fallbacks: null,
  16778. onCompiled: this.onCompiled,
  16779. onError: this.onError,
  16780. indexParameters: { maxSimultaneousLights: 4 }
  16781. }, engine));
  16782. }
  16783. if (!subMesh.effect || !subMesh.effect.isReady()) {
  16784. return false;
  16785. }
  16786. defines._renderId = scene.getRenderId();
  16787. subMesh.effect._wasPreviouslyReady = true;
  16788. return true;
  16789. };
  16790. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  16791. var scene = this.getScene();
  16792. var defines = subMesh._materialDefines;
  16793. if (!defines) {
  16794. return;
  16795. }
  16796. var effect = subMesh.effect;
  16797. if (!effect) {
  16798. return;
  16799. }
  16800. this._activeEffect = effect;
  16801. // Matrices
  16802. this.bindOnlyWorldMatrix(world);
  16803. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  16804. if (this._mustRebind(scene, effect)) {
  16805. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  16806. if (defines.INNERGLOW) {
  16807. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  16808. }
  16809. if (defines.BORDER) {
  16810. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  16811. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  16812. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  16813. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16814. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16815. }
  16816. if (defines.HOVERLIGHT) {
  16817. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  16818. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  16819. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  16820. }
  16821. if (defines.TEXTURE) {
  16822. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  16823. }
  16824. }
  16825. this._afterBind(mesh, this._activeEffect);
  16826. };
  16827. FluentMaterial.prototype.getActiveTextures = function () {
  16828. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16829. return activeTextures;
  16830. };
  16831. FluentMaterial.prototype.hasTexture = function (texture) {
  16832. if (_super.prototype.hasTexture.call(this, texture)) {
  16833. return true;
  16834. }
  16835. return false;
  16836. };
  16837. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16838. _super.prototype.dispose.call(this, forceDisposeEffect);
  16839. };
  16840. FluentMaterial.prototype.clone = function (name) {
  16841. var _this = this;
  16842. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16843. };
  16844. FluentMaterial.prototype.serialize = function () {
  16845. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16846. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16847. return serializationObject;
  16848. };
  16849. FluentMaterial.prototype.getClassName = function () {
  16850. return "FluentMaterial";
  16851. };
  16852. // Statics
  16853. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16854. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16855. };
  16856. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16857. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16858. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16859. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16860. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16861. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16862. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16863. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16864. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16865. ], FluentMaterial.prototype, "albedoColor", void 0);
  16866. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16867. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16868. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16869. ], FluentMaterial.prototype, "renderBorders", void 0);
  16870. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16871. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16872. ], FluentMaterial.prototype, "borderWidth", void 0);
  16873. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16874. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16875. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16876. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16877. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16878. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16879. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16880. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16881. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16882. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16883. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16884. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16885. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16886. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16887. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16888. ], FluentMaterial.prototype, "hoverColor", void 0);
  16889. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16890. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16891. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16892. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16893. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16894. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16895. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16896. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16897. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16898. return FluentMaterial;
  16899. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16900. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16901. /***/ }),
  16902. /***/ "./3D/materials/index.ts":
  16903. /*!*******************************!*\
  16904. !*** ./3D/materials/index.ts ***!
  16905. \*******************************/
  16906. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16908. "use strict";
  16909. __webpack_require__.r(__webpack_exports__);
  16910. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16913. /***/ }),
  16914. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16915. /*!*************************************************!*\
  16916. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16917. \*************************************************/
  16918. /*! exports provided: fluentPixelShader */
  16919. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16920. "use strict";
  16921. __webpack_require__.r(__webpack_exports__);
  16922. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16923. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  16924. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16925. var name = 'fluentPixelShader';
  16926. 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}";
  16927. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16928. /** @hidden */
  16929. var fluentPixelShader = { name: name, shader: shader };
  16930. /***/ }),
  16931. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16932. /*!***********************************************!*\
  16933. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16934. \***********************************************/
  16935. /*! exports provided: fluentVertexShader */
  16936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16937. "use strict";
  16938. __webpack_require__.r(__webpack_exports__);
  16939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16940. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  16941. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16942. var name = 'fluentVertexShader';
  16943. 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";
  16944. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16945. /** @hidden */
  16946. var fluentVertexShader = { name: name, shader: shader };
  16947. /***/ }),
  16948. /***/ "./3D/vector3WithInfo.ts":
  16949. /*!*******************************!*\
  16950. !*** ./3D/vector3WithInfo.ts ***!
  16951. \*******************************/
  16952. /*! exports provided: Vector3WithInfo */
  16953. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16954. "use strict";
  16955. __webpack_require__.r(__webpack_exports__);
  16956. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16957. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16958. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  16959. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16960. /**
  16961. * Class used to transport Vector3 information for pointer events
  16962. */
  16963. var Vector3WithInfo = /** @class */ (function (_super) {
  16964. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16965. /**
  16966. * Creates a new Vector3WithInfo
  16967. * @param source defines the vector3 data to transport
  16968. * @param buttonIndex defines the current mouse button index
  16969. */
  16970. function Vector3WithInfo(source,
  16971. /** defines the current mouse button index */
  16972. buttonIndex) {
  16973. if (buttonIndex === void 0) { buttonIndex = 0; }
  16974. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16975. _this.buttonIndex = buttonIndex;
  16976. return _this;
  16977. }
  16978. return Vector3WithInfo;
  16979. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16980. /***/ }),
  16981. /***/ "./index.ts":
  16982. /*!******************!*\
  16983. !*** ./index.ts ***!
  16984. \******************/
  16985. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, FocusableButton, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, ToggleButton, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16986. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16987. "use strict";
  16988. __webpack_require__.r(__webpack_exports__);
  16989. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16991. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16992. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16993. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16994. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16995. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16996. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["FocusableButton"]; });
  16997. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16998. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16999. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  17000. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  17001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  17002. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  17003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  17004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  17005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  17006. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  17007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  17008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  17009. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  17010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  17011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  17012. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  17013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  17014. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ToggleButton"]; });
  17015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  17016. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  17017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  17018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  17019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  17020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  17021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  17022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  17023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  17024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  17025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  17026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  17027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  17028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  17029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  17030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  17031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  17032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  17033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  17034. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  17035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  17036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  17037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  17038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  17039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  17040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  17041. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  17042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  17043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  17044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  17045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  17046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  17047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  17048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  17049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  17050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  17051. /***/ }),
  17052. /***/ "./legacy/legacy.ts":
  17053. /*!**************************!*\
  17054. !*** ./legacy/legacy.ts ***!
  17055. \**************************/
  17056. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, FocusableButton, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, ToggleButton, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  17057. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17058. "use strict";
  17059. __webpack_require__.r(__webpack_exports__);
  17060. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  17061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  17062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  17063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  17064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  17065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  17066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  17067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FocusableButton"]; });
  17068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  17069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  17070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  17071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  17072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  17073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  17074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  17075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  17076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  17077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  17078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  17079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  17080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  17081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  17082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  17083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  17084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  17085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToggleButton"]; });
  17086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  17087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  17088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  17089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  17090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  17091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  17092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  17093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  17094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  17095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  17096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  17097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  17098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  17099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  17100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  17101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  17102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  17103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  17104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  17105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  17106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  17107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  17108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  17109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  17110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  17111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  17112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  17113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  17114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  17115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  17116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  17117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  17118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  17119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  17120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  17121. /**
  17122. * Legacy support, defining window.BABYLON.GUI (global variable).
  17123. *
  17124. * This is the entry point for the UMD module.
  17125. * The entry point for a future ESM package should be index.ts
  17126. */
  17127. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  17128. if (typeof globalObject !== "undefined") {
  17129. globalObject.BABYLON = globalObject.BABYLON || {};
  17130. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  17131. }
  17132. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  17133. /***/ }),
  17134. /***/ "babylonjs/Misc/observable":
  17135. /*!****************************************************************************************************!*\
  17136. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  17137. \****************************************************************************************************/
  17138. /*! no static exports found */
  17139. /***/ (function(module, exports) {
  17140. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  17141. /***/ })
  17142. /******/ });
  17143. });
  17144. //# sourceMappingURL=babylon.gui.js.map