babylon.gui.js 769 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648
  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 Button(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 Button(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 Button(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 Button(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/grid.ts":
  5917. /*!*****************************!*\
  5918. !*** ./2D/controls/grid.ts ***!
  5919. \*****************************/
  5920. /*! exports provided: Grid */
  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__, "Grid", function() { return Grid; });
  5925. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5926. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5927. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5928. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5929. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  5930. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5931. /**
  5932. * Class used to create a 2D grid container
  5933. */
  5934. var Grid = /** @class */ (function (_super) {
  5935. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5936. /**
  5937. * Creates a new Grid
  5938. * @param name defines control name
  5939. */
  5940. function Grid(name) {
  5941. var _this = _super.call(this, name) || this;
  5942. _this.name = name;
  5943. _this._rowDefinitions = new Array();
  5944. _this._columnDefinitions = new Array();
  5945. _this._cells = {};
  5946. _this._childControls = new Array();
  5947. return _this;
  5948. }
  5949. Object.defineProperty(Grid.prototype, "columnCount", {
  5950. /**
  5951. * Gets the number of columns
  5952. */
  5953. get: function () {
  5954. return this._columnDefinitions.length;
  5955. },
  5956. enumerable: false,
  5957. configurable: true
  5958. });
  5959. Object.defineProperty(Grid.prototype, "rowCount", {
  5960. /**
  5961. * Gets the number of rows
  5962. */
  5963. get: function () {
  5964. return this._rowDefinitions.length;
  5965. },
  5966. enumerable: false,
  5967. configurable: true
  5968. });
  5969. Object.defineProperty(Grid.prototype, "children", {
  5970. /** Gets the list of children */
  5971. get: function () {
  5972. return this._childControls;
  5973. },
  5974. enumerable: false,
  5975. configurable: true
  5976. });
  5977. Object.defineProperty(Grid.prototype, "cells", {
  5978. /** Gets the list of cells (e.g. the containers) */
  5979. get: function () {
  5980. return this._cells;
  5981. },
  5982. enumerable: false,
  5983. configurable: true
  5984. });
  5985. /**
  5986. * Gets the definition of a specific row
  5987. * @param index defines the index of the row
  5988. * @returns the row definition
  5989. */
  5990. Grid.prototype.getRowDefinition = function (index) {
  5991. if (index < 0 || index >= this._rowDefinitions.length) {
  5992. return null;
  5993. }
  5994. return this._rowDefinitions[index];
  5995. };
  5996. /**
  5997. * Gets the definition of a specific column
  5998. * @param index defines the index of the column
  5999. * @returns the column definition
  6000. */
  6001. Grid.prototype.getColumnDefinition = function (index) {
  6002. if (index < 0 || index >= this._columnDefinitions.length) {
  6003. return null;
  6004. }
  6005. return this._columnDefinitions[index];
  6006. };
  6007. /**
  6008. * Adds a new row to the grid
  6009. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  6010. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  6011. * @returns the current grid
  6012. */
  6013. Grid.prototype.addRowDefinition = function (height, isPixel) {
  6014. if (isPixel === void 0) { isPixel = false; }
  6015. 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));
  6016. this._markAsDirty();
  6017. return this;
  6018. };
  6019. /**
  6020. * Adds a new column to the grid
  6021. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6022. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6023. * @returns the current grid
  6024. */
  6025. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  6026. if (isPixel === void 0) { isPixel = false; }
  6027. 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));
  6028. this._markAsDirty();
  6029. return this;
  6030. };
  6031. /**
  6032. * Update a row definition
  6033. * @param index defines the index of the row to update
  6034. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  6035. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  6036. * @returns the current grid
  6037. */
  6038. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  6039. if (isPixel === void 0) { isPixel = false; }
  6040. if (index < 0 || index >= this._rowDefinitions.length) {
  6041. return this;
  6042. }
  6043. var current = this._rowDefinitions[index];
  6044. if (current && current.isPixel === isPixel && current.internalValue === height) {
  6045. return this;
  6046. }
  6047. 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);
  6048. this._markAsDirty();
  6049. return this;
  6050. };
  6051. /**
  6052. * Update a column definition
  6053. * @param index defines the index of the column to update
  6054. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6055. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6056. * @returns the current grid
  6057. */
  6058. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  6059. if (isPixel === void 0) { isPixel = false; }
  6060. if (index < 0 || index >= this._columnDefinitions.length) {
  6061. return this;
  6062. }
  6063. var current = this._columnDefinitions[index];
  6064. if (current && current.isPixel === isPixel && current.internalValue === width) {
  6065. return this;
  6066. }
  6067. 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);
  6068. this._markAsDirty();
  6069. return this;
  6070. };
  6071. /**
  6072. * Gets the list of children stored in a specific cell
  6073. * @param row defines the row to check
  6074. * @param column defines the column to check
  6075. * @returns the list of controls
  6076. */
  6077. Grid.prototype.getChildrenAt = function (row, column) {
  6078. var cell = this._cells[row + ":" + column];
  6079. if (!cell) {
  6080. return null;
  6081. }
  6082. return cell.children;
  6083. };
  6084. /**
  6085. * Gets a string representing the child cell info (row x column)
  6086. * @param child defines the control to get info from
  6087. * @returns a string containing the child cell info (row x column)
  6088. */
  6089. Grid.prototype.getChildCellInfo = function (child) {
  6090. return child._tag;
  6091. };
  6092. Grid.prototype._removeCell = function (cell, key) {
  6093. if (!cell) {
  6094. return;
  6095. }
  6096. _super.prototype.removeControl.call(this, cell);
  6097. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  6098. var control = _a[_i];
  6099. var childIndex = this._childControls.indexOf(control);
  6100. if (childIndex !== -1) {
  6101. this._childControls.splice(childIndex, 1);
  6102. }
  6103. }
  6104. delete this._cells[key];
  6105. };
  6106. Grid.prototype._offsetCell = function (previousKey, key) {
  6107. if (!this._cells[key]) {
  6108. return;
  6109. }
  6110. this._cells[previousKey] = this._cells[key];
  6111. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  6112. var control = _a[_i];
  6113. control._tag = previousKey;
  6114. }
  6115. delete this._cells[key];
  6116. };
  6117. /**
  6118. * Remove a column definition at specified index
  6119. * @param index defines the index of the column to remove
  6120. * @returns the current grid
  6121. */
  6122. Grid.prototype.removeColumnDefinition = function (index) {
  6123. if (index < 0 || index >= this._columnDefinitions.length) {
  6124. return this;
  6125. }
  6126. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6127. var key = x + ":" + index;
  6128. var cell = this._cells[key];
  6129. this._removeCell(cell, key);
  6130. }
  6131. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6132. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6133. var previousKey = x + ":" + (y - 1);
  6134. var key = x + ":" + y;
  6135. this._offsetCell(previousKey, key);
  6136. }
  6137. }
  6138. this._columnDefinitions.splice(index, 1);
  6139. this._markAsDirty();
  6140. return this;
  6141. };
  6142. /**
  6143. * Remove a row definition at specified index
  6144. * @param index defines the index of the row to remove
  6145. * @returns the current grid
  6146. */
  6147. Grid.prototype.removeRowDefinition = function (index) {
  6148. if (index < 0 || index >= this._rowDefinitions.length) {
  6149. return this;
  6150. }
  6151. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6152. var key = index + ":" + y;
  6153. var cell = this._cells[key];
  6154. this._removeCell(cell, key);
  6155. }
  6156. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6157. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6158. var previousKey = x - 1 + ":" + y;
  6159. var key = x + ":" + y;
  6160. this._offsetCell(previousKey, key);
  6161. }
  6162. }
  6163. this._rowDefinitions.splice(index, 1);
  6164. this._markAsDirty();
  6165. return this;
  6166. };
  6167. /**
  6168. * Adds a new control to the current grid
  6169. * @param control defines the control to add
  6170. * @param row defines the row where to add the control (0 by default)
  6171. * @param column defines the column where to add the control (0 by default)
  6172. * @returns the current grid
  6173. */
  6174. Grid.prototype.addControl = function (control, row, column) {
  6175. if (row === void 0) { row = 0; }
  6176. if (column === void 0) { column = 0; }
  6177. if (this._rowDefinitions.length === 0) {
  6178. // Add default row definition
  6179. this.addRowDefinition(1, false);
  6180. }
  6181. if (this._columnDefinitions.length === 0) {
  6182. // Add default column definition
  6183. this.addColumnDefinition(1, false);
  6184. }
  6185. if (this._childControls.indexOf(control) !== -1) {
  6186. 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");
  6187. return this;
  6188. }
  6189. var x = Math.min(row, this._rowDefinitions.length - 1);
  6190. var y = Math.min(column, this._columnDefinitions.length - 1);
  6191. var key = x + ":" + y;
  6192. var goodContainer = this._cells[key];
  6193. if (!goodContainer) {
  6194. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6195. this._cells[key] = goodContainer;
  6196. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6197. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6198. _super.prototype.addControl.call(this, goodContainer);
  6199. }
  6200. goodContainer.addControl(control);
  6201. this._childControls.push(control);
  6202. control._tag = key;
  6203. control.parent = this;
  6204. this._markAsDirty();
  6205. return this;
  6206. };
  6207. /**
  6208. * Removes a control from the current container
  6209. * @param control defines the control to remove
  6210. * @returns the current container
  6211. */
  6212. Grid.prototype.removeControl = function (control) {
  6213. var index = this._childControls.indexOf(control);
  6214. if (index !== -1) {
  6215. this._childControls.splice(index, 1);
  6216. }
  6217. var cell = this._cells[control._tag];
  6218. if (cell) {
  6219. cell.removeControl(control);
  6220. control._tag = null;
  6221. }
  6222. this._markAsDirty();
  6223. return this;
  6224. };
  6225. Grid.prototype._getTypeName = function () {
  6226. return "Grid";
  6227. };
  6228. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6229. var widths = [];
  6230. var heights = [];
  6231. var lefts = [];
  6232. var tops = [];
  6233. var availableWidth = this._currentMeasure.width;
  6234. var globalWidthPercentage = 0;
  6235. var availableHeight = this._currentMeasure.height;
  6236. var globalHeightPercentage = 0;
  6237. // Heights
  6238. var index = 0;
  6239. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6240. var value = _a[_i];
  6241. if (value.isPixel) {
  6242. var height = value.getValue(this._host);
  6243. availableHeight -= height;
  6244. heights[index] = height;
  6245. }
  6246. else {
  6247. globalHeightPercentage += value.internalValue;
  6248. }
  6249. index++;
  6250. }
  6251. var top = 0;
  6252. index = 0;
  6253. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6254. var value = _c[_b];
  6255. tops.push(top);
  6256. if (!value.isPixel) {
  6257. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6258. top += height;
  6259. heights[index] = height;
  6260. }
  6261. else {
  6262. top += value.getValue(this._host);
  6263. }
  6264. index++;
  6265. }
  6266. // Widths
  6267. index = 0;
  6268. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6269. var value = _e[_d];
  6270. if (value.isPixel) {
  6271. var width = value.getValue(this._host);
  6272. availableWidth -= width;
  6273. widths[index] = width;
  6274. }
  6275. else {
  6276. globalWidthPercentage += value.internalValue;
  6277. }
  6278. index++;
  6279. }
  6280. var left = 0;
  6281. index = 0;
  6282. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6283. var value = _g[_f];
  6284. lefts.push(left);
  6285. if (!value.isPixel) {
  6286. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6287. left += width;
  6288. widths[index] = width;
  6289. }
  6290. else {
  6291. left += value.getValue(this._host);
  6292. }
  6293. index++;
  6294. }
  6295. definitionCallback(lefts, tops, widths, heights);
  6296. };
  6297. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6298. var _this = this;
  6299. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6300. // Setting child sizes
  6301. for (var key in _this._cells) {
  6302. if (!_this._cells.hasOwnProperty(key)) {
  6303. continue;
  6304. }
  6305. var split = key.split(":");
  6306. var x = parseInt(split[0]);
  6307. var y = parseInt(split[1]);
  6308. var cell = _this._cells[key];
  6309. cell.left = lefts[y] + "px";
  6310. cell.top = tops[x] + "px";
  6311. cell.width = widths[y] + "px";
  6312. cell.height = heights[x] + "px";
  6313. cell._left.ignoreAdaptiveScaling = true;
  6314. cell._top.ignoreAdaptiveScaling = true;
  6315. cell._width.ignoreAdaptiveScaling = true;
  6316. cell._height.ignoreAdaptiveScaling = true;
  6317. }
  6318. });
  6319. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6320. };
  6321. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6322. for (var key in this._cells) {
  6323. if (!this._cells.hasOwnProperty(key)) {
  6324. continue;
  6325. }
  6326. var child = this._cells[key];
  6327. child._markMatrixAsDirty();
  6328. }
  6329. };
  6330. Grid.prototype._renderHighlightSpecific = function (context) {
  6331. var _this = this;
  6332. _super.prototype._renderHighlightSpecific.call(this, context);
  6333. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6334. // Columns
  6335. for (var index = 0; index < lefts.length; index++) {
  6336. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6337. context.beginPath();
  6338. context.moveTo(left, _this._currentMeasure.top);
  6339. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6340. context.stroke();
  6341. }
  6342. // Rows
  6343. for (var index = 0; index < tops.length; index++) {
  6344. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6345. context.beginPath();
  6346. context.moveTo(_this._currentMeasure.left, top_1);
  6347. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6348. context.stroke();
  6349. }
  6350. });
  6351. context.restore();
  6352. };
  6353. /** Releases associated resources */
  6354. Grid.prototype.dispose = function () {
  6355. _super.prototype.dispose.call(this);
  6356. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6357. var control = _a[_i];
  6358. control.dispose();
  6359. }
  6360. this._childControls = [];
  6361. };
  6362. return Grid;
  6363. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6364. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6365. /***/ }),
  6366. /***/ "./2D/controls/image.ts":
  6367. /*!******************************!*\
  6368. !*** ./2D/controls/image.ts ***!
  6369. \******************************/
  6370. /*! exports provided: Image */
  6371. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6372. "use strict";
  6373. __webpack_require__.r(__webpack_exports__);
  6374. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6375. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6376. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6377. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6378. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6379. /**
  6380. * Class used to create 2D images
  6381. */
  6382. var Image = /** @class */ (function (_super) {
  6383. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6384. /**
  6385. * Creates a new Image
  6386. * @param name defines the control name
  6387. * @param url defines the image url
  6388. */
  6389. function Image(name, url) {
  6390. if (url === void 0) { url = null; }
  6391. var _this = _super.call(this, name) || this;
  6392. _this.name = name;
  6393. _this._workingCanvas = null;
  6394. _this._loaded = false;
  6395. _this._stretch = Image.STRETCH_FILL;
  6396. _this._autoScale = false;
  6397. _this._sourceLeft = 0;
  6398. _this._sourceTop = 0;
  6399. _this._sourceWidth = 0;
  6400. _this._sourceHeight = 0;
  6401. _this._svgAttributesComputationCompleted = false;
  6402. _this._isSVG = false;
  6403. _this._cellWidth = 0;
  6404. _this._cellHeight = 0;
  6405. _this._cellId = -1;
  6406. _this._populateNinePatchSlicesFromImage = false;
  6407. _this._imageDataCache = { data: null, key: "" };
  6408. /**
  6409. * Observable notified when the content is loaded
  6410. */
  6411. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6412. /**
  6413. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6414. */
  6415. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6416. _this.source = url;
  6417. return _this;
  6418. }
  6419. Object.defineProperty(Image.prototype, "isLoaded", {
  6420. /**
  6421. * Gets a boolean indicating that the content is loaded
  6422. */
  6423. get: function () {
  6424. return this._loaded;
  6425. },
  6426. enumerable: false,
  6427. configurable: true
  6428. });
  6429. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6430. /**
  6431. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6432. */
  6433. get: function () {
  6434. return this._populateNinePatchSlicesFromImage;
  6435. },
  6436. set: function (value) {
  6437. if (this._populateNinePatchSlicesFromImage === value) {
  6438. return;
  6439. }
  6440. this._populateNinePatchSlicesFromImage = value;
  6441. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6442. this._extractNinePatchSliceDataFromImage();
  6443. }
  6444. },
  6445. enumerable: false,
  6446. configurable: true
  6447. });
  6448. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6449. /**
  6450. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6451. * Beware using this as this will comsume more memory as the image has to be stored twice
  6452. */
  6453. get: function () {
  6454. return this._detectPointerOnOpaqueOnly;
  6455. },
  6456. set: function (value) {
  6457. if (this._detectPointerOnOpaqueOnly === value) {
  6458. return;
  6459. }
  6460. this._detectPointerOnOpaqueOnly = value;
  6461. },
  6462. enumerable: false,
  6463. configurable: true
  6464. });
  6465. Object.defineProperty(Image.prototype, "sliceLeft", {
  6466. /**
  6467. * Gets or sets the left value for slicing (9-patch)
  6468. */
  6469. get: function () {
  6470. return this._sliceLeft;
  6471. },
  6472. set: function (value) {
  6473. if (this._sliceLeft === value) {
  6474. return;
  6475. }
  6476. this._sliceLeft = value;
  6477. this._markAsDirty();
  6478. },
  6479. enumerable: false,
  6480. configurable: true
  6481. });
  6482. Object.defineProperty(Image.prototype, "sliceRight", {
  6483. /**
  6484. * Gets or sets the right value for slicing (9-patch)
  6485. */
  6486. get: function () {
  6487. return this._sliceRight;
  6488. },
  6489. set: function (value) {
  6490. if (this._sliceRight === value) {
  6491. return;
  6492. }
  6493. this._sliceRight = value;
  6494. this._markAsDirty();
  6495. },
  6496. enumerable: false,
  6497. configurable: true
  6498. });
  6499. Object.defineProperty(Image.prototype, "sliceTop", {
  6500. /**
  6501. * Gets or sets the top value for slicing (9-patch)
  6502. */
  6503. get: function () {
  6504. return this._sliceTop;
  6505. },
  6506. set: function (value) {
  6507. if (this._sliceTop === value) {
  6508. return;
  6509. }
  6510. this._sliceTop = value;
  6511. this._markAsDirty();
  6512. },
  6513. enumerable: false,
  6514. configurable: true
  6515. });
  6516. Object.defineProperty(Image.prototype, "sliceBottom", {
  6517. /**
  6518. * Gets or sets the bottom value for slicing (9-patch)
  6519. */
  6520. get: function () {
  6521. return this._sliceBottom;
  6522. },
  6523. set: function (value) {
  6524. if (this._sliceBottom === value) {
  6525. return;
  6526. }
  6527. this._sliceBottom = value;
  6528. this._markAsDirty();
  6529. },
  6530. enumerable: false,
  6531. configurable: true
  6532. });
  6533. Object.defineProperty(Image.prototype, "sourceLeft", {
  6534. /**
  6535. * Gets or sets the left coordinate in the source image
  6536. */
  6537. get: function () {
  6538. return this._sourceLeft;
  6539. },
  6540. set: function (value) {
  6541. if (this._sourceLeft === value) {
  6542. return;
  6543. }
  6544. this._sourceLeft = value;
  6545. this._markAsDirty();
  6546. },
  6547. enumerable: false,
  6548. configurable: true
  6549. });
  6550. Object.defineProperty(Image.prototype, "sourceTop", {
  6551. /**
  6552. * Gets or sets the top coordinate in the source image
  6553. */
  6554. get: function () {
  6555. return this._sourceTop;
  6556. },
  6557. set: function (value) {
  6558. if (this._sourceTop === value) {
  6559. return;
  6560. }
  6561. this._sourceTop = value;
  6562. this._markAsDirty();
  6563. },
  6564. enumerable: false,
  6565. configurable: true
  6566. });
  6567. Object.defineProperty(Image.prototype, "sourceWidth", {
  6568. /**
  6569. * Gets or sets the width to capture in the source image
  6570. */
  6571. get: function () {
  6572. return this._sourceWidth;
  6573. },
  6574. set: function (value) {
  6575. if (this._sourceWidth === value) {
  6576. return;
  6577. }
  6578. this._sourceWidth = value;
  6579. this._markAsDirty();
  6580. },
  6581. enumerable: false,
  6582. configurable: true
  6583. });
  6584. Object.defineProperty(Image.prototype, "sourceHeight", {
  6585. /**
  6586. * Gets or sets the height to capture in the source image
  6587. */
  6588. get: function () {
  6589. return this._sourceHeight;
  6590. },
  6591. set: function (value) {
  6592. if (this._sourceHeight === value) {
  6593. return;
  6594. }
  6595. this._sourceHeight = value;
  6596. this._markAsDirty();
  6597. },
  6598. enumerable: false,
  6599. configurable: true
  6600. });
  6601. Object.defineProperty(Image.prototype, "isSVG", {
  6602. /** Indicates if the format of the image is SVG */
  6603. get: function () {
  6604. return this._isSVG;
  6605. },
  6606. enumerable: false,
  6607. configurable: true
  6608. });
  6609. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6610. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6611. get: function () {
  6612. return this._svgAttributesComputationCompleted;
  6613. },
  6614. enumerable: false,
  6615. configurable: true
  6616. });
  6617. Object.defineProperty(Image.prototype, "autoScale", {
  6618. /**
  6619. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6620. * @see https://doc.babylonjs.com/how_to/gui#image
  6621. */
  6622. get: function () {
  6623. return this._autoScale;
  6624. },
  6625. set: function (value) {
  6626. if (this._autoScale === value) {
  6627. return;
  6628. }
  6629. this._autoScale = value;
  6630. if (value && this._loaded) {
  6631. this.synchronizeSizeWithContent();
  6632. }
  6633. },
  6634. enumerable: false,
  6635. configurable: true
  6636. });
  6637. Object.defineProperty(Image.prototype, "stretch", {
  6638. /** Gets or sets the streching mode used by the image */
  6639. get: function () {
  6640. return this._stretch;
  6641. },
  6642. set: function (value) {
  6643. if (this._stretch === value) {
  6644. return;
  6645. }
  6646. this._stretch = value;
  6647. this._markAsDirty();
  6648. },
  6649. enumerable: false,
  6650. configurable: true
  6651. });
  6652. /** @hidden */
  6653. Image.prototype._rotate90 = function (n, preserveProperties) {
  6654. if (preserveProperties === void 0) { preserveProperties = false; }
  6655. var canvas = document.createElement('canvas');
  6656. var context = canvas.getContext('2d');
  6657. var width = this._domImage.width;
  6658. var height = this._domImage.height;
  6659. canvas.width = height;
  6660. canvas.height = width;
  6661. context.translate(canvas.width / 2, canvas.height / 2);
  6662. context.rotate(n * Math.PI / 2);
  6663. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6664. var dataUrl = canvas.toDataURL("image/jpg");
  6665. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6666. if (preserveProperties) {
  6667. rotatedImage._stretch = this._stretch;
  6668. rotatedImage._autoScale = this._autoScale;
  6669. rotatedImage._cellId = this._cellId;
  6670. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6671. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6672. }
  6673. this._handleRotationForSVGImage(this, rotatedImage, n);
  6674. this._imageDataCache.data = null;
  6675. return rotatedImage;
  6676. };
  6677. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6678. var _this = this;
  6679. if (!srcImage._isSVG) {
  6680. return;
  6681. }
  6682. if (srcImage._svgAttributesComputationCompleted) {
  6683. this._rotate90SourceProperties(srcImage, dstImage, n);
  6684. this._markAsDirty();
  6685. }
  6686. else {
  6687. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6688. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6689. _this._markAsDirty();
  6690. });
  6691. }
  6692. };
  6693. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6694. var _a, _b;
  6695. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6696. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6697. if (n != 0) {
  6698. var mult = n < 0 ? -1 : 1;
  6699. n = n % 4;
  6700. for (var i = 0; i < Math.abs(n); ++i) {
  6701. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6702. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6703. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6704. if (n < 0) {
  6705. dstTop -= dstHeight;
  6706. }
  6707. else {
  6708. dstLeft -= dstWidth;
  6709. }
  6710. srcLeft = dstLeft;
  6711. srcTop = dstTop;
  6712. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6713. }
  6714. }
  6715. dstImage.sourceLeft = dstLeft;
  6716. dstImage.sourceTop = dstTop;
  6717. dstImage.sourceWidth = dstWidth;
  6718. dstImage.sourceHeight = dstHeight;
  6719. };
  6720. Object.defineProperty(Image.prototype, "domImage", {
  6721. get: function () {
  6722. return this._domImage;
  6723. },
  6724. /**
  6725. * Gets or sets the internal DOM image used to render the control
  6726. */
  6727. set: function (value) {
  6728. var _this = this;
  6729. this._domImage = value;
  6730. this._loaded = false;
  6731. this._imageDataCache.data = null;
  6732. if (this._domImage.width) {
  6733. this._onImageLoaded();
  6734. }
  6735. else {
  6736. this._domImage.onload = function () {
  6737. _this._onImageLoaded();
  6738. };
  6739. }
  6740. },
  6741. enumerable: false,
  6742. configurable: true
  6743. });
  6744. Image.prototype._onImageLoaded = function () {
  6745. this._imageDataCache.data = null;
  6746. this._imageWidth = this._domImage.width;
  6747. this._imageHeight = this._domImage.height;
  6748. this._loaded = true;
  6749. if (this._populateNinePatchSlicesFromImage) {
  6750. this._extractNinePatchSliceDataFromImage();
  6751. }
  6752. if (this._autoScale) {
  6753. this.synchronizeSizeWithContent();
  6754. }
  6755. this.onImageLoadedObservable.notifyObservers(this);
  6756. this._markAsDirty();
  6757. };
  6758. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6759. if (!this._workingCanvas) {
  6760. this._workingCanvas = document.createElement('canvas');
  6761. }
  6762. var canvas = this._workingCanvas;
  6763. var context = canvas.getContext('2d');
  6764. var width = this._domImage.width;
  6765. var height = this._domImage.height;
  6766. canvas.width = width;
  6767. canvas.height = height;
  6768. context.drawImage(this._domImage, 0, 0, width, height);
  6769. var imageData = context.getImageData(0, 0, width, height);
  6770. // Left and right
  6771. this._sliceLeft = -1;
  6772. this._sliceRight = -1;
  6773. for (var x = 0; x < width; x++) {
  6774. var alpha = imageData.data[x * 4 + 3];
  6775. if (alpha > 127 && this._sliceLeft === -1) {
  6776. this._sliceLeft = x;
  6777. continue;
  6778. }
  6779. if (alpha < 127 && this._sliceLeft > -1) {
  6780. this._sliceRight = x;
  6781. break;
  6782. }
  6783. }
  6784. // top and bottom
  6785. this._sliceTop = -1;
  6786. this._sliceBottom = -1;
  6787. for (var y = 0; y < height; y++) {
  6788. var alpha = imageData.data[y * width * 4 + 3];
  6789. if (alpha > 127 && this._sliceTop === -1) {
  6790. this._sliceTop = y;
  6791. continue;
  6792. }
  6793. if (alpha < 127 && this._sliceTop > -1) {
  6794. this._sliceBottom = y;
  6795. break;
  6796. }
  6797. }
  6798. };
  6799. Object.defineProperty(Image.prototype, "source", {
  6800. /**
  6801. * Gets or sets image source url
  6802. */
  6803. set: function (value) {
  6804. var _this = this;
  6805. if (this._source === value) {
  6806. return;
  6807. }
  6808. this._loaded = false;
  6809. this._source = value;
  6810. this._imageDataCache.data = null;
  6811. if (value) {
  6812. value = this._svgCheck(value);
  6813. }
  6814. this._domImage = document.createElement("img");
  6815. this._domImage.onload = function () {
  6816. _this._onImageLoaded();
  6817. };
  6818. if (value) {
  6819. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6820. this._domImage.src = value;
  6821. }
  6822. },
  6823. enumerable: false,
  6824. configurable: true
  6825. });
  6826. /**
  6827. * Checks for svg document with icon id present
  6828. */
  6829. Image.prototype._svgCheck = function (value) {
  6830. var _this = this;
  6831. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6832. this._isSVG = true;
  6833. var svgsrc = value.split('#')[0];
  6834. var elemid = value.split('#')[1];
  6835. // check if object alr exist in document
  6836. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6837. if (svgExist) {
  6838. var svgDoc = svgExist.contentDocument;
  6839. // get viewbox width and height, get svg document width and height in px
  6840. if (svgDoc && svgDoc.documentElement) {
  6841. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6842. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6843. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6844. var elem = svgDoc.getElementById(elemid);
  6845. if (elem && vb && docwidth && docheight) {
  6846. this._getSVGAttribs(svgExist, elemid);
  6847. return value;
  6848. }
  6849. }
  6850. // wait for object to load
  6851. svgExist.addEventListener("load", function () {
  6852. _this._getSVGAttribs(svgExist, elemid);
  6853. });
  6854. }
  6855. else {
  6856. // create document object
  6857. var svgImage = document.createElement("object");
  6858. svgImage.data = svgsrc;
  6859. svgImage.type = "image/svg+xml";
  6860. svgImage.width = "0%";
  6861. svgImage.height = "0%";
  6862. document.body.appendChild(svgImage);
  6863. // when the object has loaded, get the element attribs
  6864. svgImage.onload = function () {
  6865. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6866. if (svgobj) {
  6867. _this._getSVGAttribs(svgobj, elemid);
  6868. }
  6869. };
  6870. }
  6871. return svgsrc;
  6872. }
  6873. else {
  6874. return value;
  6875. }
  6876. };
  6877. /**
  6878. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6879. * given external svg file and icon id
  6880. */
  6881. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6882. var svgDoc = svgsrc.contentDocument;
  6883. // get viewbox width and height, get svg document width and height in px
  6884. if (svgDoc && svgDoc.documentElement) {
  6885. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6886. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6887. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6888. // get element bbox and matrix transform
  6889. var elem = svgDoc.getElementById(elemid);
  6890. if (vb && docwidth && docheight && elem) {
  6891. var vb_width = Number(vb.split(" ")[2]);
  6892. var vb_height = Number(vb.split(" ")[3]);
  6893. var elem_bbox = elem.getBBox();
  6894. var elem_matrix_a = 1;
  6895. var elem_matrix_d = 1;
  6896. var elem_matrix_e = 0;
  6897. var elem_matrix_f = 0;
  6898. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6899. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6900. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6901. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6902. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6903. }
  6904. // compute source coordinates and dimensions
  6905. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6906. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6907. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6908. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6909. this._svgAttributesComputationCompleted = true;
  6910. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6911. }
  6912. }
  6913. };
  6914. Object.defineProperty(Image.prototype, "cellWidth", {
  6915. /**
  6916. * Gets or sets the cell width to use when animation sheet is enabled
  6917. * @see https://doc.babylonjs.com/how_to/gui#image
  6918. */
  6919. get: function () {
  6920. return this._cellWidth;
  6921. },
  6922. set: function (value) {
  6923. if (this._cellWidth === value) {
  6924. return;
  6925. }
  6926. this._cellWidth = value;
  6927. this._markAsDirty();
  6928. },
  6929. enumerable: false,
  6930. configurable: true
  6931. });
  6932. Object.defineProperty(Image.prototype, "cellHeight", {
  6933. /**
  6934. * Gets or sets the cell height to use when animation sheet is enabled
  6935. * @see https://doc.babylonjs.com/how_to/gui#image
  6936. */
  6937. get: function () {
  6938. return this._cellHeight;
  6939. },
  6940. set: function (value) {
  6941. if (this._cellHeight === value) {
  6942. return;
  6943. }
  6944. this._cellHeight = value;
  6945. this._markAsDirty();
  6946. },
  6947. enumerable: false,
  6948. configurable: true
  6949. });
  6950. Object.defineProperty(Image.prototype, "cellId", {
  6951. /**
  6952. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6953. * @see https://doc.babylonjs.com/how_to/gui#image
  6954. */
  6955. get: function () {
  6956. return this._cellId;
  6957. },
  6958. set: function (value) {
  6959. if (this._cellId === value) {
  6960. return;
  6961. }
  6962. this._cellId = value;
  6963. this._markAsDirty();
  6964. },
  6965. enumerable: false,
  6966. configurable: true
  6967. });
  6968. /**
  6969. * Tests if a given coordinates belong to the current control
  6970. * @param x defines x coordinate to test
  6971. * @param y defines y coordinate to test
  6972. * @returns true if the coordinates are inside the control
  6973. */
  6974. Image.prototype.contains = function (x, y) {
  6975. if (!_super.prototype.contains.call(this, x, y)) {
  6976. return false;
  6977. }
  6978. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6979. return true;
  6980. }
  6981. var width = this._currentMeasure.width | 0;
  6982. var height = this._currentMeasure.height | 0;
  6983. var key = width + "_" + height;
  6984. var imageData = this._imageDataCache.data;
  6985. if (!imageData || this._imageDataCache.key !== key) {
  6986. var canvas = this._workingCanvas;
  6987. var context_1 = canvas.getContext("2d");
  6988. this._imageDataCache.data = imageData = context_1.getImageData(0, 0, width, height).data;
  6989. this._imageDataCache.key = key;
  6990. }
  6991. x = (x - this._currentMeasure.left) | 0;
  6992. y = (y - this._currentMeasure.top) | 0;
  6993. var pickedPixel = imageData[(x + y * width) * 4 + 3];
  6994. return pickedPixel > 0;
  6995. };
  6996. Image.prototype._getTypeName = function () {
  6997. return "Image";
  6998. };
  6999. /** Force the control to synchronize with its content */
  7000. Image.prototype.synchronizeSizeWithContent = function () {
  7001. if (!this._loaded) {
  7002. return;
  7003. }
  7004. this.width = this._domImage.width + "px";
  7005. this.height = this._domImage.height + "px";
  7006. };
  7007. Image.prototype._processMeasures = function (parentMeasure, context) {
  7008. if (this._loaded) {
  7009. switch (this._stretch) {
  7010. case Image.STRETCH_NONE:
  7011. break;
  7012. case Image.STRETCH_FILL:
  7013. break;
  7014. case Image.STRETCH_UNIFORM:
  7015. break;
  7016. case Image.STRETCH_NINE_PATCH:
  7017. break;
  7018. case Image.STRETCH_EXTEND:
  7019. if (this._autoScale) {
  7020. this.synchronizeSizeWithContent();
  7021. }
  7022. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  7023. this.parent.adaptWidthToChildren = true;
  7024. this.parent.adaptHeightToChildren = true;
  7025. }
  7026. break;
  7027. }
  7028. }
  7029. _super.prototype._processMeasures.call(this, parentMeasure, context);
  7030. };
  7031. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  7032. if (!this._detectPointerOnOpaqueOnly) {
  7033. return;
  7034. }
  7035. if (!this._workingCanvas) {
  7036. this._workingCanvas = document.createElement('canvas');
  7037. }
  7038. var canvas = this._workingCanvas;
  7039. var width = this._currentMeasure.width;
  7040. var height = this._currentMeasure.height;
  7041. var context = canvas.getContext("2d");
  7042. canvas.width = width;
  7043. canvas.height = height;
  7044. context.clearRect(0, 0, width, height);
  7045. };
  7046. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  7047. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  7048. if (!this._detectPointerOnOpaqueOnly) {
  7049. return;
  7050. }
  7051. var canvas = this._workingCanvas;
  7052. context = canvas.getContext("2d");
  7053. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  7054. };
  7055. Image.prototype._draw = function (context) {
  7056. context.save();
  7057. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7058. context.shadowColor = this.shadowColor;
  7059. context.shadowBlur = this.shadowBlur;
  7060. context.shadowOffsetX = this.shadowOffsetX;
  7061. context.shadowOffsetY = this.shadowOffsetY;
  7062. }
  7063. var x, y, width, height;
  7064. if (this.cellId == -1) {
  7065. x = this._sourceLeft;
  7066. y = this._sourceTop;
  7067. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  7068. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  7069. }
  7070. else {
  7071. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  7072. var column = (this.cellId / rowCount) >> 0;
  7073. var row = this.cellId % rowCount;
  7074. x = this.cellWidth * row;
  7075. y = this.cellHeight * column;
  7076. width = this.cellWidth;
  7077. height = this.cellHeight;
  7078. }
  7079. this._prepareWorkingCanvasForOpaqueDetection();
  7080. this._applyStates(context);
  7081. if (this._loaded) {
  7082. switch (this._stretch) {
  7083. case Image.STRETCH_NONE:
  7084. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7085. break;
  7086. case Image.STRETCH_FILL:
  7087. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7088. break;
  7089. case Image.STRETCH_UNIFORM:
  7090. var hRatio = this._currentMeasure.width / width;
  7091. var vRatio = this._currentMeasure.height / height;
  7092. var ratio = Math.min(hRatio, vRatio);
  7093. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  7094. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  7095. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  7096. break;
  7097. case Image.STRETCH_EXTEND:
  7098. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7099. break;
  7100. case Image.STRETCH_NINE_PATCH:
  7101. this._renderNinePatch(context);
  7102. break;
  7103. }
  7104. }
  7105. context.restore();
  7106. };
  7107. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  7108. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  7109. };
  7110. Image.prototype._renderNinePatch = function (context) {
  7111. var height = this._imageHeight;
  7112. var leftWidth = this._sliceLeft;
  7113. var topHeight = this._sliceTop;
  7114. var bottomHeight = this._imageHeight - this._sliceBottom;
  7115. var rightWidth = this._imageWidth - this._sliceRight;
  7116. var left = 0;
  7117. var top = 0;
  7118. if (this._populateNinePatchSlicesFromImage) {
  7119. left = 1;
  7120. top = 1;
  7121. height -= 2;
  7122. leftWidth -= 1;
  7123. topHeight -= 1;
  7124. bottomHeight -= 1;
  7125. rightWidth -= 1;
  7126. }
  7127. var centerWidth = this._sliceRight - this._sliceLeft;
  7128. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  7129. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  7130. // Corners
  7131. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  7132. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  7133. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  7134. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  7135. // Center
  7136. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  7137. // Borders
  7138. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7139. 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);
  7140. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  7141. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  7142. };
  7143. Image.prototype.dispose = function () {
  7144. _super.prototype.dispose.call(this);
  7145. this.onImageLoadedObservable.clear();
  7146. this.onSVGAttributesComputedObservable.clear();
  7147. };
  7148. // Static
  7149. /** STRETCH_NONE */
  7150. Image.STRETCH_NONE = 0;
  7151. /** STRETCH_FILL */
  7152. Image.STRETCH_FILL = 1;
  7153. /** STRETCH_UNIFORM */
  7154. Image.STRETCH_UNIFORM = 2;
  7155. /** STRETCH_EXTEND */
  7156. Image.STRETCH_EXTEND = 3;
  7157. /** NINE_PATCH */
  7158. Image.STRETCH_NINE_PATCH = 4;
  7159. return Image;
  7160. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7161. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7162. /***/ }),
  7163. /***/ "./2D/controls/index.ts":
  7164. /*!******************************!*\
  7165. !*** ./2D/controls/index.ts ***!
  7166. \******************************/
  7167. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  7168. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7169. "use strict";
  7170. __webpack_require__.r(__webpack_exports__);
  7171. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7173. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7175. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7177. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7179. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7181. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7183. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  7185. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  7187. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  7189. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  7191. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  7193. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  7195. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  7197. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  7199. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  7201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  7202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  7203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  7204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  7205. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  7207. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  7209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  7210. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _textWrapper__WEBPACK_IMPORTED_MODULE_17__["TextWrapper"]; });
  7212. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_18__["KeyPropertySet"]; });
  7214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_18__["VirtualKeyboard"]; });
  7215. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_19__["Rectangle"]; });
  7217. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_20__["DisplayGrid"]; });
  7219. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_21__["BaseSlider"]; });
  7221. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_22__["Slider"]; });
  7223. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_23__["ImageBasedSlider"]; });
  7225. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_24__["ScrollBar"]; });
  7227. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_25__["ImageScrollBar"]; });
  7229. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_26__["name"]; });
  7231. /***/ }),
  7232. /***/ "./2D/controls/inputPassword.ts":
  7233. /*!**************************************!*\
  7234. !*** ./2D/controls/inputPassword.ts ***!
  7235. \**************************************/
  7236. /*! exports provided: InputPassword */
  7237. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7238. "use strict";
  7239. __webpack_require__.r(__webpack_exports__);
  7240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7241. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7242. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7243. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  7244. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7245. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7246. /**
  7247. * Class used to create a password control
  7248. */
  7249. var InputPassword = /** @class */ (function (_super) {
  7250. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7251. function InputPassword() {
  7252. return _super !== null && _super.apply(this, arguments) || this;
  7253. }
  7254. InputPassword.prototype._beforeRenderText = function (textWrapper) {
  7255. var pwdTextWrapper = new _textWrapper__WEBPACK_IMPORTED_MODULE_3__["TextWrapper"]();
  7256. var txt = "";
  7257. for (var i = 0; i < textWrapper.length; i++) {
  7258. txt += "\u2022";
  7259. }
  7260. pwdTextWrapper.text = txt;
  7261. return pwdTextWrapper;
  7262. };
  7263. return InputPassword;
  7264. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7265. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7266. /***/ }),
  7267. /***/ "./2D/controls/inputText.ts":
  7268. /*!**********************************!*\
  7269. !*** ./2D/controls/inputText.ts ***!
  7270. \**********************************/
  7271. /*! exports provided: InputText */
  7272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7273. "use strict";
  7274. __webpack_require__.r(__webpack_exports__);
  7275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7276. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7277. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  7278. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7279. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7280. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7281. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7282. /**
  7283. * Class used to create input text control
  7284. */
  7285. var InputText = /** @class */ (function (_super) {
  7286. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7287. /**
  7288. * Creates a new InputText
  7289. * @param name defines the control name
  7290. * @param text defines the text of the control
  7291. */
  7292. function InputText(name, text) {
  7293. if (text === void 0) { text = ""; }
  7294. var _this = _super.call(this, name) || this;
  7295. _this.name = name;
  7296. _this._placeholderText = "";
  7297. _this._background = "#222222";
  7298. _this._focusedBackground = "#000000";
  7299. _this._focusedColor = "white";
  7300. _this._placeholderColor = "gray";
  7301. _this._thickness = 1;
  7302. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7303. _this._autoStretchWidth = true;
  7304. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7305. _this._isFocused = false;
  7306. _this._blinkIsEven = false;
  7307. _this._cursorOffset = 0;
  7308. _this._deadKey = false;
  7309. _this._addKey = true;
  7310. _this._currentKey = "";
  7311. _this._isTextHighlightOn = false;
  7312. _this._textHighlightColor = "#d5e0ff";
  7313. _this._highligherOpacity = 0.4;
  7314. _this._highlightedText = "";
  7315. _this._startHighlightIndex = 0;
  7316. _this._endHighlightIndex = 0;
  7317. _this._cursorIndex = -1;
  7318. _this._onFocusSelectAll = false;
  7319. _this._isPointerDown = false;
  7320. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7321. _this.promptMessage = "Please enter text:";
  7322. /** Force disable prompt on mobile device */
  7323. _this.disableMobilePrompt = false;
  7324. /** Observable raised when the text changes */
  7325. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7326. /** Observable raised just before an entered character is to be added */
  7327. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7328. /** Observable raised when the control gets the focus */
  7329. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7330. /** Observable raised when the control loses the focus */
  7331. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7332. /**Observable raised when the text is highlighted */
  7333. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7334. /**Observable raised when copy event is triggered */
  7335. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7336. /** Observable raised when cut event is triggered */
  7337. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7338. /** Observable raised when paste event is triggered */
  7339. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7340. /** Observable raised when a key event was processed */
  7341. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7342. _this.text = text;
  7343. _this.isPointerBlocker = true;
  7344. return _this;
  7345. }
  7346. Object.defineProperty(InputText.prototype, "maxWidth", {
  7347. /** Gets or sets the maximum width allowed by the control */
  7348. get: function () {
  7349. return this._maxWidth.toString(this._host);
  7350. },
  7351. set: function (value) {
  7352. if (this._maxWidth.toString(this._host) === value) {
  7353. return;
  7354. }
  7355. if (this._maxWidth.fromString(value)) {
  7356. this._markAsDirty();
  7357. }
  7358. },
  7359. enumerable: false,
  7360. configurable: true
  7361. });
  7362. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7363. /** Gets the maximum width allowed by the control in pixels */
  7364. get: function () {
  7365. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7366. },
  7367. enumerable: false,
  7368. configurable: true
  7369. });
  7370. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7371. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7372. get: function () {
  7373. return this._highligherOpacity;
  7374. },
  7375. set: function (value) {
  7376. if (this._highligherOpacity === value) {
  7377. return;
  7378. }
  7379. this._highligherOpacity = value;
  7380. this._markAsDirty();
  7381. },
  7382. enumerable: false,
  7383. configurable: true
  7384. });
  7385. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7386. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7387. get: function () {
  7388. return this._onFocusSelectAll;
  7389. },
  7390. set: function (value) {
  7391. if (this._onFocusSelectAll === value) {
  7392. return;
  7393. }
  7394. this._onFocusSelectAll = value;
  7395. this._markAsDirty();
  7396. },
  7397. enumerable: false,
  7398. configurable: true
  7399. });
  7400. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7401. /** Gets or sets the text hightlight color */
  7402. get: function () {
  7403. return this._textHighlightColor;
  7404. },
  7405. set: function (value) {
  7406. if (this._textHighlightColor === value) {
  7407. return;
  7408. }
  7409. this._textHighlightColor = value;
  7410. this._markAsDirty();
  7411. },
  7412. enumerable: false,
  7413. configurable: true
  7414. });
  7415. Object.defineProperty(InputText.prototype, "margin", {
  7416. /** Gets or sets control margin */
  7417. get: function () {
  7418. return this._margin.toString(this._host);
  7419. },
  7420. set: function (value) {
  7421. if (this._margin.toString(this._host) === value) {
  7422. return;
  7423. }
  7424. if (this._margin.fromString(value)) {
  7425. this._markAsDirty();
  7426. }
  7427. },
  7428. enumerable: false,
  7429. configurable: true
  7430. });
  7431. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7432. /** Gets control margin in pixels */
  7433. get: function () {
  7434. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7435. },
  7436. enumerable: false,
  7437. configurable: true
  7438. });
  7439. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7440. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7441. get: function () {
  7442. return this._autoStretchWidth;
  7443. },
  7444. set: function (value) {
  7445. if (this._autoStretchWidth === value) {
  7446. return;
  7447. }
  7448. this._autoStretchWidth = value;
  7449. this._markAsDirty();
  7450. },
  7451. enumerable: false,
  7452. configurable: true
  7453. });
  7454. Object.defineProperty(InputText.prototype, "thickness", {
  7455. /** Gets or sets border thickness */
  7456. get: function () {
  7457. return this._thickness;
  7458. },
  7459. set: function (value) {
  7460. if (this._thickness === value) {
  7461. return;
  7462. }
  7463. this._thickness = value;
  7464. this._markAsDirty();
  7465. },
  7466. enumerable: false,
  7467. configurable: true
  7468. });
  7469. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7470. /** Gets or sets the background color when focused */
  7471. get: function () {
  7472. return this._focusedBackground;
  7473. },
  7474. set: function (value) {
  7475. if (this._focusedBackground === value) {
  7476. return;
  7477. }
  7478. this._focusedBackground = value;
  7479. this._markAsDirty();
  7480. },
  7481. enumerable: false,
  7482. configurable: true
  7483. });
  7484. Object.defineProperty(InputText.prototype, "focusedColor", {
  7485. /** Gets or sets the background color when focused */
  7486. get: function () {
  7487. return this._focusedColor;
  7488. },
  7489. set: function (value) {
  7490. if (this._focusedColor === value) {
  7491. return;
  7492. }
  7493. this._focusedColor = value;
  7494. this._markAsDirty();
  7495. },
  7496. enumerable: false,
  7497. configurable: true
  7498. });
  7499. Object.defineProperty(InputText.prototype, "background", {
  7500. /** Gets or sets the background color */
  7501. get: function () {
  7502. return this._background;
  7503. },
  7504. set: function (value) {
  7505. if (this._background === value) {
  7506. return;
  7507. }
  7508. this._background = value;
  7509. this._markAsDirty();
  7510. },
  7511. enumerable: false,
  7512. configurable: true
  7513. });
  7514. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7515. /** Gets or sets the placeholder color */
  7516. get: function () {
  7517. return this._placeholderColor;
  7518. },
  7519. set: function (value) {
  7520. if (this._placeholderColor === value) {
  7521. return;
  7522. }
  7523. this._placeholderColor = value;
  7524. this._markAsDirty();
  7525. },
  7526. enumerable: false,
  7527. configurable: true
  7528. });
  7529. Object.defineProperty(InputText.prototype, "placeholderText", {
  7530. /** Gets or sets the text displayed when the control is empty */
  7531. get: function () {
  7532. return this._placeholderText;
  7533. },
  7534. set: function (value) {
  7535. if (this._placeholderText === value) {
  7536. return;
  7537. }
  7538. this._placeholderText = value;
  7539. this._markAsDirty();
  7540. },
  7541. enumerable: false,
  7542. configurable: true
  7543. });
  7544. Object.defineProperty(InputText.prototype, "deadKey", {
  7545. /** Gets or sets the dead key flag */
  7546. get: function () {
  7547. return this._deadKey;
  7548. },
  7549. set: function (flag) {
  7550. this._deadKey = flag;
  7551. },
  7552. enumerable: false,
  7553. configurable: true
  7554. });
  7555. Object.defineProperty(InputText.prototype, "highlightedText", {
  7556. /** Gets or sets the highlight text */
  7557. get: function () {
  7558. return this._highlightedText;
  7559. },
  7560. set: function (text) {
  7561. if (this._highlightedText === text) {
  7562. return;
  7563. }
  7564. this._highlightedText = text;
  7565. this._markAsDirty();
  7566. },
  7567. enumerable: false,
  7568. configurable: true
  7569. });
  7570. Object.defineProperty(InputText.prototype, "addKey", {
  7571. /** Gets or sets if the current key should be added */
  7572. get: function () {
  7573. return this._addKey;
  7574. },
  7575. set: function (flag) {
  7576. this._addKey = flag;
  7577. },
  7578. enumerable: false,
  7579. configurable: true
  7580. });
  7581. Object.defineProperty(InputText.prototype, "currentKey", {
  7582. /** Gets or sets the value of the current key being entered */
  7583. get: function () {
  7584. return this._currentKey;
  7585. },
  7586. set: function (key) {
  7587. this._currentKey = key;
  7588. },
  7589. enumerable: false,
  7590. configurable: true
  7591. });
  7592. Object.defineProperty(InputText.prototype, "text", {
  7593. /** Gets or sets the text displayed in the control */
  7594. get: function () {
  7595. return this._textWrapper.text;
  7596. },
  7597. set: function (value) {
  7598. var valueAsString = value.toString(); // Forcing convertion
  7599. if (!this._textWrapper) {
  7600. this._textWrapper = new _textWrapper__WEBPACK_IMPORTED_MODULE_4__["TextWrapper"]();
  7601. }
  7602. if (this._textWrapper.text === valueAsString) {
  7603. return;
  7604. }
  7605. this._textWrapper.text = valueAsString;
  7606. this._textHasChanged();
  7607. },
  7608. enumerable: false,
  7609. configurable: true
  7610. });
  7611. InputText.prototype._textHasChanged = function () {
  7612. this._markAsDirty();
  7613. this.onTextChangedObservable.notifyObservers(this);
  7614. };
  7615. Object.defineProperty(InputText.prototype, "width", {
  7616. /** Gets or sets control width */
  7617. get: function () {
  7618. return this._width.toString(this._host);
  7619. },
  7620. set: function (value) {
  7621. if (this._width.toString(this._host) === value) {
  7622. return;
  7623. }
  7624. if (this._width.fromString(value)) {
  7625. this._markAsDirty();
  7626. }
  7627. this.autoStretchWidth = false;
  7628. },
  7629. enumerable: false,
  7630. configurable: true
  7631. });
  7632. /** @hidden */
  7633. InputText.prototype.onBlur = function () {
  7634. this._isFocused = false;
  7635. this._scrollLeft = null;
  7636. this._cursorOffset = 0;
  7637. clearTimeout(this._blinkTimeout);
  7638. this._markAsDirty();
  7639. this.onBlurObservable.notifyObservers(this);
  7640. this._host.unRegisterClipboardEvents();
  7641. if (this._onClipboardObserver) {
  7642. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7643. }
  7644. var scene = this._host.getScene();
  7645. if (this._onPointerDblTapObserver && scene) {
  7646. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7647. }
  7648. };
  7649. /** @hidden */
  7650. InputText.prototype.onFocus = function () {
  7651. var _this = this;
  7652. if (!this._isEnabled) {
  7653. return;
  7654. }
  7655. this._scrollLeft = null;
  7656. this._isFocused = true;
  7657. this._blinkIsEven = false;
  7658. this._cursorOffset = 0;
  7659. this._markAsDirty();
  7660. this.onFocusObservable.notifyObservers(this);
  7661. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7662. var value = prompt(this.promptMessage);
  7663. if (value !== null) {
  7664. this.text = value;
  7665. }
  7666. this._host.focusedControl = null;
  7667. return;
  7668. }
  7669. this._host.registerClipboardEvents();
  7670. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7671. // process clipboard event, can be configured.
  7672. switch (clipboardInfo.type) {
  7673. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7674. _this._onCopyText(clipboardInfo.event);
  7675. _this.onTextCopyObservable.notifyObservers(_this);
  7676. break;
  7677. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7678. _this._onCutText(clipboardInfo.event);
  7679. _this.onTextCutObservable.notifyObservers(_this);
  7680. break;
  7681. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7682. _this._onPasteText(clipboardInfo.event);
  7683. _this.onTextPasteObservable.notifyObservers(_this);
  7684. break;
  7685. default: return;
  7686. }
  7687. });
  7688. var scene = this._host.getScene();
  7689. if (scene) {
  7690. //register the pointer double tap event
  7691. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7692. if (!_this._isFocused) {
  7693. return;
  7694. }
  7695. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7696. _this._processDblClick(pointerInfo);
  7697. }
  7698. });
  7699. }
  7700. if (this._onFocusSelectAll) {
  7701. this._selectAllText();
  7702. }
  7703. };
  7704. InputText.prototype._getTypeName = function () {
  7705. return "InputText";
  7706. };
  7707. /**
  7708. * Function called to get the list of controls that should not steal the focus from this control
  7709. * @returns an array of controls
  7710. */
  7711. InputText.prototype.keepsFocusWith = function () {
  7712. if (!this._connectedVirtualKeyboard) {
  7713. return null;
  7714. }
  7715. return [this._connectedVirtualKeyboard];
  7716. };
  7717. /** @hidden */
  7718. InputText.prototype.processKey = function (keyCode, key, evt) {
  7719. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7720. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7721. return;
  7722. }
  7723. //select all
  7724. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7725. this._selectAllText();
  7726. evt.preventDefault();
  7727. return;
  7728. }
  7729. // Specific cases
  7730. switch (keyCode) {
  7731. case 32: //SPACE
  7732. key = " "; //ie11 key for space is "Spacebar"
  7733. break;
  7734. case 191: //SLASH
  7735. if (evt) {
  7736. evt.preventDefault();
  7737. }
  7738. break;
  7739. case 8: // BACKSPACE
  7740. if (this._textWrapper.text && this._textWrapper.length > 0) {
  7741. //delete the highlighted text
  7742. if (this._isTextHighlightOn) {
  7743. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  7744. this._textHasChanged();
  7745. this._isTextHighlightOn = false;
  7746. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  7747. this._blinkIsEven = false;
  7748. if (evt) {
  7749. evt.preventDefault();
  7750. }
  7751. return;
  7752. }
  7753. //delete single character
  7754. if (this._cursorOffset === 0) {
  7755. this.text = this._textWrapper.substr(0, this._textWrapper.length - 1);
  7756. }
  7757. else {
  7758. var deletePosition = this._textWrapper.length - this._cursorOffset;
  7759. if (deletePosition > 0) {
  7760. this._textWrapper.removePart(deletePosition - 1, deletePosition);
  7761. this._textHasChanged();
  7762. }
  7763. }
  7764. }
  7765. if (evt) {
  7766. evt.preventDefault();
  7767. }
  7768. return;
  7769. case 46: // DELETE
  7770. if (this._isTextHighlightOn) {
  7771. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  7772. this._textHasChanged();
  7773. this._isTextHighlightOn = false;
  7774. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  7775. if (evt) {
  7776. evt.preventDefault();
  7777. }
  7778. return;
  7779. }
  7780. if (this._textWrapper.text && this._textWrapper.length > 0 && this._cursorOffset > 0) {
  7781. var deletePosition = this._textWrapper.length - this._cursorOffset;
  7782. this._textWrapper.removePart(deletePosition, deletePosition + 1);
  7783. this._textHasChanged();
  7784. this._cursorOffset--;
  7785. }
  7786. if (evt) {
  7787. evt.preventDefault();
  7788. }
  7789. return;
  7790. case 13: // RETURN
  7791. this._host.focusedControl = null;
  7792. this._isTextHighlightOn = false;
  7793. return;
  7794. case 35: // END
  7795. this._cursorOffset = 0;
  7796. this._blinkIsEven = false;
  7797. this._isTextHighlightOn = false;
  7798. this._markAsDirty();
  7799. return;
  7800. case 36: // HOME
  7801. this._cursorOffset = this._textWrapper.length;
  7802. this._blinkIsEven = false;
  7803. this._isTextHighlightOn = false;
  7804. this._markAsDirty();
  7805. return;
  7806. case 37: // LEFT
  7807. this._cursorOffset++;
  7808. if (this._cursorOffset > this._textWrapper.length) {
  7809. this._cursorOffset = this._textWrapper.length;
  7810. }
  7811. if (evt && evt.shiftKey) {
  7812. // update the cursor
  7813. this._blinkIsEven = false;
  7814. // shift + ctrl/cmd + <-
  7815. if (evt.ctrlKey || evt.metaKey) {
  7816. if (!this._isTextHighlightOn) {
  7817. if (this._textWrapper.length === this._cursorOffset) {
  7818. return;
  7819. }
  7820. else {
  7821. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset + 1;
  7822. }
  7823. }
  7824. this._startHighlightIndex = 0;
  7825. this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
  7826. this._cursorOffset = this._textWrapper.length;
  7827. this._isTextHighlightOn = true;
  7828. this._markAsDirty();
  7829. return;
  7830. }
  7831. //store the starting point
  7832. if (!this._isTextHighlightOn) {
  7833. this._isTextHighlightOn = true;
  7834. this._cursorIndex = (this._cursorOffset >= this._textWrapper.length) ? this._textWrapper.length : this._cursorOffset - 1;
  7835. }
  7836. //if text is already highlighted
  7837. else if (this._cursorIndex === -1) {
  7838. this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
  7839. this._cursorOffset = (this._startHighlightIndex === 0) ? this._textWrapper.length : this._textWrapper.length - this._startHighlightIndex + 1;
  7840. }
  7841. //set the highlight indexes
  7842. if (this._cursorIndex < this._cursorOffset) {
  7843. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  7844. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  7845. }
  7846. else if (this._cursorIndex > this._cursorOffset) {
  7847. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  7848. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  7849. }
  7850. else {
  7851. this._isTextHighlightOn = false;
  7852. }
  7853. this._markAsDirty();
  7854. return;
  7855. }
  7856. if (this._isTextHighlightOn) {
  7857. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  7858. this._isTextHighlightOn = false;
  7859. }
  7860. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7861. this._cursorOffset = this._textWrapper.length;
  7862. evt.preventDefault();
  7863. }
  7864. this._blinkIsEven = false;
  7865. this._isTextHighlightOn = false;
  7866. this._cursorIndex = -1;
  7867. this._markAsDirty();
  7868. return;
  7869. case 39: // RIGHT
  7870. this._cursorOffset--;
  7871. if (this._cursorOffset < 0) {
  7872. this._cursorOffset = 0;
  7873. }
  7874. if (evt && evt.shiftKey) {
  7875. //update the cursor
  7876. this._blinkIsEven = false;
  7877. //shift + ctrl/cmd + ->
  7878. if (evt.ctrlKey || evt.metaKey) {
  7879. if (!this._isTextHighlightOn) {
  7880. if (this._cursorOffset === 0) {
  7881. return;
  7882. }
  7883. else {
  7884. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset - 1;
  7885. }
  7886. }
  7887. this._endHighlightIndex = this._textWrapper.length;
  7888. this._isTextHighlightOn = true;
  7889. this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
  7890. this._cursorOffset = 0;
  7891. this._markAsDirty();
  7892. return;
  7893. }
  7894. if (!this._isTextHighlightOn) {
  7895. this._isTextHighlightOn = true;
  7896. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7897. }
  7898. //if text is already highlighted
  7899. else if (this._cursorIndex === -1) {
  7900. this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
  7901. this._cursorOffset = (this._textWrapper.length === this._endHighlightIndex) ? 0 : this._textWrapper.length - this._endHighlightIndex - 1;
  7902. }
  7903. //set the highlight indexes
  7904. if (this._cursorIndex < this._cursorOffset) {
  7905. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  7906. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  7907. }
  7908. else if (this._cursorIndex > this._cursorOffset) {
  7909. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  7910. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  7911. }
  7912. else {
  7913. this._isTextHighlightOn = false;
  7914. }
  7915. this._markAsDirty();
  7916. return;
  7917. }
  7918. if (this._isTextHighlightOn) {
  7919. this._cursorOffset = this._textWrapper.length - this._endHighlightIndex;
  7920. this._isTextHighlightOn = false;
  7921. }
  7922. //ctr + ->
  7923. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7924. this._cursorOffset = 0;
  7925. evt.preventDefault();
  7926. }
  7927. this._blinkIsEven = false;
  7928. this._isTextHighlightOn = false;
  7929. this._cursorIndex = -1;
  7930. this._markAsDirty();
  7931. return;
  7932. case 222: // Dead
  7933. if (evt) {
  7934. evt.preventDefault();
  7935. }
  7936. this._cursorIndex = -1;
  7937. this.deadKey = true;
  7938. break;
  7939. }
  7940. // Printable characters
  7941. if (key &&
  7942. ((keyCode === -1) || // Direct access
  7943. (keyCode === 32) || // Space
  7944. (keyCode > 47 && keyCode < 64) || // Numbers
  7945. (keyCode > 64 && keyCode < 91) || // Letters
  7946. (keyCode > 159 && keyCode < 193) || // Special characters
  7947. (keyCode > 218 && keyCode < 223) || // Special characters
  7948. (keyCode > 95 && keyCode < 112))) { // Numpad
  7949. this._currentKey = key;
  7950. this.onBeforeKeyAddObservable.notifyObservers(this);
  7951. key = this._currentKey;
  7952. if (this._addKey) {
  7953. if (this._isTextHighlightOn) {
  7954. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex, key);
  7955. this._textHasChanged();
  7956. this._cursorOffset = this._textWrapper.length - (this._startHighlightIndex + 1);
  7957. this._isTextHighlightOn = false;
  7958. this._blinkIsEven = false;
  7959. this._markAsDirty();
  7960. }
  7961. else if (this._cursorOffset === 0) {
  7962. this.text += key;
  7963. }
  7964. else {
  7965. var insertPosition = this._textWrapper.length - this._cursorOffset;
  7966. this._textWrapper.removePart(insertPosition, insertPosition, key);
  7967. this._textHasChanged();
  7968. }
  7969. }
  7970. }
  7971. };
  7972. /** @hidden */
  7973. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7974. //update the cursor
  7975. this._blinkIsEven = false;
  7976. if (this._cursorIndex === -1) {
  7977. this._cursorIndex = offset;
  7978. }
  7979. else {
  7980. if (this._cursorIndex < this._cursorOffset) {
  7981. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  7982. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  7983. }
  7984. else if (this._cursorIndex > this._cursorOffset) {
  7985. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  7986. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  7987. }
  7988. else {
  7989. this._isTextHighlightOn = false;
  7990. this._markAsDirty();
  7991. return;
  7992. }
  7993. }
  7994. this._isTextHighlightOn = true;
  7995. this._markAsDirty();
  7996. };
  7997. /** @hidden */
  7998. InputText.prototype._processDblClick = function (evt) {
  7999. //pre-find the start and end index of the word under cursor, speeds up the rendering
  8000. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8001. this._endHighlightIndex = this._startHighlightIndex;
  8002. var moveLeft, moveRight;
  8003. do {
  8004. moveRight = this._endHighlightIndex < this._textWrapper.length && this._textWrapper.isWord(this._endHighlightIndex) ? ++this._endHighlightIndex : 0;
  8005. moveLeft = this._startHighlightIndex > 0 && this._textWrapper.isWord(this._startHighlightIndex - 1) ? --this._startHighlightIndex : 0;
  8006. } while (moveLeft || moveRight);
  8007. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8008. this.onTextHighlightObservable.notifyObservers(this);
  8009. this._isTextHighlightOn = true;
  8010. this._clickedCoordinate = null;
  8011. this._blinkIsEven = true;
  8012. this._cursorIndex = -1;
  8013. this._markAsDirty();
  8014. };
  8015. /** @hidden */
  8016. InputText.prototype._selectAllText = function () {
  8017. this._blinkIsEven = true;
  8018. this._isTextHighlightOn = true;
  8019. this._startHighlightIndex = 0;
  8020. this._endHighlightIndex = this._textWrapper.length;
  8021. this._cursorOffset = this._textWrapper.length;
  8022. this._cursorIndex = -1;
  8023. this._markAsDirty();
  8024. };
  8025. /**
  8026. * Handles the keyboard event
  8027. * @param evt Defines the KeyboardEvent
  8028. */
  8029. InputText.prototype.processKeyboard = function (evt) {
  8030. // process pressed key
  8031. this.processKey(evt.keyCode, evt.key, evt);
  8032. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  8033. };
  8034. /** @hidden */
  8035. InputText.prototype._onCopyText = function (ev) {
  8036. this._isTextHighlightOn = false;
  8037. //when write permission to clipbaord data is denied
  8038. try {
  8039. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8040. }
  8041. catch (_a) { } //pass
  8042. this._host.clipboardData = this._highlightedText;
  8043. };
  8044. /** @hidden */
  8045. InputText.prototype._onCutText = function (ev) {
  8046. if (!this._highlightedText) {
  8047. return;
  8048. }
  8049. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  8050. this._textHasChanged();
  8051. this._isTextHighlightOn = false;
  8052. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8053. //when write permission to clipbaord data is denied
  8054. try {
  8055. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8056. }
  8057. catch (_a) { } //pass
  8058. this._host.clipboardData = this._highlightedText;
  8059. this._highlightedText = "";
  8060. };
  8061. /** @hidden */
  8062. InputText.prototype._onPasteText = function (ev) {
  8063. var data = "";
  8064. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  8065. data = ev.clipboardData.getData("text/plain");
  8066. }
  8067. else {
  8068. //get the cached data; returns blank string by default
  8069. data = this._host.clipboardData;
  8070. }
  8071. var insertPosition = this._textWrapper.length - this._cursorOffset;
  8072. this._textWrapper.removePart(insertPosition, insertPosition, data);
  8073. this._textHasChanged();
  8074. };
  8075. InputText.prototype._draw = function (context, invalidatedRectangle) {
  8076. var _this = this;
  8077. context.save();
  8078. this._applyStates(context);
  8079. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8080. context.shadowColor = this.shadowColor;
  8081. context.shadowBlur = this.shadowBlur;
  8082. context.shadowOffsetX = this.shadowOffsetX;
  8083. context.shadowOffsetY = this.shadowOffsetY;
  8084. }
  8085. // Background
  8086. if (this._isFocused) {
  8087. if (this._focusedBackground) {
  8088. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  8089. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8090. }
  8091. }
  8092. else if (this._background) {
  8093. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8094. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8095. }
  8096. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8097. context.shadowBlur = 0;
  8098. context.shadowOffsetX = 0;
  8099. context.shadowOffsetY = 0;
  8100. }
  8101. if (!this._fontOffset) {
  8102. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  8103. }
  8104. // Text
  8105. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  8106. if (this.color) {
  8107. context.fillStyle = this.color;
  8108. }
  8109. var text = this._beforeRenderText(this._textWrapper);
  8110. if (!this._isFocused && !this._textWrapper.text && this._placeholderText) {
  8111. text = new _textWrapper__WEBPACK_IMPORTED_MODULE_4__["TextWrapper"]();
  8112. text.text = this._placeholderText;
  8113. if (this._placeholderColor) {
  8114. context.fillStyle = this._placeholderColor;
  8115. }
  8116. }
  8117. this._textWidth = context.measureText(text.text).width;
  8118. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  8119. if (this._autoStretchWidth) {
  8120. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  8121. }
  8122. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  8123. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  8124. context.save();
  8125. context.beginPath();
  8126. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  8127. context.clip();
  8128. if (this._isFocused && this._textWidth > availableWidth) {
  8129. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  8130. if (!this._scrollLeft) {
  8131. this._scrollLeft = textLeft;
  8132. }
  8133. }
  8134. else {
  8135. this._scrollLeft = clipTextLeft;
  8136. }
  8137. context.fillText(text.text, this._scrollLeft, this._currentMeasure.top + rootY);
  8138. // Cursor
  8139. if (this._isFocused) {
  8140. // Need to move cursor
  8141. if (this._clickedCoordinate) {
  8142. var rightPosition = this._scrollLeft + this._textWidth;
  8143. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  8144. var currentSize = 0;
  8145. this._cursorOffset = 0;
  8146. var previousDist = 0;
  8147. do {
  8148. if (this._cursorOffset) {
  8149. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  8150. }
  8151. this._cursorOffset++;
  8152. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  8153. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  8154. // Find closest move
  8155. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8156. this._cursorOffset--;
  8157. }
  8158. this._blinkIsEven = false;
  8159. this._clickedCoordinate = null;
  8160. }
  8161. // Render cursor
  8162. if (!this._blinkIsEven) {
  8163. var cursorOffsetText = text.substr(text.length - this._cursorOffset);
  8164. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8165. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8166. if (cursorLeft < clipTextLeft) {
  8167. this._scrollLeft += (clipTextLeft - cursorLeft);
  8168. cursorLeft = clipTextLeft;
  8169. this._markAsDirty();
  8170. }
  8171. else if (cursorLeft > clipTextLeft + availableWidth) {
  8172. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8173. cursorLeft = clipTextLeft + availableWidth;
  8174. this._markAsDirty();
  8175. }
  8176. if (!this._isTextHighlightOn) {
  8177. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8178. }
  8179. }
  8180. clearTimeout(this._blinkTimeout);
  8181. this._blinkTimeout = setTimeout(function () {
  8182. _this._blinkIsEven = !_this._blinkIsEven;
  8183. _this._markAsDirty();
  8184. }, 500);
  8185. //show the highlighted text
  8186. if (this._isTextHighlightOn) {
  8187. clearTimeout(this._blinkTimeout);
  8188. var highlightCursorOffsetWidth = context.measureText(text.substring(this._startHighlightIndex)).width;
  8189. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8190. this._highlightedText = text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8191. var width = context.measureText(text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8192. if (highlightCursorLeft < clipTextLeft) {
  8193. width = width - (clipTextLeft - highlightCursorLeft);
  8194. if (!width) {
  8195. // when using left arrow on text.length > availableWidth;
  8196. // assigns the width of the first letter after clipTextLeft
  8197. width = context.measureText(text.charAt(text.length - this._cursorOffset)).width;
  8198. }
  8199. highlightCursorLeft = clipTextLeft;
  8200. }
  8201. //for transparancy
  8202. context.globalAlpha = this._highligherOpacity;
  8203. context.fillStyle = this._textHighlightColor;
  8204. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8205. context.globalAlpha = 1.0;
  8206. }
  8207. }
  8208. context.restore();
  8209. // Border
  8210. if (this._thickness) {
  8211. if (this._isFocused) {
  8212. if (this.focusedColor) {
  8213. context.strokeStyle = this.focusedColor;
  8214. }
  8215. }
  8216. else {
  8217. if (this.color) {
  8218. context.strokeStyle = this.color;
  8219. }
  8220. }
  8221. context.lineWidth = this._thickness;
  8222. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8223. }
  8224. context.restore();
  8225. };
  8226. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  8227. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  8228. return false;
  8229. }
  8230. this._clickedCoordinate = coordinates.x;
  8231. this._isTextHighlightOn = false;
  8232. this._highlightedText = "";
  8233. this._cursorIndex = -1;
  8234. this._isPointerDown = true;
  8235. this._host._capturingControl[pointerId] = this;
  8236. if (this._host.focusedControl === this) {
  8237. // Move cursor
  8238. clearTimeout(this._blinkTimeout);
  8239. this._markAsDirty();
  8240. return true;
  8241. }
  8242. if (!this._isEnabled) {
  8243. return false;
  8244. }
  8245. this._host.focusedControl = this;
  8246. return true;
  8247. };
  8248. InputText.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  8249. if (this._host.focusedControl === this && this._isPointerDown) {
  8250. this._clickedCoordinate = coordinates.x;
  8251. this._markAsDirty();
  8252. this._updateValueFromCursorIndex(this._cursorOffset);
  8253. }
  8254. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  8255. };
  8256. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8257. this._isPointerDown = false;
  8258. delete this._host._capturingControl[pointerId];
  8259. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8260. };
  8261. InputText.prototype._beforeRenderText = function (textWrapper) {
  8262. return textWrapper;
  8263. };
  8264. InputText.prototype.dispose = function () {
  8265. _super.prototype.dispose.call(this);
  8266. this.onBlurObservable.clear();
  8267. this.onFocusObservable.clear();
  8268. this.onTextChangedObservable.clear();
  8269. this.onTextCopyObservable.clear();
  8270. this.onTextCutObservable.clear();
  8271. this.onTextPasteObservable.clear();
  8272. this.onTextHighlightObservable.clear();
  8273. this.onKeyboardEventProcessedObservable.clear();
  8274. };
  8275. return InputText;
  8276. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8277. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8278. /***/ }),
  8279. /***/ "./2D/controls/line.ts":
  8280. /*!*****************************!*\
  8281. !*** ./2D/controls/line.ts ***!
  8282. \*****************************/
  8283. /*! exports provided: Line */
  8284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8285. "use strict";
  8286. __webpack_require__.r(__webpack_exports__);
  8287. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8288. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8289. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  8290. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8291. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8292. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8293. /** Class used to render 2D lines */
  8294. var Line = /** @class */ (function (_super) {
  8295. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8296. /**
  8297. * Creates a new Line
  8298. * @param name defines the control name
  8299. */
  8300. function Line(name) {
  8301. var _this = _super.call(this, name) || this;
  8302. _this.name = name;
  8303. _this._lineWidth = 1;
  8304. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8305. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8306. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8307. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8308. _this._dash = new Array();
  8309. _this._automaticSize = true;
  8310. _this.isHitTestVisible = false;
  8311. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8312. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8313. return _this;
  8314. }
  8315. Object.defineProperty(Line.prototype, "dash", {
  8316. /** Gets or sets the dash pattern */
  8317. get: function () {
  8318. return this._dash;
  8319. },
  8320. set: function (value) {
  8321. if (this._dash === value) {
  8322. return;
  8323. }
  8324. this._dash = value;
  8325. this._markAsDirty();
  8326. },
  8327. enumerable: false,
  8328. configurable: true
  8329. });
  8330. Object.defineProperty(Line.prototype, "connectedControl", {
  8331. /** Gets or sets the control connected with the line end */
  8332. get: function () {
  8333. return this._connectedControl;
  8334. },
  8335. set: function (value) {
  8336. var _this = this;
  8337. if (this._connectedControl === value) {
  8338. return;
  8339. }
  8340. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8341. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8342. this._connectedControlDirtyObserver = null;
  8343. }
  8344. if (value) {
  8345. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8346. }
  8347. this._connectedControl = value;
  8348. this._markAsDirty();
  8349. },
  8350. enumerable: false,
  8351. configurable: true
  8352. });
  8353. Object.defineProperty(Line.prototype, "x1", {
  8354. /** Gets or sets start coordinates on X axis */
  8355. get: function () {
  8356. return this._x1.toString(this._host);
  8357. },
  8358. set: function (value) {
  8359. if (this._x1.toString(this._host) === value) {
  8360. return;
  8361. }
  8362. if (this._x1.fromString(value)) {
  8363. this._markAsDirty();
  8364. }
  8365. },
  8366. enumerable: false,
  8367. configurable: true
  8368. });
  8369. Object.defineProperty(Line.prototype, "y1", {
  8370. /** Gets or sets start coordinates on Y axis */
  8371. get: function () {
  8372. return this._y1.toString(this._host);
  8373. },
  8374. set: function (value) {
  8375. if (this._y1.toString(this._host) === value) {
  8376. return;
  8377. }
  8378. if (this._y1.fromString(value)) {
  8379. this._markAsDirty();
  8380. }
  8381. },
  8382. enumerable: false,
  8383. configurable: true
  8384. });
  8385. Object.defineProperty(Line.prototype, "x2", {
  8386. /** Gets or sets end coordinates on X axis */
  8387. get: function () {
  8388. return this._x2.toString(this._host);
  8389. },
  8390. set: function (value) {
  8391. if (this._x2.toString(this._host) === value) {
  8392. return;
  8393. }
  8394. if (this._x2.fromString(value)) {
  8395. this._markAsDirty();
  8396. }
  8397. },
  8398. enumerable: false,
  8399. configurable: true
  8400. });
  8401. Object.defineProperty(Line.prototype, "y2", {
  8402. /** Gets or sets end coordinates on Y axis */
  8403. get: function () {
  8404. return this._y2.toString(this._host);
  8405. },
  8406. set: function (value) {
  8407. if (this._y2.toString(this._host) === value) {
  8408. return;
  8409. }
  8410. if (this._y2.fromString(value)) {
  8411. this._markAsDirty();
  8412. }
  8413. },
  8414. enumerable: false,
  8415. configurable: true
  8416. });
  8417. Object.defineProperty(Line.prototype, "lineWidth", {
  8418. /** Gets or sets line width */
  8419. get: function () {
  8420. return this._lineWidth;
  8421. },
  8422. set: function (value) {
  8423. if (this._lineWidth === value) {
  8424. return;
  8425. }
  8426. this._lineWidth = value;
  8427. this._markAsDirty();
  8428. },
  8429. enumerable: false,
  8430. configurable: true
  8431. });
  8432. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8433. /** Gets or sets horizontal alignment */
  8434. set: function (value) {
  8435. return;
  8436. },
  8437. enumerable: false,
  8438. configurable: true
  8439. });
  8440. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8441. /** Gets or sets vertical alignment */
  8442. set: function (value) {
  8443. return;
  8444. },
  8445. enumerable: false,
  8446. configurable: true
  8447. });
  8448. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8449. get: function () {
  8450. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8451. },
  8452. enumerable: false,
  8453. configurable: true
  8454. });
  8455. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8456. get: function () {
  8457. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8458. },
  8459. enumerable: false,
  8460. configurable: true
  8461. });
  8462. Line.prototype._getTypeName = function () {
  8463. return "Line";
  8464. };
  8465. Line.prototype._draw = function (context) {
  8466. context.save();
  8467. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8468. context.shadowColor = this.shadowColor;
  8469. context.shadowBlur = this.shadowBlur;
  8470. context.shadowOffsetX = this.shadowOffsetX;
  8471. context.shadowOffsetY = this.shadowOffsetY;
  8472. }
  8473. this._applyStates(context);
  8474. context.strokeStyle = this.color;
  8475. context.lineWidth = this._lineWidth;
  8476. context.setLineDash(this._dash);
  8477. context.beginPath();
  8478. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8479. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8480. context.stroke();
  8481. context.restore();
  8482. };
  8483. Line.prototype._measure = function () {
  8484. // Width / Height
  8485. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8486. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8487. };
  8488. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8489. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8490. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8491. };
  8492. /**
  8493. * Move one end of the line given 3D cartesian coordinates.
  8494. * @param position Targeted world position
  8495. * @param scene Scene
  8496. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8497. */
  8498. Line.prototype.moveToVector3 = function (position, scene, end) {
  8499. if (end === void 0) { end = false; }
  8500. if (!this._host || this.parent !== this._host._rootContainer) {
  8501. 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");
  8502. return;
  8503. }
  8504. var globalViewport = this._host._getGlobalViewport(scene);
  8505. 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);
  8506. this._moveToProjectedPosition(projectedPosition, end);
  8507. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8508. this.notRenderable = true;
  8509. return;
  8510. }
  8511. this.notRenderable = false;
  8512. };
  8513. /**
  8514. * Move one end of the line to a position in screen absolute space.
  8515. * @param projectedPosition Position in screen absolute space (X, Y)
  8516. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8517. */
  8518. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8519. if (end === void 0) { end = false; }
  8520. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8521. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8522. if (end) {
  8523. this.x2 = x;
  8524. this.y2 = y;
  8525. this._x2.ignoreAdaptiveScaling = true;
  8526. this._y2.ignoreAdaptiveScaling = true;
  8527. }
  8528. else {
  8529. this.x1 = x;
  8530. this.y1 = y;
  8531. this._x1.ignoreAdaptiveScaling = true;
  8532. this._y1.ignoreAdaptiveScaling = true;
  8533. }
  8534. };
  8535. return Line;
  8536. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8537. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8538. /***/ }),
  8539. /***/ "./2D/controls/multiLine.ts":
  8540. /*!**********************************!*\
  8541. !*** ./2D/controls/multiLine.ts ***!
  8542. \**********************************/
  8543. /*! exports provided: MultiLine */
  8544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8545. "use strict";
  8546. __webpack_require__.r(__webpack_exports__);
  8547. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8548. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8549. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  8550. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8551. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8552. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8553. /**
  8554. * Class used to create multi line control
  8555. */
  8556. var MultiLine = /** @class */ (function (_super) {
  8557. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8558. /**
  8559. * Creates a new MultiLine
  8560. * @param name defines the control name
  8561. */
  8562. function MultiLine(name) {
  8563. var _this = _super.call(this, name) || this;
  8564. _this.name = name;
  8565. _this._lineWidth = 1;
  8566. /** Function called when a point is updated */
  8567. _this.onPointUpdate = function () {
  8568. _this._markAsDirty();
  8569. };
  8570. _this._automaticSize = true;
  8571. _this.isHitTestVisible = false;
  8572. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8573. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8574. _this._dash = [];
  8575. _this._points = [];
  8576. return _this;
  8577. }
  8578. Object.defineProperty(MultiLine.prototype, "dash", {
  8579. /** Gets or sets dash pattern */
  8580. get: function () {
  8581. return this._dash;
  8582. },
  8583. set: function (value) {
  8584. if (this._dash === value) {
  8585. return;
  8586. }
  8587. this._dash = value;
  8588. this._markAsDirty();
  8589. },
  8590. enumerable: false,
  8591. configurable: true
  8592. });
  8593. /**
  8594. * Gets point stored at specified index
  8595. * @param index defines the index to look for
  8596. * @returns the requested point if found
  8597. */
  8598. MultiLine.prototype.getAt = function (index) {
  8599. if (!this._points[index]) {
  8600. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8601. }
  8602. return this._points[index];
  8603. };
  8604. /**
  8605. * Adds new points to the point collection
  8606. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8607. * @returns the list of created MultiLinePoint
  8608. */
  8609. MultiLine.prototype.add = function () {
  8610. var _this = this;
  8611. var items = [];
  8612. for (var _i = 0; _i < arguments.length; _i++) {
  8613. items[_i] = arguments[_i];
  8614. }
  8615. return items.map(function (item) { return _this.push(item); });
  8616. };
  8617. /**
  8618. * Adds a new point to the point collection
  8619. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8620. * @returns the created MultiLinePoint
  8621. */
  8622. MultiLine.prototype.push = function (item) {
  8623. var point = this.getAt(this._points.length);
  8624. if (item == null) {
  8625. return point;
  8626. }
  8627. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8628. point.mesh = item;
  8629. }
  8630. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8631. point.control = item;
  8632. }
  8633. else if (item.x != null && item.y != null) {
  8634. point.x = item.x;
  8635. point.y = item.y;
  8636. }
  8637. return point;
  8638. };
  8639. /**
  8640. * Remove a specific value or point from the active point collection
  8641. * @param value defines the value or point to remove
  8642. */
  8643. MultiLine.prototype.remove = function (value) {
  8644. var index;
  8645. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8646. index = this._points.indexOf(value);
  8647. if (index === -1) {
  8648. return;
  8649. }
  8650. }
  8651. else {
  8652. index = value;
  8653. }
  8654. var point = this._points[index];
  8655. if (!point) {
  8656. return;
  8657. }
  8658. point.dispose();
  8659. this._points.splice(index, 1);
  8660. };
  8661. /**
  8662. * Resets this object to initial state (no point)
  8663. */
  8664. MultiLine.prototype.reset = function () {
  8665. while (this._points.length > 0) {
  8666. this.remove(this._points.length - 1);
  8667. }
  8668. };
  8669. /**
  8670. * Resets all links
  8671. */
  8672. MultiLine.prototype.resetLinks = function () {
  8673. this._points.forEach(function (point) {
  8674. if (point != null) {
  8675. point.resetLinks();
  8676. }
  8677. });
  8678. };
  8679. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8680. /** Gets or sets line width */
  8681. get: function () {
  8682. return this._lineWidth;
  8683. },
  8684. set: function (value) {
  8685. if (this._lineWidth === value) {
  8686. return;
  8687. }
  8688. this._lineWidth = value;
  8689. this._markAsDirty();
  8690. },
  8691. enumerable: false,
  8692. configurable: true
  8693. });
  8694. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8695. set: function (value) {
  8696. return;
  8697. },
  8698. enumerable: false,
  8699. configurable: true
  8700. });
  8701. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8702. set: function (value) {
  8703. return;
  8704. },
  8705. enumerable: false,
  8706. configurable: true
  8707. });
  8708. MultiLine.prototype._getTypeName = function () {
  8709. return "MultiLine";
  8710. };
  8711. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8712. context.save();
  8713. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8714. context.shadowColor = this.shadowColor;
  8715. context.shadowBlur = this.shadowBlur;
  8716. context.shadowOffsetX = this.shadowOffsetX;
  8717. context.shadowOffsetY = this.shadowOffsetY;
  8718. }
  8719. this._applyStates(context);
  8720. context.strokeStyle = this.color;
  8721. context.lineWidth = this._lineWidth;
  8722. context.setLineDash(this._dash);
  8723. context.beginPath();
  8724. var first = true; //first index is not necessarily 0
  8725. var previousPoint;
  8726. this._points.forEach(function (point) {
  8727. if (!point) {
  8728. return;
  8729. }
  8730. if (first) {
  8731. context.moveTo(point._point.x, point._point.y);
  8732. first = false;
  8733. }
  8734. else {
  8735. if (point._point.z < 1 && previousPoint.z < 1) {
  8736. context.lineTo(point._point.x, point._point.y);
  8737. }
  8738. else {
  8739. context.moveTo(point._point.x, point._point.y);
  8740. }
  8741. }
  8742. previousPoint = point._point;
  8743. });
  8744. context.stroke();
  8745. context.restore();
  8746. };
  8747. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8748. var _this = this;
  8749. this._minX = null;
  8750. this._minY = null;
  8751. this._maxX = null;
  8752. this._maxY = null;
  8753. this._points.forEach(function (point, index) {
  8754. if (!point) {
  8755. return;
  8756. }
  8757. point.translate();
  8758. if (_this._minX == null || point._point.x < _this._minX) {
  8759. _this._minX = point._point.x;
  8760. }
  8761. if (_this._minY == null || point._point.y < _this._minY) {
  8762. _this._minY = point._point.y;
  8763. }
  8764. if (_this._maxX == null || point._point.x > _this._maxX) {
  8765. _this._maxX = point._point.x;
  8766. }
  8767. if (_this._maxY == null || point._point.y > _this._maxY) {
  8768. _this._maxY = point._point.y;
  8769. }
  8770. });
  8771. if (this._minX == null) {
  8772. this._minX = 0;
  8773. }
  8774. if (this._minY == null) {
  8775. this._minY = 0;
  8776. }
  8777. if (this._maxX == null) {
  8778. this._maxX = 0;
  8779. }
  8780. if (this._maxY == null) {
  8781. this._maxY = 0;
  8782. }
  8783. };
  8784. MultiLine.prototype._measure = function () {
  8785. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8786. return;
  8787. }
  8788. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8789. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8790. };
  8791. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8792. if (this._minX == null || this._minY == null) {
  8793. return;
  8794. }
  8795. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8796. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8797. };
  8798. MultiLine.prototype.dispose = function () {
  8799. this.reset();
  8800. _super.prototype.dispose.call(this);
  8801. };
  8802. return MultiLine;
  8803. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8804. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8805. /***/ }),
  8806. /***/ "./2D/controls/radioButton.ts":
  8807. /*!************************************!*\
  8808. !*** ./2D/controls/radioButton.ts ***!
  8809. \************************************/
  8810. /*! exports provided: RadioButton */
  8811. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8812. "use strict";
  8813. __webpack_require__.r(__webpack_exports__);
  8814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8815. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8816. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  8817. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8818. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8819. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8820. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8821. /**
  8822. * Class used to create radio button controls
  8823. */
  8824. var RadioButton = /** @class */ (function (_super) {
  8825. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8826. /**
  8827. * Creates a new RadioButton
  8828. * @param name defines the control name
  8829. */
  8830. function RadioButton(name) {
  8831. var _this = _super.call(this, name) || this;
  8832. _this.name = name;
  8833. _this._isChecked = false;
  8834. _this._background = "black";
  8835. _this._checkSizeRatio = 0.8;
  8836. _this._thickness = 1;
  8837. /** Gets or sets group name */
  8838. _this.group = "";
  8839. /** Observable raised when isChecked is changed */
  8840. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8841. _this.isPointerBlocker = true;
  8842. return _this;
  8843. }
  8844. Object.defineProperty(RadioButton.prototype, "thickness", {
  8845. /** Gets or sets border thickness */
  8846. get: function () {
  8847. return this._thickness;
  8848. },
  8849. set: function (value) {
  8850. if (this._thickness === value) {
  8851. return;
  8852. }
  8853. this._thickness = value;
  8854. this._markAsDirty();
  8855. },
  8856. enumerable: false,
  8857. configurable: true
  8858. });
  8859. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8860. /** Gets or sets a value indicating the ratio between overall size and check size */
  8861. get: function () {
  8862. return this._checkSizeRatio;
  8863. },
  8864. set: function (value) {
  8865. value = Math.max(Math.min(1, value), 0);
  8866. if (this._checkSizeRatio === value) {
  8867. return;
  8868. }
  8869. this._checkSizeRatio = value;
  8870. this._markAsDirty();
  8871. },
  8872. enumerable: false,
  8873. configurable: true
  8874. });
  8875. Object.defineProperty(RadioButton.prototype, "background", {
  8876. /** Gets or sets background color */
  8877. get: function () {
  8878. return this._background;
  8879. },
  8880. set: function (value) {
  8881. if (this._background === value) {
  8882. return;
  8883. }
  8884. this._background = value;
  8885. this._markAsDirty();
  8886. },
  8887. enumerable: false,
  8888. configurable: true
  8889. });
  8890. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8891. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8892. get: function () {
  8893. return this._isChecked;
  8894. },
  8895. set: function (value) {
  8896. var _this = this;
  8897. if (this._isChecked === value) {
  8898. return;
  8899. }
  8900. this._isChecked = value;
  8901. this._markAsDirty();
  8902. this.onIsCheckedChangedObservable.notifyObservers(value);
  8903. if (this._isChecked && this._host) {
  8904. // Update all controls from same group
  8905. this._host.executeOnAllControls(function (control) {
  8906. if (control === _this) {
  8907. return;
  8908. }
  8909. if (control.group === undefined) {
  8910. return;
  8911. }
  8912. var childRadio = control;
  8913. if (childRadio.group === _this.group) {
  8914. childRadio.isChecked = false;
  8915. }
  8916. });
  8917. }
  8918. },
  8919. enumerable: false,
  8920. configurable: true
  8921. });
  8922. RadioButton.prototype._getTypeName = function () {
  8923. return "RadioButton";
  8924. };
  8925. RadioButton.prototype._draw = function (context) {
  8926. context.save();
  8927. this._applyStates(context);
  8928. var actualWidth = this._currentMeasure.width - this._thickness;
  8929. var actualHeight = this._currentMeasure.height - this._thickness;
  8930. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8931. context.shadowColor = this.shadowColor;
  8932. context.shadowBlur = this.shadowBlur;
  8933. context.shadowOffsetX = this.shadowOffsetX;
  8934. context.shadowOffsetY = this.shadowOffsetY;
  8935. }
  8936. // Outer
  8937. _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);
  8938. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8939. context.fill();
  8940. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8941. context.shadowBlur = 0;
  8942. context.shadowOffsetX = 0;
  8943. context.shadowOffsetY = 0;
  8944. }
  8945. context.strokeStyle = this.color;
  8946. context.lineWidth = this._thickness;
  8947. context.stroke();
  8948. // Inner
  8949. if (this._isChecked) {
  8950. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8951. var offsetWidth = actualWidth * this._checkSizeRatio;
  8952. var offseHeight = actualHeight * this._checkSizeRatio;
  8953. _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);
  8954. context.fill();
  8955. }
  8956. context.restore();
  8957. };
  8958. // Events
  8959. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  8960. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  8961. return false;
  8962. }
  8963. if (!this.isChecked) {
  8964. this.isChecked = true;
  8965. }
  8966. return true;
  8967. };
  8968. /**
  8969. * Utility function to easily create a radio button with a header
  8970. * @param title defines the label to use for the header
  8971. * @param group defines the group to use for the radio button
  8972. * @param isChecked defines the initial state of the radio button
  8973. * @param onValueChanged defines the callback to call when value changes
  8974. * @returns a StackPanel containing the radio button and a textBlock
  8975. */
  8976. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8977. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8978. panel.isVertical = false;
  8979. panel.height = "30px";
  8980. var radio = new RadioButton();
  8981. radio.width = "20px";
  8982. radio.height = "20px";
  8983. radio.isChecked = isChecked;
  8984. radio.color = "green";
  8985. radio.group = group;
  8986. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8987. panel.addControl(radio);
  8988. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8989. header.text = title;
  8990. header.width = "180px";
  8991. header.paddingLeft = "5px";
  8992. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8993. header.color = "white";
  8994. panel.addControl(header);
  8995. return panel;
  8996. };
  8997. return RadioButton;
  8998. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8999. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  9000. /***/ }),
  9001. /***/ "./2D/controls/rectangle.ts":
  9002. /*!**********************************!*\
  9003. !*** ./2D/controls/rectangle.ts ***!
  9004. \**********************************/
  9005. /*! exports provided: Rectangle */
  9006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9007. "use strict";
  9008. __webpack_require__.r(__webpack_exports__);
  9009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  9010. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9011. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9012. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  9013. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  9014. /** Class used to create rectangle container */
  9015. var Rectangle = /** @class */ (function (_super) {
  9016. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  9017. /**
  9018. * Creates a new Rectangle
  9019. * @param name defines the control name
  9020. */
  9021. function Rectangle(name) {
  9022. var _this = _super.call(this, name) || this;
  9023. _this.name = name;
  9024. _this._thickness = 1;
  9025. _this._cornerRadius = 0;
  9026. return _this;
  9027. }
  9028. Object.defineProperty(Rectangle.prototype, "thickness", {
  9029. /** Gets or sets border thickness */
  9030. get: function () {
  9031. return this._thickness;
  9032. },
  9033. set: function (value) {
  9034. if (this._thickness === value) {
  9035. return;
  9036. }
  9037. this._thickness = value;
  9038. this._markAsDirty();
  9039. },
  9040. enumerable: false,
  9041. configurable: true
  9042. });
  9043. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  9044. /** Gets or sets the corner radius angle */
  9045. get: function () {
  9046. return this._cornerRadius;
  9047. },
  9048. set: function (value) {
  9049. if (value < 0) {
  9050. value = 0;
  9051. }
  9052. if (this._cornerRadius === value) {
  9053. return;
  9054. }
  9055. this._cornerRadius = value;
  9056. this._markAsDirty();
  9057. },
  9058. enumerable: false,
  9059. configurable: true
  9060. });
  9061. Rectangle.prototype._getTypeName = function () {
  9062. return "Rectangle";
  9063. };
  9064. Rectangle.prototype._localDraw = function (context) {
  9065. context.save();
  9066. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9067. context.shadowColor = this.shadowColor;
  9068. context.shadowBlur = this.shadowBlur;
  9069. context.shadowOffsetX = this.shadowOffsetX;
  9070. context.shadowOffsetY = this.shadowOffsetY;
  9071. }
  9072. if (this._background) {
  9073. context.fillStyle = this._background;
  9074. if (this._cornerRadius) {
  9075. this._drawRoundedRect(context, this._thickness / 2);
  9076. context.fill();
  9077. }
  9078. else {
  9079. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  9080. }
  9081. }
  9082. if (this._thickness) {
  9083. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9084. context.shadowBlur = 0;
  9085. context.shadowOffsetX = 0;
  9086. context.shadowOffsetY = 0;
  9087. }
  9088. if (this.color) {
  9089. context.strokeStyle = this.color;
  9090. }
  9091. context.lineWidth = this._thickness;
  9092. if (this._cornerRadius) {
  9093. this._drawRoundedRect(context, this._thickness / 2);
  9094. context.stroke();
  9095. }
  9096. else {
  9097. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  9098. }
  9099. }
  9100. context.restore();
  9101. };
  9102. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  9103. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9104. this._measureForChildren.width -= 2 * this._thickness;
  9105. this._measureForChildren.height -= 2 * this._thickness;
  9106. this._measureForChildren.left += this._thickness;
  9107. this._measureForChildren.top += this._thickness;
  9108. };
  9109. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  9110. if (offset === void 0) { offset = 0; }
  9111. var x = this._currentMeasure.left + offset;
  9112. var y = this._currentMeasure.top + offset;
  9113. var width = this._currentMeasure.width - offset * 2;
  9114. var height = this._currentMeasure.height - offset * 2;
  9115. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  9116. context.beginPath();
  9117. context.moveTo(x + radius, y);
  9118. context.lineTo(x + width - radius, y);
  9119. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  9120. context.lineTo(x + width, y + height - radius);
  9121. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  9122. context.lineTo(x + radius, y + height);
  9123. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  9124. context.lineTo(x, y + radius);
  9125. context.quadraticCurveTo(x, y, x + radius, y);
  9126. context.closePath();
  9127. };
  9128. Rectangle.prototype._clipForChildren = function (context) {
  9129. if (this._cornerRadius) {
  9130. this._drawRoundedRect(context, this._thickness);
  9131. context.clip();
  9132. }
  9133. };
  9134. return Rectangle;
  9135. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9136. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  9137. /***/ }),
  9138. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  9139. /*!***************************************************!*\
  9140. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  9141. \***************************************************/
  9142. /*! exports provided: ScrollViewer */
  9143. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9144. "use strict";
  9145. __webpack_require__.r(__webpack_exports__);
  9146. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  9147. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9148. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  9149. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  9150. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9151. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  9152. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  9153. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  9154. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  9155. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  9156. /**
  9157. * Class used to hold a viewer window and sliders in a grid
  9158. */
  9159. var ScrollViewer = /** @class */ (function (_super) {
  9160. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  9161. /**
  9162. * Creates a new ScrollViewer
  9163. * @param name of ScrollViewer
  9164. */
  9165. function ScrollViewer(name, isImageBased) {
  9166. var _this = _super.call(this, name) || this;
  9167. _this._barSize = 20;
  9168. _this._pointerIsOver = false;
  9169. _this._wheelPrecision = 0.05;
  9170. _this._thumbLength = 0.5;
  9171. _this._thumbHeight = 1;
  9172. _this._barImageHeight = 1;
  9173. _this._horizontalBarImageHeight = 1;
  9174. _this._verticalBarImageHeight = 1;
  9175. _this._oldWindowContentsWidth = 0;
  9176. _this._oldWindowContentsHeight = 0;
  9177. _this._forceHorizontalBar = false;
  9178. _this._forceVerticalBar = false;
  9179. _this._useImageBar = isImageBased ? isImageBased : false;
  9180. _this.onDirtyObservable.add(function () {
  9181. _this._horizontalBarSpace.color = _this.color;
  9182. _this._verticalBarSpace.color = _this.color;
  9183. _this._dragSpace.color = _this.color;
  9184. });
  9185. _this.onPointerEnterObservable.add(function () {
  9186. _this._pointerIsOver = true;
  9187. });
  9188. _this.onPointerOutObservable.add(function () {
  9189. _this._pointerIsOver = false;
  9190. });
  9191. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9192. if (_this._useImageBar) {
  9193. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9194. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9195. }
  9196. else {
  9197. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9198. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9199. }
  9200. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9201. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9202. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9203. _this._grid.addColumnDefinition(1);
  9204. _this._grid.addColumnDefinition(0, true);
  9205. _this._grid.addRowDefinition(1);
  9206. _this._grid.addRowDefinition(0, true);
  9207. _super.prototype.addControl.call(_this, _this._grid);
  9208. _this._grid.addControl(_this._window, 0, 0);
  9209. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9210. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9211. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9212. _this._verticalBarSpace.thickness = 1;
  9213. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9214. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9215. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9216. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9217. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9218. _this._horizontalBarSpace.thickness = 1;
  9219. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9220. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9221. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9222. _this._dragSpace.thickness = 1;
  9223. _this._grid.addControl(_this._dragSpace, 1, 1);
  9224. // Colors
  9225. if (!_this._useImageBar) {
  9226. _this.barColor = "grey";
  9227. _this.barBackground = "transparent";
  9228. }
  9229. return _this;
  9230. }
  9231. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9232. /**
  9233. * Gets the horizontal scrollbar
  9234. */
  9235. get: function () {
  9236. return this._horizontalBar;
  9237. },
  9238. enumerable: false,
  9239. configurable: true
  9240. });
  9241. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9242. /**
  9243. * Gets the vertical scrollbar
  9244. */
  9245. get: function () {
  9246. return this._verticalBar;
  9247. },
  9248. enumerable: false,
  9249. configurable: true
  9250. });
  9251. /**
  9252. * Adds a new control to the current container
  9253. * @param control defines the control to add
  9254. * @returns the current container
  9255. */
  9256. ScrollViewer.prototype.addControl = function (control) {
  9257. if (!control) {
  9258. return this;
  9259. }
  9260. this._window.addControl(control);
  9261. return this;
  9262. };
  9263. /**
  9264. * Removes a control from the current container
  9265. * @param control defines the control to remove
  9266. * @returns the current container
  9267. */
  9268. ScrollViewer.prototype.removeControl = function (control) {
  9269. this._window.removeControl(control);
  9270. return this;
  9271. };
  9272. Object.defineProperty(ScrollViewer.prototype, "children", {
  9273. /** Gets the list of children */
  9274. get: function () {
  9275. return this._window.children;
  9276. },
  9277. enumerable: false,
  9278. configurable: true
  9279. });
  9280. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9281. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9282. var child = _a[_i];
  9283. child._markMatrixAsDirty();
  9284. }
  9285. };
  9286. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9287. /**
  9288. * Freezes or unfreezes the controls in the window.
  9289. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9290. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9291. */
  9292. get: function () {
  9293. return this._window.freezeControls;
  9294. },
  9295. set: function (value) {
  9296. this._window.freezeControls = value;
  9297. },
  9298. enumerable: false,
  9299. configurable: true
  9300. });
  9301. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9302. /** Gets the bucket width */
  9303. get: function () {
  9304. return this._window.bucketWidth;
  9305. },
  9306. enumerable: false,
  9307. configurable: true
  9308. });
  9309. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9310. /** Gets the bucket height */
  9311. get: function () {
  9312. return this._window.bucketHeight;
  9313. },
  9314. enumerable: false,
  9315. configurable: true
  9316. });
  9317. /**
  9318. * Sets the bucket sizes.
  9319. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9320. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9321. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9322. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9323. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9324. * used), that's why it is not enabled by default.
  9325. * @param width width of the bucket
  9326. * @param height height of the bucket
  9327. */
  9328. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9329. this._window.setBucketSizes(width, height);
  9330. };
  9331. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9332. /**
  9333. * Forces the horizontal scroll bar to be displayed
  9334. */
  9335. get: function () {
  9336. return this._forceHorizontalBar;
  9337. },
  9338. set: function (value) {
  9339. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9340. this._horizontalBar.isVisible = value;
  9341. this._forceHorizontalBar = value;
  9342. },
  9343. enumerable: false,
  9344. configurable: true
  9345. });
  9346. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9347. /**
  9348. * Forces the vertical scroll bar to be displayed
  9349. */
  9350. get: function () {
  9351. return this._forceVerticalBar;
  9352. },
  9353. set: function (value) {
  9354. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9355. this._verticalBar.isVisible = value;
  9356. this._forceVerticalBar = value;
  9357. },
  9358. enumerable: false,
  9359. configurable: true
  9360. });
  9361. /** Reset the scroll viewer window to initial size */
  9362. ScrollViewer.prototype.resetWindow = function () {
  9363. this._window.width = "100%";
  9364. this._window.height = "100%";
  9365. };
  9366. ScrollViewer.prototype._getTypeName = function () {
  9367. return "ScrollViewer";
  9368. };
  9369. ScrollViewer.prototype._buildClientSizes = function () {
  9370. var ratio = this.host.idealRatio;
  9371. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9372. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9373. this._clientWidth = this._window.parentClientWidth;
  9374. this._clientHeight = this._window.parentClientHeight;
  9375. };
  9376. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9377. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9378. this._buildClientSizes();
  9379. };
  9380. ScrollViewer.prototype._postMeasure = function () {
  9381. _super.prototype._postMeasure.call(this);
  9382. this._updateScroller();
  9383. this._setWindowPosition(false);
  9384. };
  9385. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9386. /**
  9387. * Gets or sets the mouse wheel precision
  9388. * from 0 to 1 with a default value of 0.05
  9389. * */
  9390. get: function () {
  9391. return this._wheelPrecision;
  9392. },
  9393. set: function (value) {
  9394. if (this._wheelPrecision === value) {
  9395. return;
  9396. }
  9397. if (value < 0) {
  9398. value = 0;
  9399. }
  9400. if (value > 1) {
  9401. value = 1;
  9402. }
  9403. this._wheelPrecision = value;
  9404. },
  9405. enumerable: false,
  9406. configurable: true
  9407. });
  9408. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9409. /** Gets or sets the scroll bar container background color */
  9410. get: function () {
  9411. return this._horizontalBarSpace.background;
  9412. },
  9413. set: function (color) {
  9414. if (this._horizontalBarSpace.background === color) {
  9415. return;
  9416. }
  9417. this._horizontalBarSpace.background = color;
  9418. this._verticalBarSpace.background = color;
  9419. },
  9420. enumerable: false,
  9421. configurable: true
  9422. });
  9423. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9424. /** Gets or sets the bar color */
  9425. get: function () {
  9426. return this._barColor;
  9427. },
  9428. set: function (color) {
  9429. if (this._barColor === color) {
  9430. return;
  9431. }
  9432. this._barColor = color;
  9433. this._horizontalBar.color = color;
  9434. this._verticalBar.color = color;
  9435. },
  9436. enumerable: false,
  9437. configurable: true
  9438. });
  9439. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9440. /** Gets or sets the bar image */
  9441. get: function () {
  9442. return this._barImage;
  9443. },
  9444. set: function (value) {
  9445. if (this._barImage === value) {
  9446. return;
  9447. }
  9448. this._barImage = value;
  9449. var hb = this._horizontalBar;
  9450. var vb = this._verticalBar;
  9451. hb.thumbImage = value;
  9452. vb.thumbImage = value;
  9453. },
  9454. enumerable: false,
  9455. configurable: true
  9456. });
  9457. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9458. /** Gets or sets the horizontal bar image */
  9459. get: function () {
  9460. return this._horizontalBarImage;
  9461. },
  9462. set: function (value) {
  9463. if (this._horizontalBarImage === value) {
  9464. return;
  9465. }
  9466. this._horizontalBarImage = value;
  9467. var hb = this._horizontalBar;
  9468. hb.thumbImage = value;
  9469. },
  9470. enumerable: false,
  9471. configurable: true
  9472. });
  9473. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9474. /** Gets or sets the vertical bar image */
  9475. get: function () {
  9476. return this._verticalBarImage;
  9477. },
  9478. set: function (value) {
  9479. if (this._verticalBarImage === value) {
  9480. return;
  9481. }
  9482. this._verticalBarImage = value;
  9483. var vb = this._verticalBar;
  9484. vb.thumbImage = value;
  9485. },
  9486. enumerable: false,
  9487. configurable: true
  9488. });
  9489. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9490. /** Gets or sets the size of the bar */
  9491. get: function () {
  9492. return this._barSize;
  9493. },
  9494. set: function (value) {
  9495. if (this._barSize === value) {
  9496. return;
  9497. }
  9498. this._barSize = value;
  9499. this._markAsDirty();
  9500. if (this._horizontalBar.isVisible) {
  9501. this._grid.setRowDefinition(1, this._barSize, true);
  9502. }
  9503. if (this._verticalBar.isVisible) {
  9504. this._grid.setColumnDefinition(1, this._barSize, true);
  9505. }
  9506. },
  9507. enumerable: false,
  9508. configurable: true
  9509. });
  9510. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9511. /** Gets or sets the length of the thumb */
  9512. get: function () {
  9513. return this._thumbLength;
  9514. },
  9515. set: function (value) {
  9516. if (this._thumbLength === value) {
  9517. return;
  9518. }
  9519. if (value <= 0) {
  9520. value = 0.1;
  9521. }
  9522. if (value > 1) {
  9523. value = 1;
  9524. }
  9525. this._thumbLength = value;
  9526. var hb = this._horizontalBar;
  9527. var vb = this._verticalBar;
  9528. hb.thumbLength = value;
  9529. vb.thumbLength = value;
  9530. this._markAsDirty();
  9531. },
  9532. enumerable: false,
  9533. configurable: true
  9534. });
  9535. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9536. /** Gets or sets the height of the thumb */
  9537. get: function () {
  9538. return this._thumbHeight;
  9539. },
  9540. set: function (value) {
  9541. if (this._thumbHeight === value) {
  9542. return;
  9543. }
  9544. if (value <= 0) {
  9545. value = 0.1;
  9546. }
  9547. if (value > 1) {
  9548. value = 1;
  9549. }
  9550. this._thumbHeight = value;
  9551. var hb = this._horizontalBar;
  9552. var vb = this._verticalBar;
  9553. hb.thumbHeight = value;
  9554. vb.thumbHeight = value;
  9555. this._markAsDirty();
  9556. },
  9557. enumerable: false,
  9558. configurable: true
  9559. });
  9560. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9561. /** Gets or sets the height of the bar image */
  9562. get: function () {
  9563. return this._barImageHeight;
  9564. },
  9565. set: function (value) {
  9566. if (this._barImageHeight === value) {
  9567. return;
  9568. }
  9569. if (value <= 0) {
  9570. value = 0.1;
  9571. }
  9572. if (value > 1) {
  9573. value = 1;
  9574. }
  9575. this._barImageHeight = value;
  9576. var hb = this._horizontalBar;
  9577. var vb = this._verticalBar;
  9578. hb.barImageHeight = value;
  9579. vb.barImageHeight = value;
  9580. this._markAsDirty();
  9581. },
  9582. enumerable: false,
  9583. configurable: true
  9584. });
  9585. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9586. /** Gets or sets the height of the horizontal bar image */
  9587. get: function () {
  9588. return this._horizontalBarImageHeight;
  9589. },
  9590. set: function (value) {
  9591. if (this._horizontalBarImageHeight === value) {
  9592. return;
  9593. }
  9594. if (value <= 0) {
  9595. value = 0.1;
  9596. }
  9597. if (value > 1) {
  9598. value = 1;
  9599. }
  9600. this._horizontalBarImageHeight = value;
  9601. var hb = this._horizontalBar;
  9602. hb.barImageHeight = value;
  9603. this._markAsDirty();
  9604. },
  9605. enumerable: false,
  9606. configurable: true
  9607. });
  9608. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9609. /** Gets or sets the height of the vertical bar image */
  9610. get: function () {
  9611. return this._verticalBarImageHeight;
  9612. },
  9613. set: function (value) {
  9614. if (this._verticalBarImageHeight === value) {
  9615. return;
  9616. }
  9617. if (value <= 0) {
  9618. value = 0.1;
  9619. }
  9620. if (value > 1) {
  9621. value = 1;
  9622. }
  9623. this._verticalBarImageHeight = value;
  9624. var vb = this._verticalBar;
  9625. vb.barImageHeight = value;
  9626. this._markAsDirty();
  9627. },
  9628. enumerable: false,
  9629. configurable: true
  9630. });
  9631. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9632. /** Gets or sets the bar background */
  9633. get: function () {
  9634. return this._barBackground;
  9635. },
  9636. set: function (color) {
  9637. if (this._barBackground === color) {
  9638. return;
  9639. }
  9640. this._barBackground = color;
  9641. var hb = this._horizontalBar;
  9642. var vb = this._verticalBar;
  9643. hb.background = color;
  9644. vb.background = color;
  9645. this._dragSpace.background = color;
  9646. },
  9647. enumerable: false,
  9648. configurable: true
  9649. });
  9650. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9651. /** Gets or sets the bar background image */
  9652. get: function () {
  9653. return this._barBackgroundImage;
  9654. },
  9655. set: function (value) {
  9656. if (this._barBackgroundImage === value) {
  9657. }
  9658. this._barBackgroundImage = value;
  9659. var hb = this._horizontalBar;
  9660. var vb = this._verticalBar;
  9661. hb.backgroundImage = value;
  9662. vb.backgroundImage = value;
  9663. },
  9664. enumerable: false,
  9665. configurable: true
  9666. });
  9667. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9668. /** Gets or sets the horizontal bar background image */
  9669. get: function () {
  9670. return this._horizontalBarBackgroundImage;
  9671. },
  9672. set: function (value) {
  9673. if (this._horizontalBarBackgroundImage === value) {
  9674. }
  9675. this._horizontalBarBackgroundImage = value;
  9676. var hb = this._horizontalBar;
  9677. hb.backgroundImage = value;
  9678. },
  9679. enumerable: false,
  9680. configurable: true
  9681. });
  9682. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9683. /** Gets or sets the vertical bar background image */
  9684. get: function () {
  9685. return this._verticalBarBackgroundImage;
  9686. },
  9687. set: function (value) {
  9688. if (this._verticalBarBackgroundImage === value) {
  9689. }
  9690. this._verticalBarBackgroundImage = value;
  9691. var vb = this._verticalBar;
  9692. vb.backgroundImage = value;
  9693. },
  9694. enumerable: false,
  9695. configurable: true
  9696. });
  9697. ScrollViewer.prototype._setWindowPosition = function (force) {
  9698. if (force === void 0) { force = true; }
  9699. var ratio = this.host.idealRatio;
  9700. var windowContentsWidth = this._window._currentMeasure.width;
  9701. var windowContentsHeight = this._window._currentMeasure.height;
  9702. if (!force && this._oldWindowContentsWidth === windowContentsWidth && this._oldWindowContentsHeight === windowContentsHeight) {
  9703. return;
  9704. }
  9705. this._oldWindowContentsWidth = windowContentsWidth;
  9706. this._oldWindowContentsHeight = windowContentsHeight;
  9707. var _endLeft = this._clientWidth - windowContentsWidth;
  9708. var _endTop = this._clientHeight - windowContentsHeight;
  9709. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9710. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9711. if (newLeft !== this._window.left) {
  9712. this._window.left = newLeft;
  9713. if (!this.freezeControls) {
  9714. this._rebuildLayout = true;
  9715. }
  9716. }
  9717. if (newTop !== this._window.top) {
  9718. this._window.top = newTop;
  9719. if (!this.freezeControls) {
  9720. this._rebuildLayout = true;
  9721. }
  9722. }
  9723. };
  9724. /** @hidden */
  9725. ScrollViewer.prototype._updateScroller = function () {
  9726. var windowContentsWidth = this._window._currentMeasure.width;
  9727. var windowContentsHeight = this._window._currentMeasure.height;
  9728. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9729. this._grid.setRowDefinition(1, 0, true);
  9730. this._horizontalBar.isVisible = false;
  9731. this._horizontalBar.value = 0;
  9732. this._rebuildLayout = true;
  9733. }
  9734. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9735. this._grid.setRowDefinition(1, this._barSize, true);
  9736. this._horizontalBar.isVisible = true;
  9737. this._rebuildLayout = true;
  9738. }
  9739. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9740. this._grid.setColumnDefinition(1, 0, true);
  9741. this._verticalBar.isVisible = false;
  9742. this._verticalBar.value = 0;
  9743. this._rebuildLayout = true;
  9744. }
  9745. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9746. this._grid.setColumnDefinition(1, this._barSize, true);
  9747. this._verticalBar.isVisible = true;
  9748. this._rebuildLayout = true;
  9749. }
  9750. this._buildClientSizes();
  9751. var ratio = this.host.idealRatio;
  9752. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9753. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9754. };
  9755. ScrollViewer.prototype._link = function (host) {
  9756. _super.prototype._link.call(this, host);
  9757. this._attachWheel();
  9758. };
  9759. /** @hidden */
  9760. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9761. var _this = this;
  9762. barControl.paddingLeft = 0;
  9763. barControl.width = "100%";
  9764. barControl.height = "100%";
  9765. barControl.barOffset = 0;
  9766. barControl.value = 0;
  9767. barControl.maximum = 1;
  9768. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9769. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9770. barControl.isVertical = isVertical;
  9771. barControl.rotation = rotation;
  9772. barControl.isVisible = false;
  9773. barContainer.addControl(barControl);
  9774. barControl.onValueChangedObservable.add(function (value) {
  9775. _this._setWindowPosition();
  9776. });
  9777. };
  9778. /** @hidden */
  9779. ScrollViewer.prototype._attachWheel = function () {
  9780. var _this = this;
  9781. if (!this._host || this._onWheelObserver) {
  9782. return;
  9783. }
  9784. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  9785. if (!_this._pointerIsOver) {
  9786. return;
  9787. }
  9788. if (_this._verticalBar.isVisible == true) {
  9789. if (pi.y < 0 && _this._verticalBar.value > 0) {
  9790. _this._verticalBar.value -= _this._wheelPrecision;
  9791. }
  9792. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9793. _this._verticalBar.value += _this._wheelPrecision;
  9794. }
  9795. }
  9796. if (_this._horizontalBar.isVisible == true) {
  9797. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9798. _this._horizontalBar.value += _this._wheelPrecision;
  9799. }
  9800. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  9801. _this._horizontalBar.value -= _this._wheelPrecision;
  9802. }
  9803. }
  9804. });
  9805. };
  9806. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9807. if (!this.isHighlighted) {
  9808. return;
  9809. }
  9810. _super.prototype._renderHighlightSpecific.call(this, context);
  9811. this._grid._renderHighlightSpecific(context);
  9812. context.restore();
  9813. };
  9814. /** Releases associated resources */
  9815. ScrollViewer.prototype.dispose = function () {
  9816. this.onWheelObservable.remove(this._onWheelObserver);
  9817. this._onWheelObserver = null;
  9818. _super.prototype.dispose.call(this);
  9819. };
  9820. return ScrollViewer;
  9821. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9822. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9823. /***/ }),
  9824. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9825. /*!*********************************************************!*\
  9826. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9827. \*********************************************************/
  9828. /*! exports provided: _ScrollViewerWindow */
  9829. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9830. "use strict";
  9831. __webpack_require__.r(__webpack_exports__);
  9832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9833. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9834. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9835. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9836. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9837. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9838. /**
  9839. * Class used to hold a the container for ScrollViewer
  9840. * @hidden
  9841. */
  9842. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9843. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9844. /**
  9845. * Creates a new ScrollViewerWindow
  9846. * @param name of ScrollViewerWindow
  9847. */
  9848. function _ScrollViewerWindow(name) {
  9849. var _this = _super.call(this, name) || this;
  9850. _this._freezeControls = false;
  9851. _this._bucketWidth = 0;
  9852. _this._bucketHeight = 0;
  9853. _this._buckets = {};
  9854. return _this;
  9855. }
  9856. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9857. get: function () {
  9858. return this._freezeControls;
  9859. },
  9860. set: function (value) {
  9861. if (this._freezeControls === value) {
  9862. return;
  9863. }
  9864. if (!value) {
  9865. this._restoreMeasures();
  9866. }
  9867. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9868. this._freezeControls = false;
  9869. var textureSize = this.host.getSize();
  9870. var renderWidth = textureSize.width;
  9871. var renderHeight = textureSize.height;
  9872. var context = this.host.getContext();
  9873. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9874. this.host._numLayoutCalls = 0;
  9875. this.host._rootContainer._layout(measure, context);
  9876. // in freeze mode, prepare children measures accordingly
  9877. if (value) {
  9878. this._updateMeasures();
  9879. if (this._useBuckets()) {
  9880. this._makeBuckets();
  9881. }
  9882. }
  9883. this._freezeControls = value;
  9884. this.host.markAsDirty(); // redraw with the (new) current settings
  9885. },
  9886. enumerable: false,
  9887. configurable: true
  9888. });
  9889. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9890. get: function () {
  9891. return this._bucketWidth;
  9892. },
  9893. enumerable: false,
  9894. configurable: true
  9895. });
  9896. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9897. get: function () {
  9898. return this._bucketHeight;
  9899. },
  9900. enumerable: false,
  9901. configurable: true
  9902. });
  9903. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9904. this._bucketWidth = width;
  9905. this._bucketHeight = height;
  9906. if (this._useBuckets()) {
  9907. if (this._freezeControls) {
  9908. this._makeBuckets();
  9909. }
  9910. }
  9911. else {
  9912. this._buckets = {};
  9913. }
  9914. };
  9915. _ScrollViewerWindow.prototype._useBuckets = function () {
  9916. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9917. };
  9918. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9919. this._buckets = {};
  9920. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9921. this._dispatchInBuckets(this._children);
  9922. this._oldLeft = null;
  9923. this._oldTop = null;
  9924. };
  9925. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9926. for (var i = 0; i < children.length; ++i) {
  9927. var child = children[i];
  9928. 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);
  9929. while (bStartY <= bEndY) {
  9930. for (var x = bStartX; x <= bEndX; ++x) {
  9931. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9932. if (!lstc) {
  9933. lstc = [];
  9934. this._buckets[bucket] = lstc;
  9935. }
  9936. lstc.push(child);
  9937. }
  9938. bStartY++;
  9939. }
  9940. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9941. this._dispatchInBuckets(child._children);
  9942. }
  9943. }
  9944. };
  9945. // reset left and top measures for the window and all its children
  9946. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9947. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9948. this._measureForChildren.left -= left;
  9949. this._measureForChildren.top -= top;
  9950. this._currentMeasure.left -= left;
  9951. this._currentMeasure.top -= top;
  9952. this._customData.origLeftForChildren = this._measureForChildren.left;
  9953. this._customData.origTopForChildren = this._measureForChildren.top;
  9954. this._customData.origLeft = this._currentMeasure.left;
  9955. this._customData.origTop = this._currentMeasure.top;
  9956. this._updateChildrenMeasures(this._children, left, top);
  9957. };
  9958. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9959. for (var i = 0; i < children.length; ++i) {
  9960. var child = children[i];
  9961. child._currentMeasure.left -= left;
  9962. child._currentMeasure.top -= top;
  9963. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9964. child._customData._origTop = child._currentMeasure.top;
  9965. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9966. this._updateChildrenMeasures(child._children, left, top);
  9967. }
  9968. }
  9969. };
  9970. _ScrollViewerWindow.prototype._restoreMeasures = function () {
  9971. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9972. this._measureForChildren.left = this._customData.origLeftForChildren + left;
  9973. this._measureForChildren.top = this._customData.origTopForChildren + top;
  9974. this._currentMeasure.left = this._customData.origLeft + left;
  9975. this._currentMeasure.top = this._customData.origTop + top;
  9976. };
  9977. _ScrollViewerWindow.prototype._getTypeName = function () {
  9978. return "ScrollViewerWindow";
  9979. };
  9980. /** @hidden */
  9981. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9982. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9983. this._parentMeasure = parentMeasure;
  9984. this._measureForChildren.left = this._currentMeasure.left;
  9985. this._measureForChildren.top = this._currentMeasure.top;
  9986. this._measureForChildren.width = parentMeasure.width;
  9987. this._measureForChildren.height = parentMeasure.height;
  9988. };
  9989. /** @hidden */
  9990. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9991. if (this._freezeControls) {
  9992. this.invalidateRect(); // will trigger a redraw of the window
  9993. return false;
  9994. }
  9995. return _super.prototype._layout.call(this, parentMeasure, context);
  9996. };
  9997. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9998. for (var i = 0; i < children.length; ++i) {
  9999. var child = children[i];
  10000. child._currentMeasure.left = child._customData._origLeft + left;
  10001. child._currentMeasure.top = child._customData._origTop + top;
  10002. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  10003. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10004. this._scrollChildren(child._children, left, top);
  10005. }
  10006. }
  10007. };
  10008. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  10009. 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);
  10010. while (bStartY <= bEndY) {
  10011. for (var x = bStartX; x <= bEndX; ++x) {
  10012. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  10013. if (lstc) {
  10014. for (var i = 0; i < lstc.length; ++i) {
  10015. var child = lstc[i];
  10016. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  10017. child._currentMeasure.top = child._customData._origTop + scrollTop;
  10018. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  10019. }
  10020. }
  10021. }
  10022. bStartY++;
  10023. }
  10024. };
  10025. /** @hidden */
  10026. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  10027. if (!this._freezeControls) {
  10028. _super.prototype._draw.call(this, context, invalidatedRectangle);
  10029. return;
  10030. }
  10031. this._localDraw(context);
  10032. if (this.clipChildren) {
  10033. this._clipForChildren(context);
  10034. }
  10035. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10036. if (this._useBuckets()) {
  10037. if (this._oldLeft !== null && this._oldTop !== null) {
  10038. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  10039. this._scrollChildrenWithBuckets(left, top, left, top);
  10040. }
  10041. else {
  10042. this._scrollChildren(this._children, left, top);
  10043. }
  10044. }
  10045. else {
  10046. this._scrollChildren(this._children, left, top);
  10047. }
  10048. this._oldLeft = left;
  10049. this._oldTop = top;
  10050. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10051. var child = _a[_i];
  10052. if (!child._intersectsRect(this._parentMeasure)) {
  10053. continue;
  10054. }
  10055. child._render(context, this._parentMeasure);
  10056. }
  10057. };
  10058. _ScrollViewerWindow.prototype._postMeasure = function () {
  10059. if (this._freezeControls) {
  10060. _super.prototype._postMeasure.call(this);
  10061. return;
  10062. }
  10063. var maxWidth = this.parentClientWidth;
  10064. var maxHeight = this.parentClientHeight;
  10065. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10066. var child = _a[_i];
  10067. if (!child.isVisible || child.notRenderable) {
  10068. continue;
  10069. }
  10070. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  10071. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  10072. }
  10073. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  10074. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  10075. }
  10076. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width + child.paddingRightInPixels);
  10077. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height + child.paddingBottomInPixels);
  10078. }
  10079. if (this._currentMeasure.width !== maxWidth) {
  10080. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10081. this._currentMeasure.width = maxWidth;
  10082. this._rebuildLayout = true;
  10083. this._isDirty = true;
  10084. }
  10085. if (this._currentMeasure.height !== maxHeight) {
  10086. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10087. this._currentMeasure.height = maxHeight;
  10088. this._rebuildLayout = true;
  10089. this._isDirty = true;
  10090. }
  10091. _super.prototype._postMeasure.call(this);
  10092. };
  10093. return _ScrollViewerWindow;
  10094. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10095. /***/ }),
  10096. /***/ "./2D/controls/selector.ts":
  10097. /*!*********************************!*\
  10098. !*** ./2D/controls/selector.ts ***!
  10099. \*********************************/
  10100. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  10101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10102. "use strict";
  10103. __webpack_require__.r(__webpack_exports__);
  10104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  10105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  10106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  10107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  10108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  10109. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10110. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  10111. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10112. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10113. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10114. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  10115. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  10116. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  10117. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10118. /** Class used to create a RadioGroup
  10119. * which contains groups of radio buttons
  10120. */
  10121. var SelectorGroup = /** @class */ (function () {
  10122. /**
  10123. * Creates a new SelectorGroup
  10124. * @param name of group, used as a group heading
  10125. */
  10126. function SelectorGroup(
  10127. /** name of SelectorGroup */
  10128. name) {
  10129. this.name = name;
  10130. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10131. this._selectors = new Array();
  10132. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10133. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10134. this._groupHeader = this._addGroupHeader(name);
  10135. }
  10136. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  10137. /** Gets the groupPanel of the SelectorGroup */
  10138. get: function () {
  10139. return this._groupPanel;
  10140. },
  10141. enumerable: false,
  10142. configurable: true
  10143. });
  10144. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  10145. /** Gets the selectors array */
  10146. get: function () {
  10147. return this._selectors;
  10148. },
  10149. enumerable: false,
  10150. configurable: true
  10151. });
  10152. Object.defineProperty(SelectorGroup.prototype, "header", {
  10153. /** Gets and sets the group header */
  10154. get: function () {
  10155. return this._groupHeader.text;
  10156. },
  10157. set: function (label) {
  10158. if (this._groupHeader.text === "label") {
  10159. return;
  10160. }
  10161. this._groupHeader.text = label;
  10162. },
  10163. enumerable: false,
  10164. configurable: true
  10165. });
  10166. /** @hidden */
  10167. SelectorGroup.prototype._addGroupHeader = function (text) {
  10168. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  10169. groupHeading.width = 0.9;
  10170. groupHeading.height = "30px";
  10171. groupHeading.textWrapping = true;
  10172. groupHeading.color = "black";
  10173. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10174. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10175. groupHeading.left = "2px";
  10176. this._groupPanel.addControl(groupHeading);
  10177. return groupHeading;
  10178. };
  10179. /** @hidden*/
  10180. SelectorGroup.prototype._getSelector = function (selectorNb) {
  10181. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10182. return;
  10183. }
  10184. return this._selectors[selectorNb];
  10185. };
  10186. /** Removes the selector at the given position
  10187. * @param selectorNb the position of the selector within the group
  10188. */
  10189. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  10190. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10191. return;
  10192. }
  10193. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10194. this._selectors.splice(selectorNb, 1);
  10195. };
  10196. return SelectorGroup;
  10197. }());
  10198. /** Class used to create a CheckboxGroup
  10199. * which contains groups of checkbox buttons
  10200. */
  10201. var CheckboxGroup = /** @class */ (function (_super) {
  10202. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10203. function CheckboxGroup() {
  10204. return _super !== null && _super.apply(this, arguments) || this;
  10205. }
  10206. /** Adds a checkbox as a control
  10207. * @param text is the label for the selector
  10208. * @param func is the function called when the Selector is checked
  10209. * @param checked is true when Selector is checked
  10210. */
  10211. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10212. if (func === void 0) { func = function (s) { }; }
  10213. if (checked === void 0) { checked = false; }
  10214. var checked = checked || false;
  10215. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10216. button.width = "20px";
  10217. button.height = "20px";
  10218. button.color = "#364249";
  10219. button.background = "#CCCCCC";
  10220. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10221. button.onIsCheckedChangedObservable.add(function (state) {
  10222. func(state);
  10223. });
  10224. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10225. _selector.height = "30px";
  10226. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10227. _selector.left = "4px";
  10228. this.groupPanel.addControl(_selector);
  10229. this.selectors.push(_selector);
  10230. button.isChecked = checked;
  10231. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10232. button.color = this.groupPanel.parent.parent.buttonColor;
  10233. button.background = this.groupPanel.parent.parent.buttonBackground;
  10234. }
  10235. };
  10236. /** @hidden */
  10237. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10238. this.selectors[selectorNb].children[1].text = label;
  10239. };
  10240. /** @hidden */
  10241. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10242. this.selectors[selectorNb].children[1].color = color;
  10243. };
  10244. /** @hidden */
  10245. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10246. this.selectors[selectorNb].children[0].color = color;
  10247. };
  10248. /** @hidden */
  10249. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10250. this.selectors[selectorNb].children[0].background = color;
  10251. };
  10252. return CheckboxGroup;
  10253. }(SelectorGroup));
  10254. /** Class used to create a RadioGroup
  10255. * which contains groups of radio buttons
  10256. */
  10257. var RadioGroup = /** @class */ (function (_super) {
  10258. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10259. function RadioGroup() {
  10260. var _this = _super !== null && _super.apply(this, arguments) || this;
  10261. _this._selectNb = 0;
  10262. return _this;
  10263. }
  10264. /** Adds a radio button as a control
  10265. * @param label is the label for the selector
  10266. * @param func is the function called when the Selector is checked
  10267. * @param checked is true when Selector is checked
  10268. */
  10269. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10270. if (func === void 0) { func = function (n) { }; }
  10271. if (checked === void 0) { checked = false; }
  10272. var nb = this._selectNb++;
  10273. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10274. button.name = label;
  10275. button.width = "20px";
  10276. button.height = "20px";
  10277. button.color = "#364249";
  10278. button.background = "#CCCCCC";
  10279. button.group = this.name;
  10280. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10281. button.onIsCheckedChangedObservable.add(function (state) {
  10282. if (state) {
  10283. func(nb);
  10284. }
  10285. });
  10286. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10287. _selector.height = "30px";
  10288. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10289. _selector.left = "4px";
  10290. this.groupPanel.addControl(_selector);
  10291. this.selectors.push(_selector);
  10292. button.isChecked = checked;
  10293. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10294. button.color = this.groupPanel.parent.parent.buttonColor;
  10295. button.background = this.groupPanel.parent.parent.buttonBackground;
  10296. }
  10297. };
  10298. /** @hidden */
  10299. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10300. this.selectors[selectorNb].children[1].text = label;
  10301. };
  10302. /** @hidden */
  10303. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10304. this.selectors[selectorNb].children[1].color = color;
  10305. };
  10306. /** @hidden */
  10307. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10308. this.selectors[selectorNb].children[0].color = color;
  10309. };
  10310. /** @hidden */
  10311. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10312. this.selectors[selectorNb].children[0].background = color;
  10313. };
  10314. return RadioGroup;
  10315. }(SelectorGroup));
  10316. /** Class used to create a SliderGroup
  10317. * which contains groups of slider buttons
  10318. */
  10319. var SliderGroup = /** @class */ (function (_super) {
  10320. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10321. function SliderGroup() {
  10322. return _super !== null && _super.apply(this, arguments) || this;
  10323. }
  10324. /**
  10325. * Adds a slider to the SelectorGroup
  10326. * @param label is the label for the SliderBar
  10327. * @param func is the function called when the Slider moves
  10328. * @param unit is a string describing the units used, eg degrees or metres
  10329. * @param min is the minimum value for the Slider
  10330. * @param max is the maximum value for the Slider
  10331. * @param value is the start value for the Slider between min and max
  10332. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10333. */
  10334. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10335. if (func === void 0) { func = function (v) { }; }
  10336. if (unit === void 0) { unit = "Units"; }
  10337. if (min === void 0) { min = 0; }
  10338. if (max === void 0) { max = 0; }
  10339. if (value === void 0) { value = 0; }
  10340. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10341. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10342. button.name = unit;
  10343. button.value = value;
  10344. button.minimum = min;
  10345. button.maximum = max;
  10346. button.width = 0.9;
  10347. button.height = "20px";
  10348. button.color = "#364249";
  10349. button.background = "#CCCCCC";
  10350. button.borderColor = "black";
  10351. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10352. button.left = "4px";
  10353. button.paddingBottom = "4px";
  10354. button.onValueChangedObservable.add(function (value) {
  10355. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10356. func(value);
  10357. });
  10358. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10359. _selector.height = "60px";
  10360. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10361. _selector.left = "4px";
  10362. _selector.children[0].name = label;
  10363. this.groupPanel.addControl(_selector);
  10364. this.selectors.push(_selector);
  10365. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10366. button.color = this.groupPanel.parent.parent.buttonColor;
  10367. button.background = this.groupPanel.parent.parent.buttonBackground;
  10368. }
  10369. };
  10370. /** @hidden */
  10371. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10372. this.selectors[selectorNb].children[0].name = label;
  10373. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10374. };
  10375. /** @hidden */
  10376. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10377. this.selectors[selectorNb].children[0].color = color;
  10378. };
  10379. /** @hidden */
  10380. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10381. this.selectors[selectorNb].children[1].color = color;
  10382. };
  10383. /** @hidden */
  10384. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10385. this.selectors[selectorNb].children[1].background = color;
  10386. };
  10387. return SliderGroup;
  10388. }(SelectorGroup));
  10389. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10390. * @see https://doc.babylonjs.com/how_to/selector
  10391. */
  10392. var SelectionPanel = /** @class */ (function (_super) {
  10393. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10394. /**
  10395. * Creates a new SelectionPanel
  10396. * @param name of SelectionPanel
  10397. * @param groups is an array of SelectionGroups
  10398. */
  10399. function SelectionPanel(
  10400. /** name of SelectionPanel */
  10401. name,
  10402. /** an array of SelectionGroups */
  10403. groups) {
  10404. if (groups === void 0) { groups = []; }
  10405. var _this = _super.call(this, name) || this;
  10406. _this.name = name;
  10407. _this.groups = groups;
  10408. _this._buttonColor = "#364249";
  10409. _this._buttonBackground = "#CCCCCC";
  10410. _this._headerColor = "black";
  10411. _this._barColor = "white";
  10412. _this._barHeight = "2px";
  10413. _this._spacerHeight = "20px";
  10414. _this._bars = new Array();
  10415. _this._groups = groups;
  10416. _this.thickness = 2;
  10417. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10418. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10419. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10420. _this._panel.top = 5;
  10421. _this._panel.left = 5;
  10422. _this._panel.width = 0.95;
  10423. if (groups.length > 0) {
  10424. for (var i = 0; i < groups.length - 1; i++) {
  10425. _this._panel.addControl(groups[i].groupPanel);
  10426. _this._addSpacer();
  10427. }
  10428. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10429. }
  10430. _this.addControl(_this._panel);
  10431. return _this;
  10432. }
  10433. SelectionPanel.prototype._getTypeName = function () {
  10434. return "SelectionPanel";
  10435. };
  10436. Object.defineProperty(SelectionPanel.prototype, "panel", {
  10437. /** Gets the (stack) panel of the SelectionPanel */
  10438. get: function () {
  10439. return this._panel;
  10440. },
  10441. enumerable: false,
  10442. configurable: true
  10443. });
  10444. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10445. /** Gets or sets the headerColor */
  10446. get: function () {
  10447. return this._headerColor;
  10448. },
  10449. set: function (color) {
  10450. if (this._headerColor === color) {
  10451. return;
  10452. }
  10453. this._headerColor = color;
  10454. this._setHeaderColor();
  10455. },
  10456. enumerable: false,
  10457. configurable: true
  10458. });
  10459. SelectionPanel.prototype._setHeaderColor = function () {
  10460. for (var i = 0; i < this._groups.length; i++) {
  10461. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10462. }
  10463. };
  10464. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10465. /** Gets or sets the button color */
  10466. get: function () {
  10467. return this._buttonColor;
  10468. },
  10469. set: function (color) {
  10470. if (this._buttonColor === color) {
  10471. return;
  10472. }
  10473. this._buttonColor = color;
  10474. this._setbuttonColor();
  10475. },
  10476. enumerable: false,
  10477. configurable: true
  10478. });
  10479. SelectionPanel.prototype._setbuttonColor = function () {
  10480. for (var i = 0; i < this._groups.length; i++) {
  10481. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10482. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10483. }
  10484. }
  10485. };
  10486. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10487. /** Gets or sets the label color */
  10488. get: function () {
  10489. return this._labelColor;
  10490. },
  10491. set: function (color) {
  10492. if (this._labelColor === color) {
  10493. return;
  10494. }
  10495. this._labelColor = color;
  10496. this._setLabelColor();
  10497. },
  10498. enumerable: false,
  10499. configurable: true
  10500. });
  10501. SelectionPanel.prototype._setLabelColor = function () {
  10502. for (var i = 0; i < this._groups.length; i++) {
  10503. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10504. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10505. }
  10506. }
  10507. };
  10508. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10509. /** Gets or sets the button background */
  10510. get: function () {
  10511. return this._buttonBackground;
  10512. },
  10513. set: function (color) {
  10514. if (this._buttonBackground === color) {
  10515. return;
  10516. }
  10517. this._buttonBackground = color;
  10518. this._setButtonBackground();
  10519. },
  10520. enumerable: false,
  10521. configurable: true
  10522. });
  10523. SelectionPanel.prototype._setButtonBackground = function () {
  10524. for (var i = 0; i < this._groups.length; i++) {
  10525. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10526. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10527. }
  10528. }
  10529. };
  10530. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10531. /** Gets or sets the color of separator bar */
  10532. get: function () {
  10533. return this._barColor;
  10534. },
  10535. set: function (color) {
  10536. if (this._barColor === color) {
  10537. return;
  10538. }
  10539. this._barColor = color;
  10540. this._setBarColor();
  10541. },
  10542. enumerable: false,
  10543. configurable: true
  10544. });
  10545. SelectionPanel.prototype._setBarColor = function () {
  10546. for (var i = 0; i < this._bars.length; i++) {
  10547. this._bars[i].children[0].background = this._barColor;
  10548. }
  10549. };
  10550. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10551. /** Gets or sets the height of separator bar */
  10552. get: function () {
  10553. return this._barHeight;
  10554. },
  10555. set: function (value) {
  10556. if (this._barHeight === value) {
  10557. return;
  10558. }
  10559. this._barHeight = value;
  10560. this._setBarHeight();
  10561. },
  10562. enumerable: false,
  10563. configurable: true
  10564. });
  10565. SelectionPanel.prototype._setBarHeight = function () {
  10566. for (var i = 0; i < this._bars.length; i++) {
  10567. this._bars[i].children[0].height = this._barHeight;
  10568. }
  10569. };
  10570. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10571. /** Gets or sets the height of spacers*/
  10572. get: function () {
  10573. return this._spacerHeight;
  10574. },
  10575. set: function (value) {
  10576. if (this._spacerHeight === value) {
  10577. return;
  10578. }
  10579. this._spacerHeight = value;
  10580. this._setSpacerHeight();
  10581. },
  10582. enumerable: false,
  10583. configurable: true
  10584. });
  10585. SelectionPanel.prototype._setSpacerHeight = function () {
  10586. for (var i = 0; i < this._bars.length; i++) {
  10587. this._bars[i].height = this._spacerHeight;
  10588. }
  10589. };
  10590. /** Adds a bar between groups */
  10591. SelectionPanel.prototype._addSpacer = function () {
  10592. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10593. separator.width = 1;
  10594. separator.height = this._spacerHeight;
  10595. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10596. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10597. bar.width = 1;
  10598. bar.height = this._barHeight;
  10599. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10600. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10601. bar.background = this._barColor;
  10602. bar.color = "transparent";
  10603. separator.addControl(bar);
  10604. this._panel.addControl(separator);
  10605. this._bars.push(separator);
  10606. };
  10607. /** Add a group to the selection panel
  10608. * @param group is the selector group to add
  10609. */
  10610. SelectionPanel.prototype.addGroup = function (group) {
  10611. if (this._groups.length > 0) {
  10612. this._addSpacer();
  10613. }
  10614. this._panel.addControl(group.groupPanel);
  10615. this._groups.push(group);
  10616. group.groupPanel.children[0].color = this._headerColor;
  10617. for (var j = 0; j < group.selectors.length; j++) {
  10618. group._setSelectorButtonColor(j, this._buttonColor);
  10619. group._setSelectorButtonBackground(j, this._buttonBackground);
  10620. }
  10621. };
  10622. /** Remove the group from the given position
  10623. * @param groupNb is the position of the group in the list
  10624. */
  10625. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10626. if (groupNb < 0 || groupNb >= this._groups.length) {
  10627. return;
  10628. }
  10629. var group = this._groups[groupNb];
  10630. this._panel.removeControl(group.groupPanel);
  10631. this._groups.splice(groupNb, 1);
  10632. if (groupNb < this._bars.length) {
  10633. this._panel.removeControl(this._bars[groupNb]);
  10634. this._bars.splice(groupNb, 1);
  10635. }
  10636. };
  10637. /** Change a group header label
  10638. * @param label is the new group header label
  10639. * @param groupNb is the number of the group to relabel
  10640. * */
  10641. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10642. if (groupNb < 0 || groupNb >= this._groups.length) {
  10643. return;
  10644. }
  10645. var group = this._groups[groupNb];
  10646. group.groupPanel.children[0].text = label;
  10647. };
  10648. /** Change selector label to the one given
  10649. * @param label is the new selector label
  10650. * @param groupNb is the number of the groupcontaining the selector
  10651. * @param selectorNb is the number of the selector within a group to relabel
  10652. * */
  10653. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10654. if (groupNb < 0 || groupNb >= this._groups.length) {
  10655. return;
  10656. }
  10657. var group = this._groups[groupNb];
  10658. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10659. return;
  10660. }
  10661. group._setSelectorLabel(selectorNb, label);
  10662. };
  10663. /** For a given group position remove the selector at the given position
  10664. * @param groupNb is the number of the group to remove the selector from
  10665. * @param selectorNb is the number of the selector within the group
  10666. */
  10667. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10668. if (groupNb < 0 || groupNb >= this._groups.length) {
  10669. return;
  10670. }
  10671. var group = this._groups[groupNb];
  10672. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10673. return;
  10674. }
  10675. group.removeSelector(selectorNb);
  10676. };
  10677. /** For a given group position of correct type add a checkbox button
  10678. * @param groupNb is the number of the group to remove the selector from
  10679. * @param label is the label for the selector
  10680. * @param func is the function called when the Selector is checked
  10681. * @param checked is true when Selector is checked
  10682. */
  10683. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10684. if (func === void 0) { func = function () { }; }
  10685. if (checked === void 0) { checked = false; }
  10686. if (groupNb < 0 || groupNb >= this._groups.length) {
  10687. return;
  10688. }
  10689. var group = this._groups[groupNb];
  10690. group.addCheckbox(label, func, checked);
  10691. };
  10692. /** For a given group position of correct type add a radio button
  10693. * @param groupNb is the number of the group to remove the selector from
  10694. * @param label is the label for the selector
  10695. * @param func is the function called when the Selector is checked
  10696. * @param checked is true when Selector is checked
  10697. */
  10698. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10699. if (func === void 0) { func = function () { }; }
  10700. if (checked === void 0) { checked = false; }
  10701. if (groupNb < 0 || groupNb >= this._groups.length) {
  10702. return;
  10703. }
  10704. var group = this._groups[groupNb];
  10705. group.addRadio(label, func, checked);
  10706. };
  10707. /**
  10708. * For a given slider group add a slider
  10709. * @param groupNb is the number of the group to add the slider to
  10710. * @param label is the label for the Slider
  10711. * @param func is the function called when the Slider moves
  10712. * @param unit is a string describing the units used, eg degrees or metres
  10713. * @param min is the minimum value for the Slider
  10714. * @param max is the maximum value for the Slider
  10715. * @param value is the start value for the Slider between min and max
  10716. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10717. */
  10718. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10719. if (func === void 0) { func = function () { }; }
  10720. if (unit === void 0) { unit = "Units"; }
  10721. if (min === void 0) { min = 0; }
  10722. if (max === void 0) { max = 0; }
  10723. if (value === void 0) { value = 0; }
  10724. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10725. if (groupNb < 0 || groupNb >= this._groups.length) {
  10726. return;
  10727. }
  10728. var group = this._groups[groupNb];
  10729. group.addSlider(label, func, unit, min, max, value, onVal);
  10730. };
  10731. return SelectionPanel;
  10732. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10733. /***/ }),
  10734. /***/ "./2D/controls/sliders/baseSlider.ts":
  10735. /*!*******************************************!*\
  10736. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10737. \*******************************************/
  10738. /*! exports provided: BaseSlider */
  10739. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10740. "use strict";
  10741. __webpack_require__.r(__webpack_exports__);
  10742. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10743. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10744. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  10745. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10746. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10747. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10748. /**
  10749. * Class used to create slider controls
  10750. */
  10751. var BaseSlider = /** @class */ (function (_super) {
  10752. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10753. /**
  10754. * Creates a new BaseSlider
  10755. * @param name defines the control name
  10756. */
  10757. function BaseSlider(name) {
  10758. var _this = _super.call(this, name) || this;
  10759. _this.name = name;
  10760. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10761. _this._minimum = 0;
  10762. _this._maximum = 100;
  10763. _this._value = 50;
  10764. _this._isVertical = false;
  10765. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10766. _this._isThumbClamped = false;
  10767. _this._displayThumb = true;
  10768. _this._step = 0;
  10769. _this._lastPointerDownID = -1;
  10770. // Shared rendering info
  10771. _this._effectiveBarOffset = 0;
  10772. /** Observable raised when the sldier value changes */
  10773. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10774. // Events
  10775. _this._pointerIsDown = false;
  10776. _this.isPointerBlocker = true;
  10777. return _this;
  10778. }
  10779. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10780. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10781. get: function () {
  10782. return this._displayThumb;
  10783. },
  10784. set: function (value) {
  10785. if (this._displayThumb === value) {
  10786. return;
  10787. }
  10788. this._displayThumb = value;
  10789. this._markAsDirty();
  10790. },
  10791. enumerable: false,
  10792. configurable: true
  10793. });
  10794. Object.defineProperty(BaseSlider.prototype, "step", {
  10795. /** Gets or sets a step to apply to values (0 by default) */
  10796. get: function () {
  10797. return this._step;
  10798. },
  10799. set: function (value) {
  10800. if (this._step === value) {
  10801. return;
  10802. }
  10803. this._step = value;
  10804. this._markAsDirty();
  10805. },
  10806. enumerable: false,
  10807. configurable: true
  10808. });
  10809. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10810. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10811. get: function () {
  10812. return this._barOffset.toString(this._host);
  10813. },
  10814. set: function (value) {
  10815. if (this._barOffset.toString(this._host) === value) {
  10816. return;
  10817. }
  10818. if (this._barOffset.fromString(value)) {
  10819. this._markAsDirty();
  10820. }
  10821. },
  10822. enumerable: false,
  10823. configurable: true
  10824. });
  10825. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10826. /** Gets main bar offset in pixels*/
  10827. get: function () {
  10828. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10829. },
  10830. enumerable: false,
  10831. configurable: true
  10832. });
  10833. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10834. /** Gets or sets thumb width */
  10835. get: function () {
  10836. return this._thumbWidth.toString(this._host);
  10837. },
  10838. set: function (value) {
  10839. if (this._thumbWidth.toString(this._host) === value) {
  10840. return;
  10841. }
  10842. if (this._thumbWidth.fromString(value)) {
  10843. this._markAsDirty();
  10844. }
  10845. },
  10846. enumerable: false,
  10847. configurable: true
  10848. });
  10849. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10850. /** Gets thumb width in pixels */
  10851. get: function () {
  10852. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10853. },
  10854. enumerable: false,
  10855. configurable: true
  10856. });
  10857. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10858. /** Gets or sets minimum value */
  10859. get: function () {
  10860. return this._minimum;
  10861. },
  10862. set: function (value) {
  10863. if (this._minimum === value) {
  10864. return;
  10865. }
  10866. this._minimum = value;
  10867. this._markAsDirty();
  10868. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10869. },
  10870. enumerable: false,
  10871. configurable: true
  10872. });
  10873. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10874. /** Gets or sets maximum value */
  10875. get: function () {
  10876. return this._maximum;
  10877. },
  10878. set: function (value) {
  10879. if (this._maximum === value) {
  10880. return;
  10881. }
  10882. this._maximum = value;
  10883. this._markAsDirty();
  10884. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10885. },
  10886. enumerable: false,
  10887. configurable: true
  10888. });
  10889. Object.defineProperty(BaseSlider.prototype, "value", {
  10890. /** Gets or sets current value */
  10891. get: function () {
  10892. return this._value;
  10893. },
  10894. set: function (value) {
  10895. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10896. if (this._value === value) {
  10897. return;
  10898. }
  10899. this._value = value;
  10900. this._markAsDirty();
  10901. this.onValueChangedObservable.notifyObservers(this._value);
  10902. },
  10903. enumerable: false,
  10904. configurable: true
  10905. });
  10906. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10907. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10908. get: function () {
  10909. return this._isVertical;
  10910. },
  10911. set: function (value) {
  10912. if (this._isVertical === value) {
  10913. return;
  10914. }
  10915. this._isVertical = value;
  10916. this._markAsDirty();
  10917. },
  10918. enumerable: false,
  10919. configurable: true
  10920. });
  10921. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10922. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10923. get: function () {
  10924. return this._isThumbClamped;
  10925. },
  10926. set: function (value) {
  10927. if (this._isThumbClamped === value) {
  10928. return;
  10929. }
  10930. this._isThumbClamped = value;
  10931. this._markAsDirty();
  10932. },
  10933. enumerable: false,
  10934. configurable: true
  10935. });
  10936. BaseSlider.prototype._getTypeName = function () {
  10937. return "BaseSlider";
  10938. };
  10939. BaseSlider.prototype._getThumbPosition = function () {
  10940. if (this.isVertical) {
  10941. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10942. }
  10943. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10944. };
  10945. BaseSlider.prototype._getThumbThickness = function (type) {
  10946. var thumbThickness = 0;
  10947. switch (type) {
  10948. case "circle":
  10949. if (this._thumbWidth.isPixel) {
  10950. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10951. }
  10952. else {
  10953. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10954. }
  10955. break;
  10956. case "rectangle":
  10957. if (this._thumbWidth.isPixel) {
  10958. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10959. }
  10960. else {
  10961. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10962. }
  10963. }
  10964. return thumbThickness;
  10965. };
  10966. BaseSlider.prototype._prepareRenderingData = function (type) {
  10967. // Main bar
  10968. this._effectiveBarOffset = 0;
  10969. this._renderLeft = this._currentMeasure.left;
  10970. this._renderTop = this._currentMeasure.top;
  10971. this._renderWidth = this._currentMeasure.width;
  10972. this._renderHeight = this._currentMeasure.height;
  10973. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10974. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10975. this._effectiveThumbThickness = this._getThumbThickness(type);
  10976. if (this.displayThumb) {
  10977. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10978. }
  10979. //throw error when height is less than width for vertical slider
  10980. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10981. console.error("Height should be greater than width");
  10982. return;
  10983. }
  10984. if (this._barOffset.isPixel) {
  10985. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10986. }
  10987. else {
  10988. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10989. }
  10990. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10991. if (this.isVertical) {
  10992. this._renderLeft += this._effectiveBarOffset;
  10993. if (!this.isThumbClamped && this.displayThumb) {
  10994. this._renderTop += (this._effectiveThumbThickness / 2);
  10995. }
  10996. this._renderHeight = this._backgroundBoxLength;
  10997. this._renderWidth = this._backgroundBoxThickness;
  10998. }
  10999. else {
  11000. this._renderTop += this._effectiveBarOffset;
  11001. if (!this.isThumbClamped && this.displayThumb) {
  11002. this._renderLeft += (this._effectiveThumbThickness / 2);
  11003. }
  11004. this._renderHeight = this._backgroundBoxThickness;
  11005. this._renderWidth = this._backgroundBoxLength;
  11006. }
  11007. };
  11008. /** @hidden */
  11009. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  11010. if (this.rotation != 0) {
  11011. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11012. x = this._transformedPosition.x;
  11013. y = this._transformedPosition.y;
  11014. }
  11015. var value;
  11016. if (this._isVertical) {
  11017. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  11018. }
  11019. else {
  11020. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  11021. }
  11022. var mult = (1 / this._step) | 0;
  11023. this.value = this._step ? ((value * mult) | 0) / mult : value;
  11024. };
  11025. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  11026. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  11027. return false;
  11028. }
  11029. this._pointerIsDown = true;
  11030. this._updateValueFromPointer(coordinates.x, coordinates.y);
  11031. this._host._capturingControl[pointerId] = this;
  11032. this._lastPointerDownID = pointerId;
  11033. return true;
  11034. };
  11035. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  11036. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  11037. if (pointerId != this._lastPointerDownID) {
  11038. return;
  11039. }
  11040. if (this._pointerIsDown) {
  11041. this._updateValueFromPointer(coordinates.x, coordinates.y);
  11042. }
  11043. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  11044. };
  11045. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  11046. this._pointerIsDown = false;
  11047. delete this._host._capturingControl[pointerId];
  11048. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  11049. };
  11050. BaseSlider.prototype._onCanvasBlur = function () {
  11051. this._forcePointerUp();
  11052. _super.prototype._onCanvasBlur.call(this);
  11053. };
  11054. return BaseSlider;
  11055. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  11056. /***/ }),
  11057. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  11058. /*!*************************************************!*\
  11059. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  11060. \*************************************************/
  11061. /*! exports provided: ImageBasedSlider */
  11062. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11063. "use strict";
  11064. __webpack_require__.r(__webpack_exports__);
  11065. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  11066. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11067. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11068. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11069. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  11070. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  11071. /**
  11072. * Class used to create slider controls based on images
  11073. */
  11074. var ImageBasedSlider = /** @class */ (function (_super) {
  11075. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  11076. /**
  11077. * Creates a new ImageBasedSlider
  11078. * @param name defines the control name
  11079. */
  11080. function ImageBasedSlider(name) {
  11081. var _this = _super.call(this, name) || this;
  11082. _this.name = name;
  11083. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11084. return _this;
  11085. }
  11086. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  11087. get: function () {
  11088. return this._displayThumb && this.thumbImage != null;
  11089. },
  11090. set: function (value) {
  11091. if (this._displayThumb === value) {
  11092. return;
  11093. }
  11094. this._displayThumb = value;
  11095. this._markAsDirty();
  11096. },
  11097. enumerable: false,
  11098. configurable: true
  11099. });
  11100. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  11101. /**
  11102. * Gets or sets the image used to render the background
  11103. */
  11104. get: function () {
  11105. return this._backgroundImage;
  11106. },
  11107. set: function (value) {
  11108. var _this = this;
  11109. if (this._backgroundImage === value) {
  11110. return;
  11111. }
  11112. this._backgroundImage = value;
  11113. if (value && !value.isLoaded) {
  11114. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11115. }
  11116. this._markAsDirty();
  11117. },
  11118. enumerable: false,
  11119. configurable: true
  11120. });
  11121. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  11122. /**
  11123. * Gets or sets the image used to render the value bar
  11124. */
  11125. get: function () {
  11126. return this._valueBarImage;
  11127. },
  11128. set: function (value) {
  11129. var _this = this;
  11130. if (this._valueBarImage === value) {
  11131. return;
  11132. }
  11133. this._valueBarImage = value;
  11134. if (value && !value.isLoaded) {
  11135. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11136. }
  11137. this._markAsDirty();
  11138. },
  11139. enumerable: false,
  11140. configurable: true
  11141. });
  11142. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  11143. /**
  11144. * Gets or sets the image used to render the thumb
  11145. */
  11146. get: function () {
  11147. return this._thumbImage;
  11148. },
  11149. set: function (value) {
  11150. var _this = this;
  11151. if (this._thumbImage === value) {
  11152. return;
  11153. }
  11154. this._thumbImage = value;
  11155. if (value && !value.isLoaded) {
  11156. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11157. }
  11158. this._markAsDirty();
  11159. },
  11160. enumerable: false,
  11161. configurable: true
  11162. });
  11163. ImageBasedSlider.prototype._getTypeName = function () {
  11164. return "ImageBasedSlider";
  11165. };
  11166. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  11167. context.save();
  11168. this._applyStates(context);
  11169. this._prepareRenderingData("rectangle");
  11170. var thumbPosition = this._getThumbPosition();
  11171. var left = this._renderLeft;
  11172. var top = this._renderTop;
  11173. var width = this._renderWidth;
  11174. var height = this._renderHeight;
  11175. // Background
  11176. if (this._backgroundImage) {
  11177. this._tempMeasure.copyFromFloats(left, top, width, height);
  11178. if (this.isThumbClamped && this.displayThumb) {
  11179. if (this.isVertical) {
  11180. this._tempMeasure.height += this._effectiveThumbThickness;
  11181. }
  11182. else {
  11183. this._tempMeasure.width += this._effectiveThumbThickness;
  11184. }
  11185. }
  11186. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11187. this._backgroundImage._draw(context);
  11188. }
  11189. // Bar
  11190. if (this._valueBarImage) {
  11191. if (this.isVertical) {
  11192. if (this.isThumbClamped && this.displayThumb) {
  11193. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11194. }
  11195. else {
  11196. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  11197. }
  11198. }
  11199. else {
  11200. if (this.isThumbClamped && this.displayThumb) {
  11201. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  11202. }
  11203. else {
  11204. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11205. }
  11206. }
  11207. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11208. this._valueBarImage._draw(context);
  11209. }
  11210. // Thumb
  11211. if (this.displayThumb) {
  11212. if (this.isVertical) {
  11213. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11214. }
  11215. else {
  11216. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11217. }
  11218. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11219. this._thumbImage._draw(context);
  11220. }
  11221. context.restore();
  11222. };
  11223. return ImageBasedSlider;
  11224. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11225. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11226. /***/ }),
  11227. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11228. /*!***********************************************!*\
  11229. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11230. \***********************************************/
  11231. /*! exports provided: ImageScrollBar */
  11232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11233. "use strict";
  11234. __webpack_require__.r(__webpack_exports__);
  11235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11236. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11237. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11238. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11239. /**
  11240. * Class used to create slider controls
  11241. */
  11242. var ImageScrollBar = /** @class */ (function (_super) {
  11243. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11244. /**
  11245. * Creates a new ImageScrollBar
  11246. * @param name defines the control name
  11247. */
  11248. function ImageScrollBar(name) {
  11249. var _this = _super.call(this, name) || this;
  11250. _this.name = name;
  11251. _this._thumbLength = 0.5;
  11252. _this._thumbHeight = 1;
  11253. _this._barImageHeight = 1;
  11254. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11255. /** Number of 90° rotation to apply on the images when in vertical mode */
  11256. _this.num90RotationInVerticalMode = 1;
  11257. return _this;
  11258. }
  11259. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11260. /**
  11261. * Gets or sets the image used to render the background for horizontal bar
  11262. */
  11263. get: function () {
  11264. return this._backgroundBaseImage;
  11265. },
  11266. set: function (value) {
  11267. var _this = this;
  11268. if (this._backgroundBaseImage === value) {
  11269. return;
  11270. }
  11271. this._backgroundBaseImage = value;
  11272. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11273. if (!value.isLoaded) {
  11274. value.onImageLoadedObservable.addOnce(function () {
  11275. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11276. _this._backgroundImage = rotatedValue;
  11277. if (!rotatedValue.isLoaded) {
  11278. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11279. _this._markAsDirty();
  11280. });
  11281. }
  11282. _this._markAsDirty();
  11283. });
  11284. }
  11285. else {
  11286. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11287. this._markAsDirty();
  11288. }
  11289. }
  11290. else {
  11291. this._backgroundImage = value;
  11292. if (value && !value.isLoaded) {
  11293. value.onImageLoadedObservable.addOnce(function () {
  11294. _this._markAsDirty();
  11295. });
  11296. }
  11297. this._markAsDirty();
  11298. }
  11299. },
  11300. enumerable: false,
  11301. configurable: true
  11302. });
  11303. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11304. /**
  11305. * Gets or sets the image used to render the thumb
  11306. */
  11307. get: function () {
  11308. return this._thumbBaseImage;
  11309. },
  11310. set: function (value) {
  11311. var _this = this;
  11312. if (this._thumbBaseImage === value) {
  11313. return;
  11314. }
  11315. this._thumbBaseImage = value;
  11316. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11317. if (!value.isLoaded) {
  11318. value.onImageLoadedObservable.addOnce(function () {
  11319. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11320. _this._thumbImage = rotatedValue;
  11321. if (!rotatedValue.isLoaded) {
  11322. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11323. _this._markAsDirty();
  11324. });
  11325. }
  11326. _this._markAsDirty();
  11327. });
  11328. }
  11329. else {
  11330. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11331. this._markAsDirty();
  11332. }
  11333. }
  11334. else {
  11335. this._thumbImage = value;
  11336. if (value && !value.isLoaded) {
  11337. value.onImageLoadedObservable.addOnce(function () {
  11338. _this._markAsDirty();
  11339. });
  11340. }
  11341. this._markAsDirty();
  11342. }
  11343. },
  11344. enumerable: false,
  11345. configurable: true
  11346. });
  11347. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11348. /**
  11349. * Gets or sets the length of the thumb
  11350. */
  11351. get: function () {
  11352. return this._thumbLength;
  11353. },
  11354. set: function (value) {
  11355. if (this._thumbLength === value) {
  11356. return;
  11357. }
  11358. this._thumbLength = value;
  11359. this._markAsDirty();
  11360. },
  11361. enumerable: false,
  11362. configurable: true
  11363. });
  11364. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11365. /**
  11366. * Gets or sets the height of the thumb
  11367. */
  11368. get: function () {
  11369. return this._thumbHeight;
  11370. },
  11371. set: function (value) {
  11372. if (this._thumbLength === value) {
  11373. return;
  11374. }
  11375. this._thumbHeight = value;
  11376. this._markAsDirty();
  11377. },
  11378. enumerable: false,
  11379. configurable: true
  11380. });
  11381. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11382. /**
  11383. * Gets or sets the height of the bar image
  11384. */
  11385. get: function () {
  11386. return this._barImageHeight;
  11387. },
  11388. set: function (value) {
  11389. if (this._barImageHeight === value) {
  11390. return;
  11391. }
  11392. this._barImageHeight = value;
  11393. this._markAsDirty();
  11394. },
  11395. enumerable: false,
  11396. configurable: true
  11397. });
  11398. ImageScrollBar.prototype._getTypeName = function () {
  11399. return "ImageScrollBar";
  11400. };
  11401. ImageScrollBar.prototype._getThumbThickness = function () {
  11402. var thumbThickness = 0;
  11403. if (this._thumbWidth.isPixel) {
  11404. thumbThickness = this._thumbWidth.getValue(this._host);
  11405. }
  11406. else {
  11407. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11408. }
  11409. return thumbThickness;
  11410. };
  11411. ImageScrollBar.prototype._draw = function (context) {
  11412. context.save();
  11413. this._applyStates(context);
  11414. this._prepareRenderingData("rectangle");
  11415. var thumbPosition = this._getThumbPosition();
  11416. var left = this._renderLeft;
  11417. var top = this._renderTop;
  11418. var width = this._renderWidth;
  11419. var height = this._renderHeight;
  11420. // Background
  11421. if (this._backgroundImage) {
  11422. this._tempMeasure.copyFromFloats(left, top, width, height);
  11423. if (this.isVertical) {
  11424. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11425. this._tempMeasure.height += this._effectiveThumbThickness;
  11426. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11427. }
  11428. else {
  11429. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11430. this._tempMeasure.width += this._effectiveThumbThickness;
  11431. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11432. }
  11433. this._backgroundImage._draw(context);
  11434. }
  11435. // Thumb
  11436. if (this.isVertical) {
  11437. 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);
  11438. }
  11439. else {
  11440. 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);
  11441. }
  11442. if (this._thumbImage) {
  11443. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11444. this._thumbImage._draw(context);
  11445. }
  11446. context.restore();
  11447. };
  11448. /** @hidden */
  11449. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11450. if (this.rotation != 0) {
  11451. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11452. x = this._transformedPosition.x;
  11453. y = this._transformedPosition.y;
  11454. }
  11455. if (this._first) {
  11456. this._first = false;
  11457. this._originX = x;
  11458. this._originY = y;
  11459. // Check if move is required
  11460. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11461. if (this.isVertical) {
  11462. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11463. }
  11464. else {
  11465. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11466. }
  11467. }
  11468. }
  11469. // Delta mode
  11470. var delta = 0;
  11471. if (this.isVertical) {
  11472. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11473. }
  11474. else {
  11475. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11476. }
  11477. this.value += delta * (this.maximum - this.minimum);
  11478. this._originX = x;
  11479. this._originY = y;
  11480. };
  11481. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  11482. this._first = true;
  11483. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  11484. };
  11485. return ImageScrollBar;
  11486. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11487. /***/ }),
  11488. /***/ "./2D/controls/sliders/scrollBar.ts":
  11489. /*!******************************************!*\
  11490. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11491. \******************************************/
  11492. /*! exports provided: ScrollBar */
  11493. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11494. "use strict";
  11495. __webpack_require__.r(__webpack_exports__);
  11496. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11497. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11498. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11499. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11500. /**
  11501. * Class used to create slider controls
  11502. */
  11503. var ScrollBar = /** @class */ (function (_super) {
  11504. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11505. /**
  11506. * Creates a new Slider
  11507. * @param name defines the control name
  11508. */
  11509. function ScrollBar(name) {
  11510. var _this = _super.call(this, name) || this;
  11511. _this.name = name;
  11512. _this._background = "black";
  11513. _this._borderColor = "white";
  11514. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11515. return _this;
  11516. }
  11517. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11518. /** Gets or sets border color */
  11519. get: function () {
  11520. return this._borderColor;
  11521. },
  11522. set: function (value) {
  11523. if (this._borderColor === value) {
  11524. return;
  11525. }
  11526. this._borderColor = value;
  11527. this._markAsDirty();
  11528. },
  11529. enumerable: false,
  11530. configurable: true
  11531. });
  11532. Object.defineProperty(ScrollBar.prototype, "background", {
  11533. /** Gets or sets background color */
  11534. get: function () {
  11535. return this._background;
  11536. },
  11537. set: function (value) {
  11538. if (this._background === value) {
  11539. return;
  11540. }
  11541. this._background = value;
  11542. this._markAsDirty();
  11543. },
  11544. enumerable: false,
  11545. configurable: true
  11546. });
  11547. ScrollBar.prototype._getTypeName = function () {
  11548. return "Scrollbar";
  11549. };
  11550. ScrollBar.prototype._getThumbThickness = function () {
  11551. var thumbThickness = 0;
  11552. if (this._thumbWidth.isPixel) {
  11553. thumbThickness = this._thumbWidth.getValue(this._host);
  11554. }
  11555. else {
  11556. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11557. }
  11558. return thumbThickness;
  11559. };
  11560. ScrollBar.prototype._draw = function (context) {
  11561. context.save();
  11562. this._applyStates(context);
  11563. this._prepareRenderingData("rectangle");
  11564. var left = this._renderLeft;
  11565. var thumbPosition = this._getThumbPosition();
  11566. context.fillStyle = this._background;
  11567. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11568. // Value bar
  11569. context.fillStyle = this.color;
  11570. // Thumb
  11571. if (this.isVertical) {
  11572. this._tempMeasure.left = left - this._effectiveBarOffset;
  11573. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11574. this._tempMeasure.width = this._currentMeasure.width;
  11575. this._tempMeasure.height = this._effectiveThumbThickness;
  11576. }
  11577. else {
  11578. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11579. this._tempMeasure.top = this._currentMeasure.top;
  11580. this._tempMeasure.width = this._effectiveThumbThickness;
  11581. this._tempMeasure.height = this._currentMeasure.height;
  11582. }
  11583. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11584. context.restore();
  11585. };
  11586. /** @hidden */
  11587. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11588. if (this.rotation != 0) {
  11589. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11590. x = this._transformedPosition.x;
  11591. y = this._transformedPosition.y;
  11592. }
  11593. if (this._first) {
  11594. this._first = false;
  11595. this._originX = x;
  11596. this._originY = y;
  11597. // Check if move is required
  11598. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11599. if (this.isVertical) {
  11600. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11601. }
  11602. else {
  11603. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11604. }
  11605. }
  11606. }
  11607. // Delta mode
  11608. var delta = 0;
  11609. if (this.isVertical) {
  11610. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11611. }
  11612. else {
  11613. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11614. }
  11615. this.value += delta * (this.maximum - this.minimum);
  11616. this._originX = x;
  11617. this._originY = y;
  11618. };
  11619. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  11620. this._first = true;
  11621. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  11622. };
  11623. return ScrollBar;
  11624. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11625. /***/ }),
  11626. /***/ "./2D/controls/sliders/slider.ts":
  11627. /*!***************************************!*\
  11628. !*** ./2D/controls/sliders/slider.ts ***!
  11629. \***************************************/
  11630. /*! exports provided: Slider */
  11631. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11632. "use strict";
  11633. __webpack_require__.r(__webpack_exports__);
  11634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11635. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11636. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11637. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  11638. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11639. /**
  11640. * Class used to create slider controls
  11641. */
  11642. var Slider = /** @class */ (function (_super) {
  11643. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11644. /**
  11645. * Creates a new Slider
  11646. * @param name defines the control name
  11647. */
  11648. function Slider(name) {
  11649. var _this = _super.call(this, name) || this;
  11650. _this.name = name;
  11651. _this._background = "black";
  11652. _this._borderColor = "white";
  11653. _this._thumbColor = "";
  11654. _this._isThumbCircle = false;
  11655. _this._displayValueBar = true;
  11656. return _this;
  11657. }
  11658. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11659. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11660. get: function () {
  11661. return this._displayValueBar;
  11662. },
  11663. set: function (value) {
  11664. if (this._displayValueBar === value) {
  11665. return;
  11666. }
  11667. this._displayValueBar = value;
  11668. this._markAsDirty();
  11669. },
  11670. enumerable: false,
  11671. configurable: true
  11672. });
  11673. Object.defineProperty(Slider.prototype, "borderColor", {
  11674. /** Gets or sets border color */
  11675. get: function () {
  11676. return this._borderColor;
  11677. },
  11678. set: function (value) {
  11679. if (this._borderColor === value) {
  11680. return;
  11681. }
  11682. this._borderColor = value;
  11683. this._markAsDirty();
  11684. },
  11685. enumerable: false,
  11686. configurable: true
  11687. });
  11688. Object.defineProperty(Slider.prototype, "background", {
  11689. /** Gets or sets background color */
  11690. get: function () {
  11691. return this._background;
  11692. },
  11693. set: function (value) {
  11694. if (this._background === value) {
  11695. return;
  11696. }
  11697. this._background = value;
  11698. this._markAsDirty();
  11699. },
  11700. enumerable: false,
  11701. configurable: true
  11702. });
  11703. Object.defineProperty(Slider.prototype, "thumbColor", {
  11704. /** Gets or sets thumb's color */
  11705. get: function () {
  11706. return this._thumbColor;
  11707. },
  11708. set: function (value) {
  11709. if (this._thumbColor === value) {
  11710. return;
  11711. }
  11712. this._thumbColor = value;
  11713. this._markAsDirty();
  11714. },
  11715. enumerable: false,
  11716. configurable: true
  11717. });
  11718. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11719. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11720. get: function () {
  11721. return this._isThumbCircle;
  11722. },
  11723. set: function (value) {
  11724. if (this._isThumbCircle === value) {
  11725. return;
  11726. }
  11727. this._isThumbCircle = value;
  11728. this._markAsDirty();
  11729. },
  11730. enumerable: false,
  11731. configurable: true
  11732. });
  11733. Slider.prototype._getTypeName = function () {
  11734. return "Slider";
  11735. };
  11736. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11737. context.save();
  11738. this._applyStates(context);
  11739. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11740. var left = this._renderLeft;
  11741. var top = this._renderTop;
  11742. var width = this._renderWidth;
  11743. var height = this._renderHeight;
  11744. var radius = 0;
  11745. if (this.isThumbClamped && this.isThumbCircle) {
  11746. if (this.isVertical) {
  11747. top += (this._effectiveThumbThickness / 2);
  11748. }
  11749. else {
  11750. left += (this._effectiveThumbThickness / 2);
  11751. }
  11752. radius = this._backgroundBoxThickness / 2;
  11753. }
  11754. else {
  11755. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11756. }
  11757. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11758. context.shadowColor = this.shadowColor;
  11759. context.shadowBlur = this.shadowBlur;
  11760. context.shadowOffsetX = this.shadowOffsetX;
  11761. context.shadowOffsetY = this.shadowOffsetY;
  11762. }
  11763. var thumbPosition = this._getThumbPosition();
  11764. context.fillStyle = this._background;
  11765. if (this.isVertical) {
  11766. if (this.isThumbClamped) {
  11767. if (this.isThumbCircle) {
  11768. context.beginPath();
  11769. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11770. context.fill();
  11771. context.fillRect(left, top, width, height);
  11772. }
  11773. else {
  11774. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11775. }
  11776. }
  11777. else {
  11778. context.fillRect(left, top, width, height);
  11779. }
  11780. }
  11781. else {
  11782. if (this.isThumbClamped) {
  11783. if (this.isThumbCircle) {
  11784. context.beginPath();
  11785. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11786. context.fill();
  11787. context.fillRect(left, top, width, height);
  11788. }
  11789. else {
  11790. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11791. }
  11792. }
  11793. else {
  11794. context.fillRect(left, top, width, height);
  11795. }
  11796. }
  11797. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11798. context.shadowBlur = 0;
  11799. context.shadowOffsetX = 0;
  11800. context.shadowOffsetY = 0;
  11801. }
  11802. // Value bar
  11803. context.fillStyle = this.color;
  11804. if (this._displayValueBar) {
  11805. if (this.isVertical) {
  11806. if (this.isThumbClamped) {
  11807. if (this.isThumbCircle) {
  11808. context.beginPath();
  11809. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11810. context.fill();
  11811. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11812. }
  11813. else {
  11814. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11815. }
  11816. }
  11817. else {
  11818. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11819. }
  11820. }
  11821. else {
  11822. if (this.isThumbClamped) {
  11823. if (this.isThumbCircle) {
  11824. context.beginPath();
  11825. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11826. context.fill();
  11827. context.fillRect(left, top, thumbPosition, height);
  11828. }
  11829. else {
  11830. context.fillRect(left, top, thumbPosition, height);
  11831. }
  11832. }
  11833. else {
  11834. context.fillRect(left, top, thumbPosition, height);
  11835. }
  11836. }
  11837. }
  11838. // Thumb
  11839. context.fillStyle = this._thumbColor || this.color;
  11840. if (this.displayThumb) {
  11841. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11842. context.shadowColor = this.shadowColor;
  11843. context.shadowBlur = this.shadowBlur;
  11844. context.shadowOffsetX = this.shadowOffsetX;
  11845. context.shadowOffsetY = this.shadowOffsetY;
  11846. }
  11847. if (this._isThumbCircle) {
  11848. context.beginPath();
  11849. if (this.isVertical) {
  11850. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11851. }
  11852. else {
  11853. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11854. }
  11855. context.fill();
  11856. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11857. context.shadowBlur = 0;
  11858. context.shadowOffsetX = 0;
  11859. context.shadowOffsetY = 0;
  11860. }
  11861. context.strokeStyle = this._borderColor;
  11862. context.stroke();
  11863. }
  11864. else {
  11865. if (this.isVertical) {
  11866. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11867. }
  11868. else {
  11869. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11870. }
  11871. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11872. context.shadowBlur = 0;
  11873. context.shadowOffsetX = 0;
  11874. context.shadowOffsetY = 0;
  11875. }
  11876. context.strokeStyle = this._borderColor;
  11877. if (this.isVertical) {
  11878. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11879. }
  11880. else {
  11881. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11882. }
  11883. }
  11884. }
  11885. context.restore();
  11886. };
  11887. return Slider;
  11888. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11889. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11890. /***/ }),
  11891. /***/ "./2D/controls/stackPanel.ts":
  11892. /*!***********************************!*\
  11893. !*** ./2D/controls/stackPanel.ts ***!
  11894. \***********************************/
  11895. /*! exports provided: StackPanel */
  11896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11897. "use strict";
  11898. __webpack_require__.r(__webpack_exports__);
  11899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11900. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11901. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  11902. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11903. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11904. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11905. /**
  11906. * Class used to create a 2D stack panel container
  11907. */
  11908. var StackPanel = /** @class */ (function (_super) {
  11909. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11910. /**
  11911. * Creates a new StackPanel
  11912. * @param name defines control name
  11913. */
  11914. function StackPanel(name) {
  11915. var _this = _super.call(this, name) || this;
  11916. _this.name = name;
  11917. _this._isVertical = true;
  11918. _this._manualWidth = false;
  11919. _this._manualHeight = false;
  11920. _this._doNotTrackManualChanges = false;
  11921. /**
  11922. * Gets or sets a boolean indicating that layou warnings should be ignored
  11923. */
  11924. _this.ignoreLayoutWarnings = false;
  11925. return _this;
  11926. }
  11927. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11928. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11929. get: function () {
  11930. return this._isVertical;
  11931. },
  11932. set: function (value) {
  11933. if (this._isVertical === value) {
  11934. return;
  11935. }
  11936. this._isVertical = value;
  11937. this._markAsDirty();
  11938. },
  11939. enumerable: false,
  11940. configurable: true
  11941. });
  11942. Object.defineProperty(StackPanel.prototype, "width", {
  11943. get: function () {
  11944. return this._width.toString(this._host);
  11945. },
  11946. /**
  11947. * Gets or sets panel width.
  11948. * This value should not be set when in horizontal mode as it will be computed automatically
  11949. */
  11950. set: function (value) {
  11951. if (!this._doNotTrackManualChanges) {
  11952. this._manualWidth = true;
  11953. }
  11954. if (this._width.toString(this._host) === value) {
  11955. return;
  11956. }
  11957. if (this._width.fromString(value)) {
  11958. this._markAsDirty();
  11959. }
  11960. },
  11961. enumerable: false,
  11962. configurable: true
  11963. });
  11964. Object.defineProperty(StackPanel.prototype, "height", {
  11965. get: function () {
  11966. return this._height.toString(this._host);
  11967. },
  11968. /**
  11969. * Gets or sets panel height.
  11970. * This value should not be set when in vertical mode as it will be computed automatically
  11971. */
  11972. set: function (value) {
  11973. if (!this._doNotTrackManualChanges) {
  11974. this._manualHeight = true;
  11975. }
  11976. if (this._height.toString(this._host) === value) {
  11977. return;
  11978. }
  11979. if (this._height.fromString(value)) {
  11980. this._markAsDirty();
  11981. }
  11982. },
  11983. enumerable: false,
  11984. configurable: true
  11985. });
  11986. StackPanel.prototype._getTypeName = function () {
  11987. return "StackPanel";
  11988. };
  11989. /** @hidden */
  11990. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11991. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11992. var child = _a[_i];
  11993. if (this._isVertical) {
  11994. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11995. }
  11996. else {
  11997. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11998. }
  11999. }
  12000. _super.prototype._preMeasure.call(this, parentMeasure, context);
  12001. };
  12002. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  12003. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  12004. this._measureForChildren.copyFrom(parentMeasure);
  12005. this._measureForChildren.left = this._currentMeasure.left;
  12006. this._measureForChildren.top = this._currentMeasure.top;
  12007. if (!this.isVertical || this._manualWidth) {
  12008. this._measureForChildren.width = this._currentMeasure.width;
  12009. }
  12010. if (this.isVertical || this._manualHeight) {
  12011. this._measureForChildren.height = this._currentMeasure.height;
  12012. }
  12013. };
  12014. StackPanel.prototype._postMeasure = function () {
  12015. var stackWidth = 0;
  12016. var stackHeight = 0;
  12017. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12018. var child = _a[_i];
  12019. if (!child.isVisible || child.notRenderable) {
  12020. continue;
  12021. }
  12022. if (this._isVertical) {
  12023. if (child.top !== stackHeight + "px") {
  12024. child.top = stackHeight + "px";
  12025. this._rebuildLayout = true;
  12026. child._top.ignoreAdaptiveScaling = true;
  12027. }
  12028. if (child._height.isPercentage && !child._automaticSize) {
  12029. if (!this.ignoreLayoutWarnings) {
  12030. 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");
  12031. }
  12032. }
  12033. else {
  12034. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  12035. }
  12036. }
  12037. else {
  12038. if (child.left !== stackWidth + "px") {
  12039. child.left = stackWidth + "px";
  12040. this._rebuildLayout = true;
  12041. child._left.ignoreAdaptiveScaling = true;
  12042. }
  12043. if (child._width.isPercentage && !child._automaticSize) {
  12044. if (!this.ignoreLayoutWarnings) {
  12045. 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");
  12046. }
  12047. }
  12048. else {
  12049. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  12050. }
  12051. }
  12052. }
  12053. stackWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  12054. stackHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  12055. this._doNotTrackManualChanges = true;
  12056. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  12057. // User can now define their own height and width for stack panel.
  12058. var panelWidthChanged = false;
  12059. var panelHeightChanged = false;
  12060. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  12061. var previousHeight = this.height;
  12062. this.height = stackHeight + "px";
  12063. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  12064. }
  12065. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  12066. var previousWidth = this.width;
  12067. this.width = stackWidth + "px";
  12068. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  12069. }
  12070. if (panelHeightChanged) {
  12071. this._height.ignoreAdaptiveScaling = true;
  12072. }
  12073. if (panelWidthChanged) {
  12074. this._width.ignoreAdaptiveScaling = true;
  12075. }
  12076. this._doNotTrackManualChanges = false;
  12077. if (panelWidthChanged || panelHeightChanged) {
  12078. this._rebuildLayout = true;
  12079. }
  12080. _super.prototype._postMeasure.call(this);
  12081. };
  12082. return StackPanel;
  12083. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  12084. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  12085. /***/ }),
  12086. /***/ "./2D/controls/statics.ts":
  12087. /*!********************************!*\
  12088. !*** ./2D/controls/statics.ts ***!
  12089. \********************************/
  12090. /*! exports provided: name */
  12091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12092. "use strict";
  12093. __webpack_require__.r(__webpack_exports__);
  12094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  12095. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12096. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12097. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  12098. /**
  12099. * Forcing an export so that this code will execute
  12100. * @hidden
  12101. */
  12102. var name = "Statics";
  12103. /**
  12104. * Creates a stack panel that can be used to render headers
  12105. * @param control defines the control to associate with the header
  12106. * @param text defines the text of the header
  12107. * @param size defines the size of the header
  12108. * @param options defines options used to configure the header
  12109. * @returns a new StackPanel
  12110. */
  12111. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  12112. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  12113. var isHorizontal = options ? options.isHorizontal : true;
  12114. var controlFirst = options ? options.controlFirst : true;
  12115. panel.isVertical = !isHorizontal;
  12116. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  12117. header.text = text;
  12118. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12119. if (isHorizontal) {
  12120. header.width = size;
  12121. }
  12122. else {
  12123. header.height = size;
  12124. }
  12125. if (controlFirst) {
  12126. panel.addControl(control);
  12127. panel.addControl(header);
  12128. header.paddingLeft = "5px";
  12129. }
  12130. else {
  12131. panel.addControl(header);
  12132. panel.addControl(control);
  12133. header.paddingRight = "5px";
  12134. }
  12135. header.shadowBlur = control.shadowBlur;
  12136. header.shadowColor = control.shadowColor;
  12137. header.shadowOffsetX = control.shadowOffsetX;
  12138. header.shadowOffsetY = control.shadowOffsetY;
  12139. return panel;
  12140. };
  12141. /***/ }),
  12142. /***/ "./2D/controls/textBlock.ts":
  12143. /*!**********************************!*\
  12144. !*** ./2D/controls/textBlock.ts ***!
  12145. \**********************************/
  12146. /*! exports provided: TextWrapping, TextBlock */
  12147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12148. "use strict";
  12149. __webpack_require__.r(__webpack_exports__);
  12150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  12151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  12152. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12153. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12154. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12155. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  12156. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12157. /**
  12158. * Enum that determines the text-wrapping mode to use.
  12159. */
  12160. var TextWrapping;
  12161. (function (TextWrapping) {
  12162. /**
  12163. * Clip the text when it's larger than Control.width; this is the default mode.
  12164. */
  12165. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  12166. /**
  12167. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  12168. */
  12169. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  12170. /**
  12171. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  12172. */
  12173. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  12174. })(TextWrapping || (TextWrapping = {}));
  12175. /**
  12176. * Class used to create text block control
  12177. */
  12178. var TextBlock = /** @class */ (function (_super) {
  12179. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  12180. /**
  12181. * Creates a new TextBlock object
  12182. * @param name defines the name of the control
  12183. * @param text defines the text to display (emptry string by default)
  12184. */
  12185. function TextBlock(
  12186. /**
  12187. * Defines the name of the control
  12188. */
  12189. name, text) {
  12190. if (text === void 0) { text = ""; }
  12191. var _this = _super.call(this, name) || this;
  12192. _this.name = name;
  12193. _this._text = "";
  12194. _this._textWrapping = TextWrapping.Clip;
  12195. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  12196. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  12197. _this._resizeToFit = false;
  12198. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  12199. _this._outlineWidth = 0;
  12200. _this._outlineColor = "white";
  12201. _this._underline = false;
  12202. _this._lineThrough = false;
  12203. /**
  12204. * An event triggered after the text is changed
  12205. */
  12206. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12207. /**
  12208. * An event triggered after the text was broken up into lines
  12209. */
  12210. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12211. _this.text = text;
  12212. return _this;
  12213. }
  12214. Object.defineProperty(TextBlock.prototype, "lines", {
  12215. /**
  12216. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  12217. */
  12218. get: function () {
  12219. return this._lines;
  12220. },
  12221. enumerable: false,
  12222. configurable: true
  12223. });
  12224. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12225. /**
  12226. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12227. */
  12228. get: function () {
  12229. return this._resizeToFit;
  12230. },
  12231. /**
  12232. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12233. */
  12234. set: function (value) {
  12235. if (this._resizeToFit === value) {
  12236. return;
  12237. }
  12238. this._resizeToFit = value;
  12239. if (this._resizeToFit) {
  12240. this._width.ignoreAdaptiveScaling = true;
  12241. this._height.ignoreAdaptiveScaling = true;
  12242. }
  12243. this._markAsDirty();
  12244. },
  12245. enumerable: false,
  12246. configurable: true
  12247. });
  12248. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12249. /**
  12250. * Gets or sets a boolean indicating if text must be wrapped
  12251. */
  12252. get: function () {
  12253. return this._textWrapping;
  12254. },
  12255. /**
  12256. * Gets or sets a boolean indicating if text must be wrapped
  12257. */
  12258. set: function (value) {
  12259. if (this._textWrapping === value) {
  12260. return;
  12261. }
  12262. this._textWrapping = +value;
  12263. this._markAsDirty();
  12264. },
  12265. enumerable: false,
  12266. configurable: true
  12267. });
  12268. Object.defineProperty(TextBlock.prototype, "text", {
  12269. /**
  12270. * Gets or sets text to display
  12271. */
  12272. get: function () {
  12273. return this._text;
  12274. },
  12275. /**
  12276. * Gets or sets text to display
  12277. */
  12278. set: function (value) {
  12279. if (this._text === value) {
  12280. return;
  12281. }
  12282. this._text = value;
  12283. this._markAsDirty();
  12284. this.onTextChangedObservable.notifyObservers(this);
  12285. },
  12286. enumerable: false,
  12287. configurable: true
  12288. });
  12289. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12290. /**
  12291. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12292. */
  12293. get: function () {
  12294. return this._textHorizontalAlignment;
  12295. },
  12296. /**
  12297. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12298. */
  12299. set: function (value) {
  12300. if (this._textHorizontalAlignment === value) {
  12301. return;
  12302. }
  12303. this._textHorizontalAlignment = value;
  12304. this._markAsDirty();
  12305. },
  12306. enumerable: false,
  12307. configurable: true
  12308. });
  12309. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12310. /**
  12311. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12312. */
  12313. get: function () {
  12314. return this._textVerticalAlignment;
  12315. },
  12316. /**
  12317. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12318. */
  12319. set: function (value) {
  12320. if (this._textVerticalAlignment === value) {
  12321. return;
  12322. }
  12323. this._textVerticalAlignment = value;
  12324. this._markAsDirty();
  12325. },
  12326. enumerable: false,
  12327. configurable: true
  12328. });
  12329. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12330. /**
  12331. * Gets or sets line spacing value
  12332. */
  12333. get: function () {
  12334. return this._lineSpacing.toString(this._host);
  12335. },
  12336. /**
  12337. * Gets or sets line spacing value
  12338. */
  12339. set: function (value) {
  12340. if (this._lineSpacing.fromString(value)) {
  12341. this._markAsDirty();
  12342. }
  12343. },
  12344. enumerable: false,
  12345. configurable: true
  12346. });
  12347. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12348. /**
  12349. * Gets or sets outlineWidth of the text to display
  12350. */
  12351. get: function () {
  12352. return this._outlineWidth;
  12353. },
  12354. /**
  12355. * Gets or sets outlineWidth of the text to display
  12356. */
  12357. set: function (value) {
  12358. if (this._outlineWidth === value) {
  12359. return;
  12360. }
  12361. this._outlineWidth = value;
  12362. this._markAsDirty();
  12363. },
  12364. enumerable: false,
  12365. configurable: true
  12366. });
  12367. Object.defineProperty(TextBlock.prototype, "underline", {
  12368. /**
  12369. * Gets or sets a boolean indicating that text must have underline
  12370. */
  12371. get: function () {
  12372. return this._underline;
  12373. },
  12374. /**
  12375. * Gets or sets a boolean indicating that text must have underline
  12376. */
  12377. set: function (value) {
  12378. if (this._underline === value) {
  12379. return;
  12380. }
  12381. this._underline = value;
  12382. this._markAsDirty();
  12383. },
  12384. enumerable: false,
  12385. configurable: true
  12386. });
  12387. Object.defineProperty(TextBlock.prototype, "lineThrough", {
  12388. /**
  12389. * Gets or sets an boolean indicating that text must be crossed out
  12390. */
  12391. get: function () {
  12392. return this._lineThrough;
  12393. },
  12394. /**
  12395. * Gets or sets an boolean indicating that text must be crossed out
  12396. */
  12397. set: function (value) {
  12398. if (this._lineThrough === value) {
  12399. return;
  12400. }
  12401. this._lineThrough = value;
  12402. this._markAsDirty();
  12403. },
  12404. enumerable: false,
  12405. configurable: true
  12406. });
  12407. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12408. /**
  12409. * Gets or sets outlineColor of the text to display
  12410. */
  12411. get: function () {
  12412. return this._outlineColor;
  12413. },
  12414. /**
  12415. * Gets or sets outlineColor of the text to display
  12416. */
  12417. set: function (value) {
  12418. if (this._outlineColor === value) {
  12419. return;
  12420. }
  12421. this._outlineColor = value;
  12422. this._markAsDirty();
  12423. },
  12424. enumerable: false,
  12425. configurable: true
  12426. });
  12427. TextBlock.prototype._getTypeName = function () {
  12428. return "TextBlock";
  12429. };
  12430. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12431. if (!this._fontOffset) {
  12432. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12433. }
  12434. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12435. // Prepare lines
  12436. this._lines = this._breakLines(this._currentMeasure.width, context);
  12437. this.onLinesReadyObservable.notifyObservers(this);
  12438. var maxLineWidth = 0;
  12439. for (var i = 0; i < this._lines.length; i++) {
  12440. var line = this._lines[i];
  12441. if (line.width > maxLineWidth) {
  12442. maxLineWidth = line.width;
  12443. }
  12444. }
  12445. if (this._resizeToFit) {
  12446. if (this._textWrapping === TextWrapping.Clip) {
  12447. var newWidth = (this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth) | 0;
  12448. if (newWidth !== this._width.internalValue) {
  12449. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12450. this._rebuildLayout = true;
  12451. }
  12452. }
  12453. var newHeight = (this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;
  12454. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12455. var lineSpacing = 0;
  12456. if (this._lineSpacing.isPixel) {
  12457. lineSpacing = this._lineSpacing.getValue(this._host);
  12458. }
  12459. else {
  12460. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12461. }
  12462. newHeight += (this._lines.length - 1) * lineSpacing;
  12463. }
  12464. if (newHeight !== this._height.internalValue) {
  12465. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12466. this._rebuildLayout = true;
  12467. }
  12468. }
  12469. };
  12470. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12471. var width = this._currentMeasure.width;
  12472. var x = 0;
  12473. switch (this._textHorizontalAlignment) {
  12474. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12475. x = 0;
  12476. break;
  12477. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12478. x = width - textWidth;
  12479. break;
  12480. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12481. x = (width - textWidth) / 2;
  12482. break;
  12483. }
  12484. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12485. context.shadowColor = this.shadowColor;
  12486. context.shadowBlur = this.shadowBlur;
  12487. context.shadowOffsetX = this.shadowOffsetX;
  12488. context.shadowOffsetY = this.shadowOffsetY;
  12489. }
  12490. if (this.outlineWidth) {
  12491. context.strokeText(text, this._currentMeasure.left + x, y);
  12492. }
  12493. context.fillText(text, this._currentMeasure.left + x, y);
  12494. if (this._underline) {
  12495. context.beginPath();
  12496. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  12497. context.moveTo(this._currentMeasure.left + x, y + 3);
  12498. context.lineTo(this._currentMeasure.left + x + textWidth, y + 3);
  12499. context.stroke();
  12500. context.closePath();
  12501. }
  12502. if (this._lineThrough) {
  12503. context.beginPath();
  12504. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  12505. context.moveTo(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3);
  12506. context.lineTo(this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3);
  12507. context.stroke();
  12508. context.closePath();
  12509. }
  12510. };
  12511. /** @hidden */
  12512. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12513. context.save();
  12514. this._applyStates(context);
  12515. // Render lines
  12516. this._renderLines(context);
  12517. context.restore();
  12518. };
  12519. TextBlock.prototype._applyStates = function (context) {
  12520. _super.prototype._applyStates.call(this, context);
  12521. if (this.outlineWidth) {
  12522. context.lineWidth = this.outlineWidth;
  12523. context.strokeStyle = this.outlineColor;
  12524. context.lineJoin = 'miter';
  12525. context.miterLimit = 2;
  12526. }
  12527. };
  12528. TextBlock.prototype._breakLines = function (refWidth, context) {
  12529. var lines = [];
  12530. var _lines = this.text.split("\n");
  12531. if (this._textWrapping === TextWrapping.Ellipsis) {
  12532. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12533. var _line = _lines_1[_i];
  12534. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12535. }
  12536. }
  12537. else if (this._textWrapping === TextWrapping.WordWrap) {
  12538. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12539. var _line = _lines_2[_a];
  12540. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12541. }
  12542. }
  12543. else {
  12544. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12545. var _line = _lines_3[_b];
  12546. lines.push(this._parseLine(_line, context));
  12547. }
  12548. }
  12549. return lines;
  12550. };
  12551. TextBlock.prototype._parseLine = function (line, context) {
  12552. if (line === void 0) { line = ""; }
  12553. return { text: line, width: context.measureText(line).width };
  12554. };
  12555. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12556. if (line === void 0) { line = ""; }
  12557. var lineWidth = context.measureText(line).width;
  12558. if (lineWidth > width) {
  12559. line += "…";
  12560. }
  12561. // unicode support. split('') does not work with unicode!
  12562. // make sure Array.from is available
  12563. var characters = Array.from && Array.from(line);
  12564. if (!characters) {
  12565. // no array.from, use the old method
  12566. while (line.length > 2 && lineWidth > width) {
  12567. line = line.slice(0, -2) + "…";
  12568. lineWidth = context.measureText(line).width;
  12569. }
  12570. }
  12571. else {
  12572. while (characters.length && lineWidth > width) {
  12573. characters.pop();
  12574. line = characters.join("") + "...";
  12575. lineWidth = context.measureText(line).width;
  12576. }
  12577. }
  12578. return { text: line, width: lineWidth };
  12579. };
  12580. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12581. if (line === void 0) { line = ""; }
  12582. var lines = [];
  12583. var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(" ");
  12584. var lineWidth = 0;
  12585. for (var n = 0; n < words.length; n++) {
  12586. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12587. var metrics = context.measureText(testLine);
  12588. var testWidth = metrics.width;
  12589. if (testWidth > width && n > 0) {
  12590. lines.push({ text: line, width: lineWidth });
  12591. line = words[n];
  12592. lineWidth = context.measureText(line).width;
  12593. }
  12594. else {
  12595. lineWidth = testWidth;
  12596. line = testLine;
  12597. }
  12598. }
  12599. lines.push({ text: line, width: lineWidth });
  12600. return lines;
  12601. };
  12602. TextBlock.prototype._renderLines = function (context) {
  12603. var height = this._currentMeasure.height;
  12604. var rootY = 0;
  12605. switch (this._textVerticalAlignment) {
  12606. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12607. rootY = this._fontOffset.ascent;
  12608. break;
  12609. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12610. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12611. break;
  12612. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12613. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12614. break;
  12615. }
  12616. rootY += this._currentMeasure.top;
  12617. for (var i = 0; i < this._lines.length; i++) {
  12618. var line = this._lines[i];
  12619. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12620. if (this._lineSpacing.isPixel) {
  12621. rootY += this._lineSpacing.getValue(this._host);
  12622. }
  12623. else {
  12624. rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12625. }
  12626. }
  12627. this._drawText(line.text, line.width, rootY, context);
  12628. rootY += this._fontOffset.height;
  12629. }
  12630. };
  12631. /**
  12632. * Given a width constraint applied on the text block, find the expected height
  12633. * @returns expected height
  12634. */
  12635. TextBlock.prototype.computeExpectedHeight = function () {
  12636. if (this.text && this.widthInPixels) {
  12637. var context_1 = document.createElement("canvas").getContext("2d");
  12638. if (context_1) {
  12639. this._applyStates(context_1);
  12640. if (!this._fontOffset) {
  12641. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12642. }
  12643. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12644. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12645. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12646. var lineSpacing = 0;
  12647. if (this._lineSpacing.isPixel) {
  12648. lineSpacing = this._lineSpacing.getValue(this._host);
  12649. }
  12650. else {
  12651. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12652. }
  12653. newHeight += (lines.length - 1) * lineSpacing;
  12654. }
  12655. return newHeight;
  12656. }
  12657. }
  12658. return 0;
  12659. };
  12660. TextBlock.prototype.dispose = function () {
  12661. _super.prototype.dispose.call(this);
  12662. this.onTextChangedObservable.clear();
  12663. };
  12664. return TextBlock;
  12665. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12666. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12667. /***/ }),
  12668. /***/ "./2D/controls/textWrapper.ts":
  12669. /*!************************************!*\
  12670. !*** ./2D/controls/textWrapper.ts ***!
  12671. \************************************/
  12672. /*! exports provided: TextWrapper */
  12673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12674. "use strict";
  12675. __webpack_require__.r(__webpack_exports__);
  12676. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return TextWrapper; });
  12677. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12678. /** @hidden */
  12679. var TextWrapper = /** @class */ (function () {
  12680. function TextWrapper() {
  12681. }
  12682. Object.defineProperty(TextWrapper.prototype, "text", {
  12683. get: function () {
  12684. return this._characters ? this._characters.join("") : this._text;
  12685. },
  12686. set: function (txt) {
  12687. this._text = txt;
  12688. this._characters = Array.from && Array.from(txt);
  12689. },
  12690. enumerable: false,
  12691. configurable: true
  12692. });
  12693. Object.defineProperty(TextWrapper.prototype, "length", {
  12694. get: function () {
  12695. return this._characters ? this._characters.length : this._text.length;
  12696. },
  12697. enumerable: false,
  12698. configurable: true
  12699. });
  12700. TextWrapper.prototype.removePart = function (idxStart, idxEnd, insertTxt) {
  12701. var _a;
  12702. this._text = this._text.slice(0, idxStart) + (insertTxt ? insertTxt : "") + this._text.slice(idxEnd);
  12703. if (this._characters) {
  12704. var newCharacters = insertTxt ? Array.from(insertTxt) : [];
  12705. (_a = this._characters).splice.apply(_a, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spreadArrays"])([idxStart, idxEnd - idxStart], newCharacters));
  12706. }
  12707. };
  12708. TextWrapper.prototype.charAt = function (idx) {
  12709. return this._characters ? this._characters[idx] : this._text.charAt(idx);
  12710. };
  12711. TextWrapper.prototype.substr = function (from, length) {
  12712. if (this._characters) {
  12713. if (isNaN(from)) {
  12714. from = 0;
  12715. }
  12716. else if (from >= 0) {
  12717. from = Math.min(from, this._characters.length);
  12718. }
  12719. else {
  12720. from = this._characters.length + Math.max(from, -this._characters.length);
  12721. }
  12722. if (length === undefined) {
  12723. length = this._characters.length - from;
  12724. }
  12725. else if (isNaN(length)) {
  12726. length = 0;
  12727. }
  12728. else if (length < 0) {
  12729. length = 0;
  12730. }
  12731. var temp = [];
  12732. while (--length >= 0) {
  12733. temp[length] = this._characters[from + length];
  12734. }
  12735. return temp.join("");
  12736. }
  12737. return this._text.substr(from, length);
  12738. };
  12739. TextWrapper.prototype.substring = function (from, to) {
  12740. if (this._characters) {
  12741. if (isNaN(from)) {
  12742. from = 0;
  12743. }
  12744. else if (from > this._characters.length) {
  12745. from = this._characters.length;
  12746. }
  12747. else if (from < 0) {
  12748. from = 0;
  12749. }
  12750. if (to === undefined) {
  12751. to = this._characters.length;
  12752. }
  12753. else if (isNaN(to)) {
  12754. to = 0;
  12755. }
  12756. else if (to > this._characters.length) {
  12757. to = this._characters.length;
  12758. }
  12759. else if (to < 0) {
  12760. to = 0;
  12761. }
  12762. var temp = [];
  12763. var idx = 0;
  12764. while (from < to) {
  12765. temp[idx++] = this._characters[from++];
  12766. }
  12767. return temp.join("");
  12768. }
  12769. return this._text.substring(from, to);
  12770. };
  12771. TextWrapper.prototype.isWord = function (index) {
  12772. var rWord = /\w/g;
  12773. return this._characters ? this._characters[index].search(rWord) !== -1 : this._text.search(rWord) !== -1;
  12774. };
  12775. return TextWrapper;
  12776. }());
  12777. /***/ }),
  12778. /***/ "./2D/controls/virtualKeyboard.ts":
  12779. /*!****************************************!*\
  12780. !*** ./2D/controls/virtualKeyboard.ts ***!
  12781. \****************************************/
  12782. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12783. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12784. "use strict";
  12785. __webpack_require__.r(__webpack_exports__);
  12786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12788. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12789. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12790. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12791. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12792. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12793. /**
  12794. * Class used to store key control properties
  12795. */
  12796. var KeyPropertySet = /** @class */ (function () {
  12797. function KeyPropertySet() {
  12798. }
  12799. return KeyPropertySet;
  12800. }());
  12801. /**
  12802. * Class used to create virtual keyboard
  12803. */
  12804. var VirtualKeyboard = /** @class */ (function (_super) {
  12805. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12806. function VirtualKeyboard() {
  12807. var _this = _super !== null && _super.apply(this, arguments) || this;
  12808. /** Observable raised when a key is pressed */
  12809. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12810. /** Gets or sets default key button width */
  12811. _this.defaultButtonWidth = "40px";
  12812. /** Gets or sets default key button height */
  12813. _this.defaultButtonHeight = "40px";
  12814. /** Gets or sets default key button left padding */
  12815. _this.defaultButtonPaddingLeft = "2px";
  12816. /** Gets or sets default key button right padding */
  12817. _this.defaultButtonPaddingRight = "2px";
  12818. /** Gets or sets default key button top padding */
  12819. _this.defaultButtonPaddingTop = "2px";
  12820. /** Gets or sets default key button bottom padding */
  12821. _this.defaultButtonPaddingBottom = "2px";
  12822. /** Gets or sets default key button foreground color */
  12823. _this.defaultButtonColor = "#DDD";
  12824. /** Gets or sets default key button background color */
  12825. _this.defaultButtonBackground = "#070707";
  12826. /** Gets or sets shift button foreground color */
  12827. _this.shiftButtonColor = "#7799FF";
  12828. /** Gets or sets shift button thickness*/
  12829. _this.selectedShiftThickness = 1;
  12830. /** Gets shift key state */
  12831. _this.shiftState = 0;
  12832. _this._currentlyConnectedInputText = null;
  12833. _this._connectedInputTexts = [];
  12834. _this._onKeyPressObserver = null;
  12835. return _this;
  12836. }
  12837. VirtualKeyboard.prototype._getTypeName = function () {
  12838. return "VirtualKeyboard";
  12839. };
  12840. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12841. var _this = this;
  12842. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12843. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12844. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12845. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12846. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12847. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12848. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12849. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12850. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12851. button.thickness = 0;
  12852. button.isFocusInvisible = true;
  12853. button.shadowColor = this.shadowColor;
  12854. button.shadowBlur = this.shadowBlur;
  12855. button.shadowOffsetX = this.shadowOffsetX;
  12856. button.shadowOffsetY = this.shadowOffsetY;
  12857. button.onPointerUpObservable.add(function () {
  12858. _this.onKeyPressObservable.notifyObservers(key);
  12859. });
  12860. return button;
  12861. };
  12862. /**
  12863. * Adds a new row of keys
  12864. * @param keys defines the list of keys to add
  12865. * @param propertySets defines the associated property sets
  12866. */
  12867. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12868. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12869. panel.isVertical = false;
  12870. panel.isFocusInvisible = true;
  12871. var maxKey = null;
  12872. for (var i = 0; i < keys.length; i++) {
  12873. var properties = null;
  12874. if (propertySets && propertySets.length === keys.length) {
  12875. properties = propertySets[i];
  12876. }
  12877. var key = this._createKey(keys[i], properties);
  12878. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12879. maxKey = key;
  12880. }
  12881. panel.addControl(key);
  12882. }
  12883. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12884. this.addControl(panel);
  12885. };
  12886. /**
  12887. * Set the shift key to a specific state
  12888. * @param shiftState defines the new shift state
  12889. */
  12890. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12891. if (!this.children) {
  12892. return;
  12893. }
  12894. for (var i = 0; i < this.children.length; i++) {
  12895. var row = this.children[i];
  12896. if (!row || !row.children) {
  12897. continue;
  12898. }
  12899. var rowContainer = row;
  12900. for (var j = 0; j < rowContainer.children.length; j++) {
  12901. var button = rowContainer.children[j];
  12902. if (!button || !button.children[0]) {
  12903. continue;
  12904. }
  12905. var button_tblock = button.children[0];
  12906. if (button_tblock.text === "\u21E7") {
  12907. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12908. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12909. }
  12910. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12911. }
  12912. }
  12913. };
  12914. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12915. /** Gets the input text control currently attached to the keyboard */
  12916. get: function () {
  12917. return this._currentlyConnectedInputText;
  12918. },
  12919. enumerable: false,
  12920. configurable: true
  12921. });
  12922. /**
  12923. * Connects the keyboard with an input text control
  12924. *
  12925. * @param input defines the target control
  12926. */
  12927. VirtualKeyboard.prototype.connect = function (input) {
  12928. var _this = this;
  12929. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12930. if (inputTextAlreadyConnected) {
  12931. return;
  12932. }
  12933. if (this._onKeyPressObserver === null) {
  12934. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12935. if (!_this._currentlyConnectedInputText) {
  12936. return;
  12937. }
  12938. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12939. switch (key) {
  12940. case "\u21E7":
  12941. _this.shiftState++;
  12942. if (_this.shiftState > 2) {
  12943. _this.shiftState = 0;
  12944. }
  12945. _this.applyShiftState(_this.shiftState);
  12946. return;
  12947. case "\u2190":
  12948. _this._currentlyConnectedInputText.processKey(8);
  12949. return;
  12950. case "\u21B5":
  12951. _this._currentlyConnectedInputText.processKey(13);
  12952. return;
  12953. }
  12954. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12955. if (_this.shiftState === 1) {
  12956. _this.shiftState = 0;
  12957. _this.applyShiftState(_this.shiftState);
  12958. }
  12959. });
  12960. }
  12961. this.isVisible = false;
  12962. this._currentlyConnectedInputText = input;
  12963. input._connectedVirtualKeyboard = this;
  12964. // Events hooking
  12965. var onFocusObserver = input.onFocusObservable.add(function () {
  12966. _this._currentlyConnectedInputText = input;
  12967. input._connectedVirtualKeyboard = _this;
  12968. _this.isVisible = true;
  12969. });
  12970. var onBlurObserver = input.onBlurObservable.add(function () {
  12971. input._connectedVirtualKeyboard = null;
  12972. _this._currentlyConnectedInputText = null;
  12973. _this.isVisible = false;
  12974. });
  12975. this._connectedInputTexts.push({
  12976. input: input,
  12977. onBlurObserver: onBlurObserver,
  12978. onFocusObserver: onFocusObserver
  12979. });
  12980. };
  12981. /**
  12982. * Disconnects the keyboard from connected InputText controls
  12983. *
  12984. * @param input optionally defines a target control, otherwise all are disconnected
  12985. */
  12986. VirtualKeyboard.prototype.disconnect = function (input) {
  12987. var _this = this;
  12988. if (input) {
  12989. // .find not available on IE
  12990. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12991. if (filtered.length === 1) {
  12992. this._removeConnectedInputObservables(filtered[0]);
  12993. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12994. if (this._currentlyConnectedInputText === input) {
  12995. this._currentlyConnectedInputText = null;
  12996. }
  12997. }
  12998. }
  12999. else {
  13000. this._connectedInputTexts.forEach(function (connectedInputText) {
  13001. _this._removeConnectedInputObservables(connectedInputText);
  13002. });
  13003. this._connectedInputTexts = [];
  13004. }
  13005. if (this._connectedInputTexts.length === 0) {
  13006. this._currentlyConnectedInputText = null;
  13007. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  13008. this._onKeyPressObserver = null;
  13009. }
  13010. };
  13011. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  13012. connectedInputText.input._connectedVirtualKeyboard = null;
  13013. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  13014. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  13015. };
  13016. /**
  13017. * Release all resources
  13018. */
  13019. VirtualKeyboard.prototype.dispose = function () {
  13020. _super.prototype.dispose.call(this);
  13021. this.disconnect();
  13022. };
  13023. // Statics
  13024. /**
  13025. * Creates a new keyboard using a default layout
  13026. *
  13027. * @param name defines control name
  13028. * @returns a new VirtualKeyboard
  13029. */
  13030. VirtualKeyboard.CreateDefaultLayout = function (name) {
  13031. var returnValue = new VirtualKeyboard(name);
  13032. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  13033. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  13034. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  13035. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  13036. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  13037. return returnValue;
  13038. };
  13039. return VirtualKeyboard;
  13040. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  13041. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  13042. /***/ }),
  13043. /***/ "./2D/index.ts":
  13044. /*!*********************!*\
  13045. !*** ./2D/index.ts ***!
  13046. \*********************/
  13047. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader */
  13048. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13049. "use strict";
  13050. __webpack_require__.r(__webpack_exports__);
  13051. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  13052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  13053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  13054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  13055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  13056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  13057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  13058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  13059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  13060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  13061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  13062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  13063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  13064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  13065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  13066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  13067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  13068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  13069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  13070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  13071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  13072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  13073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  13074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  13075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  13076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  13077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  13078. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  13079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  13080. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  13081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  13082. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  13083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  13084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  13085. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  13087. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  13088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  13089. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  13090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  13091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  13092. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  13093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  13094. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  13095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  13096. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  13097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  13098. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13099. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  13100. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  13101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  13102. /***/ }),
  13103. /***/ "./2D/math2D.ts":
  13104. /*!**********************!*\
  13105. !*** ./2D/math2D.ts ***!
  13106. \**********************/
  13107. /*! exports provided: Vector2WithInfo, Matrix2D */
  13108. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13109. "use strict";
  13110. __webpack_require__.r(__webpack_exports__);
  13111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  13112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  13113. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13114. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  13115. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  13116. /**
  13117. * Class used to transport Vector2 information for pointer events
  13118. */
  13119. var Vector2WithInfo = /** @class */ (function (_super) {
  13120. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  13121. /**
  13122. * Creates a new Vector2WithInfo
  13123. * @param source defines the vector2 data to transport
  13124. * @param buttonIndex defines the current mouse button index
  13125. */
  13126. function Vector2WithInfo(source,
  13127. /** defines the current mouse button index */
  13128. buttonIndex) {
  13129. if (buttonIndex === void 0) { buttonIndex = 0; }
  13130. var _this = _super.call(this, source.x, source.y) || this;
  13131. _this.buttonIndex = buttonIndex;
  13132. return _this;
  13133. }
  13134. return Vector2WithInfo;
  13135. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  13136. /** Class used to provide 2D matrix features */
  13137. var Matrix2D = /** @class */ (function () {
  13138. /**
  13139. * Creates a new matrix
  13140. * @param m00 defines value for (0, 0)
  13141. * @param m01 defines value for (0, 1)
  13142. * @param m10 defines value for (1, 0)
  13143. * @param m11 defines value for (1, 1)
  13144. * @param m20 defines value for (2, 0)
  13145. * @param m21 defines value for (2, 1)
  13146. */
  13147. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  13148. /** Gets the internal array of 6 floats used to store matrix data */
  13149. this.m = new Float32Array(6);
  13150. this.fromValues(m00, m01, m10, m11, m20, m21);
  13151. }
  13152. /**
  13153. * Fills the matrix from direct values
  13154. * @param m00 defines value for (0, 0)
  13155. * @param m01 defines value for (0, 1)
  13156. * @param m10 defines value for (1, 0)
  13157. * @param m11 defines value for (1, 1)
  13158. * @param m20 defines value for (2, 0)
  13159. * @param m21 defines value for (2, 1)
  13160. * @returns the current modified matrix
  13161. */
  13162. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  13163. this.m[0] = m00;
  13164. this.m[1] = m01;
  13165. this.m[2] = m10;
  13166. this.m[3] = m11;
  13167. this.m[4] = m20;
  13168. this.m[5] = m21;
  13169. return this;
  13170. };
  13171. /**
  13172. * Gets matrix determinant
  13173. * @returns the determinant
  13174. */
  13175. Matrix2D.prototype.determinant = function () {
  13176. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  13177. };
  13178. /**
  13179. * Inverses the matrix and stores it in a target matrix
  13180. * @param result defines the target matrix
  13181. * @returns the current matrix
  13182. */
  13183. Matrix2D.prototype.invertToRef = function (result) {
  13184. var l0 = this.m[0];
  13185. var l1 = this.m[1];
  13186. var l2 = this.m[2];
  13187. var l3 = this.m[3];
  13188. var l4 = this.m[4];
  13189. var l5 = this.m[5];
  13190. var det = this.determinant();
  13191. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  13192. result.m[0] = 0;
  13193. result.m[1] = 0;
  13194. result.m[2] = 0;
  13195. result.m[3] = 0;
  13196. result.m[4] = 0;
  13197. result.m[5] = 0;
  13198. return this;
  13199. }
  13200. var detDiv = 1 / det;
  13201. var det4 = l2 * l5 - l3 * l4;
  13202. var det5 = l1 * l4 - l0 * l5;
  13203. result.m[0] = l3 * detDiv;
  13204. result.m[1] = -l1 * detDiv;
  13205. result.m[2] = -l2 * detDiv;
  13206. result.m[3] = l0 * detDiv;
  13207. result.m[4] = det4 * detDiv;
  13208. result.m[5] = det5 * detDiv;
  13209. return this;
  13210. };
  13211. /**
  13212. * Multiplies the current matrix with another one
  13213. * @param other defines the second operand
  13214. * @param result defines the target matrix
  13215. * @returns the current matrix
  13216. */
  13217. Matrix2D.prototype.multiplyToRef = function (other, result) {
  13218. var l0 = this.m[0];
  13219. var l1 = this.m[1];
  13220. var l2 = this.m[2];
  13221. var l3 = this.m[3];
  13222. var l4 = this.m[4];
  13223. var l5 = this.m[5];
  13224. var r0 = other.m[0];
  13225. var r1 = other.m[1];
  13226. var r2 = other.m[2];
  13227. var r3 = other.m[3];
  13228. var r4 = other.m[4];
  13229. var r5 = other.m[5];
  13230. result.m[0] = l0 * r0 + l1 * r2;
  13231. result.m[1] = l0 * r1 + l1 * r3;
  13232. result.m[2] = l2 * r0 + l3 * r2;
  13233. result.m[3] = l2 * r1 + l3 * r3;
  13234. result.m[4] = l4 * r0 + l5 * r2 + r4;
  13235. result.m[5] = l4 * r1 + l5 * r3 + r5;
  13236. return this;
  13237. };
  13238. /**
  13239. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  13240. * @param x defines the x coordinate to transform
  13241. * @param y defines the x coordinate to transform
  13242. * @param result defines the target vector2
  13243. * @returns the current matrix
  13244. */
  13245. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  13246. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  13247. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  13248. return this;
  13249. };
  13250. // Statics
  13251. /**
  13252. * Creates an identity matrix
  13253. * @returns a new matrix
  13254. */
  13255. Matrix2D.Identity = function () {
  13256. return new Matrix2D(1, 0, 0, 1, 0, 0);
  13257. };
  13258. /**
  13259. * Creates a translation matrix and stores it in a target matrix
  13260. * @param x defines the x coordinate of the translation
  13261. * @param y defines the y coordinate of the translation
  13262. * @param result defines the target matrix
  13263. */
  13264. Matrix2D.TranslationToRef = function (x, y, result) {
  13265. result.fromValues(1, 0, 0, 1, x, y);
  13266. };
  13267. /**
  13268. * Creates a scaling matrix and stores it in a target matrix
  13269. * @param x defines the x coordinate of the scaling
  13270. * @param y defines the y coordinate of the scaling
  13271. * @param result defines the target matrix
  13272. */
  13273. Matrix2D.ScalingToRef = function (x, y, result) {
  13274. result.fromValues(x, 0, 0, y, 0, 0);
  13275. };
  13276. /**
  13277. * Creates a rotation matrix and stores it in a target matrix
  13278. * @param angle defines the rotation angle
  13279. * @param result defines the target matrix
  13280. */
  13281. Matrix2D.RotationToRef = function (angle, result) {
  13282. var s = Math.sin(angle);
  13283. var c = Math.cos(angle);
  13284. result.fromValues(c, s, -s, c, 0, 0);
  13285. };
  13286. /**
  13287. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  13288. * @param tx defines the x coordinate of the translation
  13289. * @param ty defines the y coordinate of the translation
  13290. * @param angle defines the rotation angle
  13291. * @param scaleX defines the x coordinate of the scaling
  13292. * @param scaleY defines the y coordinate of the scaling
  13293. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  13294. * @param result defines the target matrix
  13295. */
  13296. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  13297. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  13298. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  13299. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  13300. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  13301. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  13302. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  13303. if (parentMatrix) {
  13304. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  13305. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  13306. }
  13307. else {
  13308. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  13309. }
  13310. };
  13311. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  13312. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  13313. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  13314. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  13315. Matrix2D._TempCompose0 = Matrix2D.Identity();
  13316. Matrix2D._TempCompose1 = Matrix2D.Identity();
  13317. Matrix2D._TempCompose2 = Matrix2D.Identity();
  13318. return Matrix2D;
  13319. }());
  13320. /***/ }),
  13321. /***/ "./2D/measure.ts":
  13322. /*!***********************!*\
  13323. !*** ./2D/measure.ts ***!
  13324. \***********************/
  13325. /*! exports provided: Measure */
  13326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13327. "use strict";
  13328. __webpack_require__.r(__webpack_exports__);
  13329. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  13330. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  13331. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13332. var tmpRect = [
  13333. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13334. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13335. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13336. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13337. ];
  13338. var tmpRect2 = [
  13339. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13340. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13341. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13342. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13343. ];
  13344. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13345. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13346. /**
  13347. * Class used to store 2D control sizes
  13348. */
  13349. var Measure = /** @class */ (function () {
  13350. /**
  13351. * Creates a new measure
  13352. * @param left defines left coordinate
  13353. * @param top defines top coordinate
  13354. * @param width defines width dimension
  13355. * @param height defines height dimension
  13356. */
  13357. function Measure(
  13358. /** defines left coordinate */
  13359. left,
  13360. /** defines top coordinate */
  13361. top,
  13362. /** defines width dimension */
  13363. width,
  13364. /** defines height dimension */
  13365. height) {
  13366. this.left = left;
  13367. this.top = top;
  13368. this.width = width;
  13369. this.height = height;
  13370. }
  13371. /**
  13372. * Copy from another measure
  13373. * @param other defines the other measure to copy from
  13374. */
  13375. Measure.prototype.copyFrom = function (other) {
  13376. this.left = other.left;
  13377. this.top = other.top;
  13378. this.width = other.width;
  13379. this.height = other.height;
  13380. };
  13381. /**
  13382. * Copy from a group of 4 floats
  13383. * @param left defines left coordinate
  13384. * @param top defines top coordinate
  13385. * @param width defines width dimension
  13386. * @param height defines height dimension
  13387. */
  13388. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  13389. this.left = left;
  13390. this.top = top;
  13391. this.width = width;
  13392. this.height = height;
  13393. };
  13394. /**
  13395. * Computes the axis aligned bounding box measure for two given measures
  13396. * @param a Input measure
  13397. * @param b Input measure
  13398. * @param result the resulting bounding measure
  13399. */
  13400. Measure.CombineToRef = function (a, b, result) {
  13401. var left = Math.min(a.left, b.left);
  13402. var top = Math.min(a.top, b.top);
  13403. var right = Math.max(a.left + a.width, b.left + b.width);
  13404. var bottom = Math.max(a.top + a.height, b.top + b.height);
  13405. result.left = left;
  13406. result.top = top;
  13407. result.width = right - left;
  13408. result.height = bottom - top;
  13409. };
  13410. /**
  13411. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13412. * @param transform the matrix to transform the measure before computing the AABB
  13413. * @param addX number to add to left
  13414. * @param addY number to add to top
  13415. * @param addWidth number to add to width
  13416. * @param addHeight number to add to height
  13417. * @param result the resulting AABB
  13418. */
  13419. Measure.prototype.addAndTransformToRef = function (transform, addX, addY, addWidth, addHeight, result) {
  13420. var left = this.left + addX;
  13421. var top = this.top + addY;
  13422. var width = this.width + addWidth;
  13423. var height = this.height + addHeight;
  13424. tmpRect[0].copyFromFloats(left, top);
  13425. tmpRect[1].copyFromFloats(left + width, top);
  13426. tmpRect[2].copyFromFloats(left + width, top + height);
  13427. tmpRect[3].copyFromFloats(left, top + height);
  13428. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  13429. tmpV2.copyFromFloats(0, 0);
  13430. for (var i = 0; i < 4; i++) {
  13431. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  13432. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  13433. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  13434. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  13435. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  13436. }
  13437. result.left = tmpV1.x;
  13438. result.top = tmpV1.y;
  13439. result.width = tmpV2.x - tmpV1.x;
  13440. result.height = tmpV2.y - tmpV1.y;
  13441. };
  13442. /**
  13443. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13444. * @param transform the matrix to transform the measure before computing the AABB
  13445. * @param result the resulting AABB
  13446. */
  13447. Measure.prototype.transformToRef = function (transform, result) {
  13448. this.addAndTransformToRef(transform, 0, 0, 0, 0, result);
  13449. };
  13450. /**
  13451. * Check equality between this measure and another one
  13452. * @param other defines the other measures
  13453. * @returns true if both measures are equals
  13454. */
  13455. Measure.prototype.isEqualsTo = function (other) {
  13456. if (this.left !== other.left) {
  13457. return false;
  13458. }
  13459. if (this.top !== other.top) {
  13460. return false;
  13461. }
  13462. if (this.width !== other.width) {
  13463. return false;
  13464. }
  13465. if (this.height !== other.height) {
  13466. return false;
  13467. }
  13468. return true;
  13469. };
  13470. /**
  13471. * Creates an empty measure
  13472. * @returns a new measure
  13473. */
  13474. Measure.Empty = function () {
  13475. return new Measure(0, 0, 0, 0);
  13476. };
  13477. return Measure;
  13478. }());
  13479. /***/ }),
  13480. /***/ "./2D/multiLinePoint.ts":
  13481. /*!******************************!*\
  13482. !*** ./2D/multiLinePoint.ts ***!
  13483. \******************************/
  13484. /*! exports provided: MultiLinePoint */
  13485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13486. "use strict";
  13487. __webpack_require__.r(__webpack_exports__);
  13488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13489. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  13490. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13491. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13492. /**
  13493. * Class used to store a point for a MultiLine object.
  13494. * The point can be pure 2D coordinates, a mesh or a control
  13495. */
  13496. var MultiLinePoint = /** @class */ (function () {
  13497. /**
  13498. * Creates a new MultiLinePoint
  13499. * @param multiLine defines the source MultiLine object
  13500. */
  13501. function MultiLinePoint(multiLine) {
  13502. this._multiLine = multiLine;
  13503. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13504. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13505. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  13506. }
  13507. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13508. /** Gets or sets x coordinate */
  13509. get: function () {
  13510. return this._x.toString(this._multiLine._host);
  13511. },
  13512. set: function (value) {
  13513. if (this._x.toString(this._multiLine._host) === value) {
  13514. return;
  13515. }
  13516. if (this._x.fromString(value)) {
  13517. this._multiLine._markAsDirty();
  13518. }
  13519. },
  13520. enumerable: false,
  13521. configurable: true
  13522. });
  13523. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13524. /** Gets or sets y coordinate */
  13525. get: function () {
  13526. return this._y.toString(this._multiLine._host);
  13527. },
  13528. set: function (value) {
  13529. if (this._y.toString(this._multiLine._host) === value) {
  13530. return;
  13531. }
  13532. if (this._y.fromString(value)) {
  13533. this._multiLine._markAsDirty();
  13534. }
  13535. },
  13536. enumerable: false,
  13537. configurable: true
  13538. });
  13539. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13540. /** Gets or sets the control associated with this point */
  13541. get: function () {
  13542. return this._control;
  13543. },
  13544. set: function (value) {
  13545. if (this._control === value) {
  13546. return;
  13547. }
  13548. if (this._control && this._controlObserver) {
  13549. this._control.onDirtyObservable.remove(this._controlObserver);
  13550. this._controlObserver = null;
  13551. }
  13552. this._control = value;
  13553. if (this._control) {
  13554. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13555. }
  13556. this._multiLine._markAsDirty();
  13557. },
  13558. enumerable: false,
  13559. configurable: true
  13560. });
  13561. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13562. /** Gets or sets the mesh associated with this point */
  13563. get: function () {
  13564. return this._mesh;
  13565. },
  13566. set: function (value) {
  13567. if (this._mesh === value) {
  13568. return;
  13569. }
  13570. if (this._mesh && this._meshObserver) {
  13571. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13572. }
  13573. this._mesh = value;
  13574. if (this._mesh) {
  13575. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13576. }
  13577. this._multiLine._markAsDirty();
  13578. },
  13579. enumerable: false,
  13580. configurable: true
  13581. });
  13582. /** Resets links */
  13583. MultiLinePoint.prototype.resetLinks = function () {
  13584. this.control = null;
  13585. this.mesh = null;
  13586. };
  13587. /**
  13588. * Gets a translation vector with Z component
  13589. * @returns the translation vector
  13590. */
  13591. MultiLinePoint.prototype.translate = function () {
  13592. this._point = this._translatePoint();
  13593. return this._point;
  13594. };
  13595. MultiLinePoint.prototype._translatePoint = function () {
  13596. if (this._mesh != null) {
  13597. return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13598. }
  13599. else if (this._control != null) {
  13600. 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"]);
  13601. }
  13602. else {
  13603. var host = this._multiLine._host;
  13604. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13605. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13606. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](xValue, yValue, 1. - babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]);
  13607. }
  13608. };
  13609. /** Release associated resources */
  13610. MultiLinePoint.prototype.dispose = function () {
  13611. this.resetLinks();
  13612. };
  13613. return MultiLinePoint;
  13614. }());
  13615. /***/ }),
  13616. /***/ "./2D/style.ts":
  13617. /*!*********************!*\
  13618. !*** ./2D/style.ts ***!
  13619. \*********************/
  13620. /*! exports provided: Style */
  13621. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13622. "use strict";
  13623. __webpack_require__.r(__webpack_exports__);
  13624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13625. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  13626. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13627. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13628. /**
  13629. * Define a style used by control to automatically setup properties based on a template.
  13630. * Only support font related properties so far
  13631. */
  13632. var Style = /** @class */ (function () {
  13633. /**
  13634. * Creates a new style object
  13635. * @param host defines the AdvancedDynamicTexture which hosts this style
  13636. */
  13637. function Style(host) {
  13638. this._fontFamily = "Arial";
  13639. this._fontStyle = "";
  13640. this._fontWeight = "";
  13641. /** @hidden */
  13642. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13643. /**
  13644. * Observable raised when the style values are changed
  13645. */
  13646. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13647. this._host = host;
  13648. }
  13649. Object.defineProperty(Style.prototype, "fontSize", {
  13650. /**
  13651. * Gets or sets the font size
  13652. */
  13653. get: function () {
  13654. return this._fontSize.toString(this._host);
  13655. },
  13656. set: function (value) {
  13657. if (this._fontSize.toString(this._host) === value) {
  13658. return;
  13659. }
  13660. if (this._fontSize.fromString(value)) {
  13661. this.onChangedObservable.notifyObservers(this);
  13662. }
  13663. },
  13664. enumerable: false,
  13665. configurable: true
  13666. });
  13667. Object.defineProperty(Style.prototype, "fontFamily", {
  13668. /**
  13669. * Gets or sets the font family
  13670. */
  13671. get: function () {
  13672. return this._fontFamily;
  13673. },
  13674. set: function (value) {
  13675. if (this._fontFamily === value) {
  13676. return;
  13677. }
  13678. this._fontFamily = value;
  13679. this.onChangedObservable.notifyObservers(this);
  13680. },
  13681. enumerable: false,
  13682. configurable: true
  13683. });
  13684. Object.defineProperty(Style.prototype, "fontStyle", {
  13685. /**
  13686. * Gets or sets the font style
  13687. */
  13688. get: function () {
  13689. return this._fontStyle;
  13690. },
  13691. set: function (value) {
  13692. if (this._fontStyle === value) {
  13693. return;
  13694. }
  13695. this._fontStyle = value;
  13696. this.onChangedObservable.notifyObservers(this);
  13697. },
  13698. enumerable: false,
  13699. configurable: true
  13700. });
  13701. Object.defineProperty(Style.prototype, "fontWeight", {
  13702. /** Gets or sets font weight */
  13703. get: function () {
  13704. return this._fontWeight;
  13705. },
  13706. set: function (value) {
  13707. if (this._fontWeight === value) {
  13708. return;
  13709. }
  13710. this._fontWeight = value;
  13711. this.onChangedObservable.notifyObservers(this);
  13712. },
  13713. enumerable: false,
  13714. configurable: true
  13715. });
  13716. /** Dispose all associated resources */
  13717. Style.prototype.dispose = function () {
  13718. this.onChangedObservable.clear();
  13719. };
  13720. return Style;
  13721. }());
  13722. /***/ }),
  13723. /***/ "./2D/valueAndUnit.ts":
  13724. /*!****************************!*\
  13725. !*** ./2D/valueAndUnit.ts ***!
  13726. \****************************/
  13727. /*! exports provided: ValueAndUnit */
  13728. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13729. "use strict";
  13730. __webpack_require__.r(__webpack_exports__);
  13731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13732. /**
  13733. * Class used to specific a value and its associated unit
  13734. */
  13735. var ValueAndUnit = /** @class */ (function () {
  13736. /**
  13737. * Creates a new ValueAndUnit
  13738. * @param value defines the value to store
  13739. * @param unit defines the unit to store
  13740. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13741. */
  13742. function ValueAndUnit(value,
  13743. /** defines the unit to store */
  13744. unit,
  13745. /** defines a boolean indicating if the value can be negative */
  13746. negativeValueAllowed) {
  13747. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13748. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13749. this.unit = unit;
  13750. this.negativeValueAllowed = negativeValueAllowed;
  13751. this._value = 1;
  13752. /**
  13753. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13754. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13755. */
  13756. this.ignoreAdaptiveScaling = false;
  13757. this._value = value;
  13758. this._originalUnit = unit;
  13759. }
  13760. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13761. /** Gets a boolean indicating if the value is a percentage */
  13762. get: function () {
  13763. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13764. },
  13765. enumerable: false,
  13766. configurable: true
  13767. });
  13768. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13769. /** Gets a boolean indicating if the value is store as pixel */
  13770. get: function () {
  13771. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13772. },
  13773. enumerable: false,
  13774. configurable: true
  13775. });
  13776. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13777. /** Gets direct internal value */
  13778. get: function () {
  13779. return this._value;
  13780. },
  13781. enumerable: false,
  13782. configurable: true
  13783. });
  13784. /**
  13785. * Gets value as pixel
  13786. * @param host defines the root host
  13787. * @param refValue defines the reference value for percentages
  13788. * @returns the value as pixel
  13789. */
  13790. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13791. if (this.isPixel) {
  13792. return this.getValue(host);
  13793. }
  13794. return this.getValue(host) * refValue;
  13795. };
  13796. /**
  13797. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13798. * @param value defines the value to store
  13799. * @param unit defines the unit to store
  13800. * @returns the current ValueAndUnit
  13801. */
  13802. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13803. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13804. this._value = value;
  13805. this.unit = unit;
  13806. return this;
  13807. };
  13808. /**
  13809. * Gets the value accordingly to its unit
  13810. * @param host defines the root host
  13811. * @returns the value
  13812. */
  13813. ValueAndUnit.prototype.getValue = function (host) {
  13814. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13815. var width = 0;
  13816. var height = 0;
  13817. if (host.idealWidth) {
  13818. width = (this._value * host.getSize().width) / host.idealWidth;
  13819. }
  13820. if (host.idealHeight) {
  13821. height = (this._value * host.getSize().height) / host.idealHeight;
  13822. }
  13823. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13824. return window.innerWidth < window.innerHeight ? width : height;
  13825. }
  13826. if (host.idealWidth) { // horizontal
  13827. return width;
  13828. }
  13829. if (host.idealHeight) { // vertical
  13830. return height;
  13831. }
  13832. }
  13833. return this._value;
  13834. };
  13835. /**
  13836. * Gets a string representation of the value
  13837. * @param host defines the root host
  13838. * @param decimals defines an optional number of decimals to display
  13839. * @returns a string
  13840. */
  13841. ValueAndUnit.prototype.toString = function (host, decimals) {
  13842. switch (this.unit) {
  13843. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13844. var percentage = this.getValue(host) * 100;
  13845. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13846. case ValueAndUnit.UNITMODE_PIXEL:
  13847. var pixels = this.getValue(host);
  13848. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13849. }
  13850. return this.unit.toString();
  13851. };
  13852. /**
  13853. * Store a value parsed from a string
  13854. * @param source defines the source string
  13855. * @returns true if the value was successfully parsed
  13856. */
  13857. ValueAndUnit.prototype.fromString = function (source) {
  13858. var match = ValueAndUnit._Regex.exec(source.toString());
  13859. if (!match || match.length === 0) {
  13860. return false;
  13861. }
  13862. var sourceValue = parseFloat(match[1]);
  13863. var sourceUnit = this._originalUnit;
  13864. if (!this.negativeValueAllowed) {
  13865. if (sourceValue < 0) {
  13866. sourceValue = 0;
  13867. }
  13868. }
  13869. if (match.length === 4) {
  13870. switch (match[3]) {
  13871. case "px":
  13872. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13873. break;
  13874. case "%":
  13875. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13876. sourceValue /= 100.0;
  13877. break;
  13878. }
  13879. }
  13880. if (sourceValue === this._value && sourceUnit === this.unit) {
  13881. return false;
  13882. }
  13883. this._value = sourceValue;
  13884. this.unit = sourceUnit;
  13885. return true;
  13886. };
  13887. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13888. /** UNITMODE_PERCENTAGE */
  13889. get: function () {
  13890. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13891. },
  13892. enumerable: false,
  13893. configurable: true
  13894. });
  13895. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13896. /** UNITMODE_PIXEL */
  13897. get: function () {
  13898. return ValueAndUnit._UNITMODE_PIXEL;
  13899. },
  13900. enumerable: false,
  13901. configurable: true
  13902. });
  13903. // Static
  13904. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13905. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13906. ValueAndUnit._UNITMODE_PIXEL = 1;
  13907. return ValueAndUnit;
  13908. }());
  13909. /***/ }),
  13910. /***/ "./2D/xmlLoader.ts":
  13911. /*!*************************!*\
  13912. !*** ./2D/xmlLoader.ts ***!
  13913. \*************************/
  13914. /*! exports provided: XmlLoader */
  13915. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13916. "use strict";
  13917. __webpack_require__.r(__webpack_exports__);
  13918. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13919. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  13920. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13921. /**
  13922. * Class used to load GUI via XML.
  13923. */
  13924. var XmlLoader = /** @class */ (function () {
  13925. /**
  13926. * Create a new xml loader
  13927. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13928. */
  13929. function XmlLoader(parentClass) {
  13930. if (parentClass === void 0) { parentClass = null; }
  13931. this._nodes = {};
  13932. this._nodeTypes = {
  13933. element: 1,
  13934. attribute: 2,
  13935. text: 3
  13936. };
  13937. this._isLoaded = false;
  13938. this._objectAttributes = {
  13939. "textHorizontalAlignment": 1,
  13940. "textVerticalAlignment": 2,
  13941. "horizontalAlignment": 3,
  13942. "verticalAlignment": 4,
  13943. "stretch": 5,
  13944. };
  13945. if (parentClass) {
  13946. this._parentClass = parentClass;
  13947. }
  13948. }
  13949. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13950. var element = window;
  13951. if (this._parentClass) {
  13952. element = this._parentClass;
  13953. }
  13954. var value = attributeValue;
  13955. value = value.split(".");
  13956. for (var i = 0; i < value.length; i++) {
  13957. element = element[value[i]];
  13958. }
  13959. return element;
  13960. };
  13961. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13962. var attribute = attributeName.split(".");
  13963. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13964. return className[attribute[1]];
  13965. };
  13966. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13967. if (linkParent === void 0) { linkParent = true; }
  13968. try {
  13969. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13970. var guiNode = new className();
  13971. if (parent && linkParent) {
  13972. parent.addControl(guiNode);
  13973. }
  13974. for (var i = 0; i < node.attributes.length; i++) {
  13975. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13976. continue;
  13977. }
  13978. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13979. var element = this._getChainElement(node.attributes[i].value);
  13980. guiNode[node.attributes[i].name].add(element);
  13981. continue;
  13982. }
  13983. else if (node.attributes[i].name == "linkWithMesh") {
  13984. if (this._parentClass) {
  13985. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13986. }
  13987. else {
  13988. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13989. }
  13990. }
  13991. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13992. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13993. guiNode[node.attributes[i].name] = element;
  13994. }
  13995. else if (!this._objectAttributes[node.attributes[i].name]) {
  13996. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13997. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13998. }
  13999. else {
  14000. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  14001. }
  14002. }
  14003. else {
  14004. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  14005. }
  14006. }
  14007. if (!node.attributes.getNamedItem("id")) {
  14008. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  14009. return guiNode;
  14010. }
  14011. var id = node.attributes.getNamedItem("id").value;
  14012. if (id.startsWith("{{") && id.endsWith("}}")) {
  14013. id = this._getChainElement(id.substring(2, id.length - 2));
  14014. }
  14015. if (!this._nodes[id]) {
  14016. this._nodes[id] = guiNode;
  14017. }
  14018. else {
  14019. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  14020. }
  14021. return guiNode;
  14022. }
  14023. catch (e) {
  14024. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  14025. }
  14026. };
  14027. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  14028. var width;
  14029. var height;
  14030. var columns;
  14031. var rows = node.children;
  14032. var cells;
  14033. var isPixel = false;
  14034. var cellNode;
  14035. var rowNumber = -1;
  14036. var columnNumber = -1;
  14037. var totalColumnsNumber = 0;
  14038. for (var i = 0; i < rows.length; i++) {
  14039. if (rows[i].nodeType != this._nodeTypes.element) {
  14040. continue;
  14041. }
  14042. if (rows[i].nodeName != "Row") {
  14043. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  14044. }
  14045. rowNumber += 1;
  14046. columns = rows[i].children;
  14047. if (!rows[i].attributes.getNamedItem("height")) {
  14048. throw "XmlLoader Exception : Height must be defined for grid rows";
  14049. }
  14050. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  14051. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  14052. guiNode.addRowDefinition(height, isPixel);
  14053. for (var j = 0; j < columns.length; j++) {
  14054. if (columns[j].nodeType != this._nodeTypes.element) {
  14055. continue;
  14056. }
  14057. if (columns[j].nodeName != "Column") {
  14058. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  14059. }
  14060. columnNumber += 1;
  14061. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  14062. 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.";
  14063. }
  14064. if (rowNumber == 0) {
  14065. if (!columns[j].attributes.getNamedItem("width")) {
  14066. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  14067. }
  14068. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  14069. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  14070. guiNode.addColumnDefinition(width, isPixel);
  14071. }
  14072. cells = columns[j].children;
  14073. for (var k = 0; k < cells.length; k++) {
  14074. if (cells[k].nodeType != this._nodeTypes.element) {
  14075. continue;
  14076. }
  14077. cellNode = this._createGuiElement(cells[k], guiNode, false);
  14078. guiNode.addControl(cellNode, rowNumber, columnNumber);
  14079. if (cells[k].firstChild) {
  14080. this._parseXml(cells[k].firstChild, cellNode);
  14081. }
  14082. }
  14083. }
  14084. if (rowNumber == 0) {
  14085. totalColumnsNumber = columnNumber;
  14086. }
  14087. columnNumber = -1;
  14088. }
  14089. if (node.nextSibling) {
  14090. this._parseXml(node.nextSibling, parent);
  14091. }
  14092. };
  14093. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  14094. if (node.firstChild) {
  14095. this._parseXml(node.firstChild, guiNode);
  14096. }
  14097. if (node.nextSibling) {
  14098. this._parseXml(node.nextSibling, parent);
  14099. }
  14100. };
  14101. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  14102. if (this._parentClass) {
  14103. this._parentClass[variable] = source[iterator];
  14104. }
  14105. else {
  14106. window[variable] = source[iterator];
  14107. }
  14108. if (node.firstChild) {
  14109. this._parseXml(node.firstChild, guiNode, true);
  14110. }
  14111. };
  14112. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  14113. var dataSource = node.attributes.getNamedItem("dataSource").value;
  14114. if (!dataSource.includes(" in ")) {
  14115. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  14116. }
  14117. else {
  14118. var isArray = true;
  14119. var splittedSource = dataSource.split(" in ");
  14120. if (splittedSource.length < 2) {
  14121. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  14122. }
  14123. var source = splittedSource[1];
  14124. if (source.startsWith("{") && source.endsWith("}")) {
  14125. isArray = false;
  14126. }
  14127. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  14128. source = source.substring(1, source.length - 1);
  14129. }
  14130. if (this._parentClass) {
  14131. source = this._parentClass[source];
  14132. }
  14133. else {
  14134. source = window[source];
  14135. }
  14136. if (isArray) {
  14137. for (var i = 0; i < source.length; i++) {
  14138. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  14139. }
  14140. }
  14141. else {
  14142. for (var i in source) {
  14143. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  14144. }
  14145. }
  14146. if (node.nextSibling) {
  14147. this._parseXml(node.nextSibling, parent);
  14148. }
  14149. }
  14150. };
  14151. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  14152. if (generated === void 0) { generated = false; }
  14153. if (node.nodeType != this._nodeTypes.element) {
  14154. if (node.nextSibling) {
  14155. this._parseXml(node.nextSibling, parent, generated);
  14156. }
  14157. return;
  14158. }
  14159. if (generated) {
  14160. node.setAttribute("id", parent.id + (parent._children.length + 1));
  14161. }
  14162. var guiNode = this._createGuiElement(node, parent);
  14163. if (node.nodeName == "Grid") {
  14164. this._parseGrid(node, guiNode, parent);
  14165. }
  14166. else if (!node.attributes.getNamedItem("dataSource")) {
  14167. this._parseElement(node, guiNode, parent);
  14168. }
  14169. else {
  14170. this._parseElementsFromSource(node, guiNode, parent);
  14171. }
  14172. };
  14173. /**
  14174. * Gets if the loading has finished.
  14175. * @returns whether the loading has finished or not
  14176. */
  14177. XmlLoader.prototype.isLoaded = function () {
  14178. return this._isLoaded;
  14179. };
  14180. /**
  14181. * Gets a loaded node / control by id.
  14182. * @param id the Controls id set in the xml
  14183. * @returns element of type Control
  14184. */
  14185. XmlLoader.prototype.getNodeById = function (id) {
  14186. return this._nodes[id];
  14187. };
  14188. /**
  14189. * Gets all loaded nodes / controls
  14190. * @returns Array of controls
  14191. */
  14192. XmlLoader.prototype.getNodes = function () {
  14193. return this._nodes;
  14194. };
  14195. /**
  14196. * Initiates the xml layout loading
  14197. * @param xmlFile defines the xml layout to load
  14198. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  14199. * @param callback defines the callback called on layout load.
  14200. */
  14201. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  14202. var xhttp = new XMLHttpRequest();
  14203. xhttp.onreadystatechange = function () {
  14204. if (xhttp.readyState == 4 && xhttp.status == 200) {
  14205. if (!xhttp.responseXML) {
  14206. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  14207. }
  14208. var xmlDoc = xhttp.responseXML.documentElement;
  14209. this._parseXml(xmlDoc.firstChild, rootNode);
  14210. this._isLoaded = true;
  14211. if (callback) {
  14212. callback();
  14213. }
  14214. }
  14215. }.bind(this);
  14216. xhttp.open("GET", xmlFile, true);
  14217. xhttp.send();
  14218. };
  14219. return XmlLoader;
  14220. }());
  14221. /***/ }),
  14222. /***/ "./3D/controls/abstractButton3D.ts":
  14223. /*!*****************************************!*\
  14224. !*** ./3D/controls/abstractButton3D.ts ***!
  14225. \*****************************************/
  14226. /*! exports provided: AbstractButton3D */
  14227. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14228. "use strict";
  14229. __webpack_require__.r(__webpack_exports__);
  14230. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  14231. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14232. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  14233. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14234. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14235. /**
  14236. * Class used as a root to all buttons
  14237. */
  14238. var AbstractButton3D = /** @class */ (function (_super) {
  14239. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  14240. /**
  14241. * Creates a new button
  14242. * @param name defines the control name
  14243. */
  14244. function AbstractButton3D(name) {
  14245. return _super.call(this, name) || this;
  14246. }
  14247. AbstractButton3D.prototype._getTypeName = function () {
  14248. return "AbstractButton3D";
  14249. };
  14250. // Mesh association
  14251. AbstractButton3D.prototype._createNode = function (scene) {
  14252. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  14253. };
  14254. return AbstractButton3D;
  14255. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14256. /***/ }),
  14257. /***/ "./3D/controls/button3D.ts":
  14258. /*!*********************************!*\
  14259. !*** ./3D/controls/button3D.ts ***!
  14260. \*********************************/
  14261. /*! exports provided: Button3D */
  14262. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14263. "use strict";
  14264. __webpack_require__.r(__webpack_exports__);
  14265. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  14266. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14267. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  14268. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  14269. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14270. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14271. /**
  14272. * Class used to create a button in 3D
  14273. */
  14274. var Button3D = /** @class */ (function (_super) {
  14275. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  14276. /**
  14277. * Creates a new button
  14278. * @param name defines the control name
  14279. */
  14280. function Button3D(name) {
  14281. var _this = _super.call(this, name) || this;
  14282. _this._contentResolution = 512;
  14283. _this._contentScaleRatio = 2;
  14284. // Default animations
  14285. _this.pointerEnterAnimation = function () {
  14286. if (!_this.mesh) {
  14287. return;
  14288. }
  14289. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  14290. };
  14291. _this.pointerOutAnimation = function () {
  14292. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14293. };
  14294. _this.pointerDownAnimation = function () {
  14295. if (!_this.mesh) {
  14296. return;
  14297. }
  14298. _this.mesh.scaling.scaleInPlace(0.95);
  14299. };
  14300. _this.pointerUpAnimation = function () {
  14301. if (!_this.mesh) {
  14302. return;
  14303. }
  14304. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14305. };
  14306. return _this;
  14307. }
  14308. Object.defineProperty(Button3D.prototype, "contentResolution", {
  14309. /**
  14310. * Gets or sets the texture resolution used to render content (512 by default)
  14311. */
  14312. get: function () {
  14313. return this._contentResolution;
  14314. },
  14315. set: function (value) {
  14316. if (this._contentResolution === value) {
  14317. return;
  14318. }
  14319. this._contentResolution = value;
  14320. this._resetContent();
  14321. },
  14322. enumerable: false,
  14323. configurable: true
  14324. });
  14325. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  14326. /**
  14327. * Gets or sets the texture scale ratio used to render content (2 by default)
  14328. */
  14329. get: function () {
  14330. return this._contentScaleRatio;
  14331. },
  14332. set: function (value) {
  14333. if (this._contentScaleRatio === value) {
  14334. return;
  14335. }
  14336. this._contentScaleRatio = value;
  14337. this._resetContent();
  14338. },
  14339. enumerable: false,
  14340. configurable: true
  14341. });
  14342. Button3D.prototype._disposeFacadeTexture = function () {
  14343. if (this._facadeTexture) {
  14344. this._facadeTexture.dispose();
  14345. this._facadeTexture = null;
  14346. }
  14347. };
  14348. Button3D.prototype._resetContent = function () {
  14349. this._disposeFacadeTexture();
  14350. this.content = this._content;
  14351. };
  14352. Object.defineProperty(Button3D.prototype, "content", {
  14353. /**
  14354. * Gets or sets the GUI 2D content used to display the button's facade
  14355. */
  14356. get: function () {
  14357. return this._content;
  14358. },
  14359. set: function (value) {
  14360. this._content = value;
  14361. if (!this._host || !this._host.utilityLayer) {
  14362. return;
  14363. }
  14364. if (!this._facadeTexture) {
  14365. 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);
  14366. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  14367. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  14368. this._facadeTexture.premulAlpha = true;
  14369. }
  14370. else {
  14371. this._facadeTexture.rootContainer.clearControls();
  14372. }
  14373. this._facadeTexture.addControl(value);
  14374. this._applyFacade(this._facadeTexture);
  14375. },
  14376. enumerable: false,
  14377. configurable: true
  14378. });
  14379. /**
  14380. * Apply the facade texture (created from the content property).
  14381. * This function can be overloaded by child classes
  14382. * @param facadeTexture defines the AdvancedDynamicTexture to use
  14383. */
  14384. Button3D.prototype._applyFacade = function (facadeTexture) {
  14385. this._currentMaterial.emissiveTexture = facadeTexture;
  14386. };
  14387. Button3D.prototype._getTypeName = function () {
  14388. return "Button3D";
  14389. };
  14390. // Mesh association
  14391. Button3D.prototype._createNode = function (scene) {
  14392. var faceUV = new Array(6);
  14393. for (var i = 0; i < 6; i++) {
  14394. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  14395. }
  14396. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  14397. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  14398. width: 1.0,
  14399. height: 1.0,
  14400. depth: 0.08,
  14401. faceUV: faceUV
  14402. }, scene);
  14403. return mesh;
  14404. };
  14405. Button3D.prototype._affectMaterial = function (mesh) {
  14406. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  14407. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14408. mesh.material = material;
  14409. this._currentMaterial = material;
  14410. this._resetContent();
  14411. };
  14412. /**
  14413. * Releases all associated resources
  14414. */
  14415. Button3D.prototype.dispose = function () {
  14416. _super.prototype.dispose.call(this);
  14417. this._disposeFacadeTexture();
  14418. if (this._currentMaterial) {
  14419. this._currentMaterial.dispose();
  14420. }
  14421. };
  14422. return Button3D;
  14423. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  14424. /***/ }),
  14425. /***/ "./3D/controls/container3D.ts":
  14426. /*!************************************!*\
  14427. !*** ./3D/controls/container3D.ts ***!
  14428. \************************************/
  14429. /*! exports provided: Container3D */
  14430. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14431. "use strict";
  14432. __webpack_require__.r(__webpack_exports__);
  14433. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  14434. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14435. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  14436. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14437. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14438. /**
  14439. * Class used to create containers for controls
  14440. */
  14441. var Container3D = /** @class */ (function (_super) {
  14442. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  14443. /**
  14444. * Creates a new container
  14445. * @param name defines the container name
  14446. */
  14447. function Container3D(name) {
  14448. var _this = _super.call(this, name) || this;
  14449. _this._blockLayout = false;
  14450. /**
  14451. * Gets the list of child controls
  14452. */
  14453. _this._children = new Array();
  14454. return _this;
  14455. }
  14456. Object.defineProperty(Container3D.prototype, "children", {
  14457. /**
  14458. * Gets the list of child controls
  14459. */
  14460. get: function () {
  14461. return this._children;
  14462. },
  14463. enumerable: false,
  14464. configurable: true
  14465. });
  14466. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14467. /**
  14468. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14469. * This is helpful to optimize layout operation when adding multiple children in a row
  14470. */
  14471. get: function () {
  14472. return this._blockLayout;
  14473. },
  14474. set: function (value) {
  14475. if (this._blockLayout === value) {
  14476. return;
  14477. }
  14478. this._blockLayout = value;
  14479. if (!this._blockLayout) {
  14480. this._arrangeChildren();
  14481. }
  14482. },
  14483. enumerable: false,
  14484. configurable: true
  14485. });
  14486. /**
  14487. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14488. * @returns the current container
  14489. */
  14490. Container3D.prototype.updateLayout = function () {
  14491. this._arrangeChildren();
  14492. return this;
  14493. };
  14494. /**
  14495. * Gets a boolean indicating if the given control is in the children of this control
  14496. * @param control defines the control to check
  14497. * @returns true if the control is in the child list
  14498. */
  14499. Container3D.prototype.containsControl = function (control) {
  14500. return this._children.indexOf(control) !== -1;
  14501. };
  14502. /**
  14503. * Adds a control to the children of this control
  14504. * @param control defines the control to add
  14505. * @returns the current container
  14506. */
  14507. Container3D.prototype.addControl = function (control) {
  14508. var index = this._children.indexOf(control);
  14509. if (index !== -1) {
  14510. return this;
  14511. }
  14512. control.parent = this;
  14513. control._host = this._host;
  14514. this._children.push(control);
  14515. if (this._host.utilityLayer) {
  14516. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14517. if (control.node) {
  14518. control.node.parent = this.node;
  14519. }
  14520. if (!this.blockLayout) {
  14521. this._arrangeChildren();
  14522. }
  14523. }
  14524. return this;
  14525. };
  14526. /**
  14527. * This function will be called everytime a new control is added
  14528. */
  14529. Container3D.prototype._arrangeChildren = function () {
  14530. };
  14531. Container3D.prototype._createNode = function (scene) {
  14532. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14533. };
  14534. /**
  14535. * Removes a control from the children of this control
  14536. * @param control defines the control to remove
  14537. * @returns the current container
  14538. */
  14539. Container3D.prototype.removeControl = function (control) {
  14540. var index = this._children.indexOf(control);
  14541. if (index !== -1) {
  14542. this._children.splice(index, 1);
  14543. control.parent = null;
  14544. control._disposeNode();
  14545. }
  14546. return this;
  14547. };
  14548. Container3D.prototype._getTypeName = function () {
  14549. return "Container3D";
  14550. };
  14551. /**
  14552. * Releases all associated resources
  14553. */
  14554. Container3D.prototype.dispose = function () {
  14555. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14556. var control = _a[_i];
  14557. control.dispose();
  14558. }
  14559. this._children = [];
  14560. _super.prototype.dispose.call(this);
  14561. };
  14562. /** Control rotation will remain unchanged */
  14563. Container3D.UNSET_ORIENTATION = 0;
  14564. /** Control will rotate to make it look at sphere central axis */
  14565. Container3D.FACEORIGIN_ORIENTATION = 1;
  14566. /** Control will rotate to make it look back at sphere central axis */
  14567. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14568. /** Control will rotate to look at z axis (0, 0, 1) */
  14569. Container3D.FACEFORWARD_ORIENTATION = 3;
  14570. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14571. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14572. return Container3D;
  14573. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14574. /***/ }),
  14575. /***/ "./3D/controls/control3D.ts":
  14576. /*!**********************************!*\
  14577. !*** ./3D/controls/control3D.ts ***!
  14578. \**********************************/
  14579. /*! exports provided: Control3D */
  14580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14581. "use strict";
  14582. __webpack_require__.r(__webpack_exports__);
  14583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14584. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  14585. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14586. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14587. /**
  14588. * Class used as base class for controls
  14589. */
  14590. var Control3D = /** @class */ (function () {
  14591. /**
  14592. * Creates a new control
  14593. * @param name defines the control name
  14594. */
  14595. function Control3D(
  14596. /** Defines the control name */
  14597. name) {
  14598. this.name = name;
  14599. this._downCount = 0;
  14600. this._enterCount = -1;
  14601. this._downPointerIds = {};
  14602. this._isVisible = true;
  14603. /**
  14604. * An event triggered when the pointer move over the control
  14605. */
  14606. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14607. /**
  14608. * An event triggered when the pointer move out of the control
  14609. */
  14610. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14611. /**
  14612. * An event triggered when the pointer taps the control
  14613. */
  14614. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14615. /**
  14616. * An event triggered when pointer is up
  14617. */
  14618. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14619. /**
  14620. * An event triggered when a control is clicked on (with a mouse)
  14621. */
  14622. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14623. /**
  14624. * An event triggered when pointer enters the control
  14625. */
  14626. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14627. // Behaviors
  14628. this._behaviors = new Array();
  14629. }
  14630. Object.defineProperty(Control3D.prototype, "position", {
  14631. /** Gets or sets the control position in world space */
  14632. get: function () {
  14633. if (!this._node) {
  14634. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14635. }
  14636. return this._node.position;
  14637. },
  14638. set: function (value) {
  14639. if (!this._node) {
  14640. return;
  14641. }
  14642. this._node.position = value;
  14643. },
  14644. enumerable: false,
  14645. configurable: true
  14646. });
  14647. Object.defineProperty(Control3D.prototype, "scaling", {
  14648. /** Gets or sets the control scaling in world space */
  14649. get: function () {
  14650. if (!this._node) {
  14651. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14652. }
  14653. return this._node.scaling;
  14654. },
  14655. set: function (value) {
  14656. if (!this._node) {
  14657. return;
  14658. }
  14659. this._node.scaling = value;
  14660. },
  14661. enumerable: false,
  14662. configurable: true
  14663. });
  14664. Object.defineProperty(Control3D.prototype, "behaviors", {
  14665. /**
  14666. * Gets the list of attached behaviors
  14667. * @see https://doc.babylonjs.com/features/behaviour
  14668. */
  14669. get: function () {
  14670. return this._behaviors;
  14671. },
  14672. enumerable: false,
  14673. configurable: true
  14674. });
  14675. /**
  14676. * Attach a behavior to the control
  14677. * @see https://doc.babylonjs.com/features/behaviour
  14678. * @param behavior defines the behavior to attach
  14679. * @returns the current control
  14680. */
  14681. Control3D.prototype.addBehavior = function (behavior) {
  14682. var _this = this;
  14683. var index = this._behaviors.indexOf(behavior);
  14684. if (index !== -1) {
  14685. return this;
  14686. }
  14687. behavior.init();
  14688. var scene = this._host.scene;
  14689. if (scene.isLoading) {
  14690. // We defer the attach when the scene will be loaded
  14691. scene.onDataLoadedObservable.addOnce(function () {
  14692. behavior.attach(_this);
  14693. });
  14694. }
  14695. else {
  14696. behavior.attach(this);
  14697. }
  14698. this._behaviors.push(behavior);
  14699. return this;
  14700. };
  14701. /**
  14702. * Remove an attached behavior
  14703. * @see https://doc.babylonjs.com/features/behaviour
  14704. * @param behavior defines the behavior to attach
  14705. * @returns the current control
  14706. */
  14707. Control3D.prototype.removeBehavior = function (behavior) {
  14708. var index = this._behaviors.indexOf(behavior);
  14709. if (index === -1) {
  14710. return this;
  14711. }
  14712. this._behaviors[index].detach();
  14713. this._behaviors.splice(index, 1);
  14714. return this;
  14715. };
  14716. /**
  14717. * Gets an attached behavior by name
  14718. * @param name defines the name of the behavior to look for
  14719. * @see https://doc.babylonjs.com/features/behaviour
  14720. * @returns null if behavior was not found else the requested behavior
  14721. */
  14722. Control3D.prototype.getBehaviorByName = function (name) {
  14723. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14724. var behavior = _a[_i];
  14725. if (behavior.name === name) {
  14726. return behavior;
  14727. }
  14728. }
  14729. return null;
  14730. };
  14731. Object.defineProperty(Control3D.prototype, "isVisible", {
  14732. /** Gets or sets a boolean indicating if the control is visible */
  14733. get: function () {
  14734. return this._isVisible;
  14735. },
  14736. set: function (value) {
  14737. if (this._isVisible === value) {
  14738. return;
  14739. }
  14740. this._isVisible = value;
  14741. var mesh = this.mesh;
  14742. if (mesh) {
  14743. mesh.setEnabled(value);
  14744. }
  14745. },
  14746. enumerable: false,
  14747. configurable: true
  14748. });
  14749. Object.defineProperty(Control3D.prototype, "typeName", {
  14750. /**
  14751. * Gets a string representing the class name
  14752. */
  14753. get: function () {
  14754. return this._getTypeName();
  14755. },
  14756. enumerable: false,
  14757. configurable: true
  14758. });
  14759. /**
  14760. * Get the current class name of the control.
  14761. * @returns current class name
  14762. */
  14763. Control3D.prototype.getClassName = function () {
  14764. return this._getTypeName();
  14765. };
  14766. Control3D.prototype._getTypeName = function () {
  14767. return "Control3D";
  14768. };
  14769. Object.defineProperty(Control3D.prototype, "node", {
  14770. /**
  14771. * Gets the transform node used by this control
  14772. */
  14773. get: function () {
  14774. return this._node;
  14775. },
  14776. enumerable: false,
  14777. configurable: true
  14778. });
  14779. Object.defineProperty(Control3D.prototype, "mesh", {
  14780. /**
  14781. * Gets the mesh used to render this control
  14782. */
  14783. get: function () {
  14784. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14785. return this._node;
  14786. }
  14787. return null;
  14788. },
  14789. enumerable: false,
  14790. configurable: true
  14791. });
  14792. /**
  14793. * Link the control as child of the given node
  14794. * @param node defines the node to link to. Use null to unlink the control
  14795. * @returns the current control
  14796. */
  14797. Control3D.prototype.linkToTransformNode = function (node) {
  14798. if (this._node) {
  14799. this._node.parent = node;
  14800. }
  14801. return this;
  14802. };
  14803. /** @hidden **/
  14804. Control3D.prototype._prepareNode = function (scene) {
  14805. if (!this._node) {
  14806. this._node = this._createNode(scene);
  14807. if (!this.node) {
  14808. return;
  14809. }
  14810. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14811. this._node.position = this.position;
  14812. this._node.scaling = this.scaling;
  14813. var mesh = this.mesh;
  14814. if (mesh) {
  14815. mesh.isPickable = true;
  14816. this._affectMaterial(mesh);
  14817. }
  14818. }
  14819. };
  14820. /**
  14821. * Node creation.
  14822. * Can be overriden by children
  14823. * @param scene defines the scene where the node must be attached
  14824. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14825. */
  14826. Control3D.prototype._createNode = function (scene) {
  14827. // Do nothing by default
  14828. return null;
  14829. };
  14830. /**
  14831. * Affect a material to the given mesh
  14832. * @param mesh defines the mesh which will represent the control
  14833. */
  14834. Control3D.prototype._affectMaterial = function (mesh) {
  14835. mesh.material = null;
  14836. };
  14837. // Pointers
  14838. /** @hidden */
  14839. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14840. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14841. };
  14842. /** @hidden */
  14843. Control3D.prototype._onPointerEnter = function (target) {
  14844. if (this._enterCount > 0) {
  14845. return false;
  14846. }
  14847. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14848. this._enterCount = 0;
  14849. }
  14850. this._enterCount++;
  14851. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14852. if (this.pointerEnterAnimation) {
  14853. this.pointerEnterAnimation();
  14854. }
  14855. return true;
  14856. };
  14857. /** @hidden */
  14858. Control3D.prototype._onPointerOut = function (target) {
  14859. this._enterCount = 0;
  14860. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14861. if (this.pointerOutAnimation) {
  14862. this.pointerOutAnimation();
  14863. }
  14864. };
  14865. /** @hidden */
  14866. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14867. if (this._downCount !== 0) {
  14868. this._downCount++;
  14869. return false;
  14870. }
  14871. this._downCount++;
  14872. this._downPointerIds[pointerId] = true;
  14873. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14874. if (this.pointerDownAnimation) {
  14875. this.pointerDownAnimation();
  14876. }
  14877. return true;
  14878. };
  14879. /** @hidden */
  14880. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14881. this._downCount--;
  14882. delete this._downPointerIds[pointerId];
  14883. if (this._downCount < 0) {
  14884. // Handle if forcePointerUp was called prior to this
  14885. this._downCount = 0;
  14886. return;
  14887. }
  14888. if (this._downCount == 0) {
  14889. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14890. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14891. }
  14892. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14893. if (this.pointerUpAnimation) {
  14894. this.pointerUpAnimation();
  14895. }
  14896. }
  14897. };
  14898. /** @hidden */
  14899. Control3D.prototype.forcePointerUp = function (pointerId) {
  14900. if (pointerId === void 0) { pointerId = null; }
  14901. if (pointerId !== null) {
  14902. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14903. }
  14904. else {
  14905. for (var key in this._downPointerIds) {
  14906. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14907. }
  14908. if (this._downCount > 0) {
  14909. this._downCount = 1;
  14910. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14911. }
  14912. }
  14913. };
  14914. /** @hidden */
  14915. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14916. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14917. this._onPointerMove(this, pickedPoint);
  14918. var previousControlOver = this._host._lastControlOver[pointerId];
  14919. if (previousControlOver && previousControlOver !== this) {
  14920. previousControlOver._onPointerOut(this);
  14921. }
  14922. if (previousControlOver !== this) {
  14923. this._onPointerEnter(this);
  14924. }
  14925. this._host._lastControlOver[pointerId] = this;
  14926. return true;
  14927. }
  14928. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14929. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14930. this._host._lastControlDown[pointerId] = this;
  14931. this._host._lastPickedControl = this;
  14932. return true;
  14933. }
  14934. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP || type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) {
  14935. if (this._host._lastControlDown[pointerId]) {
  14936. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14937. }
  14938. delete this._host._lastControlDown[pointerId];
  14939. return true;
  14940. }
  14941. return false;
  14942. };
  14943. /** @hidden */
  14944. Control3D.prototype._disposeNode = function () {
  14945. if (this._node) {
  14946. this._node.dispose();
  14947. this._node = null;
  14948. }
  14949. };
  14950. /**
  14951. * Releases all associated resources
  14952. */
  14953. Control3D.prototype.dispose = function () {
  14954. this.onPointerDownObservable.clear();
  14955. this.onPointerEnterObservable.clear();
  14956. this.onPointerMoveObservable.clear();
  14957. this.onPointerOutObservable.clear();
  14958. this.onPointerUpObservable.clear();
  14959. this.onPointerClickObservable.clear();
  14960. this._disposeNode();
  14961. // Behaviors
  14962. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14963. var behavior = _a[_i];
  14964. behavior.detach();
  14965. }
  14966. };
  14967. return Control3D;
  14968. }());
  14969. /***/ }),
  14970. /***/ "./3D/controls/cylinderPanel.ts":
  14971. /*!**************************************!*\
  14972. !*** ./3D/controls/cylinderPanel.ts ***!
  14973. \**************************************/
  14974. /*! exports provided: CylinderPanel */
  14975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14976. "use strict";
  14977. __webpack_require__.r(__webpack_exports__);
  14978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14979. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14980. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  14981. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14982. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14983. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14984. /**
  14985. * Class used to create a container panel deployed on the surface of a cylinder
  14986. */
  14987. var CylinderPanel = /** @class */ (function (_super) {
  14988. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14989. function CylinderPanel() {
  14990. var _this = _super !== null && _super.apply(this, arguments) || this;
  14991. _this._radius = 5.0;
  14992. return _this;
  14993. }
  14994. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14995. /**
  14996. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14997. */
  14998. get: function () {
  14999. return this._radius;
  15000. },
  15001. set: function (value) {
  15002. var _this = this;
  15003. if (this._radius === value) {
  15004. return;
  15005. }
  15006. this._radius = value;
  15007. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15008. _this._arrangeChildren();
  15009. });
  15010. },
  15011. enumerable: false,
  15012. configurable: true
  15013. });
  15014. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  15015. var mesh = control.mesh;
  15016. if (!mesh) {
  15017. return;
  15018. }
  15019. var newPos = this._cylindricalMapping(nodePosition);
  15020. control.position = newPos;
  15021. switch (this.orientation) {
  15022. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15023. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  15024. break;
  15025. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15026. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  15027. break;
  15028. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15029. break;
  15030. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15031. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15032. break;
  15033. }
  15034. };
  15035. CylinderPanel.prototype._cylindricalMapping = function (source) {
  15036. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  15037. var yAngle = (source.x / this._radius);
  15038. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15039. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15040. };
  15041. return CylinderPanel;
  15042. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15043. /***/ }),
  15044. /***/ "./3D/controls/holographicButton.ts":
  15045. /*!******************************************!*\
  15046. !*** ./3D/controls/holographicButton.ts ***!
  15047. \******************************************/
  15048. /*! exports provided: HolographicButton */
  15049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15050. "use strict";
  15051. __webpack_require__.r(__webpack_exports__);
  15052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  15053. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15054. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15055. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Misc/observable");
  15056. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  15057. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  15058. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  15059. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  15060. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  15061. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  15062. /**
  15063. * Class used to create a holographic button in 3D
  15064. */
  15065. var HolographicButton = /** @class */ (function (_super) {
  15066. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  15067. /**
  15068. * Creates a new button
  15069. * @param name defines the control name
  15070. */
  15071. function HolographicButton(name, shareMaterials) {
  15072. if (shareMaterials === void 0) { shareMaterials = true; }
  15073. var _this = _super.call(this, name) || this;
  15074. _this._shareMaterials = true;
  15075. _this._shareMaterials = shareMaterials;
  15076. // Default animations
  15077. _this.pointerEnterAnimation = function () {
  15078. if (!_this.mesh) {
  15079. return;
  15080. }
  15081. _this._frontPlate.setEnabled(true);
  15082. };
  15083. _this.pointerOutAnimation = function () {
  15084. if (!_this.mesh) {
  15085. return;
  15086. }
  15087. _this._frontPlate.setEnabled(false);
  15088. };
  15089. return _this;
  15090. }
  15091. HolographicButton.prototype._disposeTooltip = function () {
  15092. this._tooltipFade = null;
  15093. if (this._tooltipTextBlock) {
  15094. this._tooltipTextBlock.dispose();
  15095. }
  15096. if (this._tooltipTexture) {
  15097. this._tooltipTexture.dispose();
  15098. }
  15099. if (this._tooltipMesh) {
  15100. this._tooltipMesh.dispose();
  15101. }
  15102. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  15103. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  15104. };
  15105. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  15106. get: function () {
  15107. return this._backPlate.renderingGroupId;
  15108. },
  15109. /**
  15110. * Rendering ground id of all the mesh in the button
  15111. */
  15112. set: function (id) {
  15113. this._backPlate.renderingGroupId = id;
  15114. this._textPlate.renderingGroupId = id;
  15115. this._frontPlate.renderingGroupId = id;
  15116. if (this._tooltipMesh) {
  15117. this._tooltipMesh.renderingGroupId = id;
  15118. }
  15119. },
  15120. enumerable: false,
  15121. configurable: true
  15122. });
  15123. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  15124. get: function () {
  15125. if (this._tooltipTextBlock) {
  15126. return this._tooltipTextBlock.text;
  15127. }
  15128. return null;
  15129. },
  15130. /**
  15131. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  15132. */
  15133. set: function (text) {
  15134. var _this = this;
  15135. if (!text) {
  15136. this._disposeTooltip();
  15137. return;
  15138. }
  15139. if (!this._tooltipFade) {
  15140. // Create tooltip with mesh and text
  15141. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  15142. 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);
  15143. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  15144. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  15145. tooltipBackground.material = mat;
  15146. tooltipBackground.isPickable = false;
  15147. this._tooltipMesh.addChild(tooltipBackground);
  15148. tooltipBackground.position.z = 0.05;
  15149. this._tooltipMesh.scaling.y = 1 / 3;
  15150. this._tooltipMesh.position.y = 0.7;
  15151. this._tooltipMesh.position.z = -0.15;
  15152. this._tooltipMesh.isPickable = false;
  15153. this._tooltipMesh.parent = this._backPlate;
  15154. // Create text texture for the tooltip
  15155. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  15156. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  15157. this._tooltipTextBlock.scaleY = 3;
  15158. this._tooltipTextBlock.color = "white";
  15159. this._tooltipTextBlock.fontSize = 130;
  15160. this._tooltipTexture.addControl(this._tooltipTextBlock);
  15161. // Add hover action to tooltip
  15162. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  15163. this._tooltipFade.delay = 500;
  15164. this._tooltipMesh.addBehavior(this._tooltipFade);
  15165. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  15166. if (_this._tooltipFade) {
  15167. _this._tooltipFade.fadeIn(true);
  15168. }
  15169. });
  15170. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  15171. if (_this._tooltipFade) {
  15172. _this._tooltipFade.fadeIn(false);
  15173. }
  15174. });
  15175. }
  15176. if (this._tooltipTextBlock) {
  15177. this._tooltipTextBlock.text = text;
  15178. }
  15179. },
  15180. enumerable: false,
  15181. configurable: true
  15182. });
  15183. Object.defineProperty(HolographicButton.prototype, "text", {
  15184. /**
  15185. * Gets or sets text for the button
  15186. */
  15187. get: function () {
  15188. return this._text;
  15189. },
  15190. set: function (value) {
  15191. if (this._text === value) {
  15192. return;
  15193. }
  15194. this._text = value;
  15195. this._rebuildContent();
  15196. },
  15197. enumerable: false,
  15198. configurable: true
  15199. });
  15200. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  15201. /**
  15202. * Gets or sets the image url for the button
  15203. */
  15204. get: function () {
  15205. return this._imageUrl;
  15206. },
  15207. set: function (value) {
  15208. if (this._imageUrl === value) {
  15209. return;
  15210. }
  15211. this._imageUrl = value;
  15212. this._rebuildContent();
  15213. },
  15214. enumerable: false,
  15215. configurable: true
  15216. });
  15217. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  15218. /**
  15219. * Gets the back material used by this button
  15220. */
  15221. get: function () {
  15222. return this._backMaterial;
  15223. },
  15224. enumerable: false,
  15225. configurable: true
  15226. });
  15227. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  15228. /**
  15229. * Gets the front material used by this button
  15230. */
  15231. get: function () {
  15232. return this._frontMaterial;
  15233. },
  15234. enumerable: false,
  15235. configurable: true
  15236. });
  15237. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  15238. /**
  15239. * Gets the plate material used by this button
  15240. */
  15241. get: function () {
  15242. return this._plateMaterial;
  15243. },
  15244. enumerable: false,
  15245. configurable: true
  15246. });
  15247. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  15248. /**
  15249. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  15250. */
  15251. get: function () {
  15252. return this._shareMaterials;
  15253. },
  15254. enumerable: false,
  15255. configurable: true
  15256. });
  15257. HolographicButton.prototype._getTypeName = function () {
  15258. return "HolographicButton";
  15259. };
  15260. HolographicButton.prototype._rebuildContent = function () {
  15261. this._disposeFacadeTexture();
  15262. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  15263. panel.isVertical = true;
  15264. if (this._imageUrl) {
  15265. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  15266. image.source = this._imageUrl;
  15267. image.paddingTop = "40px";
  15268. image.height = "180px";
  15269. image.width = "100px";
  15270. image.paddingBottom = "40px";
  15271. panel.addControl(image);
  15272. }
  15273. if (this._text) {
  15274. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  15275. text.text = this._text;
  15276. text.color = "white";
  15277. text.height = "30px";
  15278. text.fontSize = 24;
  15279. panel.addControl(text);
  15280. }
  15281. if (this._frontPlate) {
  15282. this.content = panel;
  15283. }
  15284. };
  15285. // Mesh association
  15286. HolographicButton.prototype._createNode = function (scene) {
  15287. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  15288. width: 1.0,
  15289. height: 1.0,
  15290. depth: 0.08
  15291. }, scene);
  15292. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  15293. width: 1.0,
  15294. height: 1.0,
  15295. depth: 0.08
  15296. }, scene);
  15297. this._frontPlate.parent = this._backPlate;
  15298. this._frontPlate.position.z = -0.08;
  15299. this._frontPlate.isPickable = false;
  15300. this._frontPlate.setEnabled(false);
  15301. this._textPlate = _super.prototype._createNode.call(this, scene);
  15302. this._textPlate.parent = this._backPlate;
  15303. this._textPlate.position.z = -0.08;
  15304. this._textPlate.isPickable = false;
  15305. return this._backPlate;
  15306. };
  15307. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  15308. this._plateMaterial.emissiveTexture = facadeTexture;
  15309. this._plateMaterial.opacityTexture = facadeTexture;
  15310. };
  15311. HolographicButton.prototype._createBackMaterial = function (mesh) {
  15312. var _this = this;
  15313. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  15314. this._backMaterial.renderHoverLight = true;
  15315. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  15316. if (pickedPoint) {
  15317. _this._backMaterial.hoverPosition = pickedPoint;
  15318. _this._backMaterial.hoverColor.a = 1.0;
  15319. }
  15320. else {
  15321. _this._backMaterial.hoverColor.a = 0;
  15322. }
  15323. });
  15324. };
  15325. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  15326. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  15327. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  15328. this._frontMaterial.alpha = 0.5; // Additive
  15329. this._frontMaterial.renderBorders = true;
  15330. };
  15331. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  15332. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  15333. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  15334. };
  15335. HolographicButton.prototype._affectMaterial = function (mesh) {
  15336. // Back
  15337. if (this._shareMaterials) {
  15338. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  15339. this._createBackMaterial(mesh);
  15340. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  15341. }
  15342. else {
  15343. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  15344. }
  15345. // Front
  15346. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  15347. this._createFrontMaterial(mesh);
  15348. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  15349. }
  15350. else {
  15351. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  15352. }
  15353. }
  15354. else {
  15355. this._createBackMaterial(mesh);
  15356. this._createFrontMaterial(mesh);
  15357. }
  15358. this._createPlateMaterial(mesh);
  15359. this._backPlate.material = this._backMaterial;
  15360. this._frontPlate.material = this._frontMaterial;
  15361. this._textPlate.material = this._plateMaterial;
  15362. this._rebuildContent();
  15363. };
  15364. /**
  15365. * Releases all associated resources
  15366. */
  15367. HolographicButton.prototype.dispose = function () {
  15368. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  15369. this._disposeTooltip();
  15370. if (!this.shareMaterials) {
  15371. this._backMaterial.dispose();
  15372. this._frontMaterial.dispose();
  15373. this._plateMaterial.dispose();
  15374. if (this._pickedPointObserver) {
  15375. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  15376. this._pickedPointObserver = null;
  15377. }
  15378. }
  15379. };
  15380. return HolographicButton;
  15381. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15382. /***/ }),
  15383. /***/ "./3D/controls/index.ts":
  15384. /*!******************************!*\
  15385. !*** ./3D/controls/index.ts ***!
  15386. \******************************/
  15387. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  15388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15389. "use strict";
  15390. __webpack_require__.r(__webpack_exports__);
  15391. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  15392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15393. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15395. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  15397. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  15399. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  15400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  15401. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  15402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  15403. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  15404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  15405. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  15406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  15407. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  15408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  15409. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  15410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  15411. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  15412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  15413. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  15415. /***/ }),
  15416. /***/ "./3D/controls/meshButton3D.ts":
  15417. /*!*************************************!*\
  15418. !*** ./3D/controls/meshButton3D.ts ***!
  15419. \*************************************/
  15420. /*! exports provided: MeshButton3D */
  15421. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15422. "use strict";
  15423. __webpack_require__.r(__webpack_exports__);
  15424. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  15425. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15426. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15427. /**
  15428. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  15429. */
  15430. var MeshButton3D = /** @class */ (function (_super) {
  15431. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  15432. /**
  15433. * Creates a new 3D button based on a mesh
  15434. * @param mesh mesh to become a 3D button
  15435. * @param name defines the control name
  15436. */
  15437. function MeshButton3D(mesh, name) {
  15438. var _this = _super.call(this, name) || this;
  15439. _this._currentMesh = mesh;
  15440. /**
  15441. * Provides a default behavior on hover/out & up/down
  15442. * Override those function to create your own desired behavior specific to your mesh
  15443. */
  15444. _this.pointerEnterAnimation = function () {
  15445. if (!_this.mesh) {
  15446. return;
  15447. }
  15448. _this.mesh.scaling.scaleInPlace(1.1);
  15449. };
  15450. _this.pointerOutAnimation = function () {
  15451. if (!_this.mesh) {
  15452. return;
  15453. }
  15454. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  15455. };
  15456. _this.pointerDownAnimation = function () {
  15457. if (!_this.mesh) {
  15458. return;
  15459. }
  15460. _this.mesh.scaling.scaleInPlace(0.95);
  15461. };
  15462. _this.pointerUpAnimation = function () {
  15463. if (!_this.mesh) {
  15464. return;
  15465. }
  15466. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15467. };
  15468. return _this;
  15469. }
  15470. MeshButton3D.prototype._getTypeName = function () {
  15471. return "MeshButton3D";
  15472. };
  15473. // Mesh association
  15474. MeshButton3D.prototype._createNode = function (scene) {
  15475. var _this = this;
  15476. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15477. mesh.metadata = _this;
  15478. });
  15479. return this._currentMesh;
  15480. };
  15481. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15482. };
  15483. return MeshButton3D;
  15484. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15485. /***/ }),
  15486. /***/ "./3D/controls/planePanel.ts":
  15487. /*!***********************************!*\
  15488. !*** ./3D/controls/planePanel.ts ***!
  15489. \***********************************/
  15490. /*! exports provided: PlanePanel */
  15491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15492. "use strict";
  15493. __webpack_require__.r(__webpack_exports__);
  15494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15495. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15496. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  15497. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15498. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15499. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15500. /**
  15501. * Class used to create a container panel deployed on the surface of a plane
  15502. */
  15503. var PlanePanel = /** @class */ (function (_super) {
  15504. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15505. function PlanePanel() {
  15506. return _super !== null && _super.apply(this, arguments) || this;
  15507. }
  15508. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15509. var mesh = control.mesh;
  15510. if (!mesh) {
  15511. return;
  15512. }
  15513. control.position = nodePosition.clone();
  15514. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15515. target.copyFrom(nodePosition);
  15516. switch (this.orientation) {
  15517. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15518. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15519. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15520. mesh.lookAt(target);
  15521. break;
  15522. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15523. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15524. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15525. mesh.lookAt(target);
  15526. break;
  15527. }
  15528. };
  15529. return PlanePanel;
  15530. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15531. /***/ }),
  15532. /***/ "./3D/controls/scatterPanel.ts":
  15533. /*!*************************************!*\
  15534. !*** ./3D/controls/scatterPanel.ts ***!
  15535. \*************************************/
  15536. /*! exports provided: ScatterPanel */
  15537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15538. "use strict";
  15539. __webpack_require__.r(__webpack_exports__);
  15540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15541. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15542. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15543. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15544. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15545. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15546. /**
  15547. * Class used to create a container panel where items get randomized planar mapping
  15548. */
  15549. var ScatterPanel = /** @class */ (function (_super) {
  15550. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15551. function ScatterPanel() {
  15552. var _this = _super !== null && _super.apply(this, arguments) || this;
  15553. _this._iteration = 100.0;
  15554. return _this;
  15555. }
  15556. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15557. /**
  15558. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15559. */
  15560. get: function () {
  15561. return this._iteration;
  15562. },
  15563. set: function (value) {
  15564. var _this = this;
  15565. if (this._iteration === value) {
  15566. return;
  15567. }
  15568. this._iteration = value;
  15569. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15570. _this._arrangeChildren();
  15571. });
  15572. },
  15573. enumerable: false,
  15574. configurable: true
  15575. });
  15576. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15577. var mesh = control.mesh;
  15578. var newPos = this._scatterMapping(nodePosition);
  15579. if (!mesh) {
  15580. return;
  15581. }
  15582. switch (this.orientation) {
  15583. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15584. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15585. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15586. break;
  15587. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15588. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15589. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15590. break;
  15591. }
  15592. control.position = newPos;
  15593. };
  15594. ScatterPanel.prototype._scatterMapping = function (source) {
  15595. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15596. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15597. return source;
  15598. };
  15599. ScatterPanel.prototype._finalProcessing = function () {
  15600. var meshes = [];
  15601. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15602. var child = _a[_i];
  15603. if (!child.mesh) {
  15604. continue;
  15605. }
  15606. meshes.push(child.mesh);
  15607. }
  15608. for (var count = 0; count < this._iteration; count++) {
  15609. meshes.sort(function (a, b) {
  15610. var distance1 = a.position.lengthSquared();
  15611. var distance2 = b.position.lengthSquared();
  15612. if (distance1 < distance2) {
  15613. return 1;
  15614. }
  15615. else if (distance1 > distance2) {
  15616. return -1;
  15617. }
  15618. return 0;
  15619. });
  15620. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15621. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15622. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15623. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15624. for (var i = 0; i < meshes.length - 1; i++) {
  15625. for (var j = i + 1; j < meshes.length; j++) {
  15626. if (i != j) {
  15627. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15628. // Ignore Z axis
  15629. difference2D.x = difference.x;
  15630. difference2D.y = difference.y;
  15631. var combinedRadius = cellSize;
  15632. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15633. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15634. distance -= minSeparation;
  15635. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15636. difference2D.normalize();
  15637. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15638. meshes[j].position.addInPlace(difference);
  15639. meshes[i].position.subtractInPlace(difference);
  15640. }
  15641. }
  15642. }
  15643. }
  15644. }
  15645. };
  15646. return ScatterPanel;
  15647. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15648. /***/ }),
  15649. /***/ "./3D/controls/spherePanel.ts":
  15650. /*!************************************!*\
  15651. !*** ./3D/controls/spherePanel.ts ***!
  15652. \************************************/
  15653. /*! exports provided: SpherePanel */
  15654. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15655. "use strict";
  15656. __webpack_require__.r(__webpack_exports__);
  15657. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15658. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15659. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15660. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15661. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15662. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15663. /**
  15664. * Class used to create a container panel deployed on the surface of a sphere
  15665. */
  15666. var SpherePanel = /** @class */ (function (_super) {
  15667. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15668. function SpherePanel() {
  15669. var _this = _super !== null && _super.apply(this, arguments) || this;
  15670. _this._radius = 5.0;
  15671. return _this;
  15672. }
  15673. Object.defineProperty(SpherePanel.prototype, "radius", {
  15674. /**
  15675. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15676. */
  15677. get: function () {
  15678. return this._radius;
  15679. },
  15680. set: function (value) {
  15681. var _this = this;
  15682. if (this._radius === value) {
  15683. return;
  15684. }
  15685. this._radius = value;
  15686. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15687. _this._arrangeChildren();
  15688. });
  15689. },
  15690. enumerable: false,
  15691. configurable: true
  15692. });
  15693. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15694. var mesh = control.mesh;
  15695. if (!mesh) {
  15696. return;
  15697. }
  15698. var newPos = this._sphericalMapping(nodePosition);
  15699. control.position = newPos;
  15700. switch (this.orientation) {
  15701. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15702. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15703. break;
  15704. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15705. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15706. break;
  15707. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15708. break;
  15709. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15710. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15711. break;
  15712. }
  15713. };
  15714. SpherePanel.prototype._sphericalMapping = function (source) {
  15715. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15716. var xAngle = (source.y / this._radius);
  15717. var yAngle = -(source.x / this._radius);
  15718. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15719. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15720. };
  15721. return SpherePanel;
  15722. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15723. /***/ }),
  15724. /***/ "./3D/controls/stackPanel3D.ts":
  15725. /*!*************************************!*\
  15726. !*** ./3D/controls/stackPanel3D.ts ***!
  15727. \*************************************/
  15728. /*! exports provided: StackPanel3D */
  15729. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15730. "use strict";
  15731. __webpack_require__.r(__webpack_exports__);
  15732. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15733. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15734. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15735. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15736. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15737. /**
  15738. * Class used to create a stack panel in 3D on XY plane
  15739. */
  15740. var StackPanel3D = /** @class */ (function (_super) {
  15741. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15742. /**
  15743. * Creates new StackPanel
  15744. * @param isVertical
  15745. */
  15746. function StackPanel3D(isVertical) {
  15747. if (isVertical === void 0) { isVertical = false; }
  15748. var _this = _super.call(this) || this;
  15749. _this._isVertical = false;
  15750. /**
  15751. * Gets or sets the distance between elements
  15752. */
  15753. _this.margin = 0.1;
  15754. _this._isVertical = isVertical;
  15755. return _this;
  15756. }
  15757. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15758. /**
  15759. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15760. */
  15761. get: function () {
  15762. return this._isVertical;
  15763. },
  15764. set: function (value) {
  15765. var _this = this;
  15766. if (this._isVertical === value) {
  15767. return;
  15768. }
  15769. this._isVertical = value;
  15770. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15771. _this._arrangeChildren();
  15772. });
  15773. },
  15774. enumerable: false,
  15775. configurable: true
  15776. });
  15777. StackPanel3D.prototype._arrangeChildren = function () {
  15778. var width = 0;
  15779. var height = 0;
  15780. var controlCount = 0;
  15781. var extendSizes = [];
  15782. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15783. // Measure
  15784. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15785. var child = _a[_i];
  15786. if (!child.mesh) {
  15787. continue;
  15788. }
  15789. controlCount++;
  15790. child.mesh.computeWorldMatrix(true);
  15791. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15792. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15793. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15794. extendSizes.push(extendSize);
  15795. if (this._isVertical) {
  15796. height += extendSize.y;
  15797. }
  15798. else {
  15799. width += extendSize.x;
  15800. }
  15801. }
  15802. if (this._isVertical) {
  15803. height += (controlCount - 1) * this.margin / 2;
  15804. }
  15805. else {
  15806. width += (controlCount - 1) * this.margin / 2;
  15807. }
  15808. // Arrange
  15809. var offset;
  15810. if (this._isVertical) {
  15811. offset = -height;
  15812. }
  15813. else {
  15814. offset = -width;
  15815. }
  15816. var index = 0;
  15817. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15818. var child = _c[_b];
  15819. if (!child.mesh) {
  15820. continue;
  15821. }
  15822. controlCount--;
  15823. var extendSize = extendSizes[index++];
  15824. if (this._isVertical) {
  15825. child.position.y = offset + extendSize.y;
  15826. child.position.x = 0;
  15827. offset += extendSize.y * 2;
  15828. }
  15829. else {
  15830. child.position.x = offset + extendSize.x;
  15831. child.position.y = 0;
  15832. offset += extendSize.x * 2;
  15833. }
  15834. offset += (controlCount > 0 ? this.margin : 0);
  15835. }
  15836. };
  15837. return StackPanel3D;
  15838. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15839. /***/ }),
  15840. /***/ "./3D/controls/volumeBasedPanel.ts":
  15841. /*!*****************************************!*\
  15842. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15843. \*****************************************/
  15844. /*! exports provided: VolumeBasedPanel */
  15845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15846. "use strict";
  15847. __webpack_require__.r(__webpack_exports__);
  15848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15849. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15850. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15851. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15852. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15853. /**
  15854. * Abstract class used to create a container panel deployed on the surface of a volume
  15855. */
  15856. var VolumeBasedPanel = /** @class */ (function (_super) {
  15857. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15858. /**
  15859. * Creates new VolumeBasedPanel
  15860. */
  15861. function VolumeBasedPanel() {
  15862. var _this = _super.call(this) || this;
  15863. _this._columns = 10;
  15864. _this._rows = 0;
  15865. _this._rowThenColum = true;
  15866. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15867. /**
  15868. * Gets or sets the distance between elements
  15869. */
  15870. _this.margin = 0;
  15871. return _this;
  15872. }
  15873. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15874. /**
  15875. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15876. * | Value | Type | Description |
  15877. * | ----- | ----------------------------------- | ----------- |
  15878. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15879. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15880. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15881. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15882. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15883. */
  15884. get: function () {
  15885. return this._orientation;
  15886. },
  15887. set: function (value) {
  15888. var _this = this;
  15889. if (this._orientation === value) {
  15890. return;
  15891. }
  15892. this._orientation = value;
  15893. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15894. _this._arrangeChildren();
  15895. });
  15896. },
  15897. enumerable: false,
  15898. configurable: true
  15899. });
  15900. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15901. /**
  15902. * Gets or sets the number of columns requested (10 by default).
  15903. * The panel will automatically compute the number of rows based on number of child controls.
  15904. */
  15905. get: function () {
  15906. return this._columns;
  15907. },
  15908. set: function (value) {
  15909. var _this = this;
  15910. if (this._columns === value) {
  15911. return;
  15912. }
  15913. this._columns = value;
  15914. this._rowThenColum = true;
  15915. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15916. _this._arrangeChildren();
  15917. });
  15918. },
  15919. enumerable: false,
  15920. configurable: true
  15921. });
  15922. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15923. /**
  15924. * Gets or sets a the number of rows requested.
  15925. * The panel will automatically compute the number of columns based on number of child controls.
  15926. */
  15927. get: function () {
  15928. return this._rows;
  15929. },
  15930. set: function (value) {
  15931. var _this = this;
  15932. if (this._rows === value) {
  15933. return;
  15934. }
  15935. this._rows = value;
  15936. this._rowThenColum = false;
  15937. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15938. _this._arrangeChildren();
  15939. });
  15940. },
  15941. enumerable: false,
  15942. configurable: true
  15943. });
  15944. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15945. this._cellWidth = 0;
  15946. this._cellHeight = 0;
  15947. var rows = 0;
  15948. var columns = 0;
  15949. var controlCount = 0;
  15950. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15951. // Measure
  15952. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15953. var child = _a[_i];
  15954. if (!child.mesh) {
  15955. continue;
  15956. }
  15957. controlCount++;
  15958. child.mesh.computeWorldMatrix(true);
  15959. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15960. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15961. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15962. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15963. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15964. diff.scaleInPlace(0.5);
  15965. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15966. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15967. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15968. }
  15969. this._cellWidth += this.margin * 2;
  15970. this._cellHeight += this.margin * 2;
  15971. // Arrange
  15972. if (this._rowThenColum) {
  15973. columns = this._columns;
  15974. rows = Math.ceil(controlCount / this._columns);
  15975. }
  15976. else {
  15977. rows = this._rows;
  15978. columns = Math.ceil(controlCount / this._rows);
  15979. }
  15980. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15981. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15982. var nodeGrid = [];
  15983. var cellCounter = 0;
  15984. if (this._rowThenColum) {
  15985. for (var r = 0; r < rows; r++) {
  15986. for (var c = 0; c < columns; c++) {
  15987. 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));
  15988. cellCounter++;
  15989. if (cellCounter > controlCount) {
  15990. break;
  15991. }
  15992. }
  15993. }
  15994. }
  15995. else {
  15996. for (var c = 0; c < columns; c++) {
  15997. for (var r = 0; r < rows; r++) {
  15998. 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));
  15999. cellCounter++;
  16000. if (cellCounter > controlCount) {
  16001. break;
  16002. }
  16003. }
  16004. }
  16005. }
  16006. cellCounter = 0;
  16007. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  16008. var child = _c[_b];
  16009. if (!child.mesh) {
  16010. continue;
  16011. }
  16012. this._mapGridNode(child, nodeGrid[cellCounter]);
  16013. cellCounter++;
  16014. }
  16015. this._finalProcessing();
  16016. };
  16017. /** Child classes can implement this function to provide additional processing */
  16018. VolumeBasedPanel.prototype._finalProcessing = function () {
  16019. };
  16020. return VolumeBasedPanel;
  16021. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  16022. /***/ }),
  16023. /***/ "./3D/gui3DManager.ts":
  16024. /*!****************************!*\
  16025. !*** ./3D/gui3DManager.ts ***!
  16026. \****************************/
  16027. /*! exports provided: GUI3DManager */
  16028. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16029. "use strict";
  16030. __webpack_require__.r(__webpack_exports__);
  16031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  16032. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  16033. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  16034. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  16035. /**
  16036. * Class used to manage 3D user interface
  16037. * @see https://doc.babylonjs.com/how_to/gui3d
  16038. */
  16039. var GUI3DManager = /** @class */ (function () {
  16040. /**
  16041. * Creates a new GUI3DManager
  16042. * @param scene
  16043. */
  16044. function GUI3DManager(scene) {
  16045. var _this = this;
  16046. /** @hidden */
  16047. this._lastControlOver = {};
  16048. /** @hidden */
  16049. this._lastControlDown = {};
  16050. /**
  16051. * Observable raised when the point picked by the pointer events changed
  16052. */
  16053. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  16054. // Shared resources
  16055. /** @hidden */
  16056. this._sharedMaterials = {};
  16057. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  16058. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  16059. _this._sceneDisposeObserver = null;
  16060. _this._utilityLayer = null;
  16061. _this.dispose();
  16062. });
  16063. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  16064. this._utilityLayer.onlyCheckPointerDownEvents = false;
  16065. this._utilityLayer.pickUtilitySceneFirst = false;
  16066. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  16067. return mesh && mesh.metadata && mesh.metadata._node;
  16068. };
  16069. // Root
  16070. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  16071. this._rootContainer._host = this;
  16072. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  16073. // Events
  16074. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  16075. _this._handlePointerOut(pointerId, true);
  16076. });
  16077. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  16078. _this._doPicking(pi);
  16079. });
  16080. // Scene
  16081. this._utilityLayer.utilityLayerScene.autoClear = false;
  16082. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  16083. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  16084. }
  16085. Object.defineProperty(GUI3DManager.prototype, "scene", {
  16086. /** Gets the hosting scene */
  16087. get: function () {
  16088. return this._scene;
  16089. },
  16090. enumerable: false,
  16091. configurable: true
  16092. });
  16093. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  16094. /** Gets associated utility layer */
  16095. get: function () {
  16096. return this._utilityLayer;
  16097. },
  16098. enumerable: false,
  16099. configurable: true
  16100. });
  16101. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  16102. var previousControlOver = this._lastControlOver[pointerId];
  16103. if (previousControlOver) {
  16104. previousControlOver._onPointerOut(previousControlOver);
  16105. delete this._lastControlOver[pointerId];
  16106. }
  16107. if (isPointerUp) {
  16108. if (this._lastControlDown[pointerId]) {
  16109. this._lastControlDown[pointerId].forcePointerUp();
  16110. delete this._lastControlDown[pointerId];
  16111. }
  16112. }
  16113. this.onPickedPointChangedObservable.notifyObservers(null);
  16114. };
  16115. GUI3DManager.prototype._doPicking = function (pi) {
  16116. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  16117. return false;
  16118. }
  16119. var pointerEvent = (pi.event);
  16120. var pointerId = pointerEvent.pointerId || 0;
  16121. var buttonIndex = pointerEvent.button;
  16122. var pickingInfo = pi.pickInfo;
  16123. if (!pickingInfo || !pickingInfo.hit) {
  16124. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  16125. return false;
  16126. }
  16127. var control = (pickingInfo.pickedMesh.metadata);
  16128. if (pickingInfo.pickedPoint) {
  16129. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  16130. }
  16131. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  16132. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  16133. if (this._lastControlOver[pointerId]) {
  16134. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  16135. }
  16136. delete this._lastControlOver[pointerId];
  16137. }
  16138. }
  16139. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  16140. if (this._lastControlDown[pointerEvent.pointerId]) {
  16141. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  16142. delete this._lastControlDown[pointerEvent.pointerId];
  16143. }
  16144. if (pointerEvent.pointerType === "touch") {
  16145. this._handlePointerOut(pointerId, false);
  16146. }
  16147. }
  16148. return true;
  16149. };
  16150. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  16151. /**
  16152. * Gets the root container
  16153. */
  16154. get: function () {
  16155. return this._rootContainer;
  16156. },
  16157. enumerable: false,
  16158. configurable: true
  16159. });
  16160. /**
  16161. * Gets a boolean indicating if the given control is in the root child list
  16162. * @param control defines the control to check
  16163. * @returns true if the control is in the root child list
  16164. */
  16165. GUI3DManager.prototype.containsControl = function (control) {
  16166. return this._rootContainer.containsControl(control);
  16167. };
  16168. /**
  16169. * Adds a control to the root child list
  16170. * @param control defines the control to add
  16171. * @returns the current manager
  16172. */
  16173. GUI3DManager.prototype.addControl = function (control) {
  16174. this._rootContainer.addControl(control);
  16175. return this;
  16176. };
  16177. /**
  16178. * Removes a control from the root child list
  16179. * @param control defines the control to remove
  16180. * @returns the current container
  16181. */
  16182. GUI3DManager.prototype.removeControl = function (control) {
  16183. this._rootContainer.removeControl(control);
  16184. return this;
  16185. };
  16186. /**
  16187. * Releases all associated resources
  16188. */
  16189. GUI3DManager.prototype.dispose = function () {
  16190. this._rootContainer.dispose();
  16191. for (var materialName in this._sharedMaterials) {
  16192. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  16193. continue;
  16194. }
  16195. this._sharedMaterials[materialName].dispose();
  16196. }
  16197. this._sharedMaterials = {};
  16198. if (this._pointerOutObserver && this._utilityLayer) {
  16199. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  16200. this._pointerOutObserver = null;
  16201. }
  16202. this.onPickedPointChangedObservable.clear();
  16203. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  16204. if (utilityLayerScene) {
  16205. if (this._pointerObserver) {
  16206. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  16207. this._pointerObserver = null;
  16208. }
  16209. }
  16210. if (this._scene) {
  16211. if (this._sceneDisposeObserver) {
  16212. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  16213. this._sceneDisposeObserver = null;
  16214. }
  16215. }
  16216. if (this._utilityLayer) {
  16217. this._utilityLayer.dispose();
  16218. }
  16219. };
  16220. return GUI3DManager;
  16221. }());
  16222. /***/ }),
  16223. /***/ "./3D/index.ts":
  16224. /*!*********************!*\
  16225. !*** ./3D/index.ts ***!
  16226. \*********************/
  16227. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16228. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16229. "use strict";
  16230. __webpack_require__.r(__webpack_exports__);
  16231. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  16232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16244. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  16245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16247. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  16248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  16249. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  16250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  16251. /***/ }),
  16252. /***/ "./3D/materials/fluentMaterial.ts":
  16253. /*!****************************************!*\
  16254. !*** ./3D/materials/fluentMaterial.ts ***!
  16255. \****************************************/
  16256. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16257. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16258. "use strict";
  16259. __webpack_require__.r(__webpack_exports__);
  16260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  16261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  16262. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16263. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  16264. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  16265. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  16266. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  16267. /** @hidden */
  16268. var FluentMaterialDefines = /** @class */ (function (_super) {
  16269. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  16270. function FluentMaterialDefines() {
  16271. var _this = _super.call(this) || this;
  16272. _this.INNERGLOW = false;
  16273. _this.BORDER = false;
  16274. _this.HOVERLIGHT = false;
  16275. _this.TEXTURE = false;
  16276. _this.rebuild();
  16277. return _this;
  16278. }
  16279. return FluentMaterialDefines;
  16280. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  16281. /**
  16282. * Class used to render controls with fluent desgin
  16283. */
  16284. var FluentMaterial = /** @class */ (function (_super) {
  16285. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  16286. /**
  16287. * Creates a new Fluent material
  16288. * @param name defines the name of the material
  16289. * @param scene defines the hosting scene
  16290. */
  16291. function FluentMaterial(name, scene) {
  16292. var _this = _super.call(this, name, scene) || this;
  16293. /**
  16294. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  16295. */
  16296. _this.innerGlowColorIntensity = 0.5;
  16297. /**
  16298. * Gets or sets the inner glow color (white by default)
  16299. */
  16300. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  16301. /**
  16302. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  16303. */
  16304. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  16305. /**
  16306. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  16307. */
  16308. _this.renderBorders = false;
  16309. /**
  16310. * Gets or sets border width (default is 0.5)
  16311. */
  16312. _this.borderWidth = 0.5;
  16313. /**
  16314. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  16315. */
  16316. _this.edgeSmoothingValue = 0.02;
  16317. /**
  16318. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  16319. */
  16320. _this.borderMinValue = 0.1;
  16321. /**
  16322. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  16323. */
  16324. _this.renderHoverLight = false;
  16325. /**
  16326. * Gets or sets the radius used to render the hover light (default is 1.0)
  16327. */
  16328. _this.hoverRadius = 1.0;
  16329. /**
  16330. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  16331. */
  16332. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  16333. /**
  16334. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  16335. */
  16336. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  16337. return _this;
  16338. }
  16339. FluentMaterial.prototype.needAlphaBlending = function () {
  16340. return this.alpha !== 1.0;
  16341. };
  16342. FluentMaterial.prototype.needAlphaTesting = function () {
  16343. return false;
  16344. };
  16345. FluentMaterial.prototype.getAlphaTestTexture = function () {
  16346. return null;
  16347. };
  16348. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  16349. if (this.isFrozen) {
  16350. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  16351. return true;
  16352. }
  16353. }
  16354. if (!subMesh._materialDefines) {
  16355. subMesh._materialDefines = new FluentMaterialDefines();
  16356. }
  16357. var scene = this.getScene();
  16358. var defines = subMesh._materialDefines;
  16359. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  16360. if (defines._renderId === scene.getRenderId()) {
  16361. return true;
  16362. }
  16363. }
  16364. if (defines._areTexturesDirty) {
  16365. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  16366. defines.BORDER = this.renderBorders;
  16367. defines.HOVERLIGHT = this.renderHoverLight;
  16368. if (this._albedoTexture) {
  16369. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  16370. return false;
  16371. }
  16372. else {
  16373. defines.TEXTURE = true;
  16374. }
  16375. }
  16376. else {
  16377. defines.TEXTURE = false;
  16378. }
  16379. }
  16380. var engine = scene.getEngine();
  16381. // Get correct effect
  16382. if (defines.isDirty) {
  16383. defines.markAsProcessed();
  16384. scene.resetCachedMaterial();
  16385. //Attributes
  16386. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  16387. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  16388. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  16389. var shaderName = "fluent";
  16390. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  16391. "hoverColor", "hoverPosition", "hoverRadius"
  16392. ];
  16393. var samplers = ["albedoSampler"];
  16394. var uniformBuffers = new Array();
  16395. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  16396. uniformsNames: uniforms,
  16397. uniformBuffersNames: uniformBuffers,
  16398. samplers: samplers,
  16399. defines: defines,
  16400. maxSimultaneousLights: 4
  16401. });
  16402. var join = defines.toString();
  16403. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  16404. attributes: attribs,
  16405. uniformsNames: uniforms,
  16406. uniformBuffersNames: uniformBuffers,
  16407. samplers: samplers,
  16408. defines: join,
  16409. fallbacks: null,
  16410. onCompiled: this.onCompiled,
  16411. onError: this.onError,
  16412. indexParameters: { maxSimultaneousLights: 4 }
  16413. }, engine));
  16414. }
  16415. if (!subMesh.effect || !subMesh.effect.isReady()) {
  16416. return false;
  16417. }
  16418. defines._renderId = scene.getRenderId();
  16419. subMesh.effect._wasPreviouslyReady = true;
  16420. return true;
  16421. };
  16422. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  16423. var scene = this.getScene();
  16424. var defines = subMesh._materialDefines;
  16425. if (!defines) {
  16426. return;
  16427. }
  16428. var effect = subMesh.effect;
  16429. if (!effect) {
  16430. return;
  16431. }
  16432. this._activeEffect = effect;
  16433. // Matrices
  16434. this.bindOnlyWorldMatrix(world);
  16435. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  16436. if (this._mustRebind(scene, effect)) {
  16437. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  16438. if (defines.INNERGLOW) {
  16439. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  16440. }
  16441. if (defines.BORDER) {
  16442. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  16443. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  16444. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  16445. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16446. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16447. }
  16448. if (defines.HOVERLIGHT) {
  16449. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  16450. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  16451. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  16452. }
  16453. if (defines.TEXTURE) {
  16454. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  16455. }
  16456. }
  16457. this._afterBind(mesh, this._activeEffect);
  16458. };
  16459. FluentMaterial.prototype.getActiveTextures = function () {
  16460. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16461. return activeTextures;
  16462. };
  16463. FluentMaterial.prototype.hasTexture = function (texture) {
  16464. if (_super.prototype.hasTexture.call(this, texture)) {
  16465. return true;
  16466. }
  16467. return false;
  16468. };
  16469. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16470. _super.prototype.dispose.call(this, forceDisposeEffect);
  16471. };
  16472. FluentMaterial.prototype.clone = function (name) {
  16473. var _this = this;
  16474. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16475. };
  16476. FluentMaterial.prototype.serialize = function () {
  16477. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16478. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16479. return serializationObject;
  16480. };
  16481. FluentMaterial.prototype.getClassName = function () {
  16482. return "FluentMaterial";
  16483. };
  16484. // Statics
  16485. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16486. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16487. };
  16488. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16489. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16490. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16491. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16492. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16493. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16494. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16495. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16496. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16497. ], FluentMaterial.prototype, "albedoColor", void 0);
  16498. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16499. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16500. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16501. ], FluentMaterial.prototype, "renderBorders", void 0);
  16502. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16503. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16504. ], FluentMaterial.prototype, "borderWidth", void 0);
  16505. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16506. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16507. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16508. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16509. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16510. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16511. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16512. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16513. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16514. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16515. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16516. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16517. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16518. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16519. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16520. ], FluentMaterial.prototype, "hoverColor", void 0);
  16521. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16522. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16523. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16524. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16525. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16526. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16527. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16528. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16529. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16530. return FluentMaterial;
  16531. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16532. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16533. /***/ }),
  16534. /***/ "./3D/materials/index.ts":
  16535. /*!*******************************!*\
  16536. !*** ./3D/materials/index.ts ***!
  16537. \*******************************/
  16538. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16540. "use strict";
  16541. __webpack_require__.r(__webpack_exports__);
  16542. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16545. /***/ }),
  16546. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16547. /*!*************************************************!*\
  16548. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16549. \*************************************************/
  16550. /*! exports provided: fluentPixelShader */
  16551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16552. "use strict";
  16553. __webpack_require__.r(__webpack_exports__);
  16554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16555. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  16556. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16557. var name = 'fluentPixelShader';
  16558. 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}";
  16559. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16560. /** @hidden */
  16561. var fluentPixelShader = { name: name, shader: shader };
  16562. /***/ }),
  16563. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16564. /*!***********************************************!*\
  16565. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16566. \***********************************************/
  16567. /*! exports provided: fluentVertexShader */
  16568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16569. "use strict";
  16570. __webpack_require__.r(__webpack_exports__);
  16571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16572. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  16573. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16574. var name = 'fluentVertexShader';
  16575. 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";
  16576. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16577. /** @hidden */
  16578. var fluentVertexShader = { name: name, shader: shader };
  16579. /***/ }),
  16580. /***/ "./3D/vector3WithInfo.ts":
  16581. /*!*******************************!*\
  16582. !*** ./3D/vector3WithInfo.ts ***!
  16583. \*******************************/
  16584. /*! exports provided: Vector3WithInfo */
  16585. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16586. "use strict";
  16587. __webpack_require__.r(__webpack_exports__);
  16588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16589. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16590. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  16591. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16592. /**
  16593. * Class used to transport Vector3 information for pointer events
  16594. */
  16595. var Vector3WithInfo = /** @class */ (function (_super) {
  16596. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16597. /**
  16598. * Creates a new Vector3WithInfo
  16599. * @param source defines the vector3 data to transport
  16600. * @param buttonIndex defines the current mouse button index
  16601. */
  16602. function Vector3WithInfo(source,
  16603. /** defines the current mouse button index */
  16604. buttonIndex) {
  16605. if (buttonIndex === void 0) { buttonIndex = 0; }
  16606. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16607. _this.buttonIndex = buttonIndex;
  16608. return _this;
  16609. }
  16610. return Vector3WithInfo;
  16611. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16612. /***/ }),
  16613. /***/ "./index.ts":
  16614. /*!******************!*\
  16615. !*** ./index.ts ***!
  16616. \******************/
  16617. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, 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 */
  16618. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16619. "use strict";
  16620. __webpack_require__.r(__webpack_exports__);
  16621. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  16645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16664. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16681. /***/ }),
  16682. /***/ "./legacy/legacy.ts":
  16683. /*!**************************!*\
  16684. !*** ./legacy/legacy.ts ***!
  16685. \**************************/
  16686. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, 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 */
  16687. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16688. "use strict";
  16689. __webpack_require__.r(__webpack_exports__);
  16690. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  16714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16749. /**
  16750. * Legacy support, defining window.BABYLON.GUI (global variable).
  16751. *
  16752. * This is the entry point for the UMD module.
  16753. * The entry point for a future ESM package should be index.ts
  16754. */
  16755. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16756. if (typeof globalObject !== "undefined") {
  16757. globalObject.BABYLON = globalObject.BABYLON || {};
  16758. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16759. }
  16760. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16761. /***/ }),
  16762. /***/ "babylonjs/Misc/observable":
  16763. /*!****************************************************************************************************!*\
  16764. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16765. \****************************************************************************************************/
  16766. /*! no static exports found */
  16767. /***/ (function(module, exports) {
  16768. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  16769. /***/ })
  16770. /******/ });
  16771. });
  16772. //# sourceMappingURL=babylon.gui.js.map