babylon.gui.js 758 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415
  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:/Users/Ben/git/babylon/node_modules/tslib/tslib.es6.js ***!
  101. \****************************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/observable");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: false,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: false,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: false,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: false,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see https://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. _this._defaultMousePointerId = 0;
  516. /** @hidden */
  517. _this._numLayoutCalls = 0;
  518. /** @hidden */
  519. _this._numRenderCalls = 0;
  520. /**
  521. * Define type to string to ensure compatibility across browsers
  522. * Safari doesn't support DataTransfer constructor
  523. */
  524. _this._clipboardData = "";
  525. /**
  526. * Observable event triggered each time an clipboard event is received from the rendering canvas
  527. */
  528. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  529. /**
  530. * Observable event triggered each time a pointer down is intercepted by a control
  531. */
  532. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  533. /**
  534. * Observable event triggered before layout is evaluated
  535. */
  536. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  537. /**
  538. * Observable event triggered after the layout was evaluated
  539. */
  540. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  541. /**
  542. * Observable event triggered before the texture is rendered
  543. */
  544. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  545. /**
  546. * Observable event triggered after the texture was rendered
  547. */
  548. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  549. /**
  550. * Gets or sets a boolean defining if alpha is stored as premultiplied
  551. */
  552. _this.premulAlpha = false;
  553. _this._useInvalidateRectOptimization = true;
  554. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  555. _this._invalidatedRectangle = null;
  556. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  557. /** @hidden */
  558. _this.onClipboardCopy = function (rawEvt) {
  559. var evt = rawEvt;
  560. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  561. _this.onClipboardObservable.notifyObservers(ev);
  562. evt.preventDefault();
  563. };
  564. /** @hidden */
  565. _this.onClipboardCut = function (rawEvt) {
  566. var evt = rawEvt;
  567. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  568. _this.onClipboardObservable.notifyObservers(ev);
  569. evt.preventDefault();
  570. };
  571. /** @hidden */
  572. _this.onClipboardPaste = function (rawEvt) {
  573. var evt = rawEvt;
  574. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  575. _this.onClipboardObservable.notifyObservers(ev);
  576. evt.preventDefault();
  577. };
  578. scene = _this.getScene();
  579. if (!scene || !_this._texture) {
  580. return _this;
  581. }
  582. _this._rootElement = scene.getEngine().getInputElement();
  583. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  584. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  585. if (!_this._focusedControl) {
  586. return;
  587. }
  588. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  589. _this._focusedControl.processKeyboard(info.event);
  590. }
  591. info.skipOnPointerObservable = true;
  592. });
  593. _this._rootContainer._link(_this);
  594. _this.hasAlpha = true;
  595. if (!width || !height) {
  596. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  597. _this._onResize();
  598. }
  599. _this._texture.isReady = true;
  600. return _this;
  601. }
  602. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  603. /** Gets the number of layout calls made the last time the ADT has been rendered */
  604. get: function () {
  605. return this._numLayoutCalls;
  606. },
  607. enumerable: false,
  608. configurable: true
  609. });
  610. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  611. /** Gets the number of render calls made the last time the ADT has been rendered */
  612. get: function () {
  613. return this._numRenderCalls;
  614. },
  615. enumerable: false,
  616. configurable: true
  617. });
  618. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  619. /**
  620. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  621. * Useful when you want more antialiasing
  622. */
  623. get: function () {
  624. return this._renderScale;
  625. },
  626. set: function (value) {
  627. if (value === this._renderScale) {
  628. return;
  629. }
  630. this._renderScale = value;
  631. this._onResize();
  632. },
  633. enumerable: false,
  634. configurable: true
  635. });
  636. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  637. /** Gets or sets the background color */
  638. get: function () {
  639. return this._background;
  640. },
  641. set: function (value) {
  642. if (this._background === value) {
  643. return;
  644. }
  645. this._background = value;
  646. this.markAsDirty();
  647. },
  648. enumerable: false,
  649. configurable: true
  650. });
  651. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  652. /**
  653. * Gets or sets the ideal width used to design controls.
  654. * The GUI will then rescale everything accordingly
  655. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  656. */
  657. get: function () {
  658. return this._idealWidth;
  659. },
  660. set: function (value) {
  661. if (this._idealWidth === value) {
  662. return;
  663. }
  664. this._idealWidth = value;
  665. this.markAsDirty();
  666. this._rootContainer._markAllAsDirty();
  667. },
  668. enumerable: false,
  669. configurable: true
  670. });
  671. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  672. /**
  673. * Gets or sets the ideal height used to design controls.
  674. * The GUI will then rescale everything accordingly
  675. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  676. */
  677. get: function () {
  678. return this._idealHeight;
  679. },
  680. set: function (value) {
  681. if (this._idealHeight === value) {
  682. return;
  683. }
  684. this._idealHeight = value;
  685. this.markAsDirty();
  686. this._rootContainer._markAllAsDirty();
  687. },
  688. enumerable: false,
  689. configurable: true
  690. });
  691. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  692. /**
  693. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  694. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  695. */
  696. get: function () {
  697. return this._useSmallestIdeal;
  698. },
  699. set: function (value) {
  700. if (this._useSmallestIdeal === value) {
  701. return;
  702. }
  703. this._useSmallestIdeal = value;
  704. this.markAsDirty();
  705. this._rootContainer._markAllAsDirty();
  706. },
  707. enumerable: false,
  708. configurable: true
  709. });
  710. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  711. /**
  712. * Gets or sets a boolean indicating if adaptive scaling must be used
  713. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  714. */
  715. get: function () {
  716. return this._renderAtIdealSize;
  717. },
  718. set: function (value) {
  719. if (this._renderAtIdealSize === value) {
  720. return;
  721. }
  722. this._renderAtIdealSize = value;
  723. this._onResize();
  724. },
  725. enumerable: false,
  726. configurable: true
  727. });
  728. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  729. /**
  730. * Gets the ratio used when in "ideal mode"
  731. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  732. * */
  733. get: function () {
  734. var rwidth = 0;
  735. var rheight = 0;
  736. if (this._idealWidth) {
  737. rwidth = (this.getSize().width) / this._idealWidth;
  738. }
  739. if (this._idealHeight) {
  740. rheight = (this.getSize().height) / this._idealHeight;
  741. }
  742. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  743. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  744. }
  745. if (this._idealWidth) { // horizontal
  746. return rwidth;
  747. }
  748. if (this._idealHeight) { // vertical
  749. return rheight;
  750. }
  751. return 1;
  752. },
  753. enumerable: false,
  754. configurable: true
  755. });
  756. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  757. /**
  758. * Gets the underlying layer used to render the texture when in fullscreen mode
  759. */
  760. get: function () {
  761. return this._layerToDispose;
  762. },
  763. enumerable: false,
  764. configurable: true
  765. });
  766. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  767. /**
  768. * Gets the root container control
  769. */
  770. get: function () {
  771. return this._rootContainer;
  772. },
  773. enumerable: false,
  774. configurable: true
  775. });
  776. /**
  777. * Returns an array containing the root container.
  778. * This is mostly used to let the Inspector introspects the ADT
  779. * @returns an array containing the rootContainer
  780. */
  781. AdvancedDynamicTexture.prototype.getChildren = function () {
  782. return [this._rootContainer];
  783. };
  784. /**
  785. * Will return all controls that are inside this texture
  786. * @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
  787. * @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
  788. * @return all child controls
  789. */
  790. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  791. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  792. };
  793. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  794. /**
  795. * Gets or sets the current focused control
  796. */
  797. get: function () {
  798. return this._focusedControl;
  799. },
  800. set: function (control) {
  801. if (this._focusedControl == control) {
  802. return;
  803. }
  804. if (this._focusedControl) {
  805. this._focusedControl.onBlur();
  806. }
  807. if (control) {
  808. control.onFocus();
  809. }
  810. this._focusedControl = control;
  811. },
  812. enumerable: false,
  813. configurable: true
  814. });
  815. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  816. /**
  817. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  818. */
  819. get: function () {
  820. if (!this.layer) {
  821. return true;
  822. }
  823. return (!this.layer.isBackground);
  824. },
  825. set: function (value) {
  826. if (!this.layer) {
  827. return;
  828. }
  829. if (this.layer.isBackground === !value) {
  830. return;
  831. }
  832. this.layer.isBackground = !value;
  833. },
  834. enumerable: false,
  835. configurable: true
  836. });
  837. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  838. /**
  839. * Gets or set information about clipboardData
  840. */
  841. get: function () {
  842. return this._clipboardData;
  843. },
  844. set: function (value) {
  845. this._clipboardData = value;
  846. },
  847. enumerable: false,
  848. configurable: true
  849. });
  850. /**
  851. * Get the current class name of the texture useful for serialization or dynamic coding.
  852. * @returns "AdvancedDynamicTexture"
  853. */
  854. AdvancedDynamicTexture.prototype.getClassName = function () {
  855. return "AdvancedDynamicTexture";
  856. };
  857. /**
  858. * Function used to execute a function on all controls
  859. * @param func defines the function to execute
  860. * @param container defines the container where controls belong. If null the root container will be used
  861. */
  862. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  863. if (!container) {
  864. container = this._rootContainer;
  865. }
  866. func(container);
  867. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  868. var child = _a[_i];
  869. if (child.children) {
  870. this.executeOnAllControls(func, child);
  871. continue;
  872. }
  873. func(child);
  874. }
  875. };
  876. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  877. /**
  878. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  879. */
  880. get: function () {
  881. return this._useInvalidateRectOptimization;
  882. },
  883. set: function (value) {
  884. this._useInvalidateRectOptimization = value;
  885. },
  886. enumerable: false,
  887. configurable: true
  888. });
  889. /**
  890. * Invalidates a rectangle area on the gui texture
  891. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  892. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  893. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  894. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  895. */
  896. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  897. if (!this._useInvalidateRectOptimization) {
  898. return;
  899. }
  900. if (!this._invalidatedRectangle) {
  901. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  902. }
  903. else {
  904. // Compute intersection
  905. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  906. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  907. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  908. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  909. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  910. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  911. }
  912. };
  913. /**
  914. * Marks the texture as dirty forcing a complete update
  915. */
  916. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  917. this._isDirty = true;
  918. };
  919. /**
  920. * Helper function used to create a new style
  921. * @returns a new style
  922. * @see https://doc.babylonjs.com/how_to/gui#styles
  923. */
  924. AdvancedDynamicTexture.prototype.createStyle = function () {
  925. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  926. };
  927. /**
  928. * Adds a new control to the root container
  929. * @param control defines the control to add
  930. * @returns the current texture
  931. */
  932. AdvancedDynamicTexture.prototype.addControl = function (control) {
  933. this._rootContainer.addControl(control);
  934. return this;
  935. };
  936. /**
  937. * Removes a control from the root container
  938. * @param control defines the control to remove
  939. * @returns the current texture
  940. */
  941. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  942. this._rootContainer.removeControl(control);
  943. return this;
  944. };
  945. /**
  946. * Release all resources
  947. */
  948. AdvancedDynamicTexture.prototype.dispose = function () {
  949. var scene = this.getScene();
  950. if (!scene) {
  951. return;
  952. }
  953. this._rootElement = null;
  954. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  955. if (this._resizeObserver) {
  956. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  957. }
  958. if (this._pointerMoveObserver) {
  959. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  960. }
  961. if (this._pointerObserver) {
  962. scene.onPointerObservable.remove(this._pointerObserver);
  963. }
  964. if (this._preKeyboardObserver) {
  965. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  966. }
  967. if (this._canvasPointerOutObserver) {
  968. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  969. }
  970. if (this._canvasBlurObserver) {
  971. scene.getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver);
  972. }
  973. if (this._layerToDispose) {
  974. this._layerToDispose.texture = null;
  975. this._layerToDispose.dispose();
  976. this._layerToDispose = null;
  977. }
  978. this._rootContainer.dispose();
  979. this.onClipboardObservable.clear();
  980. this.onControlPickedObservable.clear();
  981. this.onBeginRenderObservable.clear();
  982. this.onEndRenderObservable.clear();
  983. this.onBeginLayoutObservable.clear();
  984. this.onEndLayoutObservable.clear();
  985. _super.prototype.dispose.call(this);
  986. };
  987. AdvancedDynamicTexture.prototype._onResize = function () {
  988. var scene = this.getScene();
  989. if (!scene) {
  990. return;
  991. }
  992. // Check size
  993. var engine = scene.getEngine();
  994. var textureSize = this.getSize();
  995. var renderWidth = engine.getRenderWidth() * this._renderScale;
  996. var renderHeight = engine.getRenderHeight() * this._renderScale;
  997. if (this._renderAtIdealSize) {
  998. if (this._idealWidth) {
  999. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  1000. renderWidth = this._idealWidth;
  1001. }
  1002. else if (this._idealHeight) {
  1003. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1004. renderHeight = this._idealHeight;
  1005. }
  1006. }
  1007. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1008. this.scaleTo(renderWidth, renderHeight);
  1009. this.markAsDirty();
  1010. if (this._idealWidth || this._idealHeight) {
  1011. this._rootContainer._markAllAsDirty();
  1012. }
  1013. }
  1014. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1015. };
  1016. /** @hidden */
  1017. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1018. var engine = scene.getEngine();
  1019. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1020. };
  1021. /**
  1022. * Get screen coordinates for a vector3
  1023. * @param position defines the position to project
  1024. * @param worldMatrix defines the world matrix to use
  1025. * @returns the projected position
  1026. */
  1027. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1028. var scene = this.getScene();
  1029. if (!scene) {
  1030. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1031. }
  1032. var globalViewport = this._getGlobalViewport(scene);
  1033. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1034. projectedPosition.scaleInPlace(this.renderScale);
  1035. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1036. };
  1037. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1038. if (this._layerToDispose) {
  1039. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1040. return;
  1041. }
  1042. }
  1043. if (this._isFullscreen && this._linkedControls.length) {
  1044. var scene = this.getScene();
  1045. if (!scene) {
  1046. return;
  1047. }
  1048. var globalViewport = this._getGlobalViewport(scene);
  1049. var _loop_1 = function (control) {
  1050. if (!control.isVisible) {
  1051. return "continue";
  1052. }
  1053. var mesh = control._linkedMesh;
  1054. if (!mesh || mesh.isDisposed()) {
  1055. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1056. control.linkWithMesh(null);
  1057. });
  1058. return "continue";
  1059. }
  1060. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1061. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1062. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1063. control.notRenderable = true;
  1064. return "continue";
  1065. }
  1066. control.notRenderable = false;
  1067. // Account for RenderScale.
  1068. projectedPosition.scaleInPlace(this_1.renderScale);
  1069. control._moveToProjectedPosition(projectedPosition);
  1070. };
  1071. var this_1 = this;
  1072. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1073. var control = _a[_i];
  1074. _loop_1(control);
  1075. }
  1076. }
  1077. if (!this._isDirty && !this._rootContainer.isDirty) {
  1078. return;
  1079. }
  1080. this._isDirty = false;
  1081. this._render();
  1082. this.update(true, this.premulAlpha);
  1083. };
  1084. AdvancedDynamicTexture.prototype._render = function () {
  1085. var textureSize = this.getSize();
  1086. var renderWidth = textureSize.width;
  1087. var renderHeight = textureSize.height;
  1088. var context = this.getContext();
  1089. context.font = "18px Arial";
  1090. context.strokeStyle = "white";
  1091. // Layout
  1092. this.onBeginLayoutObservable.notifyObservers(this);
  1093. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1094. this._numLayoutCalls = 0;
  1095. this._rootContainer._layout(measure, context);
  1096. this.onEndLayoutObservable.notifyObservers(this);
  1097. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1098. // Clear
  1099. if (this._invalidatedRectangle) {
  1100. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1101. }
  1102. else {
  1103. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1104. }
  1105. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1106. if (this._background) {
  1107. context.save();
  1108. context.fillStyle = this._background;
  1109. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1110. context.restore();
  1111. }
  1112. // Render
  1113. this.onBeginRenderObservable.notifyObservers(this);
  1114. this._numRenderCalls = 0;
  1115. this._rootContainer._render(context, this._invalidatedRectangle);
  1116. this.onEndRenderObservable.notifyObservers(this);
  1117. this._invalidatedRectangle = null;
  1118. };
  1119. /** @hidden */
  1120. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1121. if (this._rootElement) {
  1122. this._rootElement.style.cursor = cursor;
  1123. this._cursorChanged = true;
  1124. }
  1125. };
  1126. /** @hidden */
  1127. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1128. this._lastControlDown[pointerId] = control;
  1129. this.onControlPickedObservable.notifyObservers(control);
  1130. };
  1131. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1132. var scene = this.getScene();
  1133. if (!scene) {
  1134. return;
  1135. }
  1136. var engine = scene.getEngine();
  1137. var textureSize = this.getSize();
  1138. if (this._isFullscreen) {
  1139. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1140. var viewport = camera.viewport;
  1141. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1142. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1143. }
  1144. if (this._capturingControl[pointerId]) {
  1145. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1146. return;
  1147. }
  1148. this._cursorChanged = false;
  1149. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  1150. this._changeCursor("");
  1151. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1152. if (this._lastControlOver[pointerId]) {
  1153. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1154. delete this._lastControlOver[pointerId];
  1155. }
  1156. }
  1157. }
  1158. if (!this._cursorChanged) {
  1159. this._changeCursor("");
  1160. }
  1161. this._manageFocus();
  1162. };
  1163. /** @hidden */
  1164. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1165. for (var pointerId in list) {
  1166. if (!list.hasOwnProperty(pointerId)) {
  1167. continue;
  1168. }
  1169. var lastControlOver = list[pointerId];
  1170. if (lastControlOver === control) {
  1171. delete list[pointerId];
  1172. }
  1173. }
  1174. };
  1175. /** @hidden */
  1176. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1177. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1178. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1179. };
  1180. /** Attach to all scene events required to support pointer events */
  1181. AdvancedDynamicTexture.prototype.attach = function () {
  1182. var _this = this;
  1183. var scene = this.getScene();
  1184. if (!scene) {
  1185. return;
  1186. }
  1187. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1188. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1189. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1190. return;
  1191. }
  1192. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1193. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1194. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN
  1195. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  1196. return;
  1197. }
  1198. if (!scene) {
  1199. return;
  1200. }
  1201. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE && pi.event.pointerId) {
  1202. _this._defaultMousePointerId = pi.event.pointerId; // This is required to make sure we have the correct pointer ID for wheel
  1203. }
  1204. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1205. var engine = scene.getEngine();
  1206. if (!camera) {
  1207. tempViewport.x = 0;
  1208. tempViewport.y = 0;
  1209. tempViewport.width = engine.getRenderWidth();
  1210. tempViewport.height = engine.getRenderHeight();
  1211. }
  1212. else {
  1213. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1214. }
  1215. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1216. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1217. _this._shouldBlockPointer = false;
  1218. // Do picking modifies _shouldBlockPointer
  1219. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1220. _this._doPicking(x, y, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
  1221. // Avoid overwriting a true skipOnPointerObservable to false
  1222. if (_this._shouldBlockPointer) {
  1223. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1224. }
  1225. });
  1226. this._attachToOnPointerOut(scene);
  1227. this._attachToOnBlur(scene);
  1228. };
  1229. /**
  1230. * Register the clipboard Events onto the canvas
  1231. */
  1232. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1233. self.addEventListener("copy", this.onClipboardCopy, false);
  1234. self.addEventListener("cut", this.onClipboardCut, false);
  1235. self.addEventListener("paste", this.onClipboardPaste, false);
  1236. };
  1237. /**
  1238. * Unregister the clipboard Events from the canvas
  1239. */
  1240. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1241. self.removeEventListener("copy", this.onClipboardCopy);
  1242. self.removeEventListener("cut", this.onClipboardCut);
  1243. self.removeEventListener("paste", this.onClipboardPaste);
  1244. };
  1245. /**
  1246. * Connect the texture to a hosting mesh to enable interactions
  1247. * @param mesh defines the mesh to attach to
  1248. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1249. */
  1250. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1251. var _this = this;
  1252. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1253. var scene = this.getScene();
  1254. if (!scene) {
  1255. return;
  1256. }
  1257. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1258. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1259. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1260. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1261. return;
  1262. }
  1263. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1264. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1265. var uv = pi.pickInfo.getTextureCoordinates();
  1266. if (uv) {
  1267. var size = _this.getSize();
  1268. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1269. }
  1270. }
  1271. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1272. if (_this._lastControlDown[pointerId]) {
  1273. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1274. }
  1275. delete _this._lastControlDown[pointerId];
  1276. if (_this.focusedControl) {
  1277. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1278. var canMoveFocus = true;
  1279. if (friendlyControls) {
  1280. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1281. var control = friendlyControls_1[_i];
  1282. // Same host, no need to keep the focus
  1283. if (_this === control._host) {
  1284. continue;
  1285. }
  1286. // Different hosts
  1287. var otherHost = control._host;
  1288. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1289. canMoveFocus = false;
  1290. break;
  1291. }
  1292. }
  1293. }
  1294. if (canMoveFocus) {
  1295. _this.focusedControl = null;
  1296. }
  1297. }
  1298. }
  1299. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1300. if (_this._lastControlOver[pointerId]) {
  1301. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1302. }
  1303. delete _this._lastControlOver[pointerId];
  1304. }
  1305. });
  1306. mesh.enablePointerMoveEvents = supportPointerMove;
  1307. this._attachToOnPointerOut(scene);
  1308. this._attachToOnBlur(scene);
  1309. };
  1310. /**
  1311. * Move the focus to a specific control
  1312. * @param control defines the control which will receive the focus
  1313. */
  1314. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1315. this.focusedControl = control;
  1316. this._lastPickedControl = control;
  1317. this._blockNextFocusCheck = true;
  1318. };
  1319. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1320. if (this._blockNextFocusCheck) {
  1321. this._blockNextFocusCheck = false;
  1322. this._lastPickedControl = this._focusedControl;
  1323. return;
  1324. }
  1325. // Focus management
  1326. if (this._focusedControl) {
  1327. if (this._focusedControl !== this._lastPickedControl) {
  1328. if (this._lastPickedControl.isFocusInvisible) {
  1329. return;
  1330. }
  1331. this.focusedControl = null;
  1332. }
  1333. }
  1334. };
  1335. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1336. var _this = this;
  1337. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1338. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1339. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1340. }
  1341. delete _this._lastControlOver[pointerEvent.pointerId];
  1342. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1343. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1344. delete _this._lastControlDown[pointerEvent.pointerId];
  1345. }
  1346. });
  1347. };
  1348. AdvancedDynamicTexture.prototype._attachToOnBlur = function (scene) {
  1349. var _this = this;
  1350. this._canvasBlurObserver = scene.getEngine().onCanvasBlurObservable.add(function (pointerEvent) {
  1351. Object.entries(_this._lastControlDown).forEach(function (_a) {
  1352. var key = _a[0], value = _a[1];
  1353. value._onCanvasBlur();
  1354. });
  1355. _this._lastControlDown = {};
  1356. });
  1357. };
  1358. // Statics
  1359. /**
  1360. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1361. * @param mesh defines the mesh which will receive the texture
  1362. * @param width defines the texture width (1024 by default)
  1363. * @param height defines the texture height (1024 by default)
  1364. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1365. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1366. * @returns a new AdvancedDynamicTexture
  1367. */
  1368. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1369. if (width === void 0) { width = 1024; }
  1370. if (height === void 0) { height = 1024; }
  1371. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1372. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1373. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1374. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1375. material.backFaceCulling = false;
  1376. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1377. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1378. if (onlyAlphaTesting) {
  1379. material.diffuseTexture = result;
  1380. material.emissiveTexture = result;
  1381. result.hasAlpha = true;
  1382. }
  1383. else {
  1384. material.emissiveTexture = result;
  1385. material.opacityTexture = result;
  1386. }
  1387. mesh.material = material;
  1388. result.attachToMesh(mesh, supportPointerMove);
  1389. return result;
  1390. };
  1391. /**
  1392. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1393. * In this mode the texture will rely on a layer for its rendering.
  1394. * This allows it to be treated like any other layer.
  1395. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1396. * LayerMask is set through advancedTexture.layer.layerMask
  1397. * @param name defines name for the texture
  1398. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1399. * @param scene defines the hsoting scene
  1400. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1401. * @returns a new AdvancedDynamicTexture
  1402. */
  1403. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1404. if (foreground === void 0) { foreground = true; }
  1405. if (scene === void 0) { scene = null; }
  1406. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1407. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1408. // Display
  1409. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1410. layer.texture = result;
  1411. result._layerToDispose = layer;
  1412. result._isFullscreen = true;
  1413. // Attach
  1414. result.attach();
  1415. return result;
  1416. };
  1417. return AdvancedDynamicTexture;
  1418. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1419. /***/ }),
  1420. /***/ "./2D/controls/button.ts":
  1421. /*!*******************************!*\
  1422. !*** ./2D/controls/button.ts ***!
  1423. \*******************************/
  1424. /*! exports provided: Button */
  1425. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1426. "use strict";
  1427. __webpack_require__.r(__webpack_exports__);
  1428. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1429. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1430. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1431. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1432. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1433. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1434. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  1435. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1436. /**
  1437. * Class used to create 2D buttons
  1438. */
  1439. var Button = /** @class */ (function (_super) {
  1440. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1441. /**
  1442. * Creates a new Button
  1443. * @param name defines the name of the button
  1444. */
  1445. function Button(name) {
  1446. var _this = _super.call(this, name) || this;
  1447. _this.name = name;
  1448. /**
  1449. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1450. */
  1451. _this.delegatePickingToChildren = false;
  1452. _this.thickness = 1;
  1453. _this.isPointerBlocker = true;
  1454. var alphaStore = null;
  1455. _this.pointerEnterAnimation = function () {
  1456. alphaStore = _this.alpha;
  1457. _this.alpha -= 0.1;
  1458. };
  1459. _this.pointerOutAnimation = function () {
  1460. if (alphaStore !== null) {
  1461. _this.alpha = alphaStore;
  1462. }
  1463. };
  1464. _this.pointerDownAnimation = function () {
  1465. _this.scaleX -= 0.05;
  1466. _this.scaleY -= 0.05;
  1467. };
  1468. _this.pointerUpAnimation = function () {
  1469. _this.scaleX += 0.05;
  1470. _this.scaleY += 0.05;
  1471. };
  1472. return _this;
  1473. }
  1474. Object.defineProperty(Button.prototype, "image", {
  1475. /**
  1476. * Returns the image part of the button (if any)
  1477. */
  1478. get: function () {
  1479. return this._image;
  1480. },
  1481. enumerable: false,
  1482. configurable: true
  1483. });
  1484. Object.defineProperty(Button.prototype, "textBlock", {
  1485. /**
  1486. * Returns the image part of the button (if any)
  1487. */
  1488. get: function () {
  1489. return this._textBlock;
  1490. },
  1491. enumerable: false,
  1492. configurable: true
  1493. });
  1494. Button.prototype._getTypeName = function () {
  1495. return "Button";
  1496. };
  1497. // While being a container, the button behaves like a control.
  1498. /** @hidden */
  1499. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  1500. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1501. return false;
  1502. }
  1503. if (!_super.prototype.contains.call(this, x, y)) {
  1504. return false;
  1505. }
  1506. if (this.delegatePickingToChildren) {
  1507. var contains = false;
  1508. for (var index = this._children.length - 1; index >= 0; index--) {
  1509. var child = this._children[index];
  1510. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1511. contains = true;
  1512. break;
  1513. }
  1514. }
  1515. if (!contains) {
  1516. return false;
  1517. }
  1518. }
  1519. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  1520. return true;
  1521. };
  1522. /** @hidden */
  1523. Button.prototype._onPointerEnter = function (target) {
  1524. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1525. return false;
  1526. }
  1527. if (this.pointerEnterAnimation) {
  1528. this.pointerEnterAnimation();
  1529. }
  1530. return true;
  1531. };
  1532. /** @hidden */
  1533. Button.prototype._onPointerOut = function (target, force) {
  1534. if (force === void 0) { force = false; }
  1535. if (this.pointerOutAnimation) {
  1536. this.pointerOutAnimation();
  1537. }
  1538. _super.prototype._onPointerOut.call(this, target, force);
  1539. };
  1540. /** @hidden */
  1541. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1542. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1543. return false;
  1544. }
  1545. if (this.pointerDownAnimation) {
  1546. this.pointerDownAnimation();
  1547. }
  1548. return true;
  1549. };
  1550. /** @hidden */
  1551. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1552. if (this.pointerUpAnimation) {
  1553. this.pointerUpAnimation();
  1554. }
  1555. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1556. };
  1557. // Statics
  1558. /**
  1559. * Creates a new button made with an image and a text
  1560. * @param name defines the name of the button
  1561. * @param text defines the text of the button
  1562. * @param imageUrl defines the url of the image
  1563. * @returns a new Button
  1564. */
  1565. Button.CreateImageButton = function (name, text, imageUrl) {
  1566. var result = new Button(name);
  1567. // Adding text
  1568. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1569. textBlock.textWrapping = true;
  1570. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1571. textBlock.paddingLeft = "20%";
  1572. result.addControl(textBlock);
  1573. // Adding image
  1574. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1575. iconImage.width = "20%";
  1576. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1577. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1578. result.addControl(iconImage);
  1579. // Store
  1580. result._image = iconImage;
  1581. result._textBlock = textBlock;
  1582. return result;
  1583. };
  1584. /**
  1585. * Creates a new button made with an image
  1586. * @param name defines the name of the button
  1587. * @param imageUrl defines the url of the image
  1588. * @returns a new Button
  1589. */
  1590. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1591. var result = new Button(name);
  1592. // Adding image
  1593. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1594. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1595. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1596. result.addControl(iconImage);
  1597. // Store
  1598. result._image = iconImage;
  1599. return result;
  1600. };
  1601. /**
  1602. * Creates a new button made with a text
  1603. * @param name defines the name of the button
  1604. * @param text defines the text of the button
  1605. * @returns a new Button
  1606. */
  1607. Button.CreateSimpleButton = function (name, text) {
  1608. var result = new Button(name);
  1609. // Adding text
  1610. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1611. textBlock.textWrapping = true;
  1612. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1613. result.addControl(textBlock);
  1614. // Store
  1615. result._textBlock = textBlock;
  1616. return result;
  1617. };
  1618. /**
  1619. * Creates a new button made with an image and a centered text
  1620. * @param name defines the name of the button
  1621. * @param text defines the text of the button
  1622. * @param imageUrl defines the url of the image
  1623. * @returns a new Button
  1624. */
  1625. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1626. var result = new Button(name);
  1627. // Adding image
  1628. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1629. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1630. result.addControl(iconImage);
  1631. // Adding text
  1632. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1633. textBlock.textWrapping = true;
  1634. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1635. result.addControl(textBlock);
  1636. // Store
  1637. result._image = iconImage;
  1638. result._textBlock = textBlock;
  1639. return result;
  1640. };
  1641. return Button;
  1642. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1643. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1644. /***/ }),
  1645. /***/ "./2D/controls/checkbox.ts":
  1646. /*!*********************************!*\
  1647. !*** ./2D/controls/checkbox.ts ***!
  1648. \*********************************/
  1649. /*! exports provided: Checkbox */
  1650. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1651. "use strict";
  1652. __webpack_require__.r(__webpack_exports__);
  1653. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1654. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1655. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1656. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1657. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1658. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1659. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1660. /**
  1661. * Class used to represent a 2D checkbox
  1662. */
  1663. var Checkbox = /** @class */ (function (_super) {
  1664. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1665. /**
  1666. * Creates a new CheckBox
  1667. * @param name defines the control name
  1668. */
  1669. function Checkbox(name) {
  1670. var _this = _super.call(this, name) || this;
  1671. _this.name = name;
  1672. _this._isChecked = false;
  1673. _this._background = "black";
  1674. _this._checkSizeRatio = 0.8;
  1675. _this._thickness = 1;
  1676. /**
  1677. * Observable raised when isChecked property changes
  1678. */
  1679. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1680. _this.isPointerBlocker = true;
  1681. return _this;
  1682. }
  1683. Object.defineProperty(Checkbox.prototype, "thickness", {
  1684. /** Gets or sets border thickness */
  1685. get: function () {
  1686. return this._thickness;
  1687. },
  1688. set: function (value) {
  1689. if (this._thickness === value) {
  1690. return;
  1691. }
  1692. this._thickness = value;
  1693. this._markAsDirty();
  1694. },
  1695. enumerable: false,
  1696. configurable: true
  1697. });
  1698. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1699. /** Gets or sets a value indicating the ratio between overall size and check size */
  1700. get: function () {
  1701. return this._checkSizeRatio;
  1702. },
  1703. set: function (value) {
  1704. value = Math.max(Math.min(1, value), 0);
  1705. if (this._checkSizeRatio === value) {
  1706. return;
  1707. }
  1708. this._checkSizeRatio = value;
  1709. this._markAsDirty();
  1710. },
  1711. enumerable: false,
  1712. configurable: true
  1713. });
  1714. Object.defineProperty(Checkbox.prototype, "background", {
  1715. /** Gets or sets background color */
  1716. get: function () {
  1717. return this._background;
  1718. },
  1719. set: function (value) {
  1720. if (this._background === value) {
  1721. return;
  1722. }
  1723. this._background = value;
  1724. this._markAsDirty();
  1725. },
  1726. enumerable: false,
  1727. configurable: true
  1728. });
  1729. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1730. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1731. get: function () {
  1732. return this._isChecked;
  1733. },
  1734. set: function (value) {
  1735. if (this._isChecked === value) {
  1736. return;
  1737. }
  1738. this._isChecked = value;
  1739. this._markAsDirty();
  1740. this.onIsCheckedChangedObservable.notifyObservers(value);
  1741. },
  1742. enumerable: false,
  1743. configurable: true
  1744. });
  1745. Checkbox.prototype._getTypeName = function () {
  1746. return "Checkbox";
  1747. };
  1748. /** @hidden */
  1749. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1750. context.save();
  1751. this._applyStates(context);
  1752. var actualWidth = this._currentMeasure.width - this._thickness;
  1753. var actualHeight = this._currentMeasure.height - this._thickness;
  1754. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1755. context.shadowColor = this.shadowColor;
  1756. context.shadowBlur = this.shadowBlur;
  1757. context.shadowOffsetX = this.shadowOffsetX;
  1758. context.shadowOffsetY = this.shadowOffsetY;
  1759. }
  1760. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1761. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1762. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1763. context.shadowBlur = 0;
  1764. context.shadowOffsetX = 0;
  1765. context.shadowOffsetY = 0;
  1766. }
  1767. if (this._isChecked) {
  1768. context.fillStyle = this._isEnabled ? this.color : this._disabledColorItem;
  1769. var offsetWidth = actualWidth * this._checkSizeRatio;
  1770. var offseHeight = actualHeight * this._checkSizeRatio;
  1771. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1772. }
  1773. context.strokeStyle = this.color;
  1774. context.lineWidth = this._thickness;
  1775. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1776. context.restore();
  1777. };
  1778. // Events
  1779. /** @hidden */
  1780. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1781. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1782. return false;
  1783. }
  1784. this.isChecked = !this.isChecked;
  1785. return true;
  1786. };
  1787. /**
  1788. * Utility function to easily create a checkbox with a header
  1789. * @param title defines the label to use for the header
  1790. * @param onValueChanged defines the callback to call when value changes
  1791. * @returns a StackPanel containing the checkbox and a textBlock
  1792. */
  1793. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1794. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1795. panel.isVertical = false;
  1796. panel.height = "30px";
  1797. var checkbox = new Checkbox();
  1798. checkbox.width = "20px";
  1799. checkbox.height = "20px";
  1800. checkbox.isChecked = true;
  1801. checkbox.color = "green";
  1802. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1803. panel.addControl(checkbox);
  1804. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1805. header.text = title;
  1806. header.width = "180px";
  1807. header.paddingLeft = "5px";
  1808. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1809. header.color = "white";
  1810. panel.addControl(header);
  1811. return panel;
  1812. };
  1813. return Checkbox;
  1814. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1815. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1816. /***/ }),
  1817. /***/ "./2D/controls/colorpicker.ts":
  1818. /*!************************************!*\
  1819. !*** ./2D/controls/colorpicker.ts ***!
  1820. \************************************/
  1821. /*! exports provided: ColorPicker */
  1822. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1823. "use strict";
  1824. __webpack_require__.r(__webpack_exports__);
  1825. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1826. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1827. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1828. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1829. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1830. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1831. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1832. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1833. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1834. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1835. /** Class used to create color pickers */
  1836. var ColorPicker = /** @class */ (function (_super) {
  1837. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1838. /**
  1839. * Creates a new ColorPicker
  1840. * @param name defines the control name
  1841. */
  1842. function ColorPicker(name) {
  1843. var _this = _super.call(this, name) || this;
  1844. _this.name = name;
  1845. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1846. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1847. _this._pointerStartedOnSquare = false;
  1848. _this._pointerStartedOnWheel = false;
  1849. _this._squareLeft = 0;
  1850. _this._squareTop = 0;
  1851. _this._squareSize = 0;
  1852. _this._h = 360;
  1853. _this._s = 1;
  1854. _this._v = 1;
  1855. _this._lastPointerDownID = -1;
  1856. /**
  1857. * Observable raised when the value changes
  1858. */
  1859. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1860. // Events
  1861. _this._pointerIsDown = false;
  1862. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1863. _this.size = "200px";
  1864. _this.isPointerBlocker = true;
  1865. return _this;
  1866. }
  1867. Object.defineProperty(ColorPicker.prototype, "value", {
  1868. /** Gets or sets the color of the color picker */
  1869. get: function () {
  1870. return this._value;
  1871. },
  1872. set: function (value) {
  1873. if (this._value.equals(value)) {
  1874. return;
  1875. }
  1876. this._value.copyFrom(value);
  1877. this._value.toHSVToRef(this._tmpColor);
  1878. this._h = this._tmpColor.r;
  1879. this._s = Math.max(this._tmpColor.g, 0.00001);
  1880. this._v = Math.max(this._tmpColor.b, 0.00001);
  1881. this._markAsDirty();
  1882. if (this._value.r <= ColorPicker._Epsilon) {
  1883. this._value.r = 0;
  1884. }
  1885. if (this._value.g <= ColorPicker._Epsilon) {
  1886. this._value.g = 0;
  1887. }
  1888. if (this._value.b <= ColorPicker._Epsilon) {
  1889. this._value.b = 0;
  1890. }
  1891. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1892. this._value.r = 1.0;
  1893. }
  1894. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1895. this._value.g = 1.0;
  1896. }
  1897. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1898. this._value.b = 1.0;
  1899. }
  1900. this.onValueChangedObservable.notifyObservers(this._value);
  1901. },
  1902. enumerable: false,
  1903. configurable: true
  1904. });
  1905. Object.defineProperty(ColorPicker.prototype, "width", {
  1906. /**
  1907. * Gets or sets control width
  1908. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1909. */
  1910. get: function () {
  1911. return this._width.toString(this._host);
  1912. },
  1913. set: function (value) {
  1914. if (this._width.toString(this._host) === value) {
  1915. return;
  1916. }
  1917. if (this._width.fromString(value)) {
  1918. this._height.fromString(value);
  1919. this._markAsDirty();
  1920. }
  1921. },
  1922. enumerable: false,
  1923. configurable: true
  1924. });
  1925. Object.defineProperty(ColorPicker.prototype, "height", {
  1926. /**
  1927. * Gets or sets control height
  1928. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1929. */
  1930. get: function () {
  1931. return this._height.toString(this._host);
  1932. },
  1933. /** Gets or sets control height */
  1934. set: function (value) {
  1935. if (this._height.toString(this._host) === value) {
  1936. return;
  1937. }
  1938. if (this._height.fromString(value)) {
  1939. this._width.fromString(value);
  1940. this._markAsDirty();
  1941. }
  1942. },
  1943. enumerable: false,
  1944. configurable: true
  1945. });
  1946. Object.defineProperty(ColorPicker.prototype, "size", {
  1947. /** Gets or sets control size */
  1948. get: function () {
  1949. return this.width;
  1950. },
  1951. set: function (value) {
  1952. this.width = value;
  1953. },
  1954. enumerable: false,
  1955. configurable: true
  1956. });
  1957. ColorPicker.prototype._getTypeName = function () {
  1958. return "ColorPicker";
  1959. };
  1960. /** @hidden */
  1961. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1962. if (parentMeasure.width < parentMeasure.height) {
  1963. this._currentMeasure.height = parentMeasure.width;
  1964. }
  1965. else {
  1966. this._currentMeasure.width = parentMeasure.height;
  1967. }
  1968. };
  1969. ColorPicker.prototype._updateSquareProps = function () {
  1970. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1971. var wheelThickness = radius * .2;
  1972. var innerDiameter = (radius - wheelThickness) * 2;
  1973. var squareSize = innerDiameter / (Math.sqrt(2));
  1974. var offset = radius - squareSize * .5;
  1975. this._squareLeft = this._currentMeasure.left + offset;
  1976. this._squareTop = this._currentMeasure.top + offset;
  1977. this._squareSize = squareSize;
  1978. };
  1979. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1980. var lgh = context.createLinearGradient(left, top, width + left, top);
  1981. lgh.addColorStop(0, '#fff');
  1982. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1983. context.fillStyle = lgh;
  1984. context.fillRect(left, top, width, height);
  1985. var lgv = context.createLinearGradient(left, top, left, height + top);
  1986. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1987. lgv.addColorStop(1, '#000');
  1988. context.fillStyle = lgv;
  1989. context.fillRect(left, top, width, height);
  1990. };
  1991. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1992. context.beginPath();
  1993. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1994. context.lineWidth = 3;
  1995. context.strokeStyle = '#333333';
  1996. context.stroke();
  1997. context.beginPath();
  1998. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1999. context.lineWidth = 3;
  2000. context.strokeStyle = '#ffffff';
  2001. context.stroke();
  2002. };
  2003. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  2004. var canvas = document.createElement("canvas");
  2005. canvas.width = radius * 2;
  2006. canvas.height = radius * 2;
  2007. var context = canvas.getContext("2d");
  2008. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  2009. var data = image.data;
  2010. var color = this._tmpColor;
  2011. var maxDistSq = radius * radius;
  2012. var innerRadius = radius - thickness;
  2013. var minDistSq = innerRadius * innerRadius;
  2014. for (var x = -radius; x < radius; x++) {
  2015. for (var y = -radius; y < radius; y++) {
  2016. var distSq = x * x + y * y;
  2017. if (distSq > maxDistSq || distSq < minDistSq) {
  2018. continue;
  2019. }
  2020. var dist = Math.sqrt(distSq);
  2021. var ang = Math.atan2(y, x);
  2022. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  2023. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  2024. data[index] = color.r * 255;
  2025. data[index + 1] = color.g * 255;
  2026. data[index + 2] = color.b * 255;
  2027. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2028. //apply less alpha to bigger color pickers
  2029. var alphaAmount = .2;
  2030. var maxAlpha = .2;
  2031. var minAlpha = .04;
  2032. var lowerRadius = 50;
  2033. var upperRadius = 150;
  2034. if (radius < lowerRadius) {
  2035. alphaAmount = maxAlpha;
  2036. }
  2037. else if (radius > upperRadius) {
  2038. alphaAmount = minAlpha;
  2039. }
  2040. else {
  2041. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2042. }
  2043. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2044. if (alphaRatio < alphaAmount) {
  2045. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2046. }
  2047. else if (alphaRatio > 1 - alphaAmount) {
  2048. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2049. }
  2050. else {
  2051. data[index + 3] = 255;
  2052. }
  2053. }
  2054. }
  2055. context.putImageData(image, 0, 0);
  2056. return canvas;
  2057. };
  2058. /** @hidden */
  2059. ColorPicker.prototype._draw = function (context) {
  2060. context.save();
  2061. this._applyStates(context);
  2062. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2063. var wheelThickness = radius * .2;
  2064. var left = this._currentMeasure.left;
  2065. var top = this._currentMeasure.top;
  2066. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2067. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2068. }
  2069. this._updateSquareProps();
  2070. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2071. context.shadowColor = this.shadowColor;
  2072. context.shadowBlur = this.shadowBlur;
  2073. context.shadowOffsetX = this.shadowOffsetX;
  2074. context.shadowOffsetY = this.shadowOffsetY;
  2075. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2076. }
  2077. context.drawImage(this._colorWheelCanvas, left, top);
  2078. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2079. context.shadowBlur = 0;
  2080. context.shadowOffsetX = 0;
  2081. context.shadowOffsetY = 0;
  2082. }
  2083. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2084. var cx = this._squareLeft + this._squareSize * this._s;
  2085. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2086. this._drawCircle(cx, cy, radius * .04, context);
  2087. var dist = radius - wheelThickness * .5;
  2088. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2089. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2090. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2091. context.restore();
  2092. };
  2093. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2094. if (this._pointerStartedOnWheel) {
  2095. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2096. var centerX = radius + this._currentMeasure.left;
  2097. var centerY = radius + this._currentMeasure.top;
  2098. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2099. }
  2100. else if (this._pointerStartedOnSquare) {
  2101. this._updateSquareProps();
  2102. this._s = (x - this._squareLeft) / this._squareSize;
  2103. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2104. this._s = Math.min(this._s, 1);
  2105. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2106. this._v = Math.min(this._v, 1);
  2107. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2108. }
  2109. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2110. this.value = this._tmpColor;
  2111. };
  2112. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2113. this._updateSquareProps();
  2114. var left = this._squareLeft;
  2115. var top = this._squareTop;
  2116. var size = this._squareSize;
  2117. if (x >= left && x <= left + size &&
  2118. y >= top && y <= top + size) {
  2119. return true;
  2120. }
  2121. return false;
  2122. };
  2123. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2124. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2125. var centerX = radius + this._currentMeasure.left;
  2126. var centerY = radius + this._currentMeasure.top;
  2127. var wheelThickness = radius * .2;
  2128. var innerRadius = radius - wheelThickness;
  2129. var radiusSq = radius * radius;
  2130. var innerRadiusSq = innerRadius * innerRadius;
  2131. var dx = x - centerX;
  2132. var dy = y - centerY;
  2133. var distSq = dx * dx + dy * dy;
  2134. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2135. return true;
  2136. }
  2137. return false;
  2138. };
  2139. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2140. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2141. return false;
  2142. }
  2143. this._pointerIsDown = true;
  2144. this._pointerStartedOnSquare = false;
  2145. this._pointerStartedOnWheel = false;
  2146. // Invert transform
  2147. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2148. var x = this._transformedPosition.x;
  2149. var y = this._transformedPosition.y;
  2150. if (this._isPointOnSquare(x, y)) {
  2151. this._pointerStartedOnSquare = true;
  2152. }
  2153. else if (this._isPointOnWheel(x, y)) {
  2154. this._pointerStartedOnWheel = true;
  2155. }
  2156. this._updateValueFromPointer(x, y);
  2157. this._host._capturingControl[pointerId] = this;
  2158. this._lastPointerDownID = pointerId;
  2159. return true;
  2160. };
  2161. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2162. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2163. if (pointerId != this._lastPointerDownID) {
  2164. return;
  2165. }
  2166. // Invert transform
  2167. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2168. var x = this._transformedPosition.x;
  2169. var y = this._transformedPosition.y;
  2170. if (this._pointerIsDown) {
  2171. this._updateValueFromPointer(x, y);
  2172. }
  2173. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2174. };
  2175. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2176. this._pointerIsDown = false;
  2177. delete this._host._capturingControl[pointerId];
  2178. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2179. };
  2180. ColorPicker.prototype._onCanvasBlur = function () {
  2181. this._forcePointerUp();
  2182. _super.prototype._onCanvasBlur.call(this);
  2183. };
  2184. /**
  2185. * This function expands the color picker by creating a color picker dialog with manual
  2186. * color value input and the ability to save colors into an array to be used later in
  2187. * subsequent launches of the dialogue.
  2188. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2189. * @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.
  2190. * @returns picked color as a hex string and the saved colors array as hex strings.
  2191. */
  2192. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2193. return new Promise(function (resolve, reject) {
  2194. // Default options
  2195. options.pickerWidth = options.pickerWidth || "640px";
  2196. options.pickerHeight = options.pickerHeight || "400px";
  2197. options.headerHeight = options.headerHeight || "35px";
  2198. options.lastColor = options.lastColor || "#000000";
  2199. options.swatchLimit = options.swatchLimit || 20;
  2200. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2201. // Window size settings
  2202. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2203. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2204. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2205. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2206. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2207. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2208. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2209. // Button Colors
  2210. var buttonColor = "#c0c0c0";
  2211. var buttonBackgroundColor = "#535353";
  2212. var buttonBackgroundHoverColor = "#414141";
  2213. var buttonBackgroundClickColor = "515151";
  2214. var buttonDisabledColor = "#555555";
  2215. var buttonDisabledBackgroundColor = "#454545";
  2216. var currentSwatchesOutlineColor = "#404040";
  2217. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2218. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2219. var iconColorDark = "#aaaaaa";
  2220. var iconColorLight = "#ffffff";
  2221. var closeIconColor;
  2222. // Button settings
  2223. var buttonFontSize;
  2224. var butEdit;
  2225. var buttonWidth;
  2226. var buttonHeight;
  2227. // Input Text Colors
  2228. var inputFieldLabels = ["R", "G", "B"];
  2229. var inputTextBackgroundColor = "#454545";
  2230. var inputTextColor = "#f0f0f0";
  2231. // This is the current color as set by either the picker or by entering a value
  2232. var currentColor;
  2233. // This int is used for naming swatches and serves as the index for calling them from the list
  2234. var swatchNumber;
  2235. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2236. var swatchDrawer;
  2237. var editSwatchMode = false;
  2238. // Color InputText fields that will be updated upon value change
  2239. var picker;
  2240. var rValInt;
  2241. var gValInt;
  2242. var bValInt;
  2243. var rValDec;
  2244. var gValDec;
  2245. var bValDec;
  2246. var hexVal;
  2247. var newSwatch;
  2248. var lastVal;
  2249. var activeField;
  2250. /**
  2251. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2252. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2253. * are will receive no update. This is to prevent the input from the user being overwritten.
  2254. */
  2255. function updateValues(value, inputField) {
  2256. activeField = inputField;
  2257. var pickedColor = value.toHexString();
  2258. newSwatch.background = pickedColor;
  2259. if (rValInt.name != activeField) {
  2260. rValInt.text = Math.floor(value.r * 255).toString();
  2261. }
  2262. if (gValInt.name != activeField) {
  2263. gValInt.text = Math.floor(value.g * 255).toString();
  2264. }
  2265. if (bValInt.name != activeField) {
  2266. bValInt.text = Math.floor(value.b * 255).toString();
  2267. }
  2268. if (rValDec.name != activeField) {
  2269. rValDec.text = value.r.toString();
  2270. }
  2271. if (gValDec.name != activeField) {
  2272. gValDec.text = value.g.toString();
  2273. }
  2274. if (bValDec.name != activeField) {
  2275. bValDec.text = value.b.toString();
  2276. }
  2277. if (hexVal.name != activeField) {
  2278. var minusPound = pickedColor.split("#");
  2279. hexVal.text = minusPound[1];
  2280. }
  2281. if (picker.name != activeField) {
  2282. picker.value = value;
  2283. }
  2284. }
  2285. // 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.
  2286. function updateInt(field, channel) {
  2287. var newValue = field.text;
  2288. var checkVal = /[^0-9]/g.test(newValue);
  2289. if (checkVal) {
  2290. field.text = lastVal;
  2291. return;
  2292. }
  2293. else {
  2294. if (newValue != "") {
  2295. if (Math.floor(parseInt(newValue)) < 0) {
  2296. newValue = "0";
  2297. }
  2298. else if (Math.floor(parseInt(newValue)) > 255) {
  2299. newValue = "255";
  2300. }
  2301. else if (isNaN(parseInt(newValue))) {
  2302. newValue = "0";
  2303. }
  2304. }
  2305. if (activeField == field.name) {
  2306. lastVal = newValue;
  2307. }
  2308. }
  2309. if (newValue != "") {
  2310. newValue = parseInt(newValue).toString();
  2311. field.text = newValue;
  2312. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2313. if (activeField == field.name) {
  2314. if (channel == "r") {
  2315. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2316. }
  2317. else if (channel == "g") {
  2318. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2319. }
  2320. else {
  2321. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2322. }
  2323. }
  2324. }
  2325. }
  2326. // 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.
  2327. function updateFloat(field, channel) {
  2328. var newValue = field.text;
  2329. var checkVal = /[^0-9\.]/g.test(newValue);
  2330. if (checkVal) {
  2331. field.text = lastVal;
  2332. return;
  2333. }
  2334. else {
  2335. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2336. if (parseFloat(newValue) < 0.0) {
  2337. newValue = "0.0";
  2338. }
  2339. else if (parseFloat(newValue) > 1.0) {
  2340. newValue = "1.0";
  2341. }
  2342. else if (isNaN(parseFloat(newValue))) {
  2343. newValue = "0.0";
  2344. }
  2345. }
  2346. if (activeField == field.name) {
  2347. lastVal = newValue;
  2348. }
  2349. }
  2350. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2351. newValue = parseFloat(newValue).toString();
  2352. field.text = newValue;
  2353. }
  2354. else {
  2355. newValue = "0.0";
  2356. }
  2357. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2358. if (activeField == field.name) {
  2359. if (channel == "r") {
  2360. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2361. }
  2362. else if (channel == "g") {
  2363. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2364. }
  2365. else {
  2366. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2367. }
  2368. }
  2369. }
  2370. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2371. function deleteSwatch(index) {
  2372. if (options.savedColors) {
  2373. options.savedColors.splice(index, 1);
  2374. }
  2375. if (options.savedColors && options.savedColors.length == 0) {
  2376. setEditButtonVisibility(false);
  2377. editSwatchMode = false;
  2378. }
  2379. }
  2380. // Creates and styles an individual swatch when updateSwatches is called.
  2381. function createSwatch() {
  2382. if (options.savedColors && options.savedColors[swatchNumber]) {
  2383. if (editSwatchMode) {
  2384. var icon = "b";
  2385. }
  2386. else {
  2387. var icon = "";
  2388. }
  2389. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2390. swatch.fontFamily = "BabylonJSglyphs";
  2391. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2392. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2393. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2394. if (swatchLuminence > luminanceLimit) {
  2395. swatch.color = iconColorDark;
  2396. }
  2397. else {
  2398. swatch.color = iconColorLight;
  2399. }
  2400. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2401. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2402. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2403. swatch.background = options.savedColors[swatchNumber];
  2404. swatch.thickness = 2;
  2405. var metadata_1 = swatchNumber;
  2406. swatch.pointerDownAnimation = function () {
  2407. swatch.thickness = 4;
  2408. };
  2409. swatch.pointerUpAnimation = function () {
  2410. swatch.thickness = 3;
  2411. };
  2412. swatch.pointerEnterAnimation = function () {
  2413. swatch.thickness = 3;
  2414. };
  2415. swatch.pointerOutAnimation = function () {
  2416. swatch.thickness = 2;
  2417. };
  2418. swatch.onPointerClickObservable.add(function () {
  2419. if (!editSwatchMode) {
  2420. if (options.savedColors) {
  2421. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2422. }
  2423. }
  2424. else {
  2425. deleteSwatch(metadata_1);
  2426. updateSwatches("", butSave);
  2427. }
  2428. });
  2429. return swatch;
  2430. }
  2431. else {
  2432. return null;
  2433. }
  2434. }
  2435. // Mode switch to render button text and close symbols on swatch controls
  2436. function editSwatches(mode) {
  2437. if (mode !== undefined) {
  2438. editSwatchMode = mode;
  2439. }
  2440. if (editSwatchMode) {
  2441. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2442. var thisButton = swatchDrawer.children[i];
  2443. thisButton.textBlock.text = "b";
  2444. }
  2445. if (butEdit !== undefined) {
  2446. butEdit.textBlock.text = "Done";
  2447. }
  2448. }
  2449. else {
  2450. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2451. var thisButton = swatchDrawer.children[i];
  2452. thisButton.textBlock.text = "";
  2453. }
  2454. if (butEdit !== undefined) {
  2455. butEdit.textBlock.text = "Edit";
  2456. }
  2457. }
  2458. }
  2459. /**
  2460. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2461. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2462. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2463. * saved colors there are and how many can be stored per row.
  2464. */
  2465. function updateSwatches(color, button) {
  2466. if (options.savedColors) {
  2467. if (color != "") {
  2468. options.savedColors.push(color);
  2469. }
  2470. swatchNumber = 0;
  2471. swatchDrawer.clearControls();
  2472. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2473. if (rowCount == 0) {
  2474. var gutterCount = 0;
  2475. }
  2476. else {
  2477. var gutterCount = rowCount + 1;
  2478. }
  2479. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2480. var currentRows = swatchDrawer.rowCount;
  2481. for (var i = 0; i < currentRows; i++) {
  2482. swatchDrawer.removeRowDefinition(0);
  2483. }
  2484. for (var i = 0; i < rowCount + gutterCount; i++) {
  2485. if (i % 2) {
  2486. swatchDrawer.addRowDefinition(swatchSize, true);
  2487. }
  2488. else {
  2489. swatchDrawer.addRowDefinition(gutterSize, true);
  2490. }
  2491. }
  2492. }
  2493. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2494. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2495. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2496. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2497. var totalButtonsThisRow = options.numSwatchesPerLine;
  2498. }
  2499. else {
  2500. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2501. }
  2502. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2503. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2504. if (x > options.numSwatchesPerLine) {
  2505. continue;
  2506. }
  2507. var swatch = createSwatch();
  2508. if (swatch != null) {
  2509. swatchDrawer.addControl(swatch, y, w);
  2510. w += 2;
  2511. swatchNumber++;
  2512. }
  2513. else {
  2514. continue;
  2515. }
  2516. }
  2517. }
  2518. if (options.savedColors.length >= options.swatchLimit) {
  2519. disableButton(button, true);
  2520. }
  2521. else {
  2522. disableButton(button, false);
  2523. }
  2524. }
  2525. }
  2526. // Shows or hides edit swatches button depending on if there are saved swatches
  2527. function setEditButtonVisibility(enableButton) {
  2528. if (enableButton) {
  2529. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2530. butEdit.width = buttonWidth;
  2531. butEdit.height = buttonHeight;
  2532. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2533. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2534. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2535. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2536. butEdit.thickness = 2;
  2537. butEdit.color = buttonColor;
  2538. butEdit.fontSize = buttonFontSize;
  2539. butEdit.background = buttonBackgroundColor;
  2540. butEdit.onPointerEnterObservable.add(function () {
  2541. butEdit.background = buttonBackgroundHoverColor;
  2542. });
  2543. butEdit.onPointerOutObservable.add(function () {
  2544. butEdit.background = buttonBackgroundColor;
  2545. });
  2546. butEdit.pointerDownAnimation = function () {
  2547. butEdit.background = buttonBackgroundClickColor;
  2548. };
  2549. butEdit.pointerUpAnimation = function () {
  2550. butEdit.background = buttonBackgroundHoverColor;
  2551. };
  2552. butEdit.onPointerClickObservable.add(function () {
  2553. if (editSwatchMode) {
  2554. editSwatchMode = false;
  2555. }
  2556. else {
  2557. editSwatchMode = true;
  2558. }
  2559. editSwatches();
  2560. });
  2561. pickerGrid.addControl(butEdit, 1, 0);
  2562. }
  2563. else {
  2564. pickerGrid.removeControl(butEdit);
  2565. }
  2566. }
  2567. // Called when the user hits the limit of saved colors in the drawer.
  2568. function disableButton(button, disabled) {
  2569. if (disabled) {
  2570. button.color = buttonDisabledColor;
  2571. button.background = buttonDisabledBackgroundColor;
  2572. }
  2573. else {
  2574. button.color = buttonColor;
  2575. button.background = buttonBackgroundColor;
  2576. }
  2577. }
  2578. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2579. function closePicker(color) {
  2580. if (options.savedColors && options.savedColors.length > 0) {
  2581. resolve({
  2582. savedColors: options.savedColors,
  2583. pickedColor: color
  2584. });
  2585. }
  2586. else {
  2587. resolve({
  2588. pickedColor: color
  2589. });
  2590. }
  2591. advancedTexture.removeControl(dialogContainer);
  2592. }
  2593. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2594. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2595. dialogContainer.name = "Dialog Container";
  2596. dialogContainer.width = options.pickerWidth;
  2597. if (options.savedColors) {
  2598. dialogContainer.height = containerSize;
  2599. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2600. dialogContainer.addRowDefinition(topRow, false);
  2601. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2602. }
  2603. else {
  2604. dialogContainer.height = options.pickerHeight;
  2605. dialogContainer.addRowDefinition(1.0, false);
  2606. }
  2607. advancedTexture.addControl(dialogContainer);
  2608. // Swatch drawer which contains all saved color buttons
  2609. if (options.savedColors) {
  2610. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2611. swatchDrawer.name = "Swatch Drawer";
  2612. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2613. swatchDrawer.background = buttonBackgroundColor;
  2614. swatchDrawer.width = options.pickerWidth;
  2615. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2616. if (initialRows == 0) {
  2617. var gutterCount = 0;
  2618. }
  2619. else {
  2620. var gutterCount = initialRows + 1;
  2621. }
  2622. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2623. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2624. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2625. if (i % 2 != 0) {
  2626. swatchDrawer.addRowDefinition(swatchSize, true);
  2627. }
  2628. else {
  2629. swatchDrawer.addRowDefinition(gutterSize, true);
  2630. }
  2631. }
  2632. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2633. if (i % 2 != 0) {
  2634. swatchDrawer.addColumnDefinition(swatchSize, true);
  2635. }
  2636. else {
  2637. swatchDrawer.addColumnDefinition(gutterSize, true);
  2638. }
  2639. }
  2640. dialogContainer.addControl(swatchDrawer, 1, 0);
  2641. }
  2642. // Picker container
  2643. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2644. pickerPanel.name = "Picker Panel";
  2645. pickerPanel.height = options.pickerHeight;
  2646. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2647. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2648. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2649. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2650. dialogContainer.addControl(pickerPanel, 0, 0);
  2651. // Picker container header
  2652. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2653. header.name = "Dialogue Header Bar";
  2654. header.background = "#cccccc";
  2655. header.thickness = 0;
  2656. pickerPanel.addControl(header, 0, 0);
  2657. // Header close button
  2658. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2659. closeButton.fontFamily = "BabylonJSglyphs";
  2660. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2661. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2662. closeButton.color = closeIconColor.toHexString();
  2663. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2664. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2665. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2666. closeButton.height = closeButton.width = options.headerHeight;
  2667. closeButton.background = header.background;
  2668. closeButton.thickness = 0;
  2669. closeButton.pointerDownAnimation = function () {
  2670. };
  2671. closeButton.pointerUpAnimation = function () {
  2672. closeButton.background = header.background;
  2673. };
  2674. closeButton.pointerEnterAnimation = function () {
  2675. closeButton.color = header.background;
  2676. closeButton.background = "red";
  2677. };
  2678. closeButton.pointerOutAnimation = function () {
  2679. closeButton.color = closeIconColor.toHexString();
  2680. closeButton.background = header.background;
  2681. };
  2682. closeButton.onPointerClickObservable.add(function () {
  2683. closePicker(currentSwatch.background);
  2684. });
  2685. pickerPanel.addControl(closeButton, 0, 0);
  2686. // Dialog container body
  2687. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2688. dialogBody.name = "Dialogue Body";
  2689. dialogBody.background = buttonBackgroundColor;
  2690. var dialogBodyCols = [0.4375, 0.5625];
  2691. dialogBody.addRowDefinition(1.0, false);
  2692. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2693. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2694. pickerPanel.addControl(dialogBody, 1, 0);
  2695. // Picker grid
  2696. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2697. pickerGrid.name = "Picker Grid";
  2698. pickerGrid.addRowDefinition(0.85, false);
  2699. pickerGrid.addRowDefinition(0.15, false);
  2700. dialogBody.addControl(pickerGrid, 0, 0);
  2701. // Picker control
  2702. picker = new ColorPicker();
  2703. picker.name = "GUI Color Picker";
  2704. if (options.pickerHeight < options.pickerWidth) {
  2705. picker.width = 0.89;
  2706. }
  2707. else {
  2708. picker.height = 0.89;
  2709. }
  2710. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2711. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2712. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2713. picker.onPointerDownObservable.add(function () {
  2714. activeField = picker.name;
  2715. lastVal = "";
  2716. editSwatches(false);
  2717. });
  2718. picker.onValueChangedObservable.add(function (value) {
  2719. if (activeField == picker.name) {
  2720. updateValues(value, picker.name);
  2721. }
  2722. });
  2723. pickerGrid.addControl(picker, 0, 0);
  2724. // Picker body right quarant
  2725. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2726. pickerBodyRight.name = "Dialogue Right Half";
  2727. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2728. var pickerBodyRightRows = [0.514, 0.486];
  2729. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2730. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2731. dialogBody.addControl(pickerBodyRight, 1, 1);
  2732. // Picker container swatches and buttons
  2733. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2734. pickerSwatchesButtons.name = "Swatches and Buttons";
  2735. var pickerButtonsCol = [0.417, 0.583];
  2736. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2737. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2738. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2739. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2740. // Picker Swatches quadrant
  2741. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2742. pickerSwatches.name = "New and Current Swatches";
  2743. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2744. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2745. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2746. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2747. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2748. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2749. // Active swatches
  2750. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2751. activeSwatches.name = "Active Swatches";
  2752. activeSwatches.width = 0.67;
  2753. activeSwatches.addRowDefinition(0.5, false);
  2754. activeSwatches.addRowDefinition(0.5, false);
  2755. pickerSwatches.addControl(activeSwatches, 2, 0);
  2756. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2757. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2758. if (options.pickerWidth > options.pickerHeight) {
  2759. var labelTextSize = labelHeight;
  2760. }
  2761. else {
  2762. var labelTextSize = labelWidth;
  2763. }
  2764. // New color swatch and previous color button
  2765. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2766. newText.text = "new";
  2767. newText.name = "New Color Label";
  2768. newText.color = buttonColor;
  2769. newText.fontSize = labelTextSize;
  2770. pickerSwatches.addControl(newText, 1, 0);
  2771. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2772. newSwatch.name = "New Color Swatch";
  2773. newSwatch.background = options.lastColor;
  2774. newSwatch.thickness = 0;
  2775. activeSwatches.addControl(newSwatch, 0, 0);
  2776. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2777. currentSwatch.background = options.lastColor;
  2778. currentSwatch.thickness = 0;
  2779. currentSwatch.onPointerClickObservable.add(function () {
  2780. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2781. updateValues(revertColor, currentSwatch.name);
  2782. editSwatches(false);
  2783. });
  2784. currentSwatch.pointerDownAnimation = function () { };
  2785. currentSwatch.pointerUpAnimation = function () { };
  2786. currentSwatch.pointerEnterAnimation = function () { };
  2787. currentSwatch.pointerOutAnimation = function () { };
  2788. activeSwatches.addControl(currentSwatch, 1, 0);
  2789. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2790. swatchOutline.name = "Swatch Outline";
  2791. swatchOutline.width = 0.67;
  2792. swatchOutline.thickness = 2;
  2793. swatchOutline.color = currentSwatchesOutlineColor;
  2794. swatchOutline.isHitTestVisible = false;
  2795. pickerSwatches.addControl(swatchOutline, 2, 0);
  2796. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2797. currentText.name = "Current Color Label";
  2798. currentText.text = "current";
  2799. currentText.color = buttonColor;
  2800. currentText.fontSize = labelTextSize;
  2801. pickerSwatches.addControl(currentText, 3, 0);
  2802. // Buttons grid
  2803. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2804. buttonGrid.name = "Button Grid";
  2805. buttonGrid.height = 0.8;
  2806. var buttonGridRows = 1 / 3;
  2807. buttonGrid.addRowDefinition(buttonGridRows, false);
  2808. buttonGrid.addRowDefinition(buttonGridRows, false);
  2809. buttonGrid.addRowDefinition(buttonGridRows, false);
  2810. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2811. // Determine pixel width and height for all buttons from overall panel dimensions
  2812. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2813. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2814. // Determine button type size
  2815. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2816. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2817. }
  2818. else {
  2819. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2820. }
  2821. // Panel Buttons
  2822. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2823. butOK.width = buttonWidth;
  2824. butOK.height = buttonHeight;
  2825. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2826. butOK.thickness = 2;
  2827. butOK.color = buttonColor;
  2828. butOK.fontSize = buttonFontSize;
  2829. butOK.background = buttonBackgroundColor;
  2830. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2831. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2832. butOK.pointerDownAnimation = function () {
  2833. butOK.background = buttonBackgroundClickColor;
  2834. };
  2835. butOK.pointerUpAnimation = function () {
  2836. butOK.background = buttonBackgroundHoverColor;
  2837. };
  2838. butOK.onPointerClickObservable.add(function () {
  2839. editSwatches(false);
  2840. closePicker(newSwatch.background);
  2841. });
  2842. buttonGrid.addControl(butOK, 0, 0);
  2843. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2844. butCancel.width = buttonWidth;
  2845. butCancel.height = buttonHeight;
  2846. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2847. butCancel.thickness = 2;
  2848. butCancel.color = buttonColor;
  2849. butCancel.fontSize = buttonFontSize;
  2850. butCancel.background = buttonBackgroundColor;
  2851. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2852. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2853. butCancel.pointerDownAnimation = function () {
  2854. butCancel.background = buttonBackgroundClickColor;
  2855. };
  2856. butCancel.pointerUpAnimation = function () {
  2857. butCancel.background = buttonBackgroundHoverColor;
  2858. };
  2859. butCancel.onPointerClickObservable.add(function () {
  2860. editSwatches(false);
  2861. closePicker(currentSwatch.background);
  2862. });
  2863. buttonGrid.addControl(butCancel, 1, 0);
  2864. if (options.savedColors) {
  2865. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2866. butSave.width = buttonWidth;
  2867. butSave.height = buttonHeight;
  2868. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2869. butSave.thickness = 2;
  2870. butSave.fontSize = buttonFontSize;
  2871. if (options.savedColors.length < options.swatchLimit) {
  2872. butSave.color = buttonColor;
  2873. butSave.background = buttonBackgroundColor;
  2874. }
  2875. else {
  2876. disableButton(butSave, true);
  2877. }
  2878. butSave.onPointerEnterObservable.add(function () {
  2879. if (options.savedColors) {
  2880. if (options.savedColors.length < options.swatchLimit) {
  2881. butSave.background = buttonBackgroundHoverColor;
  2882. }
  2883. }
  2884. });
  2885. butSave.onPointerOutObservable.add(function () {
  2886. if (options.savedColors) {
  2887. if (options.savedColors.length < options.swatchLimit) {
  2888. butSave.background = buttonBackgroundColor;
  2889. }
  2890. }
  2891. });
  2892. butSave.pointerDownAnimation = function () {
  2893. if (options.savedColors) {
  2894. if (options.savedColors.length < options.swatchLimit) {
  2895. butSave.background = buttonBackgroundClickColor;
  2896. }
  2897. }
  2898. };
  2899. butSave.pointerUpAnimation = function () {
  2900. if (options.savedColors) {
  2901. if (options.savedColors.length < options.swatchLimit) {
  2902. butSave.background = buttonBackgroundHoverColor;
  2903. }
  2904. }
  2905. };
  2906. butSave.onPointerClickObservable.add(function () {
  2907. if (options.savedColors) {
  2908. if (options.savedColors.length == 0) {
  2909. setEditButtonVisibility(true);
  2910. }
  2911. if (options.savedColors.length < options.swatchLimit) {
  2912. updateSwatches(newSwatch.background, butSave);
  2913. }
  2914. editSwatches(false);
  2915. }
  2916. });
  2917. if (options.savedColors.length > 0) {
  2918. setEditButtonVisibility(true);
  2919. }
  2920. buttonGrid.addControl(butSave, 2, 0);
  2921. }
  2922. // Picker color values input
  2923. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2924. pickerColorValues.name = "Dialog Lower Right";
  2925. pickerColorValues.addRowDefinition(0.02, false);
  2926. pickerColorValues.addRowDefinition(0.63, false);
  2927. pickerColorValues.addRowDefinition(0.21, false);
  2928. pickerColorValues.addRowDefinition(0.14, false);
  2929. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2930. // RGB values text boxes
  2931. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2932. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2933. rgbValuesQuadrant.name = "RGB Values";
  2934. rgbValuesQuadrant.width = 0.82;
  2935. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2936. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2937. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2938. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2939. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2940. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2941. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2942. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2943. for (var i = 0; i < inputFieldLabels.length; i++) {
  2944. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2945. labelText.text = inputFieldLabels[i];
  2946. labelText.color = buttonColor;
  2947. labelText.fontSize = buttonFontSize;
  2948. rgbValuesQuadrant.addControl(labelText, i, 0);
  2949. }
  2950. // Input fields for RGB values
  2951. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2952. rValInt.width = 0.83;
  2953. rValInt.height = 0.72;
  2954. rValInt.name = "rIntField";
  2955. rValInt.fontSize = buttonFontSize;
  2956. rValInt.text = (currentColor.r * 255).toString();
  2957. rValInt.color = inputTextColor;
  2958. rValInt.background = inputTextBackgroundColor;
  2959. rValInt.onFocusObservable.add(function () {
  2960. activeField = rValInt.name;
  2961. lastVal = rValInt.text;
  2962. editSwatches(false);
  2963. });
  2964. rValInt.onBlurObservable.add(function () {
  2965. if (rValInt.text == "") {
  2966. rValInt.text = "0";
  2967. }
  2968. updateInt(rValInt, "r");
  2969. if (activeField == rValInt.name) {
  2970. activeField = "";
  2971. }
  2972. });
  2973. rValInt.onTextChangedObservable.add(function () {
  2974. if (activeField == rValInt.name) {
  2975. updateInt(rValInt, "r");
  2976. }
  2977. });
  2978. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2979. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2980. gValInt.width = 0.83;
  2981. gValInt.height = 0.72;
  2982. gValInt.name = "gIntField";
  2983. gValInt.fontSize = buttonFontSize;
  2984. gValInt.text = (currentColor.g * 255).toString();
  2985. gValInt.color = inputTextColor;
  2986. gValInt.background = inputTextBackgroundColor;
  2987. gValInt.onFocusObservable.add(function () {
  2988. activeField = gValInt.name;
  2989. lastVal = gValInt.text;
  2990. editSwatches(false);
  2991. });
  2992. gValInt.onBlurObservable.add(function () {
  2993. if (gValInt.text == "") {
  2994. gValInt.text = "0";
  2995. }
  2996. updateInt(gValInt, "g");
  2997. if (activeField == gValInt.name) {
  2998. activeField = "";
  2999. }
  3000. });
  3001. gValInt.onTextChangedObservable.add(function () {
  3002. if (activeField == gValInt.name) {
  3003. updateInt(gValInt, "g");
  3004. }
  3005. });
  3006. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  3007. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3008. bValInt.width = 0.83;
  3009. bValInt.height = 0.72;
  3010. bValInt.name = "bIntField";
  3011. bValInt.fontSize = buttonFontSize;
  3012. bValInt.text = (currentColor.b * 255).toString();
  3013. bValInt.color = inputTextColor;
  3014. bValInt.background = inputTextBackgroundColor;
  3015. bValInt.onFocusObservable.add(function () {
  3016. activeField = bValInt.name;
  3017. lastVal = bValInt.text;
  3018. editSwatches(false);
  3019. });
  3020. bValInt.onBlurObservable.add(function () {
  3021. if (bValInt.text == "") {
  3022. bValInt.text = "0";
  3023. }
  3024. updateInt(bValInt, "b");
  3025. if (activeField == bValInt.name) {
  3026. activeField = "";
  3027. }
  3028. });
  3029. bValInt.onTextChangedObservable.add(function () {
  3030. if (activeField == bValInt.name) {
  3031. updateInt(bValInt, "b");
  3032. }
  3033. });
  3034. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3035. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3036. rValDec.width = 0.95;
  3037. rValDec.height = 0.72;
  3038. rValDec.name = "rDecField";
  3039. rValDec.fontSize = buttonFontSize;
  3040. rValDec.text = currentColor.r.toString();
  3041. rValDec.color = inputTextColor;
  3042. rValDec.background = inputTextBackgroundColor;
  3043. rValDec.onFocusObservable.add(function () {
  3044. activeField = rValDec.name;
  3045. lastVal = rValDec.text;
  3046. editSwatches(false);
  3047. });
  3048. rValDec.onBlurObservable.add(function () {
  3049. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3050. rValDec.text = "0";
  3051. updateFloat(rValDec, "r");
  3052. }
  3053. if (activeField == rValDec.name) {
  3054. activeField = "";
  3055. }
  3056. });
  3057. rValDec.onTextChangedObservable.add(function () {
  3058. if (activeField == rValDec.name) {
  3059. updateFloat(rValDec, "r");
  3060. }
  3061. });
  3062. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3063. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3064. gValDec.width = 0.95;
  3065. gValDec.height = 0.72;
  3066. gValDec.name = "gDecField";
  3067. gValDec.fontSize = buttonFontSize;
  3068. gValDec.text = currentColor.g.toString();
  3069. gValDec.color = inputTextColor;
  3070. gValDec.background = inputTextBackgroundColor;
  3071. gValDec.onFocusObservable.add(function () {
  3072. activeField = gValDec.name;
  3073. lastVal = gValDec.text;
  3074. editSwatches(false);
  3075. });
  3076. gValDec.onBlurObservable.add(function () {
  3077. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3078. gValDec.text = "0";
  3079. updateFloat(gValDec, "g");
  3080. }
  3081. if (activeField == gValDec.name) {
  3082. activeField = "";
  3083. }
  3084. });
  3085. gValDec.onTextChangedObservable.add(function () {
  3086. if (activeField == gValDec.name) {
  3087. updateFloat(gValDec, "g");
  3088. }
  3089. });
  3090. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3091. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3092. bValDec.width = 0.95;
  3093. bValDec.height = 0.72;
  3094. bValDec.name = "bDecField";
  3095. bValDec.fontSize = buttonFontSize;
  3096. bValDec.text = currentColor.b.toString();
  3097. bValDec.color = inputTextColor;
  3098. bValDec.background = inputTextBackgroundColor;
  3099. bValDec.onFocusObservable.add(function () {
  3100. activeField = bValDec.name;
  3101. lastVal = bValDec.text;
  3102. editSwatches(false);
  3103. });
  3104. bValDec.onBlurObservable.add(function () {
  3105. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3106. bValDec.text = "0";
  3107. updateFloat(bValDec, "b");
  3108. }
  3109. if (activeField == bValDec.name) {
  3110. activeField = "";
  3111. }
  3112. });
  3113. bValDec.onTextChangedObservable.add(function () {
  3114. if (activeField == bValDec.name) {
  3115. updateFloat(bValDec, "b");
  3116. }
  3117. });
  3118. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3119. // Hex value input
  3120. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3121. hexValueQuadrant.name = "Hex Value";
  3122. hexValueQuadrant.width = 0.82;
  3123. hexValueQuadrant.addRowDefinition(1.0, false);
  3124. hexValueQuadrant.addColumnDefinition(0.1, false);
  3125. hexValueQuadrant.addColumnDefinition(0.9, false);
  3126. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3127. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3128. labelText.text = "#";
  3129. labelText.color = buttonColor;
  3130. labelText.fontSize = buttonFontSize;
  3131. hexValueQuadrant.addControl(labelText, 0, 0);
  3132. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3133. hexVal.width = 0.96;
  3134. hexVal.height = 0.72;
  3135. hexVal.name = "hexField";
  3136. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3137. hexVal.fontSize = buttonFontSize;
  3138. var minusPound = options.lastColor.split("#");
  3139. hexVal.text = minusPound[1];
  3140. hexVal.color = inputTextColor;
  3141. hexVal.background = inputTextBackgroundColor;
  3142. hexVal.onFocusObservable.add(function () {
  3143. activeField = hexVal.name;
  3144. lastVal = hexVal.text;
  3145. editSwatches(false);
  3146. });
  3147. hexVal.onBlurObservable.add(function () {
  3148. if (hexVal.text.length == 3) {
  3149. var val = hexVal.text.split("");
  3150. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3151. }
  3152. if (hexVal.text == "") {
  3153. hexVal.text = "000000";
  3154. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3155. }
  3156. if (activeField == hexVal.name) {
  3157. activeField = "";
  3158. }
  3159. });
  3160. hexVal.onTextChangedObservable.add(function () {
  3161. var newHexValue = hexVal.text;
  3162. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3163. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3164. hexVal.text = lastVal;
  3165. }
  3166. else {
  3167. if (hexVal.text.length < 6) {
  3168. var leadingZero = 6 - hexVal.text.length;
  3169. for (var i = 0; i < leadingZero; i++) {
  3170. newHexValue = "0" + newHexValue;
  3171. }
  3172. }
  3173. if (hexVal.text.length == 3) {
  3174. var val = hexVal.text.split("");
  3175. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3176. }
  3177. newHexValue = "#" + newHexValue;
  3178. if (activeField == hexVal.name) {
  3179. lastVal = hexVal.text;
  3180. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3181. }
  3182. }
  3183. });
  3184. hexValueQuadrant.addControl(hexVal, 0, 1);
  3185. if (options.savedColors && options.savedColors.length > 0) {
  3186. updateSwatches("", butSave);
  3187. }
  3188. });
  3189. };
  3190. ColorPicker._Epsilon = 0.000001;
  3191. return ColorPicker;
  3192. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3193. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3194. /***/ }),
  3195. /***/ "./2D/controls/container.ts":
  3196. /*!**********************************!*\
  3197. !*** ./2D/controls/container.ts ***!
  3198. \**********************************/
  3199. /*! exports provided: Container */
  3200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3201. "use strict";
  3202. __webpack_require__.r(__webpack_exports__);
  3203. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3204. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3205. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable");
  3206. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3207. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3208. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3209. /**
  3210. * Root class for 2D containers
  3211. * @see https://doc.babylonjs.com/how_to/gui#containers
  3212. */
  3213. var Container = /** @class */ (function (_super) {
  3214. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3215. /**
  3216. * Creates a new Container
  3217. * @param name defines the name of the container
  3218. */
  3219. function Container(name) {
  3220. var _this = _super.call(this, name) || this;
  3221. _this.name = name;
  3222. /** @hidden */
  3223. _this._children = new Array();
  3224. /** @hidden */
  3225. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3226. /** @hidden */
  3227. _this._background = "";
  3228. /** @hidden */
  3229. _this._adaptWidthToChildren = false;
  3230. /** @hidden */
  3231. _this._adaptHeightToChildren = false;
  3232. /**
  3233. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3234. */
  3235. _this.logLayoutCycleErrors = false;
  3236. /**
  3237. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3238. */
  3239. _this.maxLayoutCycle = 3;
  3240. return _this;
  3241. }
  3242. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3243. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3244. get: function () {
  3245. return this._adaptHeightToChildren;
  3246. },
  3247. set: function (value) {
  3248. if (this._adaptHeightToChildren === value) {
  3249. return;
  3250. }
  3251. this._adaptHeightToChildren = value;
  3252. if (value) {
  3253. this.height = "100%";
  3254. }
  3255. this._markAsDirty();
  3256. },
  3257. enumerable: false,
  3258. configurable: true
  3259. });
  3260. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3261. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3262. get: function () {
  3263. return this._adaptWidthToChildren;
  3264. },
  3265. set: function (value) {
  3266. if (this._adaptWidthToChildren === value) {
  3267. return;
  3268. }
  3269. this._adaptWidthToChildren = value;
  3270. if (value) {
  3271. this.width = "100%";
  3272. }
  3273. this._markAsDirty();
  3274. },
  3275. enumerable: false,
  3276. configurable: true
  3277. });
  3278. Object.defineProperty(Container.prototype, "background", {
  3279. /** Gets or sets background color */
  3280. get: function () {
  3281. return this._background;
  3282. },
  3283. set: function (value) {
  3284. if (this._background === value) {
  3285. return;
  3286. }
  3287. this._background = value;
  3288. this._markAsDirty();
  3289. },
  3290. enumerable: false,
  3291. configurable: true
  3292. });
  3293. Object.defineProperty(Container.prototype, "children", {
  3294. /** Gets the list of children */
  3295. get: function () {
  3296. return this._children;
  3297. },
  3298. enumerable: false,
  3299. configurable: true
  3300. });
  3301. Container.prototype._getTypeName = function () {
  3302. return "Container";
  3303. };
  3304. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3305. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3306. var child = _a[_i];
  3307. child._markMatrixAsDirty();
  3308. }
  3309. };
  3310. /**
  3311. * Gets a child using its name
  3312. * @param name defines the child name to look for
  3313. * @returns the child control if found
  3314. */
  3315. Container.prototype.getChildByName = function (name) {
  3316. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3317. var child = _a[_i];
  3318. if (child.name === name) {
  3319. return child;
  3320. }
  3321. }
  3322. return null;
  3323. };
  3324. /**
  3325. * Gets a child using its type and its name
  3326. * @param name defines the child name to look for
  3327. * @param type defines the child type to look for
  3328. * @returns the child control if found
  3329. */
  3330. Container.prototype.getChildByType = function (name, type) {
  3331. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3332. var child = _a[_i];
  3333. if (child.typeName === type) {
  3334. return child;
  3335. }
  3336. }
  3337. return null;
  3338. };
  3339. /**
  3340. * Search for a specific control in children
  3341. * @param control defines the control to look for
  3342. * @returns true if the control is in child list
  3343. */
  3344. Container.prototype.containsControl = function (control) {
  3345. return this.children.indexOf(control) !== -1;
  3346. };
  3347. /**
  3348. * Adds a new control to the current container
  3349. * @param control defines the control to add
  3350. * @returns the current container
  3351. */
  3352. Container.prototype.addControl = function (control) {
  3353. if (!control) {
  3354. return this;
  3355. }
  3356. var index = this._children.indexOf(control);
  3357. if (index !== -1) {
  3358. return this;
  3359. }
  3360. control._link(this._host);
  3361. control._markAllAsDirty();
  3362. this._reOrderControl(control);
  3363. this._markAsDirty();
  3364. return this;
  3365. };
  3366. /**
  3367. * Removes all controls from the current container
  3368. * @returns the current container
  3369. */
  3370. Container.prototype.clearControls = function () {
  3371. var children = this.children.slice();
  3372. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3373. var child = children_1[_i];
  3374. this.removeControl(child);
  3375. }
  3376. return this;
  3377. };
  3378. /**
  3379. * Removes a control from the current container
  3380. * @param control defines the control to remove
  3381. * @returns the current container
  3382. */
  3383. Container.prototype.removeControl = function (control) {
  3384. var index = this._children.indexOf(control);
  3385. if (index !== -1) {
  3386. this._children.splice(index, 1);
  3387. control.parent = null;
  3388. }
  3389. control.linkWithMesh(null);
  3390. if (this._host) {
  3391. this._host._cleanControlAfterRemoval(control);
  3392. }
  3393. this._markAsDirty();
  3394. return this;
  3395. };
  3396. /** @hidden */
  3397. Container.prototype._reOrderControl = function (control) {
  3398. this.removeControl(control);
  3399. var wasAdded = false;
  3400. for (var index = 0; index < this._children.length; index++) {
  3401. if (this._children[index].zIndex > control.zIndex) {
  3402. this._children.splice(index, 0, control);
  3403. wasAdded = true;
  3404. break;
  3405. }
  3406. }
  3407. if (!wasAdded) {
  3408. this._children.push(control);
  3409. }
  3410. control.parent = this;
  3411. this._markAsDirty();
  3412. };
  3413. /** @hidden */
  3414. Container.prototype._offsetLeft = function (offset) {
  3415. _super.prototype._offsetLeft.call(this, offset);
  3416. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3417. var child = _a[_i];
  3418. child._offsetLeft(offset);
  3419. }
  3420. };
  3421. /** @hidden */
  3422. Container.prototype._offsetTop = function (offset) {
  3423. _super.prototype._offsetTop.call(this, offset);
  3424. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3425. var child = _a[_i];
  3426. child._offsetTop(offset);
  3427. }
  3428. };
  3429. /** @hidden */
  3430. Container.prototype._markAllAsDirty = function () {
  3431. _super.prototype._markAllAsDirty.call(this);
  3432. for (var index = 0; index < this._children.length; index++) {
  3433. this._children[index]._markAllAsDirty();
  3434. }
  3435. };
  3436. /** @hidden */
  3437. Container.prototype._localDraw = function (context) {
  3438. if (this._background) {
  3439. context.save();
  3440. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3441. context.shadowColor = this.shadowColor;
  3442. context.shadowBlur = this.shadowBlur;
  3443. context.shadowOffsetX = this.shadowOffsetX;
  3444. context.shadowOffsetY = this.shadowOffsetY;
  3445. }
  3446. context.fillStyle = this._background;
  3447. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3448. context.restore();
  3449. }
  3450. };
  3451. /** @hidden */
  3452. Container.prototype._link = function (host) {
  3453. _super.prototype._link.call(this, host);
  3454. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3455. var child = _a[_i];
  3456. child._link(host);
  3457. }
  3458. };
  3459. /** @hidden */
  3460. Container.prototype._beforeLayout = function () {
  3461. // Do nothing
  3462. };
  3463. /** @hidden */
  3464. Container.prototype._processMeasures = function (parentMeasure, context) {
  3465. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3466. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3467. this._evaluateClippingState(parentMeasure);
  3468. }
  3469. };
  3470. /** @hidden */
  3471. Container.prototype._layout = function (parentMeasure, context) {
  3472. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3473. return false;
  3474. }
  3475. this.host._numLayoutCalls++;
  3476. if (this._isDirty) {
  3477. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3478. }
  3479. var rebuildCount = 0;
  3480. context.save();
  3481. this._applyStates(context);
  3482. this._beforeLayout();
  3483. do {
  3484. var computedWidth = -1;
  3485. var computedHeight = -1;
  3486. this._rebuildLayout = false;
  3487. this._processMeasures(parentMeasure, context);
  3488. if (!this._isClipped) {
  3489. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3490. var child = _a[_i];
  3491. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3492. if (child._layout(this._measureForChildren, context)) {
  3493. if (this.adaptWidthToChildren && child._width.isPixel) {
  3494. computedWidth = Math.max(computedWidth, child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels);
  3495. }
  3496. if (this.adaptHeightToChildren && child._height.isPixel) {
  3497. computedHeight = Math.max(computedHeight, child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels);
  3498. }
  3499. }
  3500. }
  3501. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3502. computedWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  3503. if (this.width !== computedWidth + "px") {
  3504. this.width = computedWidth + "px";
  3505. this._rebuildLayout = true;
  3506. }
  3507. }
  3508. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3509. computedHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  3510. if (this.height !== computedHeight + "px") {
  3511. this.height = computedHeight + "px";
  3512. this._rebuildLayout = true;
  3513. }
  3514. }
  3515. this._postMeasure();
  3516. }
  3517. rebuildCount++;
  3518. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3519. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3520. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3521. }
  3522. context.restore();
  3523. if (this._isDirty) {
  3524. this.invalidateRect();
  3525. this._isDirty = false;
  3526. }
  3527. return true;
  3528. };
  3529. Container.prototype._postMeasure = function () {
  3530. // Do nothing by default
  3531. };
  3532. /** @hidden */
  3533. Container.prototype._draw = function (context, invalidatedRectangle) {
  3534. this._localDraw(context);
  3535. if (this.clipChildren) {
  3536. this._clipForChildren(context);
  3537. }
  3538. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3539. var child = _a[_i];
  3540. // Only redraw parts of the screen that are invalidated
  3541. if (invalidatedRectangle) {
  3542. if (!child._intersectsRect(invalidatedRectangle)) {
  3543. continue;
  3544. }
  3545. }
  3546. child._render(context, invalidatedRectangle);
  3547. }
  3548. };
  3549. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3550. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3551. if (!this.children) {
  3552. return;
  3553. }
  3554. for (var index = 0; index < this.children.length; index++) {
  3555. var item = this.children[index];
  3556. if (!predicate || predicate(item)) {
  3557. results.push(item);
  3558. }
  3559. if (!directDescendantsOnly) {
  3560. item.getDescendantsToRef(results, false, predicate);
  3561. }
  3562. }
  3563. };
  3564. /** @hidden */
  3565. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  3566. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3567. return false;
  3568. }
  3569. if (!_super.prototype.contains.call(this, x, y)) {
  3570. return false;
  3571. }
  3572. // Checking backwards to pick closest first
  3573. for (var index = this._children.length - 1; index >= 0; index--) {
  3574. var child = this._children[index];
  3575. if (child._processPicking(x, y, type, pointerId, buttonIndex, deltaX, deltaY)) {
  3576. if (child.hoverCursor) {
  3577. this._host._changeCursor(child.hoverCursor);
  3578. }
  3579. return true;
  3580. }
  3581. }
  3582. if (!this.isHitTestVisible) {
  3583. return false;
  3584. }
  3585. return this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  3586. };
  3587. /** @hidden */
  3588. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3589. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3590. this._measureForChildren.copyFrom(this._currentMeasure);
  3591. };
  3592. /** Releases associated resources */
  3593. Container.prototype.dispose = function () {
  3594. _super.prototype.dispose.call(this);
  3595. for (var index = this.children.length - 1; index >= 0; index--) {
  3596. this.children[index].dispose();
  3597. }
  3598. };
  3599. return Container;
  3600. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3601. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3602. /***/ }),
  3603. /***/ "./2D/controls/control.ts":
  3604. /*!********************************!*\
  3605. !*** ./2D/controls/control.ts ***!
  3606. \********************************/
  3607. /*! exports provided: Control */
  3608. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3609. "use strict";
  3610. __webpack_require__.r(__webpack_exports__);
  3611. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3612. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  3613. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3614. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3615. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3616. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3617. /**
  3618. * Root class used for all 2D controls
  3619. * @see https://doc.babylonjs.com/how_to/gui#controls
  3620. */
  3621. var Control = /** @class */ (function () {
  3622. // Functions
  3623. /**
  3624. * Creates a new control
  3625. * @param name defines the name of the control
  3626. */
  3627. function Control(
  3628. /** defines the name of the control */
  3629. name) {
  3630. this.name = name;
  3631. this._alpha = 1;
  3632. this._alphaSet = false;
  3633. this._zIndex = 0;
  3634. /** @hidden */
  3635. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3636. this._fontFamily = "Arial";
  3637. this._fontStyle = "";
  3638. this._fontWeight = "";
  3639. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3640. /** @hidden */
  3641. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3642. /** @hidden */
  3643. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3644. this._color = "";
  3645. this._style = null;
  3646. /** @hidden */
  3647. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3648. /** @hidden */
  3649. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3650. /** @hidden */
  3651. this._isDirty = true;
  3652. /** @hidden */
  3653. this._wasDirty = false;
  3654. /** @hidden */
  3655. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3656. /** @hidden */
  3657. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3658. /** @hidden */
  3659. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3660. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3661. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3662. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3663. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3664. /** @hidden */
  3665. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3666. /** @hidden */
  3667. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3668. this._scaleX = 1.0;
  3669. this._scaleY = 1.0;
  3670. this._rotation = 0;
  3671. this._transformCenterX = 0.5;
  3672. this._transformCenterY = 0.5;
  3673. /** @hidden */
  3674. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3675. /** @hidden */
  3676. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3677. /** @hidden */
  3678. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3679. this._isMatrixDirty = true;
  3680. this._isVisible = true;
  3681. this._isHighlighted = false;
  3682. this._fontSet = false;
  3683. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3684. this._downCount = 0;
  3685. this._enterCount = -1;
  3686. this._doNotRender = false;
  3687. this._downPointerIds = {};
  3688. this._isEnabled = true;
  3689. this._disabledColor = "#9a9a9a";
  3690. this._disabledColorItem = "#6a6a6a";
  3691. /** @hidden */
  3692. this._rebuildLayout = false;
  3693. /** @hidden */
  3694. this._customData = {};
  3695. /** @hidden */
  3696. this._isClipped = false;
  3697. /** @hidden */
  3698. this._automaticSize = false;
  3699. /**
  3700. * Gets or sets an object used to store user defined information for the node
  3701. */
  3702. this.metadata = null;
  3703. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3704. this.isHitTestVisible = true;
  3705. /** Gets or sets a boolean indicating if the control can block pointer events */
  3706. this.isPointerBlocker = false;
  3707. /** Gets or sets a boolean indicating if the control can be focusable */
  3708. this.isFocusInvisible = false;
  3709. /**
  3710. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3711. * 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
  3712. */
  3713. this.clipChildren = true;
  3714. /**
  3715. * Gets or sets a boolean indicating that control content must be clipped
  3716. * 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
  3717. */
  3718. this.clipContent = true;
  3719. /**
  3720. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3721. */
  3722. this.useBitmapCache = false;
  3723. this._shadowOffsetX = 0;
  3724. this._shadowOffsetY = 0;
  3725. this._shadowBlur = 0;
  3726. this._shadowColor = 'black';
  3727. /** Gets or sets the cursor to use when the control is hovered */
  3728. this.hoverCursor = "";
  3729. /** @hidden */
  3730. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3731. /** @hidden */
  3732. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3733. /**
  3734. * An event triggered when pointer wheel is scrolled
  3735. */
  3736. this.onWheelObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3737. /**
  3738. * An event triggered when the pointer move over the control.
  3739. */
  3740. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3741. /**
  3742. * An event triggered when the pointer move out of the control.
  3743. */
  3744. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3745. /**
  3746. * An event triggered when the pointer taps the control
  3747. */
  3748. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3749. /**
  3750. * An event triggered when pointer up
  3751. */
  3752. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3753. /**
  3754. * An event triggered when a control is clicked on
  3755. */
  3756. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3757. /**
  3758. * An event triggered when pointer enters the control
  3759. */
  3760. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3761. /**
  3762. * An event triggered when the control is marked as dirty
  3763. */
  3764. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3765. /**
  3766. * An event triggered before drawing the control
  3767. */
  3768. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3769. /**
  3770. * An event triggered after the control was drawn
  3771. */
  3772. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3773. /**
  3774. * An event triggered when the control has been disposed
  3775. */
  3776. this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3777. /**
  3778. * Gets or sets a fixed ratio for this control.
  3779. * When different from 0, the ratio is used to compute the "second" dimension.
  3780. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  3781. * second dimension is computed as first dimension * fixedRatio
  3782. */
  3783. this.fixedRatio = 0;
  3784. this._fixedRatioMasterIsWidth = true;
  3785. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3786. }
  3787. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3788. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3789. get: function () {
  3790. return this._shadowOffsetX;
  3791. },
  3792. set: function (value) {
  3793. if (this._shadowOffsetX === value) {
  3794. return;
  3795. }
  3796. this._shadowOffsetX = value;
  3797. this._markAsDirty();
  3798. },
  3799. enumerable: false,
  3800. configurable: true
  3801. });
  3802. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3803. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3804. get: function () {
  3805. return this._shadowOffsetY;
  3806. },
  3807. set: function (value) {
  3808. if (this._shadowOffsetY === value) {
  3809. return;
  3810. }
  3811. this._shadowOffsetY = value;
  3812. this._markAsDirty();
  3813. },
  3814. enumerable: false,
  3815. configurable: true
  3816. });
  3817. Object.defineProperty(Control.prototype, "shadowBlur", {
  3818. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3819. get: function () {
  3820. return this._shadowBlur;
  3821. },
  3822. set: function (value) {
  3823. if (this._shadowBlur === value) {
  3824. return;
  3825. }
  3826. this._shadowBlur = value;
  3827. this._markAsDirty();
  3828. },
  3829. enumerable: false,
  3830. configurable: true
  3831. });
  3832. Object.defineProperty(Control.prototype, "shadowColor", {
  3833. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3834. get: function () {
  3835. return this._shadowColor;
  3836. },
  3837. set: function (value) {
  3838. if (this._shadowColor === value) {
  3839. return;
  3840. }
  3841. this._shadowColor = value;
  3842. this._markAsDirty();
  3843. },
  3844. enumerable: false,
  3845. configurable: true
  3846. });
  3847. Object.defineProperty(Control.prototype, "typeName", {
  3848. // Properties
  3849. /** Gets the control type name */
  3850. get: function () {
  3851. return this._getTypeName();
  3852. },
  3853. enumerable: false,
  3854. configurable: true
  3855. });
  3856. /**
  3857. * Get the current class name of the control.
  3858. * @returns current class name
  3859. */
  3860. Control.prototype.getClassName = function () {
  3861. return this._getTypeName();
  3862. };
  3863. Object.defineProperty(Control.prototype, "host", {
  3864. /**
  3865. * Get the hosting AdvancedDynamicTexture
  3866. */
  3867. get: function () {
  3868. return this._host;
  3869. },
  3870. enumerable: false,
  3871. configurable: true
  3872. });
  3873. Object.defineProperty(Control.prototype, "fontOffset", {
  3874. /** Gets or set information about font offsets (used to render and align text) */
  3875. get: function () {
  3876. return this._fontOffset;
  3877. },
  3878. set: function (offset) {
  3879. this._fontOffset = offset;
  3880. },
  3881. enumerable: false,
  3882. configurable: true
  3883. });
  3884. Object.defineProperty(Control.prototype, "alpha", {
  3885. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3886. get: function () {
  3887. return this._alpha;
  3888. },
  3889. set: function (value) {
  3890. if (this._alpha === value) {
  3891. return;
  3892. }
  3893. this._alphaSet = true;
  3894. this._alpha = value;
  3895. this._markAsDirty();
  3896. },
  3897. enumerable: false,
  3898. configurable: true
  3899. });
  3900. Object.defineProperty(Control.prototype, "isHighlighted", {
  3901. /**
  3902. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3903. */
  3904. get: function () {
  3905. return this._isHighlighted;
  3906. },
  3907. set: function (value) {
  3908. if (this._isHighlighted === value) {
  3909. return;
  3910. }
  3911. this._isHighlighted = value;
  3912. this._markAsDirty();
  3913. },
  3914. enumerable: false,
  3915. configurable: true
  3916. });
  3917. Object.defineProperty(Control.prototype, "scaleX", {
  3918. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3919. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3920. */
  3921. get: function () {
  3922. return this._scaleX;
  3923. },
  3924. set: function (value) {
  3925. if (this._scaleX === value) {
  3926. return;
  3927. }
  3928. this._scaleX = value;
  3929. this._markAsDirty();
  3930. this._markMatrixAsDirty();
  3931. },
  3932. enumerable: false,
  3933. configurable: true
  3934. });
  3935. Object.defineProperty(Control.prototype, "scaleY", {
  3936. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3937. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3938. */
  3939. get: function () {
  3940. return this._scaleY;
  3941. },
  3942. set: function (value) {
  3943. if (this._scaleY === value) {
  3944. return;
  3945. }
  3946. this._scaleY = value;
  3947. this._markAsDirty();
  3948. this._markMatrixAsDirty();
  3949. },
  3950. enumerable: false,
  3951. configurable: true
  3952. });
  3953. Object.defineProperty(Control.prototype, "rotation", {
  3954. /** Gets or sets the rotation angle (0 by default)
  3955. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3956. */
  3957. get: function () {
  3958. return this._rotation;
  3959. },
  3960. set: function (value) {
  3961. if (this._rotation === value) {
  3962. return;
  3963. }
  3964. this._rotation = value;
  3965. this._markAsDirty();
  3966. this._markMatrixAsDirty();
  3967. },
  3968. enumerable: false,
  3969. configurable: true
  3970. });
  3971. Object.defineProperty(Control.prototype, "transformCenterY", {
  3972. /** Gets or sets the transformation center on Y axis (0 by default)
  3973. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3974. */
  3975. get: function () {
  3976. return this._transformCenterY;
  3977. },
  3978. set: function (value) {
  3979. if (this._transformCenterY === value) {
  3980. return;
  3981. }
  3982. this._transformCenterY = value;
  3983. this._markAsDirty();
  3984. this._markMatrixAsDirty();
  3985. },
  3986. enumerable: false,
  3987. configurable: true
  3988. });
  3989. Object.defineProperty(Control.prototype, "transformCenterX", {
  3990. /** Gets or sets the transformation center on X axis (0 by default)
  3991. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3992. */
  3993. get: function () {
  3994. return this._transformCenterX;
  3995. },
  3996. set: function (value) {
  3997. if (this._transformCenterX === value) {
  3998. return;
  3999. }
  4000. this._transformCenterX = value;
  4001. this._markAsDirty();
  4002. this._markMatrixAsDirty();
  4003. },
  4004. enumerable: false,
  4005. configurable: true
  4006. });
  4007. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  4008. /**
  4009. * Gets or sets the horizontal alignment
  4010. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4011. */
  4012. get: function () {
  4013. return this._horizontalAlignment;
  4014. },
  4015. set: function (value) {
  4016. if (this._horizontalAlignment === value) {
  4017. return;
  4018. }
  4019. this._horizontalAlignment = value;
  4020. this._markAsDirty();
  4021. },
  4022. enumerable: false,
  4023. configurable: true
  4024. });
  4025. Object.defineProperty(Control.prototype, "verticalAlignment", {
  4026. /**
  4027. * Gets or sets the vertical alignment
  4028. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4029. */
  4030. get: function () {
  4031. return this._verticalAlignment;
  4032. },
  4033. set: function (value) {
  4034. if (this._verticalAlignment === value) {
  4035. return;
  4036. }
  4037. this._verticalAlignment = value;
  4038. this._markAsDirty();
  4039. },
  4040. enumerable: false,
  4041. configurable: true
  4042. });
  4043. Object.defineProperty(Control.prototype, "width", {
  4044. /**
  4045. * Gets or sets control width
  4046. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4047. */
  4048. get: function () {
  4049. return this._width.toString(this._host);
  4050. },
  4051. set: function (value) {
  4052. this._fixedRatioMasterIsWidth = true;
  4053. if (this._width.toString(this._host) === value) {
  4054. return;
  4055. }
  4056. if (this._width.fromString(value)) {
  4057. this._markAsDirty();
  4058. }
  4059. },
  4060. enumerable: false,
  4061. configurable: true
  4062. });
  4063. Object.defineProperty(Control.prototype, "widthInPixels", {
  4064. /**
  4065. * Gets or sets the control width in pixel
  4066. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4067. */
  4068. get: function () {
  4069. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4070. },
  4071. set: function (value) {
  4072. if (isNaN(value)) {
  4073. return;
  4074. }
  4075. this._fixedRatioMasterIsWidth = true;
  4076. this.width = value + "px";
  4077. },
  4078. enumerable: false,
  4079. configurable: true
  4080. });
  4081. Object.defineProperty(Control.prototype, "height", {
  4082. /**
  4083. * Gets or sets control height
  4084. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4085. */
  4086. get: function () {
  4087. return this._height.toString(this._host);
  4088. },
  4089. set: function (value) {
  4090. this._fixedRatioMasterIsWidth = false;
  4091. if (this._height.toString(this._host) === value) {
  4092. return;
  4093. }
  4094. if (this._height.fromString(value)) {
  4095. this._markAsDirty();
  4096. }
  4097. },
  4098. enumerable: false,
  4099. configurable: true
  4100. });
  4101. Object.defineProperty(Control.prototype, "heightInPixels", {
  4102. /**
  4103. * Gets or sets control height in pixel
  4104. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4105. */
  4106. get: function () {
  4107. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4108. },
  4109. set: function (value) {
  4110. if (isNaN(value)) {
  4111. return;
  4112. }
  4113. this._fixedRatioMasterIsWidth = false;
  4114. this.height = value + "px";
  4115. },
  4116. enumerable: false,
  4117. configurable: true
  4118. });
  4119. Object.defineProperty(Control.prototype, "fontFamily", {
  4120. /** Gets or set font family */
  4121. get: function () {
  4122. if (!this._fontSet) {
  4123. return "";
  4124. }
  4125. return this._fontFamily;
  4126. },
  4127. set: function (value) {
  4128. if (this._fontFamily === value) {
  4129. return;
  4130. }
  4131. this._fontFamily = value;
  4132. this._resetFontCache();
  4133. },
  4134. enumerable: false,
  4135. configurable: true
  4136. });
  4137. Object.defineProperty(Control.prototype, "fontStyle", {
  4138. /** Gets or sets font style */
  4139. get: function () {
  4140. return this._fontStyle;
  4141. },
  4142. set: function (value) {
  4143. if (this._fontStyle === value) {
  4144. return;
  4145. }
  4146. this._fontStyle = value;
  4147. this._resetFontCache();
  4148. },
  4149. enumerable: false,
  4150. configurable: true
  4151. });
  4152. Object.defineProperty(Control.prototype, "fontWeight", {
  4153. /** Gets or sets font weight */
  4154. get: function () {
  4155. return this._fontWeight;
  4156. },
  4157. set: function (value) {
  4158. if (this._fontWeight === value) {
  4159. return;
  4160. }
  4161. this._fontWeight = value;
  4162. this._resetFontCache();
  4163. },
  4164. enumerable: false,
  4165. configurable: true
  4166. });
  4167. Object.defineProperty(Control.prototype, "style", {
  4168. /**
  4169. * Gets or sets style
  4170. * @see https://doc.babylonjs.com/how_to/gui#styles
  4171. */
  4172. get: function () {
  4173. return this._style;
  4174. },
  4175. set: function (value) {
  4176. var _this = this;
  4177. if (this._style) {
  4178. this._style.onChangedObservable.remove(this._styleObserver);
  4179. this._styleObserver = null;
  4180. }
  4181. this._style = value;
  4182. if (this._style) {
  4183. this._styleObserver = this._style.onChangedObservable.add(function () {
  4184. _this._markAsDirty();
  4185. _this._resetFontCache();
  4186. });
  4187. }
  4188. this._markAsDirty();
  4189. this._resetFontCache();
  4190. },
  4191. enumerable: false,
  4192. configurable: true
  4193. });
  4194. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4195. /** @hidden */
  4196. get: function () {
  4197. return this._fontSize.isPercentage;
  4198. },
  4199. enumerable: false,
  4200. configurable: true
  4201. });
  4202. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4203. /** Gets or sets font size in pixels */
  4204. get: function () {
  4205. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4206. if (fontSizeToUse.isPixel) {
  4207. return fontSizeToUse.getValue(this._host);
  4208. }
  4209. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4210. },
  4211. set: function (value) {
  4212. if (isNaN(value)) {
  4213. return;
  4214. }
  4215. this.fontSize = value + "px";
  4216. },
  4217. enumerable: false,
  4218. configurable: true
  4219. });
  4220. Object.defineProperty(Control.prototype, "fontSize", {
  4221. /** Gets or sets font size */
  4222. get: function () {
  4223. return this._fontSize.toString(this._host);
  4224. },
  4225. set: function (value) {
  4226. if (this._fontSize.toString(this._host) === value) {
  4227. return;
  4228. }
  4229. if (this._fontSize.fromString(value)) {
  4230. this._markAsDirty();
  4231. this._resetFontCache();
  4232. }
  4233. },
  4234. enumerable: false,
  4235. configurable: true
  4236. });
  4237. Object.defineProperty(Control.prototype, "color", {
  4238. /** Gets or sets foreground color */
  4239. get: function () {
  4240. return this._color;
  4241. },
  4242. set: function (value) {
  4243. if (this._color === value) {
  4244. return;
  4245. }
  4246. this._color = value;
  4247. this._markAsDirty();
  4248. },
  4249. enumerable: false,
  4250. configurable: true
  4251. });
  4252. Object.defineProperty(Control.prototype, "zIndex", {
  4253. /** Gets or sets z index which is used to reorder controls on the z axis */
  4254. get: function () {
  4255. return this._zIndex;
  4256. },
  4257. set: function (value) {
  4258. if (this.zIndex === value) {
  4259. return;
  4260. }
  4261. this._zIndex = value;
  4262. if (this.parent) {
  4263. this.parent._reOrderControl(this);
  4264. }
  4265. },
  4266. enumerable: false,
  4267. configurable: true
  4268. });
  4269. Object.defineProperty(Control.prototype, "notRenderable", {
  4270. /** Gets or sets a boolean indicating if the control can be rendered */
  4271. get: function () {
  4272. return this._doNotRender;
  4273. },
  4274. set: function (value) {
  4275. if (this._doNotRender === value) {
  4276. return;
  4277. }
  4278. this._doNotRender = value;
  4279. this._markAsDirty();
  4280. },
  4281. enumerable: false,
  4282. configurable: true
  4283. });
  4284. Object.defineProperty(Control.prototype, "isVisible", {
  4285. /** Gets or sets a boolean indicating if the control is visible */
  4286. get: function () {
  4287. return this._isVisible;
  4288. },
  4289. set: function (value) {
  4290. if (this._isVisible === value) {
  4291. return;
  4292. }
  4293. this._isVisible = value;
  4294. this._markAsDirty(true);
  4295. },
  4296. enumerable: false,
  4297. configurable: true
  4298. });
  4299. Object.defineProperty(Control.prototype, "isDirty", {
  4300. /** Gets a boolean indicating that the control needs to update its rendering */
  4301. get: function () {
  4302. return this._isDirty;
  4303. },
  4304. enumerable: false,
  4305. configurable: true
  4306. });
  4307. Object.defineProperty(Control.prototype, "linkedMesh", {
  4308. /**
  4309. * Gets the current linked mesh (or null if none)
  4310. */
  4311. get: function () {
  4312. return this._linkedMesh;
  4313. },
  4314. enumerable: false,
  4315. configurable: true
  4316. });
  4317. Object.defineProperty(Control.prototype, "paddingLeft", {
  4318. /**
  4319. * Gets or sets a value indicating the padding to use on the left of the control
  4320. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4321. */
  4322. get: function () {
  4323. return this._paddingLeft.toString(this._host);
  4324. },
  4325. set: function (value) {
  4326. if (this._paddingLeft.fromString(value)) {
  4327. this._markAsDirty();
  4328. }
  4329. },
  4330. enumerable: false,
  4331. configurable: true
  4332. });
  4333. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4334. /**
  4335. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4336. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4337. */
  4338. get: function () {
  4339. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4340. },
  4341. set: function (value) {
  4342. if (isNaN(value)) {
  4343. return;
  4344. }
  4345. this.paddingLeft = value + "px";
  4346. },
  4347. enumerable: false,
  4348. configurable: true
  4349. });
  4350. Object.defineProperty(Control.prototype, "paddingRight", {
  4351. /**
  4352. * Gets or sets a value indicating the padding to use on the right of the control
  4353. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4354. */
  4355. get: function () {
  4356. return this._paddingRight.toString(this._host);
  4357. },
  4358. set: function (value) {
  4359. if (this._paddingRight.fromString(value)) {
  4360. this._markAsDirty();
  4361. }
  4362. },
  4363. enumerable: false,
  4364. configurable: true
  4365. });
  4366. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4367. /**
  4368. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4369. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4370. */
  4371. get: function () {
  4372. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4373. },
  4374. set: function (value) {
  4375. if (isNaN(value)) {
  4376. return;
  4377. }
  4378. this.paddingRight = value + "px";
  4379. },
  4380. enumerable: false,
  4381. configurable: true
  4382. });
  4383. Object.defineProperty(Control.prototype, "paddingTop", {
  4384. /**
  4385. * Gets or sets a value indicating the padding to use on the top of the control
  4386. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4387. */
  4388. get: function () {
  4389. return this._paddingTop.toString(this._host);
  4390. },
  4391. set: function (value) {
  4392. if (this._paddingTop.fromString(value)) {
  4393. this._markAsDirty();
  4394. }
  4395. },
  4396. enumerable: false,
  4397. configurable: true
  4398. });
  4399. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4400. /**
  4401. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4402. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4403. */
  4404. get: function () {
  4405. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4406. },
  4407. set: function (value) {
  4408. if (isNaN(value)) {
  4409. return;
  4410. }
  4411. this.paddingTop = value + "px";
  4412. },
  4413. enumerable: false,
  4414. configurable: true
  4415. });
  4416. Object.defineProperty(Control.prototype, "paddingBottom", {
  4417. /**
  4418. * Gets or sets a value indicating the padding to use on the bottom of the control
  4419. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4420. */
  4421. get: function () {
  4422. return this._paddingBottom.toString(this._host);
  4423. },
  4424. set: function (value) {
  4425. if (this._paddingBottom.fromString(value)) {
  4426. this._markAsDirty();
  4427. }
  4428. },
  4429. enumerable: false,
  4430. configurable: true
  4431. });
  4432. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4433. /**
  4434. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4435. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4436. */
  4437. get: function () {
  4438. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4439. },
  4440. set: function (value) {
  4441. if (isNaN(value)) {
  4442. return;
  4443. }
  4444. this.paddingBottom = value + "px";
  4445. },
  4446. enumerable: false,
  4447. configurable: true
  4448. });
  4449. Object.defineProperty(Control.prototype, "left", {
  4450. /**
  4451. * Gets or sets a value indicating the left coordinate of the control
  4452. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4453. */
  4454. get: function () {
  4455. return this._left.toString(this._host);
  4456. },
  4457. set: function (value) {
  4458. if (this._left.fromString(value)) {
  4459. this._markAsDirty();
  4460. }
  4461. },
  4462. enumerable: false,
  4463. configurable: true
  4464. });
  4465. Object.defineProperty(Control.prototype, "leftInPixels", {
  4466. /**
  4467. * Gets or sets a value indicating the left coordinate in pixels of the control
  4468. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4469. */
  4470. get: function () {
  4471. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4472. },
  4473. set: function (value) {
  4474. if (isNaN(value)) {
  4475. return;
  4476. }
  4477. this.left = value + "px";
  4478. },
  4479. enumerable: false,
  4480. configurable: true
  4481. });
  4482. Object.defineProperty(Control.prototype, "top", {
  4483. /**
  4484. * Gets or sets a value indicating the top coordinate of the control
  4485. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4486. */
  4487. get: function () {
  4488. return this._top.toString(this._host);
  4489. },
  4490. set: function (value) {
  4491. if (this._top.fromString(value)) {
  4492. this._markAsDirty();
  4493. }
  4494. },
  4495. enumerable: false,
  4496. configurable: true
  4497. });
  4498. Object.defineProperty(Control.prototype, "topInPixels", {
  4499. /**
  4500. * Gets or sets a value indicating the top coordinate in pixels of the control
  4501. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4502. */
  4503. get: function () {
  4504. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4505. },
  4506. set: function (value) {
  4507. if (isNaN(value)) {
  4508. return;
  4509. }
  4510. this.top = value + "px";
  4511. },
  4512. enumerable: false,
  4513. configurable: true
  4514. });
  4515. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4516. /**
  4517. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4518. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4519. */
  4520. get: function () {
  4521. return this._linkOffsetX.toString(this._host);
  4522. },
  4523. set: function (value) {
  4524. if (this._linkOffsetX.fromString(value)) {
  4525. this._markAsDirty();
  4526. }
  4527. },
  4528. enumerable: false,
  4529. configurable: true
  4530. });
  4531. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4532. /**
  4533. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4534. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4535. */
  4536. get: function () {
  4537. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4538. },
  4539. set: function (value) {
  4540. if (isNaN(value)) {
  4541. return;
  4542. }
  4543. this.linkOffsetX = value + "px";
  4544. },
  4545. enumerable: false,
  4546. configurable: true
  4547. });
  4548. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4549. /**
  4550. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4551. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4552. */
  4553. get: function () {
  4554. return this._linkOffsetY.toString(this._host);
  4555. },
  4556. set: function (value) {
  4557. if (this._linkOffsetY.fromString(value)) {
  4558. this._markAsDirty();
  4559. }
  4560. },
  4561. enumerable: false,
  4562. configurable: true
  4563. });
  4564. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4565. /**
  4566. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4567. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4568. */
  4569. get: function () {
  4570. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4571. },
  4572. set: function (value) {
  4573. if (isNaN(value)) {
  4574. return;
  4575. }
  4576. this.linkOffsetY = value + "px";
  4577. },
  4578. enumerable: false,
  4579. configurable: true
  4580. });
  4581. Object.defineProperty(Control.prototype, "centerX", {
  4582. /** Gets the center coordinate on X axis */
  4583. get: function () {
  4584. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4585. },
  4586. enumerable: false,
  4587. configurable: true
  4588. });
  4589. Object.defineProperty(Control.prototype, "centerY", {
  4590. /** Gets the center coordinate on Y axis */
  4591. get: function () {
  4592. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4593. },
  4594. enumerable: false,
  4595. configurable: true
  4596. });
  4597. Object.defineProperty(Control.prototype, "isEnabled", {
  4598. /** Gets or sets if control is Enabled*/
  4599. get: function () {
  4600. return this._isEnabled;
  4601. },
  4602. set: function (value) {
  4603. if (this._isEnabled === value) {
  4604. return;
  4605. }
  4606. this._isEnabled = value;
  4607. this._markAsDirty();
  4608. },
  4609. enumerable: false,
  4610. configurable: true
  4611. });
  4612. Object.defineProperty(Control.prototype, "disabledColor", {
  4613. /** Gets or sets background color of control if it's disabled*/
  4614. get: function () {
  4615. return this._disabledColor;
  4616. },
  4617. set: function (value) {
  4618. if (this._disabledColor === value) {
  4619. return;
  4620. }
  4621. this._disabledColor = value;
  4622. this._markAsDirty();
  4623. },
  4624. enumerable: false,
  4625. configurable: true
  4626. });
  4627. Object.defineProperty(Control.prototype, "disabledColorItem", {
  4628. /** Gets or sets front color of control if it's disabled*/
  4629. get: function () {
  4630. return this._disabledColorItem;
  4631. },
  4632. set: function (value) {
  4633. if (this._disabledColorItem === value) {
  4634. return;
  4635. }
  4636. this._disabledColorItem = value;
  4637. this._markAsDirty();
  4638. },
  4639. enumerable: false,
  4640. configurable: true
  4641. });
  4642. /** @hidden */
  4643. Control.prototype._getTypeName = function () {
  4644. return "Control";
  4645. };
  4646. /**
  4647. * Gets the first ascendant in the hierarchy of the given type
  4648. * @param className defines the required type
  4649. * @returns the ascendant or null if not found
  4650. */
  4651. Control.prototype.getAscendantOfClass = function (className) {
  4652. if (!this.parent) {
  4653. return null;
  4654. }
  4655. if (this.parent.getClassName() === className) {
  4656. return this.parent;
  4657. }
  4658. return this.parent.getAscendantOfClass(className);
  4659. };
  4660. /** @hidden */
  4661. Control.prototype._resetFontCache = function () {
  4662. this._fontSet = true;
  4663. this._markAsDirty();
  4664. };
  4665. /**
  4666. * Determines if a container is an ascendant of the current control
  4667. * @param container defines the container to look for
  4668. * @returns true if the container is one of the ascendant of the control
  4669. */
  4670. Control.prototype.isAscendant = function (container) {
  4671. if (!this.parent) {
  4672. return false;
  4673. }
  4674. if (this.parent === container) {
  4675. return true;
  4676. }
  4677. return this.parent.isAscendant(container);
  4678. };
  4679. /**
  4680. * Gets coordinates in local control space
  4681. * @param globalCoordinates defines the coordinates to transform
  4682. * @returns the new coordinates in local space
  4683. */
  4684. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4685. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4686. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4687. return result;
  4688. };
  4689. /**
  4690. * Gets coordinates in local control space
  4691. * @param globalCoordinates defines the coordinates to transform
  4692. * @param result defines the target vector2 where to store the result
  4693. * @returns the current control
  4694. */
  4695. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4696. result.x = globalCoordinates.x - this._currentMeasure.left;
  4697. result.y = globalCoordinates.y - this._currentMeasure.top;
  4698. return this;
  4699. };
  4700. /**
  4701. * Gets coordinates in parent local control space
  4702. * @param globalCoordinates defines the coordinates to transform
  4703. * @returns the new coordinates in parent local space
  4704. */
  4705. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4706. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4707. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4708. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4709. return result;
  4710. };
  4711. /**
  4712. * Move the current control to a vector3 position projected onto the screen.
  4713. * @param position defines the target position
  4714. * @param scene defines the hosting scene
  4715. */
  4716. Control.prototype.moveToVector3 = function (position, scene) {
  4717. if (!this._host || this.parent !== this._host._rootContainer) {
  4718. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4719. return;
  4720. }
  4721. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4722. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4723. var globalViewport = this._host._getGlobalViewport(scene);
  4724. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4725. this._moveToProjectedPosition(projectedPosition);
  4726. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4727. this.notRenderable = true;
  4728. return;
  4729. }
  4730. this.notRenderable = false;
  4731. };
  4732. /**
  4733. * Will store all controls that have this control as ascendant in a given array
  4734. * @param results defines the array where to store the descendants
  4735. * @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
  4736. * @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
  4737. */
  4738. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4739. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4740. // Do nothing by default
  4741. };
  4742. /**
  4743. * Will return all controls that have this control as ascendant
  4744. * @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
  4745. * @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
  4746. * @return all child controls
  4747. */
  4748. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4749. var results = new Array();
  4750. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4751. return results;
  4752. };
  4753. /**
  4754. * Link current control with a target mesh
  4755. * @param mesh defines the mesh to link with
  4756. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4757. */
  4758. Control.prototype.linkWithMesh = function (mesh) {
  4759. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4760. if (mesh) {
  4761. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4762. }
  4763. return;
  4764. }
  4765. var index = this._host._linkedControls.indexOf(this);
  4766. if (index !== -1) {
  4767. this._linkedMesh = mesh;
  4768. if (!mesh) {
  4769. this._host._linkedControls.splice(index, 1);
  4770. }
  4771. return;
  4772. }
  4773. else if (!mesh) {
  4774. return;
  4775. }
  4776. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4777. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4778. this._linkedMesh = mesh;
  4779. this._host._linkedControls.push(this);
  4780. };
  4781. /** @hidden */
  4782. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4783. var oldLeft = this._left.getValue(this._host);
  4784. var oldTop = this._top.getValue(this._host);
  4785. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4786. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4787. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4788. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4789. newLeft = oldLeft;
  4790. }
  4791. if (Math.abs(newTop - oldTop) < 0.5) {
  4792. newTop = oldTop;
  4793. }
  4794. }
  4795. this.left = newLeft + "px";
  4796. this.top = newTop + "px";
  4797. this._left.ignoreAdaptiveScaling = true;
  4798. this._top.ignoreAdaptiveScaling = true;
  4799. this._markAsDirty();
  4800. };
  4801. /** @hidden */
  4802. Control.prototype._offsetLeft = function (offset) {
  4803. this._isDirty = true;
  4804. this._currentMeasure.left += offset;
  4805. };
  4806. /** @hidden */
  4807. Control.prototype._offsetTop = function (offset) {
  4808. this._isDirty = true;
  4809. this._currentMeasure.top += offset;
  4810. };
  4811. /** @hidden */
  4812. Control.prototype._markMatrixAsDirty = function () {
  4813. this._isMatrixDirty = true;
  4814. this._flagDescendantsAsMatrixDirty();
  4815. };
  4816. /** @hidden */
  4817. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4818. // No child
  4819. };
  4820. /** @hidden */
  4821. Control.prototype._intersectsRect = function (rect) {
  4822. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4823. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4824. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4825. return false;
  4826. }
  4827. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4828. return false;
  4829. }
  4830. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4831. return false;
  4832. }
  4833. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4834. return false;
  4835. }
  4836. return true;
  4837. };
  4838. /** @hidden */
  4839. Control.prototype.invalidateRect = function () {
  4840. this._transform();
  4841. if (this.host && this.host.useInvalidateRectOptimization) {
  4842. // Rotate by transform to get the measure transformed to global space
  4843. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4844. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4845. // the previous measure is used to properly clear a control that is scaled down
  4846. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4847. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4848. // Expand rect based on shadows
  4849. var shadowOffsetX = this.shadowOffsetX;
  4850. var shadowOffsetY = this.shadowOffsetY;
  4851. var shadowBlur = this.shadowBlur;
  4852. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4853. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4854. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4855. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4856. 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));
  4857. }
  4858. else {
  4859. 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));
  4860. }
  4861. }
  4862. };
  4863. /** @hidden */
  4864. Control.prototype._markAsDirty = function (force) {
  4865. if (force === void 0) { force = false; }
  4866. if (!this._isVisible && !force) {
  4867. return;
  4868. }
  4869. this._isDirty = true;
  4870. // Redraw only this rectangle
  4871. if (this._host) {
  4872. this._host.markAsDirty();
  4873. }
  4874. };
  4875. /** @hidden */
  4876. Control.prototype._markAllAsDirty = function () {
  4877. this._markAsDirty();
  4878. if (this._font) {
  4879. this._prepareFont();
  4880. }
  4881. };
  4882. /** @hidden */
  4883. Control.prototype._link = function (host) {
  4884. this._host = host;
  4885. if (this._host) {
  4886. this.uniqueId = this._host.getScene().getUniqueId();
  4887. }
  4888. };
  4889. /** @hidden */
  4890. Control.prototype._transform = function (context) {
  4891. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4892. return;
  4893. }
  4894. // postTranslate
  4895. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4896. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4897. if (context) {
  4898. context.translate(offsetX, offsetY);
  4899. // rotate
  4900. context.rotate(this._rotation);
  4901. // scale
  4902. context.scale(this._scaleX, this._scaleY);
  4903. // preTranslate
  4904. context.translate(-offsetX, -offsetY);
  4905. }
  4906. // Need to update matrices?
  4907. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4908. this._cachedOffsetX = offsetX;
  4909. this._cachedOffsetY = offsetY;
  4910. this._isMatrixDirty = false;
  4911. this._flagDescendantsAsMatrixDirty();
  4912. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4913. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4914. }
  4915. };
  4916. /** @hidden */
  4917. Control.prototype._renderHighlight = function (context) {
  4918. if (!this.isHighlighted) {
  4919. return;
  4920. }
  4921. context.save();
  4922. context.strokeStyle = "#4affff";
  4923. context.lineWidth = 2;
  4924. this._renderHighlightSpecific(context);
  4925. context.restore();
  4926. };
  4927. /** @hidden */
  4928. Control.prototype._renderHighlightSpecific = function (context) {
  4929. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4930. };
  4931. /** @hidden */
  4932. Control.prototype._applyStates = function (context) {
  4933. if (this._isFontSizeInPercentage) {
  4934. this._fontSet = true;
  4935. }
  4936. if (this._fontSet) {
  4937. this._prepareFont();
  4938. this._fontSet = false;
  4939. }
  4940. if (this._font) {
  4941. context.font = this._font;
  4942. }
  4943. if (this._color) {
  4944. context.fillStyle = this._color;
  4945. }
  4946. if (Control.AllowAlphaInheritance) {
  4947. context.globalAlpha *= this._alpha;
  4948. }
  4949. else if (this._alphaSet) {
  4950. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4951. }
  4952. };
  4953. /** @hidden */
  4954. Control.prototype._layout = function (parentMeasure, context) {
  4955. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4956. return false;
  4957. }
  4958. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4959. this.host._numLayoutCalls++;
  4960. this._currentMeasure.addAndTransformToRef(this._transformMatrix, -this.paddingLeftInPixels | 0, -this.paddingTopInPixels | 0, this.paddingRightInPixels | 0, this.paddingBottomInPixels | 0, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4961. context.save();
  4962. this._applyStates(context);
  4963. var rebuildCount = 0;
  4964. do {
  4965. this._rebuildLayout = false;
  4966. this._processMeasures(parentMeasure, context);
  4967. rebuildCount++;
  4968. } while (this._rebuildLayout && rebuildCount < 3);
  4969. if (rebuildCount >= 3) {
  4970. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4971. }
  4972. context.restore();
  4973. this.invalidateRect();
  4974. this._evaluateClippingState(parentMeasure);
  4975. }
  4976. this._wasDirty = this._isDirty;
  4977. this._isDirty = false;
  4978. return true;
  4979. };
  4980. /** @hidden */
  4981. Control.prototype._processMeasures = function (parentMeasure, context) {
  4982. this._currentMeasure.copyFrom(parentMeasure);
  4983. // Let children take some pre-measurement actions
  4984. this._preMeasure(parentMeasure, context);
  4985. this._measure();
  4986. this._computeAlignment(parentMeasure, context);
  4987. // Convert to int values
  4988. this._currentMeasure.left = this._currentMeasure.left | 0;
  4989. this._currentMeasure.top = this._currentMeasure.top | 0;
  4990. this._currentMeasure.width = this._currentMeasure.width | 0;
  4991. this._currentMeasure.height = this._currentMeasure.height | 0;
  4992. // Let children add more features
  4993. this._additionalProcessing(parentMeasure, context);
  4994. this._cachedParentMeasure.copyFrom(parentMeasure);
  4995. if (this.onDirtyObservable.hasObservers()) {
  4996. this.onDirtyObservable.notifyObservers(this);
  4997. }
  4998. };
  4999. Control.prototype._evaluateClippingState = function (parentMeasure) {
  5000. if (this.parent && this.parent.clipChildren) {
  5001. // Early clip
  5002. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  5003. this._isClipped = true;
  5004. return;
  5005. }
  5006. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  5007. this._isClipped = true;
  5008. return;
  5009. }
  5010. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  5011. this._isClipped = true;
  5012. return;
  5013. }
  5014. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  5015. this._isClipped = true;
  5016. return;
  5017. }
  5018. }
  5019. this._isClipped = false;
  5020. };
  5021. /** @hidden */
  5022. Control.prototype._measure = function () {
  5023. // Width / Height
  5024. if (this._width.isPixel) {
  5025. this._currentMeasure.width = this._width.getValue(this._host);
  5026. }
  5027. else {
  5028. this._currentMeasure.width *= this._width.getValue(this._host);
  5029. }
  5030. if (this._height.isPixel) {
  5031. this._currentMeasure.height = this._height.getValue(this._host);
  5032. }
  5033. else {
  5034. this._currentMeasure.height *= this._height.getValue(this._host);
  5035. }
  5036. if (this.fixedRatio !== 0) {
  5037. if (this._fixedRatioMasterIsWidth) {
  5038. this._currentMeasure.height = this._currentMeasure.width * this.fixedRatio;
  5039. }
  5040. else {
  5041. this._currentMeasure.width = this._currentMeasure.height * this.fixedRatio;
  5042. }
  5043. }
  5044. };
  5045. /** @hidden */
  5046. Control.prototype._computeAlignment = function (parentMeasure, context) {
  5047. var width = this._currentMeasure.width;
  5048. var height = this._currentMeasure.height;
  5049. var parentWidth = parentMeasure.width;
  5050. var parentHeight = parentMeasure.height;
  5051. // Left / top
  5052. var x = 0;
  5053. var y = 0;
  5054. switch (this.horizontalAlignment) {
  5055. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  5056. x = 0;
  5057. break;
  5058. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  5059. x = parentWidth - width;
  5060. break;
  5061. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  5062. x = (parentWidth - width) / 2;
  5063. break;
  5064. }
  5065. switch (this.verticalAlignment) {
  5066. case Control.VERTICAL_ALIGNMENT_TOP:
  5067. y = 0;
  5068. break;
  5069. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5070. y = parentHeight - height;
  5071. break;
  5072. case Control.VERTICAL_ALIGNMENT_CENTER:
  5073. y = (parentHeight - height) / 2;
  5074. break;
  5075. }
  5076. if (this._paddingLeft.isPixel) {
  5077. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5078. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5079. }
  5080. else {
  5081. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5082. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5083. }
  5084. if (this._paddingRight.isPixel) {
  5085. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5086. }
  5087. else {
  5088. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5089. }
  5090. if (this._paddingTop.isPixel) {
  5091. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5092. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5093. }
  5094. else {
  5095. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5096. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5097. }
  5098. if (this._paddingBottom.isPixel) {
  5099. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5100. }
  5101. else {
  5102. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5103. }
  5104. if (this._left.isPixel) {
  5105. this._currentMeasure.left += this._left.getValue(this._host);
  5106. }
  5107. else {
  5108. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5109. }
  5110. if (this._top.isPixel) {
  5111. this._currentMeasure.top += this._top.getValue(this._host);
  5112. }
  5113. else {
  5114. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5115. }
  5116. this._currentMeasure.left += x;
  5117. this._currentMeasure.top += y;
  5118. };
  5119. /** @hidden */
  5120. Control.prototype._preMeasure = function (parentMeasure, context) {
  5121. // Do nothing
  5122. };
  5123. /** @hidden */
  5124. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5125. // Do nothing
  5126. };
  5127. /** @hidden */
  5128. Control.prototype._clipForChildren = function (context) {
  5129. // DO nothing
  5130. };
  5131. Control.prototype._clip = function (context, invalidatedRectangle) {
  5132. context.beginPath();
  5133. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5134. if (invalidatedRectangle) {
  5135. // Rotate the invalidated rect into the control's space
  5136. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5137. // Get the intersection of the rect in context space and the current context
  5138. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5139. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5140. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5141. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5142. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5143. Control._ClipMeasure.copyFrom(intersection);
  5144. }
  5145. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5146. var shadowOffsetX = this.shadowOffsetX;
  5147. var shadowOffsetY = this.shadowOffsetY;
  5148. var shadowBlur = this.shadowBlur;
  5149. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5150. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5151. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5152. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5153. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5154. }
  5155. else {
  5156. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5157. }
  5158. context.clip();
  5159. };
  5160. /** @hidden */
  5161. Control.prototype._render = function (context, invalidatedRectangle) {
  5162. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5163. this._isDirty = false;
  5164. return false;
  5165. }
  5166. this.host._numRenderCalls++;
  5167. context.save();
  5168. this._applyStates(context);
  5169. // Transform
  5170. this._transform(context);
  5171. // Clip
  5172. if (this.clipContent) {
  5173. this._clip(context, invalidatedRectangle);
  5174. }
  5175. if (this.onBeforeDrawObservable.hasObservers()) {
  5176. this.onBeforeDrawObservable.notifyObservers(this);
  5177. }
  5178. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5179. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5180. }
  5181. else {
  5182. this._draw(context, invalidatedRectangle);
  5183. }
  5184. if (this.useBitmapCache && this._wasDirty) {
  5185. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5186. }
  5187. this._renderHighlight(context);
  5188. if (this.onAfterDrawObservable.hasObservers()) {
  5189. this.onAfterDrawObservable.notifyObservers(this);
  5190. }
  5191. context.restore();
  5192. return true;
  5193. };
  5194. /** @hidden */
  5195. Control.prototype._draw = function (context, invalidatedRectangle) {
  5196. // Do nothing
  5197. };
  5198. /**
  5199. * Tests if a given coordinates belong to the current control
  5200. * @param x defines x coordinate to test
  5201. * @param y defines y coordinate to test
  5202. * @returns true if the coordinates are inside the control
  5203. */
  5204. Control.prototype.contains = function (x, y) {
  5205. // Invert transform
  5206. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5207. x = this._transformedPosition.x;
  5208. y = this._transformedPosition.y;
  5209. // Check
  5210. if (x < this._currentMeasure.left) {
  5211. return false;
  5212. }
  5213. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5214. return false;
  5215. }
  5216. if (y < this._currentMeasure.top) {
  5217. return false;
  5218. }
  5219. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5220. return false;
  5221. }
  5222. if (this.isPointerBlocker) {
  5223. this._host._shouldBlockPointer = true;
  5224. }
  5225. return true;
  5226. };
  5227. /** @hidden */
  5228. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex, deltaX, deltaY) {
  5229. if (!this._isEnabled) {
  5230. return false;
  5231. }
  5232. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5233. return false;
  5234. }
  5235. if (!this.contains(x, y)) {
  5236. return false;
  5237. }
  5238. this._processObservables(type, x, y, pointerId, buttonIndex, deltaX, deltaY);
  5239. return true;
  5240. };
  5241. /** @hidden */
  5242. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5243. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5244. if (canNotify && this.parent != null) {
  5245. this.parent._onPointerMove(target, coordinates, pointerId);
  5246. }
  5247. };
  5248. /** @hidden */
  5249. Control.prototype._onPointerEnter = function (target) {
  5250. if (!this._isEnabled) {
  5251. return false;
  5252. }
  5253. if (this._enterCount > 0) {
  5254. return false;
  5255. }
  5256. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5257. this._enterCount = 0;
  5258. }
  5259. this._enterCount++;
  5260. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5261. if (canNotify && this.parent != null) {
  5262. this.parent._onPointerEnter(target);
  5263. }
  5264. return true;
  5265. };
  5266. /** @hidden */
  5267. Control.prototype._onPointerOut = function (target, force) {
  5268. if (force === void 0) { force = false; }
  5269. if (!force && (!this._isEnabled || target === this)) {
  5270. return;
  5271. }
  5272. this._enterCount = 0;
  5273. var canNotify = true;
  5274. if (!target.isAscendant(this)) {
  5275. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5276. }
  5277. if (canNotify && this.parent != null) {
  5278. this.parent._onPointerOut(target, force);
  5279. }
  5280. };
  5281. /** @hidden */
  5282. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5283. // Prevent pointerout to lose control context.
  5284. // Event redundancy is checked inside the function.
  5285. this._onPointerEnter(this);
  5286. if (this._downCount !== 0) {
  5287. return false;
  5288. }
  5289. this._downCount++;
  5290. this._downPointerIds[pointerId] = true;
  5291. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5292. if (canNotify && this.parent != null) {
  5293. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5294. }
  5295. return true;
  5296. };
  5297. /** @hidden */
  5298. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5299. if (!this._isEnabled) {
  5300. return;
  5301. }
  5302. this._downCount = 0;
  5303. delete this._downPointerIds[pointerId];
  5304. var canNotifyClick = notifyClick;
  5305. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5306. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5307. }
  5308. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5309. if (canNotify && this.parent != null) {
  5310. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5311. }
  5312. };
  5313. /** @hidden */
  5314. Control.prototype._forcePointerUp = function (pointerId) {
  5315. if (pointerId === void 0) { pointerId = null; }
  5316. if (pointerId !== null) {
  5317. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5318. }
  5319. else {
  5320. for (var key in this._downPointerIds) {
  5321. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5322. }
  5323. }
  5324. };
  5325. /** @hidden */
  5326. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5327. if (!this._isEnabled) {
  5328. return;
  5329. }
  5330. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"](deltaX, deltaY));
  5331. if (canNotify && this.parent != null) {
  5332. this.parent._onWheelScroll(deltaX, deltaY);
  5333. }
  5334. };
  5335. /** @hidden */
  5336. Control.prototype._onCanvasBlur = function () { };
  5337. /** @hidden */
  5338. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex, deltaX, deltaY) {
  5339. if (!this._isEnabled) {
  5340. return false;
  5341. }
  5342. this._dummyVector2.copyFromFloats(x, y);
  5343. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5344. this._onPointerMove(this, this._dummyVector2, pointerId);
  5345. var previousControlOver = this._host._lastControlOver[pointerId];
  5346. if (previousControlOver && previousControlOver !== this) {
  5347. previousControlOver._onPointerOut(this);
  5348. }
  5349. if (previousControlOver !== this) {
  5350. this._onPointerEnter(this);
  5351. }
  5352. this._host._lastControlOver[pointerId] = this;
  5353. return true;
  5354. }
  5355. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5356. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5357. this._host._registerLastControlDown(this, pointerId);
  5358. this._host._lastPickedControl = this;
  5359. return true;
  5360. }
  5361. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5362. if (this._host._lastControlDown[pointerId]) {
  5363. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5364. }
  5365. delete this._host._lastControlDown[pointerId];
  5366. return true;
  5367. }
  5368. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL) {
  5369. if (this._host._lastControlOver[pointerId]) {
  5370. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5371. return true;
  5372. }
  5373. }
  5374. return false;
  5375. };
  5376. Control.prototype._prepareFont = function () {
  5377. if (!this._font && !this._fontSet) {
  5378. return;
  5379. }
  5380. if (this._style) {
  5381. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5382. }
  5383. else {
  5384. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5385. }
  5386. this._fontOffset = Control._GetFontOffset(this._font);
  5387. };
  5388. /** Releases associated resources */
  5389. Control.prototype.dispose = function () {
  5390. this.onDirtyObservable.clear();
  5391. this.onBeforeDrawObservable.clear();
  5392. this.onAfterDrawObservable.clear();
  5393. this.onPointerDownObservable.clear();
  5394. this.onPointerEnterObservable.clear();
  5395. this.onPointerMoveObservable.clear();
  5396. this.onPointerOutObservable.clear();
  5397. this.onPointerUpObservable.clear();
  5398. this.onPointerClickObservable.clear();
  5399. this.onWheelObservable.clear();
  5400. if (this._styleObserver && this._style) {
  5401. this._style.onChangedObservable.remove(this._styleObserver);
  5402. this._styleObserver = null;
  5403. }
  5404. if (this.parent) {
  5405. this.parent.removeControl(this);
  5406. this.parent = null;
  5407. }
  5408. if (this._host) {
  5409. var index = this._host._linkedControls.indexOf(this);
  5410. if (index > -1) {
  5411. this.linkWithMesh(null);
  5412. }
  5413. }
  5414. // Callback
  5415. this.onDisposeObservable.notifyObservers(this);
  5416. this.onDisposeObservable.clear();
  5417. };
  5418. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5419. /** HORIZONTAL_ALIGNMENT_LEFT */
  5420. get: function () {
  5421. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5422. },
  5423. enumerable: false,
  5424. configurable: true
  5425. });
  5426. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5427. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5428. get: function () {
  5429. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5430. },
  5431. enumerable: false,
  5432. configurable: true
  5433. });
  5434. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5435. /** HORIZONTAL_ALIGNMENT_CENTER */
  5436. get: function () {
  5437. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5438. },
  5439. enumerable: false,
  5440. configurable: true
  5441. });
  5442. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5443. /** VERTICAL_ALIGNMENT_TOP */
  5444. get: function () {
  5445. return Control._VERTICAL_ALIGNMENT_TOP;
  5446. },
  5447. enumerable: false,
  5448. configurable: true
  5449. });
  5450. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5451. /** VERTICAL_ALIGNMENT_BOTTOM */
  5452. get: function () {
  5453. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5454. },
  5455. enumerable: false,
  5456. configurable: true
  5457. });
  5458. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5459. /** VERTICAL_ALIGNMENT_CENTER */
  5460. get: function () {
  5461. return Control._VERTICAL_ALIGNMENT_CENTER;
  5462. },
  5463. enumerable: false,
  5464. configurable: true
  5465. });
  5466. /** @hidden */
  5467. Control._GetFontOffset = function (font) {
  5468. if (Control._FontHeightSizes[font]) {
  5469. return Control._FontHeightSizes[font];
  5470. }
  5471. var text = document.createElement("span");
  5472. text.innerHTML = "Hg";
  5473. text.style.font = font;
  5474. var block = document.createElement("div");
  5475. block.style.display = "inline-block";
  5476. block.style.width = "1px";
  5477. block.style.height = "0px";
  5478. block.style.verticalAlign = "bottom";
  5479. var div = document.createElement("div");
  5480. div.style.whiteSpace = "nowrap";
  5481. div.appendChild(text);
  5482. div.appendChild(block);
  5483. document.body.appendChild(div);
  5484. var fontAscent = 0;
  5485. var fontHeight = 0;
  5486. try {
  5487. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5488. block.style.verticalAlign = "baseline";
  5489. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5490. }
  5491. finally {
  5492. document.body.removeChild(div);
  5493. }
  5494. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5495. Control._FontHeightSizes[font] = result;
  5496. return result;
  5497. };
  5498. /** @hidden */
  5499. Control.drawEllipse = function (x, y, width, height, context) {
  5500. context.translate(x, y);
  5501. context.scale(width, height);
  5502. context.beginPath();
  5503. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5504. context.closePath();
  5505. context.scale(1 / width, 1 / height);
  5506. context.translate(-x, -y);
  5507. };
  5508. /**
  5509. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5510. */
  5511. Control.AllowAlphaInheritance = false;
  5512. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5513. // Statics
  5514. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5515. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5516. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5517. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5518. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5519. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5520. Control._FontHeightSizes = {};
  5521. /**
  5522. * Creates a stack panel that can be used to render headers
  5523. * @param control defines the control to associate with the header
  5524. * @param text defines the text of the header
  5525. * @param size defines the size of the header
  5526. * @param options defines options used to configure the header
  5527. * @returns a new StackPanel
  5528. * @ignore
  5529. * @hidden
  5530. */
  5531. Control.AddHeader = function () { };
  5532. return Control;
  5533. }());
  5534. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5535. /***/ }),
  5536. /***/ "./2D/controls/displayGrid.ts":
  5537. /*!************************************!*\
  5538. !*** ./2D/controls/displayGrid.ts ***!
  5539. \************************************/
  5540. /*! exports provided: DisplayGrid */
  5541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5542. "use strict";
  5543. __webpack_require__.r(__webpack_exports__);
  5544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5545. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5546. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5547. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  5548. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5549. /** Class used to render a grid */
  5550. var DisplayGrid = /** @class */ (function (_super) {
  5551. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5552. /**
  5553. * Creates a new GridDisplayRectangle
  5554. * @param name defines the control name
  5555. */
  5556. function DisplayGrid(name) {
  5557. var _this = _super.call(this, name) || this;
  5558. _this.name = name;
  5559. _this._cellWidth = 20;
  5560. _this._cellHeight = 20;
  5561. _this._minorLineTickness = 1;
  5562. _this._minorLineColor = "DarkGray";
  5563. _this._majorLineTickness = 2;
  5564. _this._majorLineColor = "White";
  5565. _this._majorLineFrequency = 5;
  5566. _this._background = "Black";
  5567. _this._displayMajorLines = true;
  5568. _this._displayMinorLines = true;
  5569. return _this;
  5570. }
  5571. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5572. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5573. get: function () {
  5574. return this._displayMinorLines;
  5575. },
  5576. set: function (value) {
  5577. if (this._displayMinorLines === value) {
  5578. return;
  5579. }
  5580. this._displayMinorLines = value;
  5581. this._markAsDirty();
  5582. },
  5583. enumerable: false,
  5584. configurable: true
  5585. });
  5586. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5587. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5588. get: function () {
  5589. return this._displayMajorLines;
  5590. },
  5591. set: function (value) {
  5592. if (this._displayMajorLines === value) {
  5593. return;
  5594. }
  5595. this._displayMajorLines = value;
  5596. this._markAsDirty();
  5597. },
  5598. enumerable: false,
  5599. configurable: true
  5600. });
  5601. Object.defineProperty(DisplayGrid.prototype, "background", {
  5602. /** Gets or sets background color (Black by default) */
  5603. get: function () {
  5604. return this._background;
  5605. },
  5606. set: function (value) {
  5607. if (this._background === value) {
  5608. return;
  5609. }
  5610. this._background = value;
  5611. this._markAsDirty();
  5612. },
  5613. enumerable: false,
  5614. configurable: true
  5615. });
  5616. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5617. /** Gets or sets the width of each cell (20 by default) */
  5618. get: function () {
  5619. return this._cellWidth;
  5620. },
  5621. set: function (value) {
  5622. this._cellWidth = value;
  5623. this._markAsDirty();
  5624. },
  5625. enumerable: false,
  5626. configurable: true
  5627. });
  5628. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5629. /** Gets or sets the height of each cell (20 by default) */
  5630. get: function () {
  5631. return this._cellHeight;
  5632. },
  5633. set: function (value) {
  5634. this._cellHeight = value;
  5635. this._markAsDirty();
  5636. },
  5637. enumerable: false,
  5638. configurable: true
  5639. });
  5640. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5641. /** Gets or sets the tickness of minor lines (1 by default) */
  5642. get: function () {
  5643. return this._minorLineTickness;
  5644. },
  5645. set: function (value) {
  5646. this._minorLineTickness = value;
  5647. this._markAsDirty();
  5648. },
  5649. enumerable: false,
  5650. configurable: true
  5651. });
  5652. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5653. /** Gets or sets the color of minor lines (DarkGray by default) */
  5654. get: function () {
  5655. return this._minorLineColor;
  5656. },
  5657. set: function (value) {
  5658. this._minorLineColor = value;
  5659. this._markAsDirty();
  5660. },
  5661. enumerable: false,
  5662. configurable: true
  5663. });
  5664. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5665. /** Gets or sets the tickness of major lines (2 by default) */
  5666. get: function () {
  5667. return this._majorLineTickness;
  5668. },
  5669. set: function (value) {
  5670. this._majorLineTickness = value;
  5671. this._markAsDirty();
  5672. },
  5673. enumerable: false,
  5674. configurable: true
  5675. });
  5676. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5677. /** Gets or sets the color of major lines (White by default) */
  5678. get: function () {
  5679. return this._majorLineColor;
  5680. },
  5681. set: function (value) {
  5682. this._majorLineColor = value;
  5683. this._markAsDirty();
  5684. },
  5685. enumerable: false,
  5686. configurable: true
  5687. });
  5688. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5689. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5690. get: function () {
  5691. return this._majorLineFrequency;
  5692. },
  5693. set: function (value) {
  5694. this._majorLineFrequency = value;
  5695. this._markAsDirty();
  5696. },
  5697. enumerable: false,
  5698. configurable: true
  5699. });
  5700. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5701. context.save();
  5702. this._applyStates(context);
  5703. if (this._isEnabled) {
  5704. if (this._background) {
  5705. context.fillStyle = this._background;
  5706. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5707. }
  5708. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5709. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5710. // Minor lines
  5711. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5712. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5713. if (this._displayMinorLines) {
  5714. context.strokeStyle = this._minorLineColor;
  5715. context.lineWidth = this._minorLineTickness;
  5716. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5717. var cellX = left + x * this.cellWidth;
  5718. context.beginPath();
  5719. context.moveTo(cellX, this._currentMeasure.top);
  5720. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5721. context.stroke();
  5722. }
  5723. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5724. var cellY = top_1 + y * this.cellHeight;
  5725. context.beginPath();
  5726. context.moveTo(this._currentMeasure.left, cellY);
  5727. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5728. context.stroke();
  5729. }
  5730. }
  5731. // Major lines
  5732. if (this._displayMajorLines) {
  5733. context.strokeStyle = this._majorLineColor;
  5734. context.lineWidth = this._majorLineTickness;
  5735. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5736. var cellX = left + x * this.cellWidth;
  5737. context.beginPath();
  5738. context.moveTo(cellX, this._currentMeasure.top);
  5739. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5740. context.stroke();
  5741. }
  5742. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5743. var cellY = top_1 + y * this.cellHeight;
  5744. context.moveTo(this._currentMeasure.left, cellY);
  5745. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5746. context.closePath();
  5747. context.stroke();
  5748. }
  5749. }
  5750. }
  5751. context.restore();
  5752. };
  5753. DisplayGrid.prototype._getTypeName = function () {
  5754. return "DisplayGrid";
  5755. };
  5756. return DisplayGrid;
  5757. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5758. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5759. /***/ }),
  5760. /***/ "./2D/controls/ellipse.ts":
  5761. /*!********************************!*\
  5762. !*** ./2D/controls/ellipse.ts ***!
  5763. \********************************/
  5764. /*! exports provided: Ellipse */
  5765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5766. "use strict";
  5767. __webpack_require__.r(__webpack_exports__);
  5768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5769. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5770. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5771. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5772. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  5773. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5774. /** Class used to create 2D ellipse containers */
  5775. var Ellipse = /** @class */ (function (_super) {
  5776. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5777. /**
  5778. * Creates a new Ellipse
  5779. * @param name defines the control name
  5780. */
  5781. function Ellipse(name) {
  5782. var _this = _super.call(this, name) || this;
  5783. _this.name = name;
  5784. _this._thickness = 1;
  5785. return _this;
  5786. }
  5787. Object.defineProperty(Ellipse.prototype, "thickness", {
  5788. /** Gets or sets border thickness */
  5789. get: function () {
  5790. return this._thickness;
  5791. },
  5792. set: function (value) {
  5793. if (this._thickness === value) {
  5794. return;
  5795. }
  5796. this._thickness = value;
  5797. this._markAsDirty();
  5798. },
  5799. enumerable: false,
  5800. configurable: true
  5801. });
  5802. Ellipse.prototype._getTypeName = function () {
  5803. return "Ellipse";
  5804. };
  5805. Ellipse.prototype._localDraw = function (context) {
  5806. context.save();
  5807. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5808. context.shadowColor = this.shadowColor;
  5809. context.shadowBlur = this.shadowBlur;
  5810. context.shadowOffsetX = this.shadowOffsetX;
  5811. context.shadowOffsetY = this.shadowOffsetY;
  5812. }
  5813. _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);
  5814. if (this._background) {
  5815. context.fillStyle = this._background;
  5816. context.fill();
  5817. }
  5818. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5819. context.shadowBlur = 0;
  5820. context.shadowOffsetX = 0;
  5821. context.shadowOffsetY = 0;
  5822. }
  5823. if (this._thickness) {
  5824. if (this.color) {
  5825. context.strokeStyle = this.color;
  5826. }
  5827. context.lineWidth = this._thickness;
  5828. context.stroke();
  5829. }
  5830. context.restore();
  5831. };
  5832. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5833. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5834. this._measureForChildren.width -= 2 * this._thickness;
  5835. this._measureForChildren.height -= 2 * this._thickness;
  5836. this._measureForChildren.left += this._thickness;
  5837. this._measureForChildren.top += this._thickness;
  5838. };
  5839. Ellipse.prototype._clipForChildren = function (context) {
  5840. _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);
  5841. context.clip();
  5842. };
  5843. return Ellipse;
  5844. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5845. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5846. /***/ }),
  5847. /***/ "./2D/controls/grid.ts":
  5848. /*!*****************************!*\
  5849. !*** ./2D/controls/grid.ts ***!
  5850. \*****************************/
  5851. /*! exports provided: Grid */
  5852. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5853. "use strict";
  5854. __webpack_require__.r(__webpack_exports__);
  5855. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5856. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5857. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5858. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5859. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5860. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  5861. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5862. /**
  5863. * Class used to create a 2D grid container
  5864. */
  5865. var Grid = /** @class */ (function (_super) {
  5866. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5867. /**
  5868. * Creates a new Grid
  5869. * @param name defines control name
  5870. */
  5871. function Grid(name) {
  5872. var _this = _super.call(this, name) || this;
  5873. _this.name = name;
  5874. _this._rowDefinitions = new Array();
  5875. _this._columnDefinitions = new Array();
  5876. _this._cells = {};
  5877. _this._childControls = new Array();
  5878. return _this;
  5879. }
  5880. Object.defineProperty(Grid.prototype, "columnCount", {
  5881. /**
  5882. * Gets the number of columns
  5883. */
  5884. get: function () {
  5885. return this._columnDefinitions.length;
  5886. },
  5887. enumerable: false,
  5888. configurable: true
  5889. });
  5890. Object.defineProperty(Grid.prototype, "rowCount", {
  5891. /**
  5892. * Gets the number of rows
  5893. */
  5894. get: function () {
  5895. return this._rowDefinitions.length;
  5896. },
  5897. enumerable: false,
  5898. configurable: true
  5899. });
  5900. Object.defineProperty(Grid.prototype, "children", {
  5901. /** Gets the list of children */
  5902. get: function () {
  5903. return this._childControls;
  5904. },
  5905. enumerable: false,
  5906. configurable: true
  5907. });
  5908. Object.defineProperty(Grid.prototype, "cells", {
  5909. /** Gets the list of cells (e.g. the containers) */
  5910. get: function () {
  5911. return this._cells;
  5912. },
  5913. enumerable: false,
  5914. configurable: true
  5915. });
  5916. /**
  5917. * Gets the definition of a specific row
  5918. * @param index defines the index of the row
  5919. * @returns the row definition
  5920. */
  5921. Grid.prototype.getRowDefinition = function (index) {
  5922. if (index < 0 || index >= this._rowDefinitions.length) {
  5923. return null;
  5924. }
  5925. return this._rowDefinitions[index];
  5926. };
  5927. /**
  5928. * Gets the definition of a specific column
  5929. * @param index defines the index of the column
  5930. * @returns the column definition
  5931. */
  5932. Grid.prototype.getColumnDefinition = function (index) {
  5933. if (index < 0 || index >= this._columnDefinitions.length) {
  5934. return null;
  5935. }
  5936. return this._columnDefinitions[index];
  5937. };
  5938. /**
  5939. * Adds a new row to the grid
  5940. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5941. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5942. * @returns the current grid
  5943. */
  5944. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5945. if (isPixel === void 0) { isPixel = false; }
  5946. 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));
  5947. this._markAsDirty();
  5948. return this;
  5949. };
  5950. /**
  5951. * Adds a new column to the grid
  5952. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5953. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5954. * @returns the current grid
  5955. */
  5956. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5957. if (isPixel === void 0) { isPixel = false; }
  5958. 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));
  5959. this._markAsDirty();
  5960. return this;
  5961. };
  5962. /**
  5963. * Update a row definition
  5964. * @param index defines the index of the row to update
  5965. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5966. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5967. * @returns the current grid
  5968. */
  5969. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5970. if (isPixel === void 0) { isPixel = false; }
  5971. if (index < 0 || index >= this._rowDefinitions.length) {
  5972. return this;
  5973. }
  5974. var current = this._rowDefinitions[index];
  5975. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5976. return this;
  5977. }
  5978. 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);
  5979. this._markAsDirty();
  5980. return this;
  5981. };
  5982. /**
  5983. * Update a column definition
  5984. * @param index defines the index of the column to update
  5985. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5986. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5987. * @returns the current grid
  5988. */
  5989. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5990. if (isPixel === void 0) { isPixel = false; }
  5991. if (index < 0 || index >= this._columnDefinitions.length) {
  5992. return this;
  5993. }
  5994. var current = this._columnDefinitions[index];
  5995. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5996. return this;
  5997. }
  5998. 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);
  5999. this._markAsDirty();
  6000. return this;
  6001. };
  6002. /**
  6003. * Gets the list of children stored in a specific cell
  6004. * @param row defines the row to check
  6005. * @param column defines the column to check
  6006. * @returns the list of controls
  6007. */
  6008. Grid.prototype.getChildrenAt = function (row, column) {
  6009. var cell = this._cells[row + ":" + column];
  6010. if (!cell) {
  6011. return null;
  6012. }
  6013. return cell.children;
  6014. };
  6015. /**
  6016. * Gets a string representing the child cell info (row x column)
  6017. * @param child defines the control to get info from
  6018. * @returns a string containing the child cell info (row x column)
  6019. */
  6020. Grid.prototype.getChildCellInfo = function (child) {
  6021. return child._tag;
  6022. };
  6023. Grid.prototype._removeCell = function (cell, key) {
  6024. if (!cell) {
  6025. return;
  6026. }
  6027. _super.prototype.removeControl.call(this, cell);
  6028. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  6029. var control = _a[_i];
  6030. var childIndex = this._childControls.indexOf(control);
  6031. if (childIndex !== -1) {
  6032. this._childControls.splice(childIndex, 1);
  6033. }
  6034. }
  6035. delete this._cells[key];
  6036. };
  6037. Grid.prototype._offsetCell = function (previousKey, key) {
  6038. if (!this._cells[key]) {
  6039. return;
  6040. }
  6041. this._cells[previousKey] = this._cells[key];
  6042. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  6043. var control = _a[_i];
  6044. control._tag = previousKey;
  6045. }
  6046. delete this._cells[key];
  6047. };
  6048. /**
  6049. * Remove a column definition at specified index
  6050. * @param index defines the index of the column to remove
  6051. * @returns the current grid
  6052. */
  6053. Grid.prototype.removeColumnDefinition = function (index) {
  6054. if (index < 0 || index >= this._columnDefinitions.length) {
  6055. return this;
  6056. }
  6057. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6058. var key = x + ":" + index;
  6059. var cell = this._cells[key];
  6060. this._removeCell(cell, key);
  6061. }
  6062. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6063. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6064. var previousKey = x + ":" + (y - 1);
  6065. var key = x + ":" + y;
  6066. this._offsetCell(previousKey, key);
  6067. }
  6068. }
  6069. this._columnDefinitions.splice(index, 1);
  6070. this._markAsDirty();
  6071. return this;
  6072. };
  6073. /**
  6074. * Remove a row definition at specified index
  6075. * @param index defines the index of the row to remove
  6076. * @returns the current grid
  6077. */
  6078. Grid.prototype.removeRowDefinition = function (index) {
  6079. if (index < 0 || index >= this._rowDefinitions.length) {
  6080. return this;
  6081. }
  6082. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6083. var key = index + ":" + y;
  6084. var cell = this._cells[key];
  6085. this._removeCell(cell, key);
  6086. }
  6087. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6088. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6089. var previousKey = x - 1 + ":" + y;
  6090. var key = x + ":" + y;
  6091. this._offsetCell(previousKey, key);
  6092. }
  6093. }
  6094. this._rowDefinitions.splice(index, 1);
  6095. this._markAsDirty();
  6096. return this;
  6097. };
  6098. /**
  6099. * Adds a new control to the current grid
  6100. * @param control defines the control to add
  6101. * @param row defines the row where to add the control (0 by default)
  6102. * @param column defines the column where to add the control (0 by default)
  6103. * @returns the current grid
  6104. */
  6105. Grid.prototype.addControl = function (control, row, column) {
  6106. if (row === void 0) { row = 0; }
  6107. if (column === void 0) { column = 0; }
  6108. if (this._rowDefinitions.length === 0) {
  6109. // Add default row definition
  6110. this.addRowDefinition(1, false);
  6111. }
  6112. if (this._columnDefinitions.length === 0) {
  6113. // Add default column definition
  6114. this.addColumnDefinition(1, false);
  6115. }
  6116. if (this._childControls.indexOf(control) !== -1) {
  6117. 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");
  6118. return this;
  6119. }
  6120. var x = Math.min(row, this._rowDefinitions.length - 1);
  6121. var y = Math.min(column, this._columnDefinitions.length - 1);
  6122. var key = x + ":" + y;
  6123. var goodContainer = this._cells[key];
  6124. if (!goodContainer) {
  6125. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6126. this._cells[key] = goodContainer;
  6127. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6128. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6129. _super.prototype.addControl.call(this, goodContainer);
  6130. }
  6131. goodContainer.addControl(control);
  6132. this._childControls.push(control);
  6133. control._tag = key;
  6134. control.parent = this;
  6135. this._markAsDirty();
  6136. return this;
  6137. };
  6138. /**
  6139. * Removes a control from the current container
  6140. * @param control defines the control to remove
  6141. * @returns the current container
  6142. */
  6143. Grid.prototype.removeControl = function (control) {
  6144. var index = this._childControls.indexOf(control);
  6145. if (index !== -1) {
  6146. this._childControls.splice(index, 1);
  6147. }
  6148. var cell = this._cells[control._tag];
  6149. if (cell) {
  6150. cell.removeControl(control);
  6151. control._tag = null;
  6152. }
  6153. this._markAsDirty();
  6154. return this;
  6155. };
  6156. Grid.prototype._getTypeName = function () {
  6157. return "Grid";
  6158. };
  6159. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6160. var widths = [];
  6161. var heights = [];
  6162. var lefts = [];
  6163. var tops = [];
  6164. var availableWidth = this._currentMeasure.width;
  6165. var globalWidthPercentage = 0;
  6166. var availableHeight = this._currentMeasure.height;
  6167. var globalHeightPercentage = 0;
  6168. // Heights
  6169. var index = 0;
  6170. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6171. var value = _a[_i];
  6172. if (value.isPixel) {
  6173. var height = value.getValue(this._host);
  6174. availableHeight -= height;
  6175. heights[index] = height;
  6176. }
  6177. else {
  6178. globalHeightPercentage += value.internalValue;
  6179. }
  6180. index++;
  6181. }
  6182. var top = 0;
  6183. index = 0;
  6184. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6185. var value = _c[_b];
  6186. tops.push(top);
  6187. if (!value.isPixel) {
  6188. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6189. top += height;
  6190. heights[index] = height;
  6191. }
  6192. else {
  6193. top += value.getValue(this._host);
  6194. }
  6195. index++;
  6196. }
  6197. // Widths
  6198. index = 0;
  6199. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6200. var value = _e[_d];
  6201. if (value.isPixel) {
  6202. var width = value.getValue(this._host);
  6203. availableWidth -= width;
  6204. widths[index] = width;
  6205. }
  6206. else {
  6207. globalWidthPercentage += value.internalValue;
  6208. }
  6209. index++;
  6210. }
  6211. var left = 0;
  6212. index = 0;
  6213. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6214. var value = _g[_f];
  6215. lefts.push(left);
  6216. if (!value.isPixel) {
  6217. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6218. left += width;
  6219. widths[index] = width;
  6220. }
  6221. else {
  6222. left += value.getValue(this._host);
  6223. }
  6224. index++;
  6225. }
  6226. definitionCallback(lefts, tops, widths, heights);
  6227. };
  6228. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6229. var _this = this;
  6230. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6231. // Setting child sizes
  6232. for (var key in _this._cells) {
  6233. if (!_this._cells.hasOwnProperty(key)) {
  6234. continue;
  6235. }
  6236. var split = key.split(":");
  6237. var x = parseInt(split[0]);
  6238. var y = parseInt(split[1]);
  6239. var cell = _this._cells[key];
  6240. cell.left = lefts[y] + "px";
  6241. cell.top = tops[x] + "px";
  6242. cell.width = widths[y] + "px";
  6243. cell.height = heights[x] + "px";
  6244. cell._left.ignoreAdaptiveScaling = true;
  6245. cell._top.ignoreAdaptiveScaling = true;
  6246. cell._width.ignoreAdaptiveScaling = true;
  6247. cell._height.ignoreAdaptiveScaling = true;
  6248. }
  6249. });
  6250. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6251. };
  6252. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6253. for (var key in this._cells) {
  6254. if (!this._cells.hasOwnProperty(key)) {
  6255. continue;
  6256. }
  6257. var child = this._cells[key];
  6258. child._markMatrixAsDirty();
  6259. }
  6260. };
  6261. Grid.prototype._renderHighlightSpecific = function (context) {
  6262. var _this = this;
  6263. _super.prototype._renderHighlightSpecific.call(this, context);
  6264. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6265. // Columns
  6266. for (var index = 0; index < lefts.length; index++) {
  6267. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6268. context.beginPath();
  6269. context.moveTo(left, _this._currentMeasure.top);
  6270. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6271. context.stroke();
  6272. }
  6273. // Rows
  6274. for (var index = 0; index < tops.length; index++) {
  6275. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6276. context.beginPath();
  6277. context.moveTo(_this._currentMeasure.left, top_1);
  6278. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6279. context.stroke();
  6280. }
  6281. });
  6282. context.restore();
  6283. };
  6284. /** Releases associated resources */
  6285. Grid.prototype.dispose = function () {
  6286. _super.prototype.dispose.call(this);
  6287. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6288. var control = _a[_i];
  6289. control.dispose();
  6290. }
  6291. this._childControls = [];
  6292. };
  6293. return Grid;
  6294. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6295. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6296. /***/ }),
  6297. /***/ "./2D/controls/image.ts":
  6298. /*!******************************!*\
  6299. !*** ./2D/controls/image.ts ***!
  6300. \******************************/
  6301. /*! exports provided: Image */
  6302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6303. "use strict";
  6304. __webpack_require__.r(__webpack_exports__);
  6305. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6306. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6307. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6308. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6309. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6310. /**
  6311. * Class used to create 2D images
  6312. */
  6313. var Image = /** @class */ (function (_super) {
  6314. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6315. /**
  6316. * Creates a new Image
  6317. * @param name defines the control name
  6318. * @param url defines the image url
  6319. */
  6320. function Image(name, url) {
  6321. if (url === void 0) { url = null; }
  6322. var _this = _super.call(this, name) || this;
  6323. _this.name = name;
  6324. _this._workingCanvas = null;
  6325. _this._loaded = false;
  6326. _this._stretch = Image.STRETCH_FILL;
  6327. _this._autoScale = false;
  6328. _this._sourceLeft = 0;
  6329. _this._sourceTop = 0;
  6330. _this._sourceWidth = 0;
  6331. _this._sourceHeight = 0;
  6332. _this._svgAttributesComputationCompleted = false;
  6333. _this._isSVG = false;
  6334. _this._cellWidth = 0;
  6335. _this._cellHeight = 0;
  6336. _this._cellId = -1;
  6337. _this._populateNinePatchSlicesFromImage = false;
  6338. _this._imageDataCache = { data: null, key: "" };
  6339. /**
  6340. * Observable notified when the content is loaded
  6341. */
  6342. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6343. /**
  6344. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6345. */
  6346. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6347. _this.source = url;
  6348. return _this;
  6349. }
  6350. Object.defineProperty(Image.prototype, "isLoaded", {
  6351. /**
  6352. * Gets a boolean indicating that the content is loaded
  6353. */
  6354. get: function () {
  6355. return this._loaded;
  6356. },
  6357. enumerable: false,
  6358. configurable: true
  6359. });
  6360. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6361. /**
  6362. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6363. */
  6364. get: function () {
  6365. return this._populateNinePatchSlicesFromImage;
  6366. },
  6367. set: function (value) {
  6368. if (this._populateNinePatchSlicesFromImage === value) {
  6369. return;
  6370. }
  6371. this._populateNinePatchSlicesFromImage = value;
  6372. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6373. this._extractNinePatchSliceDataFromImage();
  6374. }
  6375. },
  6376. enumerable: false,
  6377. configurable: true
  6378. });
  6379. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6380. /**
  6381. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6382. * Beware using this as this will comsume more memory as the image has to be stored twice
  6383. */
  6384. get: function () {
  6385. return this._detectPointerOnOpaqueOnly;
  6386. },
  6387. set: function (value) {
  6388. if (this._detectPointerOnOpaqueOnly === value) {
  6389. return;
  6390. }
  6391. this._detectPointerOnOpaqueOnly = value;
  6392. },
  6393. enumerable: false,
  6394. configurable: true
  6395. });
  6396. Object.defineProperty(Image.prototype, "sliceLeft", {
  6397. /**
  6398. * Gets or sets the left value for slicing (9-patch)
  6399. */
  6400. get: function () {
  6401. return this._sliceLeft;
  6402. },
  6403. set: function (value) {
  6404. if (this._sliceLeft === value) {
  6405. return;
  6406. }
  6407. this._sliceLeft = value;
  6408. this._markAsDirty();
  6409. },
  6410. enumerable: false,
  6411. configurable: true
  6412. });
  6413. Object.defineProperty(Image.prototype, "sliceRight", {
  6414. /**
  6415. * Gets or sets the right value for slicing (9-patch)
  6416. */
  6417. get: function () {
  6418. return this._sliceRight;
  6419. },
  6420. set: function (value) {
  6421. if (this._sliceRight === value) {
  6422. return;
  6423. }
  6424. this._sliceRight = value;
  6425. this._markAsDirty();
  6426. },
  6427. enumerable: false,
  6428. configurable: true
  6429. });
  6430. Object.defineProperty(Image.prototype, "sliceTop", {
  6431. /**
  6432. * Gets or sets the top value for slicing (9-patch)
  6433. */
  6434. get: function () {
  6435. return this._sliceTop;
  6436. },
  6437. set: function (value) {
  6438. if (this._sliceTop === value) {
  6439. return;
  6440. }
  6441. this._sliceTop = value;
  6442. this._markAsDirty();
  6443. },
  6444. enumerable: false,
  6445. configurable: true
  6446. });
  6447. Object.defineProperty(Image.prototype, "sliceBottom", {
  6448. /**
  6449. * Gets or sets the bottom value for slicing (9-patch)
  6450. */
  6451. get: function () {
  6452. return this._sliceBottom;
  6453. },
  6454. set: function (value) {
  6455. if (this._sliceBottom === value) {
  6456. return;
  6457. }
  6458. this._sliceBottom = value;
  6459. this._markAsDirty();
  6460. },
  6461. enumerable: false,
  6462. configurable: true
  6463. });
  6464. Object.defineProperty(Image.prototype, "sourceLeft", {
  6465. /**
  6466. * Gets or sets the left coordinate in the source image
  6467. */
  6468. get: function () {
  6469. return this._sourceLeft;
  6470. },
  6471. set: function (value) {
  6472. if (this._sourceLeft === value) {
  6473. return;
  6474. }
  6475. this._sourceLeft = value;
  6476. this._markAsDirty();
  6477. },
  6478. enumerable: false,
  6479. configurable: true
  6480. });
  6481. Object.defineProperty(Image.prototype, "sourceTop", {
  6482. /**
  6483. * Gets or sets the top coordinate in the source image
  6484. */
  6485. get: function () {
  6486. return this._sourceTop;
  6487. },
  6488. set: function (value) {
  6489. if (this._sourceTop === value) {
  6490. return;
  6491. }
  6492. this._sourceTop = value;
  6493. this._markAsDirty();
  6494. },
  6495. enumerable: false,
  6496. configurable: true
  6497. });
  6498. Object.defineProperty(Image.prototype, "sourceWidth", {
  6499. /**
  6500. * Gets or sets the width to capture in the source image
  6501. */
  6502. get: function () {
  6503. return this._sourceWidth;
  6504. },
  6505. set: function (value) {
  6506. if (this._sourceWidth === value) {
  6507. return;
  6508. }
  6509. this._sourceWidth = value;
  6510. this._markAsDirty();
  6511. },
  6512. enumerable: false,
  6513. configurable: true
  6514. });
  6515. Object.defineProperty(Image.prototype, "sourceHeight", {
  6516. /**
  6517. * Gets or sets the height to capture in the source image
  6518. */
  6519. get: function () {
  6520. return this._sourceHeight;
  6521. },
  6522. set: function (value) {
  6523. if (this._sourceHeight === value) {
  6524. return;
  6525. }
  6526. this._sourceHeight = value;
  6527. this._markAsDirty();
  6528. },
  6529. enumerable: false,
  6530. configurable: true
  6531. });
  6532. Object.defineProperty(Image.prototype, "isSVG", {
  6533. /** Indicates if the format of the image is SVG */
  6534. get: function () {
  6535. return this._isSVG;
  6536. },
  6537. enumerable: false,
  6538. configurable: true
  6539. });
  6540. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6541. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6542. get: function () {
  6543. return this._svgAttributesComputationCompleted;
  6544. },
  6545. enumerable: false,
  6546. configurable: true
  6547. });
  6548. Object.defineProperty(Image.prototype, "autoScale", {
  6549. /**
  6550. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6551. * @see https://doc.babylonjs.com/how_to/gui#image
  6552. */
  6553. get: function () {
  6554. return this._autoScale;
  6555. },
  6556. set: function (value) {
  6557. if (this._autoScale === value) {
  6558. return;
  6559. }
  6560. this._autoScale = value;
  6561. if (value && this._loaded) {
  6562. this.synchronizeSizeWithContent();
  6563. }
  6564. },
  6565. enumerable: false,
  6566. configurable: true
  6567. });
  6568. Object.defineProperty(Image.prototype, "stretch", {
  6569. /** Gets or sets the streching mode used by the image */
  6570. get: function () {
  6571. return this._stretch;
  6572. },
  6573. set: function (value) {
  6574. if (this._stretch === value) {
  6575. return;
  6576. }
  6577. this._stretch = value;
  6578. this._markAsDirty();
  6579. },
  6580. enumerable: false,
  6581. configurable: true
  6582. });
  6583. /** @hidden */
  6584. Image.prototype._rotate90 = function (n, preserveProperties) {
  6585. if (preserveProperties === void 0) { preserveProperties = false; }
  6586. var canvas = document.createElement('canvas');
  6587. var context = canvas.getContext('2d');
  6588. var width = this._domImage.width;
  6589. var height = this._domImage.height;
  6590. canvas.width = height;
  6591. canvas.height = width;
  6592. context.translate(canvas.width / 2, canvas.height / 2);
  6593. context.rotate(n * Math.PI / 2);
  6594. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6595. var dataUrl = canvas.toDataURL("image/jpg");
  6596. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6597. if (preserveProperties) {
  6598. rotatedImage._stretch = this._stretch;
  6599. rotatedImage._autoScale = this._autoScale;
  6600. rotatedImage._cellId = this._cellId;
  6601. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6602. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6603. }
  6604. this._handleRotationForSVGImage(this, rotatedImage, n);
  6605. this._imageDataCache.data = null;
  6606. return rotatedImage;
  6607. };
  6608. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6609. var _this = this;
  6610. if (!srcImage._isSVG) {
  6611. return;
  6612. }
  6613. if (srcImage._svgAttributesComputationCompleted) {
  6614. this._rotate90SourceProperties(srcImage, dstImage, n);
  6615. this._markAsDirty();
  6616. }
  6617. else {
  6618. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6619. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6620. _this._markAsDirty();
  6621. });
  6622. }
  6623. };
  6624. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6625. var _a, _b;
  6626. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6627. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6628. if (n != 0) {
  6629. var mult = n < 0 ? -1 : 1;
  6630. n = n % 4;
  6631. for (var i = 0; i < Math.abs(n); ++i) {
  6632. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6633. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6634. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6635. if (n < 0) {
  6636. dstTop -= dstHeight;
  6637. }
  6638. else {
  6639. dstLeft -= dstWidth;
  6640. }
  6641. srcLeft = dstLeft;
  6642. srcTop = dstTop;
  6643. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6644. }
  6645. }
  6646. dstImage.sourceLeft = dstLeft;
  6647. dstImage.sourceTop = dstTop;
  6648. dstImage.sourceWidth = dstWidth;
  6649. dstImage.sourceHeight = dstHeight;
  6650. };
  6651. Object.defineProperty(Image.prototype, "domImage", {
  6652. get: function () {
  6653. return this._domImage;
  6654. },
  6655. /**
  6656. * Gets or sets the internal DOM image used to render the control
  6657. */
  6658. set: function (value) {
  6659. var _this = this;
  6660. this._domImage = value;
  6661. this._loaded = false;
  6662. this._imageDataCache.data = null;
  6663. if (this._domImage.width) {
  6664. this._onImageLoaded();
  6665. }
  6666. else {
  6667. this._domImage.onload = function () {
  6668. _this._onImageLoaded();
  6669. };
  6670. }
  6671. },
  6672. enumerable: false,
  6673. configurable: true
  6674. });
  6675. Image.prototype._onImageLoaded = function () {
  6676. this._imageDataCache.data = null;
  6677. this._imageWidth = this._domImage.width;
  6678. this._imageHeight = this._domImage.height;
  6679. this._loaded = true;
  6680. if (this._populateNinePatchSlicesFromImage) {
  6681. this._extractNinePatchSliceDataFromImage();
  6682. }
  6683. if (this._autoScale) {
  6684. this.synchronizeSizeWithContent();
  6685. }
  6686. this.onImageLoadedObservable.notifyObservers(this);
  6687. this._markAsDirty();
  6688. };
  6689. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6690. if (!this._workingCanvas) {
  6691. this._workingCanvas = document.createElement('canvas');
  6692. }
  6693. var canvas = this._workingCanvas;
  6694. var context = canvas.getContext('2d');
  6695. var width = this._domImage.width;
  6696. var height = this._domImage.height;
  6697. canvas.width = width;
  6698. canvas.height = height;
  6699. context.drawImage(this._domImage, 0, 0, width, height);
  6700. var imageData = context.getImageData(0, 0, width, height);
  6701. // Left and right
  6702. this._sliceLeft = -1;
  6703. this._sliceRight = -1;
  6704. for (var x = 0; x < width; x++) {
  6705. var alpha = imageData.data[x * 4 + 3];
  6706. if (alpha > 127 && this._sliceLeft === -1) {
  6707. this._sliceLeft = x;
  6708. continue;
  6709. }
  6710. if (alpha < 127 && this._sliceLeft > -1) {
  6711. this._sliceRight = x;
  6712. break;
  6713. }
  6714. }
  6715. // top and bottom
  6716. this._sliceTop = -1;
  6717. this._sliceBottom = -1;
  6718. for (var y = 0; y < height; y++) {
  6719. var alpha = imageData.data[y * width * 4 + 3];
  6720. if (alpha > 127 && this._sliceTop === -1) {
  6721. this._sliceTop = y;
  6722. continue;
  6723. }
  6724. if (alpha < 127 && this._sliceTop > -1) {
  6725. this._sliceBottom = y;
  6726. break;
  6727. }
  6728. }
  6729. };
  6730. Object.defineProperty(Image.prototype, "source", {
  6731. /**
  6732. * Gets or sets image source url
  6733. */
  6734. set: function (value) {
  6735. var _this = this;
  6736. if (this._source === value) {
  6737. return;
  6738. }
  6739. this._loaded = false;
  6740. this._source = value;
  6741. this._imageDataCache.data = null;
  6742. if (value) {
  6743. value = this._svgCheck(value);
  6744. }
  6745. this._domImage = document.createElement("img");
  6746. this._domImage.onload = function () {
  6747. _this._onImageLoaded();
  6748. };
  6749. if (value) {
  6750. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6751. this._domImage.src = value;
  6752. }
  6753. },
  6754. enumerable: false,
  6755. configurable: true
  6756. });
  6757. /**
  6758. * Checks for svg document with icon id present
  6759. */
  6760. Image.prototype._svgCheck = function (value) {
  6761. var _this = this;
  6762. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6763. this._isSVG = true;
  6764. var svgsrc = value.split('#')[0];
  6765. var elemid = value.split('#')[1];
  6766. // check if object alr exist in document
  6767. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6768. if (svgExist) {
  6769. var svgDoc = svgExist.contentDocument;
  6770. // get viewbox width and height, get svg document width and height in px
  6771. if (svgDoc && svgDoc.documentElement) {
  6772. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6773. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6774. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6775. var elem = svgDoc.getElementById(elemid);
  6776. if (elem && vb && docwidth && docheight) {
  6777. this._getSVGAttribs(svgExist, elemid);
  6778. return value;
  6779. }
  6780. }
  6781. // wait for object to load
  6782. svgExist.addEventListener("load", function () {
  6783. _this._getSVGAttribs(svgExist, elemid);
  6784. });
  6785. }
  6786. else {
  6787. // create document object
  6788. var svgImage = document.createElement("object");
  6789. svgImage.data = svgsrc;
  6790. svgImage.type = "image/svg+xml";
  6791. svgImage.width = "0%";
  6792. svgImage.height = "0%";
  6793. document.body.appendChild(svgImage);
  6794. // when the object has loaded, get the element attribs
  6795. svgImage.onload = function () {
  6796. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6797. if (svgobj) {
  6798. _this._getSVGAttribs(svgobj, elemid);
  6799. }
  6800. };
  6801. }
  6802. return svgsrc;
  6803. }
  6804. else {
  6805. return value;
  6806. }
  6807. };
  6808. /**
  6809. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6810. * given external svg file and icon id
  6811. */
  6812. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6813. var svgDoc = svgsrc.contentDocument;
  6814. // get viewbox width and height, get svg document width and height in px
  6815. if (svgDoc && svgDoc.documentElement) {
  6816. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6817. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6818. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6819. // get element bbox and matrix transform
  6820. var elem = svgDoc.getElementById(elemid);
  6821. if (vb && docwidth && docheight && elem) {
  6822. var vb_width = Number(vb.split(" ")[2]);
  6823. var vb_height = Number(vb.split(" ")[3]);
  6824. var elem_bbox = elem.getBBox();
  6825. var elem_matrix_a = 1;
  6826. var elem_matrix_d = 1;
  6827. var elem_matrix_e = 0;
  6828. var elem_matrix_f = 0;
  6829. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6830. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6831. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6832. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6833. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6834. }
  6835. // compute source coordinates and dimensions
  6836. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6837. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6838. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6839. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6840. this._svgAttributesComputationCompleted = true;
  6841. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6842. }
  6843. }
  6844. };
  6845. Object.defineProperty(Image.prototype, "cellWidth", {
  6846. /**
  6847. * Gets or sets the cell width to use when animation sheet is enabled
  6848. * @see https://doc.babylonjs.com/how_to/gui#image
  6849. */
  6850. get: function () {
  6851. return this._cellWidth;
  6852. },
  6853. set: function (value) {
  6854. if (this._cellWidth === value) {
  6855. return;
  6856. }
  6857. this._cellWidth = value;
  6858. this._markAsDirty();
  6859. },
  6860. enumerable: false,
  6861. configurable: true
  6862. });
  6863. Object.defineProperty(Image.prototype, "cellHeight", {
  6864. /**
  6865. * Gets or sets the cell height to use when animation sheet is enabled
  6866. * @see https://doc.babylonjs.com/how_to/gui#image
  6867. */
  6868. get: function () {
  6869. return this._cellHeight;
  6870. },
  6871. set: function (value) {
  6872. if (this._cellHeight === value) {
  6873. return;
  6874. }
  6875. this._cellHeight = value;
  6876. this._markAsDirty();
  6877. },
  6878. enumerable: false,
  6879. configurable: true
  6880. });
  6881. Object.defineProperty(Image.prototype, "cellId", {
  6882. /**
  6883. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6884. * @see https://doc.babylonjs.com/how_to/gui#image
  6885. */
  6886. get: function () {
  6887. return this._cellId;
  6888. },
  6889. set: function (value) {
  6890. if (this._cellId === value) {
  6891. return;
  6892. }
  6893. this._cellId = value;
  6894. this._markAsDirty();
  6895. },
  6896. enumerable: false,
  6897. configurable: true
  6898. });
  6899. /**
  6900. * Tests if a given coordinates belong to the current control
  6901. * @param x defines x coordinate to test
  6902. * @param y defines y coordinate to test
  6903. * @returns true if the coordinates are inside the control
  6904. */
  6905. Image.prototype.contains = function (x, y) {
  6906. if (!_super.prototype.contains.call(this, x, y)) {
  6907. return false;
  6908. }
  6909. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6910. return true;
  6911. }
  6912. var width = this._currentMeasure.width | 0;
  6913. var height = this._currentMeasure.height | 0;
  6914. var key = width + "_" + height;
  6915. var imageData = this._imageDataCache.data;
  6916. if (!imageData || this._imageDataCache.key !== key) {
  6917. var canvas = this._workingCanvas;
  6918. var context_1 = canvas.getContext("2d");
  6919. this._imageDataCache.data = imageData = context_1.getImageData(0, 0, width, height).data;
  6920. this._imageDataCache.key = key;
  6921. }
  6922. x = (x - this._currentMeasure.left) | 0;
  6923. y = (y - this._currentMeasure.top) | 0;
  6924. var pickedPixel = imageData[(x + y * width) * 4 + 3];
  6925. return pickedPixel > 0;
  6926. };
  6927. Image.prototype._getTypeName = function () {
  6928. return "Image";
  6929. };
  6930. /** Force the control to synchronize with its content */
  6931. Image.prototype.synchronizeSizeWithContent = function () {
  6932. if (!this._loaded) {
  6933. return;
  6934. }
  6935. this.width = this._domImage.width + "px";
  6936. this.height = this._domImage.height + "px";
  6937. };
  6938. Image.prototype._processMeasures = function (parentMeasure, context) {
  6939. if (this._loaded) {
  6940. switch (this._stretch) {
  6941. case Image.STRETCH_NONE:
  6942. break;
  6943. case Image.STRETCH_FILL:
  6944. break;
  6945. case Image.STRETCH_UNIFORM:
  6946. break;
  6947. case Image.STRETCH_NINE_PATCH:
  6948. break;
  6949. case Image.STRETCH_EXTEND:
  6950. if (this._autoScale) {
  6951. this.synchronizeSizeWithContent();
  6952. }
  6953. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6954. this.parent.adaptWidthToChildren = true;
  6955. this.parent.adaptHeightToChildren = true;
  6956. }
  6957. break;
  6958. }
  6959. }
  6960. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6961. };
  6962. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6963. if (!this._detectPointerOnOpaqueOnly) {
  6964. return;
  6965. }
  6966. if (!this._workingCanvas) {
  6967. this._workingCanvas = document.createElement('canvas');
  6968. }
  6969. var canvas = this._workingCanvas;
  6970. var width = this._currentMeasure.width;
  6971. var height = this._currentMeasure.height;
  6972. var context = canvas.getContext("2d");
  6973. canvas.width = width;
  6974. canvas.height = height;
  6975. context.clearRect(0, 0, width, height);
  6976. };
  6977. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6978. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6979. if (!this._detectPointerOnOpaqueOnly) {
  6980. return;
  6981. }
  6982. var canvas = this._workingCanvas;
  6983. context = canvas.getContext("2d");
  6984. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6985. };
  6986. Image.prototype._draw = function (context) {
  6987. context.save();
  6988. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6989. context.shadowColor = this.shadowColor;
  6990. context.shadowBlur = this.shadowBlur;
  6991. context.shadowOffsetX = this.shadowOffsetX;
  6992. context.shadowOffsetY = this.shadowOffsetY;
  6993. }
  6994. var x, y, width, height;
  6995. if (this.cellId == -1) {
  6996. x = this._sourceLeft;
  6997. y = this._sourceTop;
  6998. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6999. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  7000. }
  7001. else {
  7002. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  7003. var column = (this.cellId / rowCount) >> 0;
  7004. var row = this.cellId % rowCount;
  7005. x = this.cellWidth * row;
  7006. y = this.cellHeight * column;
  7007. width = this.cellWidth;
  7008. height = this.cellHeight;
  7009. }
  7010. this._prepareWorkingCanvasForOpaqueDetection();
  7011. this._applyStates(context);
  7012. if (this._loaded) {
  7013. switch (this._stretch) {
  7014. case Image.STRETCH_NONE:
  7015. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7016. break;
  7017. case Image.STRETCH_FILL:
  7018. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7019. break;
  7020. case Image.STRETCH_UNIFORM:
  7021. var hRatio = this._currentMeasure.width / width;
  7022. var vRatio = this._currentMeasure.height / height;
  7023. var ratio = Math.min(hRatio, vRatio);
  7024. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  7025. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  7026. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  7027. break;
  7028. case Image.STRETCH_EXTEND:
  7029. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7030. break;
  7031. case Image.STRETCH_NINE_PATCH:
  7032. this._renderNinePatch(context);
  7033. break;
  7034. }
  7035. }
  7036. context.restore();
  7037. };
  7038. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  7039. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  7040. };
  7041. Image.prototype._renderNinePatch = function (context) {
  7042. var height = this._imageHeight;
  7043. var leftWidth = this._sliceLeft;
  7044. var topHeight = this._sliceTop;
  7045. var bottomHeight = this._imageHeight - this._sliceBottom;
  7046. var rightWidth = this._imageWidth - this._sliceRight;
  7047. var left = 0;
  7048. var top = 0;
  7049. if (this._populateNinePatchSlicesFromImage) {
  7050. left = 1;
  7051. top = 1;
  7052. height -= 2;
  7053. leftWidth -= 1;
  7054. topHeight -= 1;
  7055. bottomHeight -= 1;
  7056. rightWidth -= 1;
  7057. }
  7058. var centerWidth = this._sliceRight - this._sliceLeft;
  7059. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  7060. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  7061. // Corners
  7062. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  7063. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  7064. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  7065. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  7066. // Center
  7067. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  7068. // Borders
  7069. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7070. 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);
  7071. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  7072. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  7073. };
  7074. Image.prototype.dispose = function () {
  7075. _super.prototype.dispose.call(this);
  7076. this.onImageLoadedObservable.clear();
  7077. this.onSVGAttributesComputedObservable.clear();
  7078. };
  7079. // Static
  7080. /** STRETCH_NONE */
  7081. Image.STRETCH_NONE = 0;
  7082. /** STRETCH_FILL */
  7083. Image.STRETCH_FILL = 1;
  7084. /** STRETCH_UNIFORM */
  7085. Image.STRETCH_UNIFORM = 2;
  7086. /** STRETCH_EXTEND */
  7087. Image.STRETCH_EXTEND = 3;
  7088. /** NINE_PATCH */
  7089. Image.STRETCH_NINE_PATCH = 4;
  7090. return Image;
  7091. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7092. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7093. /***/ }),
  7094. /***/ "./2D/controls/index.ts":
  7095. /*!******************************!*\
  7096. !*** ./2D/controls/index.ts ***!
  7097. \******************************/
  7098. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  7099. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7100. "use strict";
  7101. __webpack_require__.r(__webpack_exports__);
  7102. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7104. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7106. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7108. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7110. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7112. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7114. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  7116. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  7118. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  7120. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  7122. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  7124. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  7126. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  7128. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  7130. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  7132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  7133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  7134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  7135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  7136. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  7138. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  7140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  7141. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  7143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  7144. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  7146. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  7148. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  7150. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  7152. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  7154. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  7156. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  7158. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  7160. /***/ }),
  7161. /***/ "./2D/controls/inputPassword.ts":
  7162. /*!**************************************!*\
  7163. !*** ./2D/controls/inputPassword.ts ***!
  7164. \**************************************/
  7165. /*! exports provided: InputPassword */
  7166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7167. "use strict";
  7168. __webpack_require__.r(__webpack_exports__);
  7169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7170. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7171. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7172. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  7173. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7174. /**
  7175. * Class used to create a password control
  7176. */
  7177. var InputPassword = /** @class */ (function (_super) {
  7178. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7179. function InputPassword() {
  7180. return _super !== null && _super.apply(this, arguments) || this;
  7181. }
  7182. InputPassword.prototype._beforeRenderText = function (text) {
  7183. var txt = "";
  7184. for (var i = 0; i < text.length; i++) {
  7185. txt += "\u2022";
  7186. }
  7187. return txt;
  7188. };
  7189. return InputPassword;
  7190. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7191. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7192. /***/ }),
  7193. /***/ "./2D/controls/inputText.ts":
  7194. /*!**********************************!*\
  7195. !*** ./2D/controls/inputText.ts ***!
  7196. \**********************************/
  7197. /*! exports provided: InputText */
  7198. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7199. "use strict";
  7200. __webpack_require__.r(__webpack_exports__);
  7201. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7202. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7203. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  7204. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7205. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7206. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7207. /**
  7208. * Class used to create input text control
  7209. */
  7210. var InputText = /** @class */ (function (_super) {
  7211. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7212. /**
  7213. * Creates a new InputText
  7214. * @param name defines the control name
  7215. * @param text defines the text of the control
  7216. */
  7217. function InputText(name, text) {
  7218. if (text === void 0) { text = ""; }
  7219. var _this = _super.call(this, name) || this;
  7220. _this.name = name;
  7221. _this._text = "";
  7222. _this._placeholderText = "";
  7223. _this._background = "#222222";
  7224. _this._focusedBackground = "#000000";
  7225. _this._focusedColor = "white";
  7226. _this._placeholderColor = "gray";
  7227. _this._thickness = 1;
  7228. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7229. _this._autoStretchWidth = true;
  7230. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7231. _this._isFocused = false;
  7232. _this._blinkIsEven = false;
  7233. _this._cursorOffset = 0;
  7234. _this._deadKey = false;
  7235. _this._addKey = true;
  7236. _this._currentKey = "";
  7237. _this._isTextHighlightOn = false;
  7238. _this._textHighlightColor = "#d5e0ff";
  7239. _this._highligherOpacity = 0.4;
  7240. _this._highlightedText = "";
  7241. _this._startHighlightIndex = 0;
  7242. _this._endHighlightIndex = 0;
  7243. _this._cursorIndex = -1;
  7244. _this._onFocusSelectAll = false;
  7245. _this._isPointerDown = false;
  7246. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7247. _this.promptMessage = "Please enter text:";
  7248. /** Force disable prompt on mobile device */
  7249. _this.disableMobilePrompt = false;
  7250. /** Observable raised when the text changes */
  7251. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7252. /** Observable raised just before an entered character is to be added */
  7253. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7254. /** Observable raised when the control gets the focus */
  7255. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7256. /** Observable raised when the control loses the focus */
  7257. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7258. /**Observable raised when the text is highlighted */
  7259. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7260. /**Observable raised when copy event is triggered */
  7261. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7262. /** Observable raised when cut event is triggered */
  7263. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7264. /** Observable raised when paste event is triggered */
  7265. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7266. /** Observable raised when a key event was processed */
  7267. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7268. _this.text = text;
  7269. _this.isPointerBlocker = true;
  7270. return _this;
  7271. }
  7272. Object.defineProperty(InputText.prototype, "maxWidth", {
  7273. /** Gets or sets the maximum width allowed by the control */
  7274. get: function () {
  7275. return this._maxWidth.toString(this._host);
  7276. },
  7277. set: function (value) {
  7278. if (this._maxWidth.toString(this._host) === value) {
  7279. return;
  7280. }
  7281. if (this._maxWidth.fromString(value)) {
  7282. this._markAsDirty();
  7283. }
  7284. },
  7285. enumerable: false,
  7286. configurable: true
  7287. });
  7288. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7289. /** Gets the maximum width allowed by the control in pixels */
  7290. get: function () {
  7291. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7292. },
  7293. enumerable: false,
  7294. configurable: true
  7295. });
  7296. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7297. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7298. get: function () {
  7299. return this._highligherOpacity;
  7300. },
  7301. set: function (value) {
  7302. if (this._highligherOpacity === value) {
  7303. return;
  7304. }
  7305. this._highligherOpacity = value;
  7306. this._markAsDirty();
  7307. },
  7308. enumerable: false,
  7309. configurable: true
  7310. });
  7311. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7312. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7313. get: function () {
  7314. return this._onFocusSelectAll;
  7315. },
  7316. set: function (value) {
  7317. if (this._onFocusSelectAll === value) {
  7318. return;
  7319. }
  7320. this._onFocusSelectAll = value;
  7321. this._markAsDirty();
  7322. },
  7323. enumerable: false,
  7324. configurable: true
  7325. });
  7326. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7327. /** Gets or sets the text hightlight color */
  7328. get: function () {
  7329. return this._textHighlightColor;
  7330. },
  7331. set: function (value) {
  7332. if (this._textHighlightColor === value) {
  7333. return;
  7334. }
  7335. this._textHighlightColor = value;
  7336. this._markAsDirty();
  7337. },
  7338. enumerable: false,
  7339. configurable: true
  7340. });
  7341. Object.defineProperty(InputText.prototype, "margin", {
  7342. /** Gets or sets control margin */
  7343. get: function () {
  7344. return this._margin.toString(this._host);
  7345. },
  7346. set: function (value) {
  7347. if (this._margin.toString(this._host) === value) {
  7348. return;
  7349. }
  7350. if (this._margin.fromString(value)) {
  7351. this._markAsDirty();
  7352. }
  7353. },
  7354. enumerable: false,
  7355. configurable: true
  7356. });
  7357. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7358. /** Gets control margin in pixels */
  7359. get: function () {
  7360. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7361. },
  7362. enumerable: false,
  7363. configurable: true
  7364. });
  7365. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7366. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7367. get: function () {
  7368. return this._autoStretchWidth;
  7369. },
  7370. set: function (value) {
  7371. if (this._autoStretchWidth === value) {
  7372. return;
  7373. }
  7374. this._autoStretchWidth = value;
  7375. this._markAsDirty();
  7376. },
  7377. enumerable: false,
  7378. configurable: true
  7379. });
  7380. Object.defineProperty(InputText.prototype, "thickness", {
  7381. /** Gets or sets border thickness */
  7382. get: function () {
  7383. return this._thickness;
  7384. },
  7385. set: function (value) {
  7386. if (this._thickness === value) {
  7387. return;
  7388. }
  7389. this._thickness = value;
  7390. this._markAsDirty();
  7391. },
  7392. enumerable: false,
  7393. configurable: true
  7394. });
  7395. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7396. /** Gets or sets the background color when focused */
  7397. get: function () {
  7398. return this._focusedBackground;
  7399. },
  7400. set: function (value) {
  7401. if (this._focusedBackground === value) {
  7402. return;
  7403. }
  7404. this._focusedBackground = value;
  7405. this._markAsDirty();
  7406. },
  7407. enumerable: false,
  7408. configurable: true
  7409. });
  7410. Object.defineProperty(InputText.prototype, "focusedColor", {
  7411. /** Gets or sets the background color when focused */
  7412. get: function () {
  7413. return this._focusedColor;
  7414. },
  7415. set: function (value) {
  7416. if (this._focusedColor === value) {
  7417. return;
  7418. }
  7419. this._focusedColor = value;
  7420. this._markAsDirty();
  7421. },
  7422. enumerable: false,
  7423. configurable: true
  7424. });
  7425. Object.defineProperty(InputText.prototype, "background", {
  7426. /** Gets or sets the background color */
  7427. get: function () {
  7428. return this._background;
  7429. },
  7430. set: function (value) {
  7431. if (this._background === value) {
  7432. return;
  7433. }
  7434. this._background = value;
  7435. this._markAsDirty();
  7436. },
  7437. enumerable: false,
  7438. configurable: true
  7439. });
  7440. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7441. /** Gets or sets the placeholder color */
  7442. get: function () {
  7443. return this._placeholderColor;
  7444. },
  7445. set: function (value) {
  7446. if (this._placeholderColor === value) {
  7447. return;
  7448. }
  7449. this._placeholderColor = value;
  7450. this._markAsDirty();
  7451. },
  7452. enumerable: false,
  7453. configurable: true
  7454. });
  7455. Object.defineProperty(InputText.prototype, "placeholderText", {
  7456. /** Gets or sets the text displayed when the control is empty */
  7457. get: function () {
  7458. return this._placeholderText;
  7459. },
  7460. set: function (value) {
  7461. if (this._placeholderText === value) {
  7462. return;
  7463. }
  7464. this._placeholderText = value;
  7465. this._markAsDirty();
  7466. },
  7467. enumerable: false,
  7468. configurable: true
  7469. });
  7470. Object.defineProperty(InputText.prototype, "deadKey", {
  7471. /** Gets or sets the dead key flag */
  7472. get: function () {
  7473. return this._deadKey;
  7474. },
  7475. set: function (flag) {
  7476. this._deadKey = flag;
  7477. },
  7478. enumerable: false,
  7479. configurable: true
  7480. });
  7481. Object.defineProperty(InputText.prototype, "highlightedText", {
  7482. /** Gets or sets the highlight text */
  7483. get: function () {
  7484. return this._highlightedText;
  7485. },
  7486. set: function (text) {
  7487. if (this._highlightedText === text) {
  7488. return;
  7489. }
  7490. this._highlightedText = text;
  7491. this._markAsDirty();
  7492. },
  7493. enumerable: false,
  7494. configurable: true
  7495. });
  7496. Object.defineProperty(InputText.prototype, "addKey", {
  7497. /** Gets or sets if the current key should be added */
  7498. get: function () {
  7499. return this._addKey;
  7500. },
  7501. set: function (flag) {
  7502. this._addKey = flag;
  7503. },
  7504. enumerable: false,
  7505. configurable: true
  7506. });
  7507. Object.defineProperty(InputText.prototype, "currentKey", {
  7508. /** Gets or sets the value of the current key being entered */
  7509. get: function () {
  7510. return this._currentKey;
  7511. },
  7512. set: function (key) {
  7513. this._currentKey = key;
  7514. },
  7515. enumerable: false,
  7516. configurable: true
  7517. });
  7518. Object.defineProperty(InputText.prototype, "text", {
  7519. /** Gets or sets the text displayed in the control */
  7520. get: function () {
  7521. return this._text;
  7522. },
  7523. set: function (value) {
  7524. var valueAsString = value.toString(); // Forcing convertion
  7525. if (this._text === valueAsString) {
  7526. return;
  7527. }
  7528. this._text = valueAsString;
  7529. this._markAsDirty();
  7530. this.onTextChangedObservable.notifyObservers(this);
  7531. },
  7532. enumerable: false,
  7533. configurable: true
  7534. });
  7535. Object.defineProperty(InputText.prototype, "width", {
  7536. /** Gets or sets control width */
  7537. get: function () {
  7538. return this._width.toString(this._host);
  7539. },
  7540. set: function (value) {
  7541. if (this._width.toString(this._host) === value) {
  7542. return;
  7543. }
  7544. if (this._width.fromString(value)) {
  7545. this._markAsDirty();
  7546. }
  7547. this.autoStretchWidth = false;
  7548. },
  7549. enumerable: false,
  7550. configurable: true
  7551. });
  7552. /** @hidden */
  7553. InputText.prototype.onBlur = function () {
  7554. this._isFocused = false;
  7555. this._scrollLeft = null;
  7556. this._cursorOffset = 0;
  7557. clearTimeout(this._blinkTimeout);
  7558. this._markAsDirty();
  7559. this.onBlurObservable.notifyObservers(this);
  7560. this._host.unRegisterClipboardEvents();
  7561. if (this._onClipboardObserver) {
  7562. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7563. }
  7564. var scene = this._host.getScene();
  7565. if (this._onPointerDblTapObserver && scene) {
  7566. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7567. }
  7568. };
  7569. /** @hidden */
  7570. InputText.prototype.onFocus = function () {
  7571. var _this = this;
  7572. if (!this._isEnabled) {
  7573. return;
  7574. }
  7575. this._scrollLeft = null;
  7576. this._isFocused = true;
  7577. this._blinkIsEven = false;
  7578. this._cursorOffset = 0;
  7579. this._markAsDirty();
  7580. this.onFocusObservable.notifyObservers(this);
  7581. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7582. var value = prompt(this.promptMessage);
  7583. if (value !== null) {
  7584. this.text = value;
  7585. }
  7586. this._host.focusedControl = null;
  7587. return;
  7588. }
  7589. this._host.registerClipboardEvents();
  7590. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7591. // process clipboard event, can be configured.
  7592. switch (clipboardInfo.type) {
  7593. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7594. _this._onCopyText(clipboardInfo.event);
  7595. _this.onTextCopyObservable.notifyObservers(_this);
  7596. break;
  7597. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7598. _this._onCutText(clipboardInfo.event);
  7599. _this.onTextCutObservable.notifyObservers(_this);
  7600. break;
  7601. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7602. _this._onPasteText(clipboardInfo.event);
  7603. _this.onTextPasteObservable.notifyObservers(_this);
  7604. break;
  7605. default: return;
  7606. }
  7607. });
  7608. var scene = this._host.getScene();
  7609. if (scene) {
  7610. //register the pointer double tap event
  7611. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7612. if (!_this._isFocused) {
  7613. return;
  7614. }
  7615. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7616. _this._processDblClick(pointerInfo);
  7617. }
  7618. });
  7619. }
  7620. if (this._onFocusSelectAll) {
  7621. this._selectAllText();
  7622. }
  7623. };
  7624. InputText.prototype._getTypeName = function () {
  7625. return "InputText";
  7626. };
  7627. /**
  7628. * Function called to get the list of controls that should not steal the focus from this control
  7629. * @returns an array of controls
  7630. */
  7631. InputText.prototype.keepsFocusWith = function () {
  7632. if (!this._connectedVirtualKeyboard) {
  7633. return null;
  7634. }
  7635. return [this._connectedVirtualKeyboard];
  7636. };
  7637. /** @hidden */
  7638. InputText.prototype.processKey = function (keyCode, key, evt) {
  7639. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7640. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7641. return;
  7642. }
  7643. //select all
  7644. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7645. this._selectAllText();
  7646. evt.preventDefault();
  7647. return;
  7648. }
  7649. // Specific cases
  7650. switch (keyCode) {
  7651. case 32: //SPACE
  7652. key = " "; //ie11 key for space is "Spacebar"
  7653. break;
  7654. case 191: //SLASH
  7655. if (evt) {
  7656. evt.preventDefault();
  7657. }
  7658. break;
  7659. case 8: // BACKSPACE
  7660. if (this._text && this._text.length > 0) {
  7661. //delete the highlighted text
  7662. if (this._isTextHighlightOn) {
  7663. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7664. this._isTextHighlightOn = false;
  7665. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7666. this._blinkIsEven = false;
  7667. if (evt) {
  7668. evt.preventDefault();
  7669. }
  7670. return;
  7671. }
  7672. //delete single character
  7673. if (this._cursorOffset === 0) {
  7674. this.text = this._text.substr(0, this._text.length - 1);
  7675. }
  7676. else {
  7677. var deletePosition = this._text.length - this._cursorOffset;
  7678. if (deletePosition > 0) {
  7679. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7680. }
  7681. }
  7682. }
  7683. if (evt) {
  7684. evt.preventDefault();
  7685. }
  7686. return;
  7687. case 46: // DELETE
  7688. if (this._isTextHighlightOn) {
  7689. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7690. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7691. while (decrementor > 0 && this._cursorOffset > 0) {
  7692. this._cursorOffset--;
  7693. }
  7694. this._isTextHighlightOn = false;
  7695. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7696. if (evt) {
  7697. evt.preventDefault();
  7698. }
  7699. return;
  7700. }
  7701. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7702. var deletePosition = this._text.length - this._cursorOffset;
  7703. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7704. this._cursorOffset--;
  7705. }
  7706. if (evt) {
  7707. evt.preventDefault();
  7708. }
  7709. return;
  7710. case 13: // RETURN
  7711. this._host.focusedControl = null;
  7712. this._isTextHighlightOn = false;
  7713. return;
  7714. case 35: // END
  7715. this._cursorOffset = 0;
  7716. this._blinkIsEven = false;
  7717. this._isTextHighlightOn = false;
  7718. this._markAsDirty();
  7719. return;
  7720. case 36: // HOME
  7721. this._cursorOffset = this._text.length;
  7722. this._blinkIsEven = false;
  7723. this._isTextHighlightOn = false;
  7724. this._markAsDirty();
  7725. return;
  7726. case 37: // LEFT
  7727. this._cursorOffset++;
  7728. if (this._cursorOffset > this._text.length) {
  7729. this._cursorOffset = this._text.length;
  7730. }
  7731. if (evt && evt.shiftKey) {
  7732. // update the cursor
  7733. this._blinkIsEven = false;
  7734. // shift + ctrl/cmd + <-
  7735. if (evt.ctrlKey || evt.metaKey) {
  7736. if (!this._isTextHighlightOn) {
  7737. if (this._text.length === this._cursorOffset) {
  7738. return;
  7739. }
  7740. else {
  7741. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7742. }
  7743. }
  7744. this._startHighlightIndex = 0;
  7745. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7746. this._cursorOffset = this._text.length;
  7747. this._isTextHighlightOn = true;
  7748. this._markAsDirty();
  7749. return;
  7750. }
  7751. //store the starting point
  7752. if (!this._isTextHighlightOn) {
  7753. this._isTextHighlightOn = true;
  7754. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7755. }
  7756. //if text is already highlighted
  7757. else if (this._cursorIndex === -1) {
  7758. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7759. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7760. }
  7761. //set the highlight indexes
  7762. if (this._cursorIndex < this._cursorOffset) {
  7763. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7764. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7765. }
  7766. else if (this._cursorIndex > this._cursorOffset) {
  7767. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7768. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7769. }
  7770. else {
  7771. this._isTextHighlightOn = false;
  7772. }
  7773. this._markAsDirty();
  7774. return;
  7775. }
  7776. if (this._isTextHighlightOn) {
  7777. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7778. this._isTextHighlightOn = false;
  7779. }
  7780. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7781. this._cursorOffset = this.text.length;
  7782. evt.preventDefault();
  7783. }
  7784. this._blinkIsEven = false;
  7785. this._isTextHighlightOn = false;
  7786. this._cursorIndex = -1;
  7787. this._markAsDirty();
  7788. return;
  7789. case 39: // RIGHT
  7790. this._cursorOffset--;
  7791. if (this._cursorOffset < 0) {
  7792. this._cursorOffset = 0;
  7793. }
  7794. if (evt && evt.shiftKey) {
  7795. //update the cursor
  7796. this._blinkIsEven = false;
  7797. //shift + ctrl/cmd + ->
  7798. if (evt.ctrlKey || evt.metaKey) {
  7799. if (!this._isTextHighlightOn) {
  7800. if (this._cursorOffset === 0) {
  7801. return;
  7802. }
  7803. else {
  7804. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7805. }
  7806. }
  7807. this._endHighlightIndex = this._text.length;
  7808. this._isTextHighlightOn = true;
  7809. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7810. this._cursorOffset = 0;
  7811. this._markAsDirty();
  7812. return;
  7813. }
  7814. if (!this._isTextHighlightOn) {
  7815. this._isTextHighlightOn = true;
  7816. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7817. }
  7818. //if text is already highlighted
  7819. else if (this._cursorIndex === -1) {
  7820. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7821. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7822. }
  7823. //set the highlight indexes
  7824. if (this._cursorIndex < this._cursorOffset) {
  7825. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7826. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7827. }
  7828. else if (this._cursorIndex > this._cursorOffset) {
  7829. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7830. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7831. }
  7832. else {
  7833. this._isTextHighlightOn = false;
  7834. }
  7835. this._markAsDirty();
  7836. return;
  7837. }
  7838. if (this._isTextHighlightOn) {
  7839. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7840. this._isTextHighlightOn = false;
  7841. }
  7842. //ctr + ->
  7843. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7844. this._cursorOffset = 0;
  7845. evt.preventDefault();
  7846. }
  7847. this._blinkIsEven = false;
  7848. this._isTextHighlightOn = false;
  7849. this._cursorIndex = -1;
  7850. this._markAsDirty();
  7851. return;
  7852. case 222: // Dead
  7853. if (evt) {
  7854. evt.preventDefault();
  7855. }
  7856. this._cursorIndex = -1;
  7857. this.deadKey = true;
  7858. break;
  7859. }
  7860. // Printable characters
  7861. if (key &&
  7862. ((keyCode === -1) || // Direct access
  7863. (keyCode === 32) || // Space
  7864. (keyCode > 47 && keyCode < 64) || // Numbers
  7865. (keyCode > 64 && keyCode < 91) || // Letters
  7866. (keyCode > 159 && keyCode < 193) || // Special characters
  7867. (keyCode > 218 && keyCode < 223) || // Special characters
  7868. (keyCode > 95 && keyCode < 112))) { // Numpad
  7869. this._currentKey = key;
  7870. this.onBeforeKeyAddObservable.notifyObservers(this);
  7871. key = this._currentKey;
  7872. if (this._addKey) {
  7873. if (this._isTextHighlightOn) {
  7874. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7875. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7876. this._isTextHighlightOn = false;
  7877. this._blinkIsEven = false;
  7878. this._markAsDirty();
  7879. }
  7880. else if (this._cursorOffset === 0) {
  7881. this.text += key;
  7882. }
  7883. else {
  7884. var insertPosition = this._text.length - this._cursorOffset;
  7885. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7886. }
  7887. }
  7888. }
  7889. };
  7890. /** @hidden */
  7891. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7892. //update the cursor
  7893. this._blinkIsEven = false;
  7894. if (this._cursorIndex === -1) {
  7895. this._cursorIndex = offset;
  7896. }
  7897. else {
  7898. if (this._cursorIndex < this._cursorOffset) {
  7899. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7900. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7901. }
  7902. else if (this._cursorIndex > this._cursorOffset) {
  7903. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7904. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7905. }
  7906. else {
  7907. this._isTextHighlightOn = false;
  7908. this._markAsDirty();
  7909. return;
  7910. }
  7911. }
  7912. this._isTextHighlightOn = true;
  7913. this._markAsDirty();
  7914. };
  7915. /** @hidden */
  7916. InputText.prototype._processDblClick = function (evt) {
  7917. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7918. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7919. this._endHighlightIndex = this._startHighlightIndex;
  7920. var rWord = /\w+/g, moveLeft, moveRight;
  7921. do {
  7922. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7923. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7924. } while (moveLeft || moveRight);
  7925. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7926. this.onTextHighlightObservable.notifyObservers(this);
  7927. this._isTextHighlightOn = true;
  7928. this._clickedCoordinate = null;
  7929. this._blinkIsEven = true;
  7930. this._cursorIndex = -1;
  7931. this._markAsDirty();
  7932. };
  7933. /** @hidden */
  7934. InputText.prototype._selectAllText = function () {
  7935. this._blinkIsEven = true;
  7936. this._isTextHighlightOn = true;
  7937. this._startHighlightIndex = 0;
  7938. this._endHighlightIndex = this._text.length;
  7939. this._cursorOffset = this._text.length;
  7940. this._cursorIndex = -1;
  7941. this._markAsDirty();
  7942. };
  7943. /**
  7944. * Handles the keyboard event
  7945. * @param evt Defines the KeyboardEvent
  7946. */
  7947. InputText.prototype.processKeyboard = function (evt) {
  7948. // process pressed key
  7949. this.processKey(evt.keyCode, evt.key, evt);
  7950. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7951. };
  7952. /** @hidden */
  7953. InputText.prototype._onCopyText = function (ev) {
  7954. this._isTextHighlightOn = false;
  7955. //when write permission to clipbaord data is denied
  7956. try {
  7957. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7958. }
  7959. catch (_a) { } //pass
  7960. this._host.clipboardData = this._highlightedText;
  7961. };
  7962. /** @hidden */
  7963. InputText.prototype._onCutText = function (ev) {
  7964. if (!this._highlightedText) {
  7965. return;
  7966. }
  7967. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7968. this._isTextHighlightOn = false;
  7969. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7970. //when write permission to clipbaord data is denied
  7971. try {
  7972. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7973. }
  7974. catch (_a) { } //pass
  7975. this._host.clipboardData = this._highlightedText;
  7976. this._highlightedText = "";
  7977. };
  7978. /** @hidden */
  7979. InputText.prototype._onPasteText = function (ev) {
  7980. var data = "";
  7981. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7982. data = ev.clipboardData.getData("text/plain");
  7983. }
  7984. else {
  7985. //get the cached data; returns blank string by default
  7986. data = this._host.clipboardData;
  7987. }
  7988. var insertPosition = this._text.length - this._cursorOffset;
  7989. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7990. };
  7991. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7992. var _this = this;
  7993. context.save();
  7994. this._applyStates(context);
  7995. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7996. context.shadowColor = this.shadowColor;
  7997. context.shadowBlur = this.shadowBlur;
  7998. context.shadowOffsetX = this.shadowOffsetX;
  7999. context.shadowOffsetY = this.shadowOffsetY;
  8000. }
  8001. // Background
  8002. if (this._isFocused) {
  8003. if (this._focusedBackground) {
  8004. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  8005. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8006. }
  8007. }
  8008. else if (this._background) {
  8009. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8010. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8011. }
  8012. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8013. context.shadowBlur = 0;
  8014. context.shadowOffsetX = 0;
  8015. context.shadowOffsetY = 0;
  8016. }
  8017. if (!this._fontOffset) {
  8018. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  8019. }
  8020. // Text
  8021. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  8022. if (this.color) {
  8023. context.fillStyle = this.color;
  8024. }
  8025. var text = this._beforeRenderText(this._text);
  8026. if (!this._isFocused && !this._text && this._placeholderText) {
  8027. text = this._placeholderText;
  8028. if (this._placeholderColor) {
  8029. context.fillStyle = this._placeholderColor;
  8030. }
  8031. }
  8032. this._textWidth = context.measureText(text).width;
  8033. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  8034. if (this._autoStretchWidth) {
  8035. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  8036. }
  8037. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  8038. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  8039. context.save();
  8040. context.beginPath();
  8041. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  8042. context.clip();
  8043. if (this._isFocused && this._textWidth > availableWidth) {
  8044. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  8045. if (!this._scrollLeft) {
  8046. this._scrollLeft = textLeft;
  8047. }
  8048. }
  8049. else {
  8050. this._scrollLeft = clipTextLeft;
  8051. }
  8052. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  8053. // Cursor
  8054. if (this._isFocused) {
  8055. // Need to move cursor
  8056. if (this._clickedCoordinate) {
  8057. var rightPosition = this._scrollLeft + this._textWidth;
  8058. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  8059. var currentSize = 0;
  8060. this._cursorOffset = 0;
  8061. var previousDist = 0;
  8062. do {
  8063. if (this._cursorOffset) {
  8064. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  8065. }
  8066. this._cursorOffset++;
  8067. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  8068. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  8069. // Find closest move
  8070. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8071. this._cursorOffset--;
  8072. }
  8073. this._blinkIsEven = false;
  8074. this._clickedCoordinate = null;
  8075. }
  8076. // Render cursor
  8077. if (!this._blinkIsEven) {
  8078. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  8079. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8080. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8081. if (cursorLeft < clipTextLeft) {
  8082. this._scrollLeft += (clipTextLeft - cursorLeft);
  8083. cursorLeft = clipTextLeft;
  8084. this._markAsDirty();
  8085. }
  8086. else if (cursorLeft > clipTextLeft + availableWidth) {
  8087. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8088. cursorLeft = clipTextLeft + availableWidth;
  8089. this._markAsDirty();
  8090. }
  8091. if (!this._isTextHighlightOn) {
  8092. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8093. }
  8094. }
  8095. clearTimeout(this._blinkTimeout);
  8096. this._blinkTimeout = setTimeout(function () {
  8097. _this._blinkIsEven = !_this._blinkIsEven;
  8098. _this._markAsDirty();
  8099. }, 500);
  8100. //show the highlighted text
  8101. if (this._isTextHighlightOn) {
  8102. clearTimeout(this._blinkTimeout);
  8103. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  8104. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8105. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8106. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8107. if (highlightCursorLeft < clipTextLeft) {
  8108. width = width - (clipTextLeft - highlightCursorLeft);
  8109. if (!width) {
  8110. // when using left arrow on text.length > availableWidth;
  8111. // assigns the width of the first letter after clipTextLeft
  8112. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  8113. }
  8114. highlightCursorLeft = clipTextLeft;
  8115. }
  8116. //for transparancy
  8117. context.globalAlpha = this._highligherOpacity;
  8118. context.fillStyle = this._textHighlightColor;
  8119. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8120. context.globalAlpha = 1.0;
  8121. }
  8122. }
  8123. context.restore();
  8124. // Border
  8125. if (this._thickness) {
  8126. if (this._isFocused) {
  8127. if (this.focusedColor) {
  8128. context.strokeStyle = this.focusedColor;
  8129. }
  8130. }
  8131. else {
  8132. if (this.color) {
  8133. context.strokeStyle = this.color;
  8134. }
  8135. }
  8136. context.lineWidth = this._thickness;
  8137. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8138. }
  8139. context.restore();
  8140. };
  8141. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8142. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8143. return false;
  8144. }
  8145. this._clickedCoordinate = coordinates.x;
  8146. this._isTextHighlightOn = false;
  8147. this._highlightedText = "";
  8148. this._cursorIndex = -1;
  8149. this._isPointerDown = true;
  8150. this._host._capturingControl[pointerId] = this;
  8151. if (this._host.focusedControl === this) {
  8152. // Move cursor
  8153. clearTimeout(this._blinkTimeout);
  8154. this._markAsDirty();
  8155. return true;
  8156. }
  8157. if (!this._isEnabled) {
  8158. return false;
  8159. }
  8160. this._host.focusedControl = this;
  8161. return true;
  8162. };
  8163. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  8164. if (this._host.focusedControl === this && this._isPointerDown) {
  8165. this._clickedCoordinate = coordinates.x;
  8166. this._markAsDirty();
  8167. this._updateValueFromCursorIndex(this._cursorOffset);
  8168. }
  8169. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  8170. };
  8171. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8172. this._isPointerDown = false;
  8173. delete this._host._capturingControl[pointerId];
  8174. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8175. };
  8176. InputText.prototype._beforeRenderText = function (text) {
  8177. return text;
  8178. };
  8179. InputText.prototype.dispose = function () {
  8180. _super.prototype.dispose.call(this);
  8181. this.onBlurObservable.clear();
  8182. this.onFocusObservable.clear();
  8183. this.onTextChangedObservable.clear();
  8184. this.onTextCopyObservable.clear();
  8185. this.onTextCutObservable.clear();
  8186. this.onTextPasteObservable.clear();
  8187. this.onTextHighlightObservable.clear();
  8188. this.onKeyboardEventProcessedObservable.clear();
  8189. };
  8190. return InputText;
  8191. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8192. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8193. /***/ }),
  8194. /***/ "./2D/controls/line.ts":
  8195. /*!*****************************!*\
  8196. !*** ./2D/controls/line.ts ***!
  8197. \*****************************/
  8198. /*! exports provided: Line */
  8199. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8200. "use strict";
  8201. __webpack_require__.r(__webpack_exports__);
  8202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8203. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8204. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  8205. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8206. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8207. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8208. /** Class used to render 2D lines */
  8209. var Line = /** @class */ (function (_super) {
  8210. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8211. /**
  8212. * Creates a new Line
  8213. * @param name defines the control name
  8214. */
  8215. function Line(name) {
  8216. var _this = _super.call(this, name) || this;
  8217. _this.name = name;
  8218. _this._lineWidth = 1;
  8219. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8220. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8221. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8222. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8223. _this._dash = new Array();
  8224. _this._automaticSize = true;
  8225. _this.isHitTestVisible = false;
  8226. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8227. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8228. return _this;
  8229. }
  8230. Object.defineProperty(Line.prototype, "dash", {
  8231. /** Gets or sets the dash pattern */
  8232. get: function () {
  8233. return this._dash;
  8234. },
  8235. set: function (value) {
  8236. if (this._dash === value) {
  8237. return;
  8238. }
  8239. this._dash = value;
  8240. this._markAsDirty();
  8241. },
  8242. enumerable: false,
  8243. configurable: true
  8244. });
  8245. Object.defineProperty(Line.prototype, "connectedControl", {
  8246. /** Gets or sets the control connected with the line end */
  8247. get: function () {
  8248. return this._connectedControl;
  8249. },
  8250. set: function (value) {
  8251. var _this = this;
  8252. if (this._connectedControl === value) {
  8253. return;
  8254. }
  8255. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8256. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8257. this._connectedControlDirtyObserver = null;
  8258. }
  8259. if (value) {
  8260. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8261. }
  8262. this._connectedControl = value;
  8263. this._markAsDirty();
  8264. },
  8265. enumerable: false,
  8266. configurable: true
  8267. });
  8268. Object.defineProperty(Line.prototype, "x1", {
  8269. /** Gets or sets start coordinates on X axis */
  8270. get: function () {
  8271. return this._x1.toString(this._host);
  8272. },
  8273. set: function (value) {
  8274. if (this._x1.toString(this._host) === value) {
  8275. return;
  8276. }
  8277. if (this._x1.fromString(value)) {
  8278. this._markAsDirty();
  8279. }
  8280. },
  8281. enumerable: false,
  8282. configurable: true
  8283. });
  8284. Object.defineProperty(Line.prototype, "y1", {
  8285. /** Gets or sets start coordinates on Y axis */
  8286. get: function () {
  8287. return this._y1.toString(this._host);
  8288. },
  8289. set: function (value) {
  8290. if (this._y1.toString(this._host) === value) {
  8291. return;
  8292. }
  8293. if (this._y1.fromString(value)) {
  8294. this._markAsDirty();
  8295. }
  8296. },
  8297. enumerable: false,
  8298. configurable: true
  8299. });
  8300. Object.defineProperty(Line.prototype, "x2", {
  8301. /** Gets or sets end coordinates on X axis */
  8302. get: function () {
  8303. return this._x2.toString(this._host);
  8304. },
  8305. set: function (value) {
  8306. if (this._x2.toString(this._host) === value) {
  8307. return;
  8308. }
  8309. if (this._x2.fromString(value)) {
  8310. this._markAsDirty();
  8311. }
  8312. },
  8313. enumerable: false,
  8314. configurable: true
  8315. });
  8316. Object.defineProperty(Line.prototype, "y2", {
  8317. /** Gets or sets end coordinates on Y axis */
  8318. get: function () {
  8319. return this._y2.toString(this._host);
  8320. },
  8321. set: function (value) {
  8322. if (this._y2.toString(this._host) === value) {
  8323. return;
  8324. }
  8325. if (this._y2.fromString(value)) {
  8326. this._markAsDirty();
  8327. }
  8328. },
  8329. enumerable: false,
  8330. configurable: true
  8331. });
  8332. Object.defineProperty(Line.prototype, "lineWidth", {
  8333. /** Gets or sets line width */
  8334. get: function () {
  8335. return this._lineWidth;
  8336. },
  8337. set: function (value) {
  8338. if (this._lineWidth === value) {
  8339. return;
  8340. }
  8341. this._lineWidth = value;
  8342. this._markAsDirty();
  8343. },
  8344. enumerable: false,
  8345. configurable: true
  8346. });
  8347. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8348. /** Gets or sets horizontal alignment */
  8349. set: function (value) {
  8350. return;
  8351. },
  8352. enumerable: false,
  8353. configurable: true
  8354. });
  8355. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8356. /** Gets or sets vertical alignment */
  8357. set: function (value) {
  8358. return;
  8359. },
  8360. enumerable: false,
  8361. configurable: true
  8362. });
  8363. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8364. get: function () {
  8365. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8366. },
  8367. enumerable: false,
  8368. configurable: true
  8369. });
  8370. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8371. get: function () {
  8372. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8373. },
  8374. enumerable: false,
  8375. configurable: true
  8376. });
  8377. Line.prototype._getTypeName = function () {
  8378. return "Line";
  8379. };
  8380. Line.prototype._draw = function (context) {
  8381. context.save();
  8382. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8383. context.shadowColor = this.shadowColor;
  8384. context.shadowBlur = this.shadowBlur;
  8385. context.shadowOffsetX = this.shadowOffsetX;
  8386. context.shadowOffsetY = this.shadowOffsetY;
  8387. }
  8388. this._applyStates(context);
  8389. context.strokeStyle = this.color;
  8390. context.lineWidth = this._lineWidth;
  8391. context.setLineDash(this._dash);
  8392. context.beginPath();
  8393. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8394. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8395. context.stroke();
  8396. context.restore();
  8397. };
  8398. Line.prototype._measure = function () {
  8399. // Width / Height
  8400. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8401. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8402. };
  8403. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8404. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8405. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8406. };
  8407. /**
  8408. * Move one end of the line given 3D cartesian coordinates.
  8409. * @param position Targeted world position
  8410. * @param scene Scene
  8411. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8412. */
  8413. Line.prototype.moveToVector3 = function (position, scene, end) {
  8414. if (end === void 0) { end = false; }
  8415. if (!this._host || this.parent !== this._host._rootContainer) {
  8416. 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");
  8417. return;
  8418. }
  8419. var globalViewport = this._host._getGlobalViewport(scene);
  8420. 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);
  8421. this._moveToProjectedPosition(projectedPosition, end);
  8422. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8423. this.notRenderable = true;
  8424. return;
  8425. }
  8426. this.notRenderable = false;
  8427. };
  8428. /**
  8429. * Move one end of the line to a position in screen absolute space.
  8430. * @param projectedPosition Position in screen absolute space (X, Y)
  8431. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8432. */
  8433. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8434. if (end === void 0) { end = false; }
  8435. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8436. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8437. if (end) {
  8438. this.x2 = x;
  8439. this.y2 = y;
  8440. this._x2.ignoreAdaptiveScaling = true;
  8441. this._y2.ignoreAdaptiveScaling = true;
  8442. }
  8443. else {
  8444. this.x1 = x;
  8445. this.y1 = y;
  8446. this._x1.ignoreAdaptiveScaling = true;
  8447. this._y1.ignoreAdaptiveScaling = true;
  8448. }
  8449. };
  8450. return Line;
  8451. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8452. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8453. /***/ }),
  8454. /***/ "./2D/controls/multiLine.ts":
  8455. /*!**********************************!*\
  8456. !*** ./2D/controls/multiLine.ts ***!
  8457. \**********************************/
  8458. /*! exports provided: MultiLine */
  8459. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8460. "use strict";
  8461. __webpack_require__.r(__webpack_exports__);
  8462. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8463. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8464. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  8465. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8466. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8467. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8468. /**
  8469. * Class used to create multi line control
  8470. */
  8471. var MultiLine = /** @class */ (function (_super) {
  8472. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8473. /**
  8474. * Creates a new MultiLine
  8475. * @param name defines the control name
  8476. */
  8477. function MultiLine(name) {
  8478. var _this = _super.call(this, name) || this;
  8479. _this.name = name;
  8480. _this._lineWidth = 1;
  8481. /** Function called when a point is updated */
  8482. _this.onPointUpdate = function () {
  8483. _this._markAsDirty();
  8484. };
  8485. _this._automaticSize = true;
  8486. _this.isHitTestVisible = false;
  8487. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8488. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8489. _this._dash = [];
  8490. _this._points = [];
  8491. return _this;
  8492. }
  8493. Object.defineProperty(MultiLine.prototype, "dash", {
  8494. /** Gets or sets dash pattern */
  8495. get: function () {
  8496. return this._dash;
  8497. },
  8498. set: function (value) {
  8499. if (this._dash === value) {
  8500. return;
  8501. }
  8502. this._dash = value;
  8503. this._markAsDirty();
  8504. },
  8505. enumerable: false,
  8506. configurable: true
  8507. });
  8508. /**
  8509. * Gets point stored at specified index
  8510. * @param index defines the index to look for
  8511. * @returns the requested point if found
  8512. */
  8513. MultiLine.prototype.getAt = function (index) {
  8514. if (!this._points[index]) {
  8515. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8516. }
  8517. return this._points[index];
  8518. };
  8519. /**
  8520. * Adds new points to the point collection
  8521. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8522. * @returns the list of created MultiLinePoint
  8523. */
  8524. MultiLine.prototype.add = function () {
  8525. var _this = this;
  8526. var items = [];
  8527. for (var _i = 0; _i < arguments.length; _i++) {
  8528. items[_i] = arguments[_i];
  8529. }
  8530. return items.map(function (item) { return _this.push(item); });
  8531. };
  8532. /**
  8533. * Adds a new point to the point collection
  8534. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8535. * @returns the created MultiLinePoint
  8536. */
  8537. MultiLine.prototype.push = function (item) {
  8538. var point = this.getAt(this._points.length);
  8539. if (item == null) {
  8540. return point;
  8541. }
  8542. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8543. point.mesh = item;
  8544. }
  8545. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8546. point.control = item;
  8547. }
  8548. else if (item.x != null && item.y != null) {
  8549. point.x = item.x;
  8550. point.y = item.y;
  8551. }
  8552. return point;
  8553. };
  8554. /**
  8555. * Remove a specific value or point from the active point collection
  8556. * @param value defines the value or point to remove
  8557. */
  8558. MultiLine.prototype.remove = function (value) {
  8559. var index;
  8560. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8561. index = this._points.indexOf(value);
  8562. if (index === -1) {
  8563. return;
  8564. }
  8565. }
  8566. else {
  8567. index = value;
  8568. }
  8569. var point = this._points[index];
  8570. if (!point) {
  8571. return;
  8572. }
  8573. point.dispose();
  8574. this._points.splice(index, 1);
  8575. };
  8576. /**
  8577. * Resets this object to initial state (no point)
  8578. */
  8579. MultiLine.prototype.reset = function () {
  8580. while (this._points.length > 0) {
  8581. this.remove(this._points.length - 1);
  8582. }
  8583. };
  8584. /**
  8585. * Resets all links
  8586. */
  8587. MultiLine.prototype.resetLinks = function () {
  8588. this._points.forEach(function (point) {
  8589. if (point != null) {
  8590. point.resetLinks();
  8591. }
  8592. });
  8593. };
  8594. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8595. /** Gets or sets line width */
  8596. get: function () {
  8597. return this._lineWidth;
  8598. },
  8599. set: function (value) {
  8600. if (this._lineWidth === value) {
  8601. return;
  8602. }
  8603. this._lineWidth = value;
  8604. this._markAsDirty();
  8605. },
  8606. enumerable: false,
  8607. configurable: true
  8608. });
  8609. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8610. set: function (value) {
  8611. return;
  8612. },
  8613. enumerable: false,
  8614. configurable: true
  8615. });
  8616. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8617. set: function (value) {
  8618. return;
  8619. },
  8620. enumerable: false,
  8621. configurable: true
  8622. });
  8623. MultiLine.prototype._getTypeName = function () {
  8624. return "MultiLine";
  8625. };
  8626. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8627. context.save();
  8628. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8629. context.shadowColor = this.shadowColor;
  8630. context.shadowBlur = this.shadowBlur;
  8631. context.shadowOffsetX = this.shadowOffsetX;
  8632. context.shadowOffsetY = this.shadowOffsetY;
  8633. }
  8634. this._applyStates(context);
  8635. context.strokeStyle = this.color;
  8636. context.lineWidth = this._lineWidth;
  8637. context.setLineDash(this._dash);
  8638. context.beginPath();
  8639. var first = true; //first index is not necessarily 0
  8640. this._points.forEach(function (point) {
  8641. if (!point) {
  8642. return;
  8643. }
  8644. if (first) {
  8645. context.moveTo(point._point.x, point._point.y);
  8646. first = false;
  8647. }
  8648. else {
  8649. context.lineTo(point._point.x, point._point.y);
  8650. }
  8651. });
  8652. context.stroke();
  8653. context.restore();
  8654. };
  8655. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8656. var _this = this;
  8657. this._minX = null;
  8658. this._minY = null;
  8659. this._maxX = null;
  8660. this._maxY = null;
  8661. this._points.forEach(function (point, index) {
  8662. if (!point) {
  8663. return;
  8664. }
  8665. point.translate();
  8666. if (_this._minX == null || point._point.x < _this._minX) {
  8667. _this._minX = point._point.x;
  8668. }
  8669. if (_this._minY == null || point._point.y < _this._minY) {
  8670. _this._minY = point._point.y;
  8671. }
  8672. if (_this._maxX == null || point._point.x > _this._maxX) {
  8673. _this._maxX = point._point.x;
  8674. }
  8675. if (_this._maxY == null || point._point.y > _this._maxY) {
  8676. _this._maxY = point._point.y;
  8677. }
  8678. });
  8679. if (this._minX == null) {
  8680. this._minX = 0;
  8681. }
  8682. if (this._minY == null) {
  8683. this._minY = 0;
  8684. }
  8685. if (this._maxX == null) {
  8686. this._maxX = 0;
  8687. }
  8688. if (this._maxY == null) {
  8689. this._maxY = 0;
  8690. }
  8691. };
  8692. MultiLine.prototype._measure = function () {
  8693. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8694. return;
  8695. }
  8696. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8697. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8698. };
  8699. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8700. if (this._minX == null || this._minY == null) {
  8701. return;
  8702. }
  8703. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8704. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8705. };
  8706. MultiLine.prototype.dispose = function () {
  8707. this.reset();
  8708. _super.prototype.dispose.call(this);
  8709. };
  8710. return MultiLine;
  8711. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8712. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8713. /***/ }),
  8714. /***/ "./2D/controls/radioButton.ts":
  8715. /*!************************************!*\
  8716. !*** ./2D/controls/radioButton.ts ***!
  8717. \************************************/
  8718. /*! exports provided: RadioButton */
  8719. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8720. "use strict";
  8721. __webpack_require__.r(__webpack_exports__);
  8722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8723. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8724. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  8725. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8726. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8727. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8728. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8729. /**
  8730. * Class used to create radio button controls
  8731. */
  8732. var RadioButton = /** @class */ (function (_super) {
  8733. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8734. /**
  8735. * Creates a new RadioButton
  8736. * @param name defines the control name
  8737. */
  8738. function RadioButton(name) {
  8739. var _this = _super.call(this, name) || this;
  8740. _this.name = name;
  8741. _this._isChecked = false;
  8742. _this._background = "black";
  8743. _this._checkSizeRatio = 0.8;
  8744. _this._thickness = 1;
  8745. /** Gets or sets group name */
  8746. _this.group = "";
  8747. /** Observable raised when isChecked is changed */
  8748. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8749. _this.isPointerBlocker = true;
  8750. return _this;
  8751. }
  8752. Object.defineProperty(RadioButton.prototype, "thickness", {
  8753. /** Gets or sets border thickness */
  8754. get: function () {
  8755. return this._thickness;
  8756. },
  8757. set: function (value) {
  8758. if (this._thickness === value) {
  8759. return;
  8760. }
  8761. this._thickness = value;
  8762. this._markAsDirty();
  8763. },
  8764. enumerable: false,
  8765. configurable: true
  8766. });
  8767. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8768. /** Gets or sets a value indicating the ratio between overall size and check size */
  8769. get: function () {
  8770. return this._checkSizeRatio;
  8771. },
  8772. set: function (value) {
  8773. value = Math.max(Math.min(1, value), 0);
  8774. if (this._checkSizeRatio === value) {
  8775. return;
  8776. }
  8777. this._checkSizeRatio = value;
  8778. this._markAsDirty();
  8779. },
  8780. enumerable: false,
  8781. configurable: true
  8782. });
  8783. Object.defineProperty(RadioButton.prototype, "background", {
  8784. /** Gets or sets background color */
  8785. get: function () {
  8786. return this._background;
  8787. },
  8788. set: function (value) {
  8789. if (this._background === value) {
  8790. return;
  8791. }
  8792. this._background = value;
  8793. this._markAsDirty();
  8794. },
  8795. enumerable: false,
  8796. configurable: true
  8797. });
  8798. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8799. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8800. get: function () {
  8801. return this._isChecked;
  8802. },
  8803. set: function (value) {
  8804. var _this = this;
  8805. if (this._isChecked === value) {
  8806. return;
  8807. }
  8808. this._isChecked = value;
  8809. this._markAsDirty();
  8810. this.onIsCheckedChangedObservable.notifyObservers(value);
  8811. if (this._isChecked && this._host) {
  8812. // Update all controls from same group
  8813. this._host.executeOnAllControls(function (control) {
  8814. if (control === _this) {
  8815. return;
  8816. }
  8817. if (control.group === undefined) {
  8818. return;
  8819. }
  8820. var childRadio = control;
  8821. if (childRadio.group === _this.group) {
  8822. childRadio.isChecked = false;
  8823. }
  8824. });
  8825. }
  8826. },
  8827. enumerable: false,
  8828. configurable: true
  8829. });
  8830. RadioButton.prototype._getTypeName = function () {
  8831. return "RadioButton";
  8832. };
  8833. RadioButton.prototype._draw = function (context) {
  8834. context.save();
  8835. this._applyStates(context);
  8836. var actualWidth = this._currentMeasure.width - this._thickness;
  8837. var actualHeight = this._currentMeasure.height - this._thickness;
  8838. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8839. context.shadowColor = this.shadowColor;
  8840. context.shadowBlur = this.shadowBlur;
  8841. context.shadowOffsetX = this.shadowOffsetX;
  8842. context.shadowOffsetY = this.shadowOffsetY;
  8843. }
  8844. // Outer
  8845. _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);
  8846. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8847. context.fill();
  8848. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8849. context.shadowBlur = 0;
  8850. context.shadowOffsetX = 0;
  8851. context.shadowOffsetY = 0;
  8852. }
  8853. context.strokeStyle = this.color;
  8854. context.lineWidth = this._thickness;
  8855. context.stroke();
  8856. // Inner
  8857. if (this._isChecked) {
  8858. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8859. var offsetWidth = actualWidth * this._checkSizeRatio;
  8860. var offseHeight = actualHeight * this._checkSizeRatio;
  8861. _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);
  8862. context.fill();
  8863. }
  8864. context.restore();
  8865. };
  8866. // Events
  8867. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8868. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8869. return false;
  8870. }
  8871. if (!this.isChecked) {
  8872. this.isChecked = true;
  8873. }
  8874. return true;
  8875. };
  8876. /**
  8877. * Utility function to easily create a radio button with a header
  8878. * @param title defines the label to use for the header
  8879. * @param group defines the group to use for the radio button
  8880. * @param isChecked defines the initial state of the radio button
  8881. * @param onValueChanged defines the callback to call when value changes
  8882. * @returns a StackPanel containing the radio button and a textBlock
  8883. */
  8884. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8885. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8886. panel.isVertical = false;
  8887. panel.height = "30px";
  8888. var radio = new RadioButton();
  8889. radio.width = "20px";
  8890. radio.height = "20px";
  8891. radio.isChecked = isChecked;
  8892. radio.color = "green";
  8893. radio.group = group;
  8894. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8895. panel.addControl(radio);
  8896. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8897. header.text = title;
  8898. header.width = "180px";
  8899. header.paddingLeft = "5px";
  8900. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8901. header.color = "white";
  8902. panel.addControl(header);
  8903. return panel;
  8904. };
  8905. return RadioButton;
  8906. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8907. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8908. /***/ }),
  8909. /***/ "./2D/controls/rectangle.ts":
  8910. /*!**********************************!*\
  8911. !*** ./2D/controls/rectangle.ts ***!
  8912. \**********************************/
  8913. /*! exports provided: Rectangle */
  8914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8915. "use strict";
  8916. __webpack_require__.r(__webpack_exports__);
  8917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8918. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8919. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8920. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  8921. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8922. /** Class used to create rectangle container */
  8923. var Rectangle = /** @class */ (function (_super) {
  8924. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8925. /**
  8926. * Creates a new Rectangle
  8927. * @param name defines the control name
  8928. */
  8929. function Rectangle(name) {
  8930. var _this = _super.call(this, name) || this;
  8931. _this.name = name;
  8932. _this._thickness = 1;
  8933. _this._cornerRadius = 0;
  8934. return _this;
  8935. }
  8936. Object.defineProperty(Rectangle.prototype, "thickness", {
  8937. /** Gets or sets border thickness */
  8938. get: function () {
  8939. return this._thickness;
  8940. },
  8941. set: function (value) {
  8942. if (this._thickness === value) {
  8943. return;
  8944. }
  8945. this._thickness = value;
  8946. this._markAsDirty();
  8947. },
  8948. enumerable: false,
  8949. configurable: true
  8950. });
  8951. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8952. /** Gets or sets the corner radius angle */
  8953. get: function () {
  8954. return this._cornerRadius;
  8955. },
  8956. set: function (value) {
  8957. if (value < 0) {
  8958. value = 0;
  8959. }
  8960. if (this._cornerRadius === value) {
  8961. return;
  8962. }
  8963. this._cornerRadius = value;
  8964. this._markAsDirty();
  8965. },
  8966. enumerable: false,
  8967. configurable: true
  8968. });
  8969. Rectangle.prototype._getTypeName = function () {
  8970. return "Rectangle";
  8971. };
  8972. Rectangle.prototype._localDraw = function (context) {
  8973. context.save();
  8974. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8975. context.shadowColor = this.shadowColor;
  8976. context.shadowBlur = this.shadowBlur;
  8977. context.shadowOffsetX = this.shadowOffsetX;
  8978. context.shadowOffsetY = this.shadowOffsetY;
  8979. }
  8980. if (this._background) {
  8981. context.fillStyle = this._background;
  8982. if (this._cornerRadius) {
  8983. this._drawRoundedRect(context, this._thickness / 2);
  8984. context.fill();
  8985. }
  8986. else {
  8987. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8988. }
  8989. }
  8990. if (this._thickness) {
  8991. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8992. context.shadowBlur = 0;
  8993. context.shadowOffsetX = 0;
  8994. context.shadowOffsetY = 0;
  8995. }
  8996. if (this.color) {
  8997. context.strokeStyle = this.color;
  8998. }
  8999. context.lineWidth = this._thickness;
  9000. if (this._cornerRadius) {
  9001. this._drawRoundedRect(context, this._thickness / 2);
  9002. context.stroke();
  9003. }
  9004. else {
  9005. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  9006. }
  9007. }
  9008. context.restore();
  9009. };
  9010. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  9011. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9012. this._measureForChildren.width -= 2 * this._thickness;
  9013. this._measureForChildren.height -= 2 * this._thickness;
  9014. this._measureForChildren.left += this._thickness;
  9015. this._measureForChildren.top += this._thickness;
  9016. };
  9017. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  9018. if (offset === void 0) { offset = 0; }
  9019. var x = this._currentMeasure.left + offset;
  9020. var y = this._currentMeasure.top + offset;
  9021. var width = this._currentMeasure.width - offset * 2;
  9022. var height = this._currentMeasure.height - offset * 2;
  9023. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  9024. context.beginPath();
  9025. context.moveTo(x + radius, y);
  9026. context.lineTo(x + width - radius, y);
  9027. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  9028. context.lineTo(x + width, y + height - radius);
  9029. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  9030. context.lineTo(x + radius, y + height);
  9031. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  9032. context.lineTo(x, y + radius);
  9033. context.quadraticCurveTo(x, y, x + radius, y);
  9034. context.closePath();
  9035. };
  9036. Rectangle.prototype._clipForChildren = function (context) {
  9037. if (this._cornerRadius) {
  9038. this._drawRoundedRect(context, this._thickness);
  9039. context.clip();
  9040. }
  9041. };
  9042. return Rectangle;
  9043. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9044. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  9045. /***/ }),
  9046. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  9047. /*!***************************************************!*\
  9048. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  9049. \***************************************************/
  9050. /*! exports provided: ScrollViewer */
  9051. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9052. "use strict";
  9053. __webpack_require__.r(__webpack_exports__);
  9054. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  9055. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9056. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  9057. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  9058. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9059. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  9060. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  9061. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  9062. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  9063. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  9064. /**
  9065. * Class used to hold a viewer window and sliders in a grid
  9066. */
  9067. var ScrollViewer = /** @class */ (function (_super) {
  9068. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  9069. /**
  9070. * Creates a new ScrollViewer
  9071. * @param name of ScrollViewer
  9072. */
  9073. function ScrollViewer(name, isImageBased) {
  9074. var _this = _super.call(this, name) || this;
  9075. _this._barSize = 20;
  9076. _this._pointerIsOver = false;
  9077. _this._wheelPrecision = 0.05;
  9078. _this._thumbLength = 0.5;
  9079. _this._thumbHeight = 1;
  9080. _this._barImageHeight = 1;
  9081. _this._horizontalBarImageHeight = 1;
  9082. _this._verticalBarImageHeight = 1;
  9083. _this._oldWindowContentsWidth = 0;
  9084. _this._oldWindowContentsHeight = 0;
  9085. _this._forceHorizontalBar = false;
  9086. _this._forceVerticalBar = false;
  9087. _this._useImageBar = isImageBased ? isImageBased : false;
  9088. _this.onDirtyObservable.add(function () {
  9089. _this._horizontalBarSpace.color = _this.color;
  9090. _this._verticalBarSpace.color = _this.color;
  9091. _this._dragSpace.color = _this.color;
  9092. });
  9093. _this.onPointerEnterObservable.add(function () {
  9094. _this._pointerIsOver = true;
  9095. });
  9096. _this.onPointerOutObservable.add(function () {
  9097. _this._pointerIsOver = false;
  9098. });
  9099. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9100. if (_this._useImageBar) {
  9101. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9102. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9103. }
  9104. else {
  9105. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9106. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9107. }
  9108. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9109. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9110. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9111. _this._grid.addColumnDefinition(1);
  9112. _this._grid.addColumnDefinition(0, true);
  9113. _this._grid.addRowDefinition(1);
  9114. _this._grid.addRowDefinition(0, true);
  9115. _super.prototype.addControl.call(_this, _this._grid);
  9116. _this._grid.addControl(_this._window, 0, 0);
  9117. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9118. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9119. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9120. _this._verticalBarSpace.thickness = 1;
  9121. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9122. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9123. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9124. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9125. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9126. _this._horizontalBarSpace.thickness = 1;
  9127. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9128. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9129. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9130. _this._dragSpace.thickness = 1;
  9131. _this._grid.addControl(_this._dragSpace, 1, 1);
  9132. // Colors
  9133. if (!_this._useImageBar) {
  9134. _this.barColor = "grey";
  9135. _this.barBackground = "transparent";
  9136. }
  9137. return _this;
  9138. }
  9139. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9140. /**
  9141. * Gets the horizontal scrollbar
  9142. */
  9143. get: function () {
  9144. return this._horizontalBar;
  9145. },
  9146. enumerable: false,
  9147. configurable: true
  9148. });
  9149. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9150. /**
  9151. * Gets the vertical scrollbar
  9152. */
  9153. get: function () {
  9154. return this._verticalBar;
  9155. },
  9156. enumerable: false,
  9157. configurable: true
  9158. });
  9159. /**
  9160. * Adds a new control to the current container
  9161. * @param control defines the control to add
  9162. * @returns the current container
  9163. */
  9164. ScrollViewer.prototype.addControl = function (control) {
  9165. if (!control) {
  9166. return this;
  9167. }
  9168. this._window.addControl(control);
  9169. return this;
  9170. };
  9171. /**
  9172. * Removes a control from the current container
  9173. * @param control defines the control to remove
  9174. * @returns the current container
  9175. */
  9176. ScrollViewer.prototype.removeControl = function (control) {
  9177. this._window.removeControl(control);
  9178. return this;
  9179. };
  9180. Object.defineProperty(ScrollViewer.prototype, "children", {
  9181. /** Gets the list of children */
  9182. get: function () {
  9183. return this._window.children;
  9184. },
  9185. enumerable: false,
  9186. configurable: true
  9187. });
  9188. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9189. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9190. var child = _a[_i];
  9191. child._markMatrixAsDirty();
  9192. }
  9193. };
  9194. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9195. /**
  9196. * Freezes or unfreezes the controls in the window.
  9197. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9198. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9199. */
  9200. get: function () {
  9201. return this._window.freezeControls;
  9202. },
  9203. set: function (value) {
  9204. this._window.freezeControls = value;
  9205. },
  9206. enumerable: false,
  9207. configurable: true
  9208. });
  9209. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9210. /** Gets the bucket width */
  9211. get: function () {
  9212. return this._window.bucketWidth;
  9213. },
  9214. enumerable: false,
  9215. configurable: true
  9216. });
  9217. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9218. /** Gets the bucket height */
  9219. get: function () {
  9220. return this._window.bucketHeight;
  9221. },
  9222. enumerable: false,
  9223. configurable: true
  9224. });
  9225. /**
  9226. * Sets the bucket sizes.
  9227. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9228. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9229. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9230. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9231. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9232. * used), that's why it is not enabled by default.
  9233. * @param width width of the bucket
  9234. * @param height height of the bucket
  9235. */
  9236. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9237. this._window.setBucketSizes(width, height);
  9238. };
  9239. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9240. /**
  9241. * Forces the horizontal scroll bar to be displayed
  9242. */
  9243. get: function () {
  9244. return this._forceHorizontalBar;
  9245. },
  9246. set: function (value) {
  9247. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9248. this._horizontalBar.isVisible = value;
  9249. this._forceHorizontalBar = value;
  9250. },
  9251. enumerable: false,
  9252. configurable: true
  9253. });
  9254. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9255. /**
  9256. * Forces the vertical scroll bar to be displayed
  9257. */
  9258. get: function () {
  9259. return this._forceVerticalBar;
  9260. },
  9261. set: function (value) {
  9262. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9263. this._verticalBar.isVisible = value;
  9264. this._forceVerticalBar = value;
  9265. },
  9266. enumerable: false,
  9267. configurable: true
  9268. });
  9269. /** Reset the scroll viewer window to initial size */
  9270. ScrollViewer.prototype.resetWindow = function () {
  9271. this._window.width = "100%";
  9272. this._window.height = "100%";
  9273. };
  9274. ScrollViewer.prototype._getTypeName = function () {
  9275. return "ScrollViewer";
  9276. };
  9277. ScrollViewer.prototype._buildClientSizes = function () {
  9278. var ratio = this.host.idealRatio;
  9279. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9280. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9281. this._clientWidth = this._window.parentClientWidth;
  9282. this._clientHeight = this._window.parentClientHeight;
  9283. };
  9284. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9285. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9286. this._buildClientSizes();
  9287. };
  9288. ScrollViewer.prototype._postMeasure = function () {
  9289. _super.prototype._postMeasure.call(this);
  9290. this._updateScroller();
  9291. this._setWindowPosition(false);
  9292. };
  9293. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9294. /**
  9295. * Gets or sets the mouse wheel precision
  9296. * from 0 to 1 with a default value of 0.05
  9297. * */
  9298. get: function () {
  9299. return this._wheelPrecision;
  9300. },
  9301. set: function (value) {
  9302. if (this._wheelPrecision === value) {
  9303. return;
  9304. }
  9305. if (value < 0) {
  9306. value = 0;
  9307. }
  9308. if (value > 1) {
  9309. value = 1;
  9310. }
  9311. this._wheelPrecision = value;
  9312. },
  9313. enumerable: false,
  9314. configurable: true
  9315. });
  9316. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9317. /** Gets or sets the scroll bar container background color */
  9318. get: function () {
  9319. return this._horizontalBarSpace.background;
  9320. },
  9321. set: function (color) {
  9322. if (this._horizontalBarSpace.background === color) {
  9323. return;
  9324. }
  9325. this._horizontalBarSpace.background = color;
  9326. this._verticalBarSpace.background = color;
  9327. },
  9328. enumerable: false,
  9329. configurable: true
  9330. });
  9331. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9332. /** Gets or sets the bar color */
  9333. get: function () {
  9334. return this._barColor;
  9335. },
  9336. set: function (color) {
  9337. if (this._barColor === color) {
  9338. return;
  9339. }
  9340. this._barColor = color;
  9341. this._horizontalBar.color = color;
  9342. this._verticalBar.color = color;
  9343. },
  9344. enumerable: false,
  9345. configurable: true
  9346. });
  9347. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9348. /** Gets or sets the bar image */
  9349. get: function () {
  9350. return this._barImage;
  9351. },
  9352. set: function (value) {
  9353. if (this._barImage === value) {
  9354. return;
  9355. }
  9356. this._barImage = value;
  9357. var hb = this._horizontalBar;
  9358. var vb = this._verticalBar;
  9359. hb.thumbImage = value;
  9360. vb.thumbImage = value;
  9361. },
  9362. enumerable: false,
  9363. configurable: true
  9364. });
  9365. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9366. /** Gets or sets the horizontal bar image */
  9367. get: function () {
  9368. return this._horizontalBarImage;
  9369. },
  9370. set: function (value) {
  9371. if (this._horizontalBarImage === value) {
  9372. return;
  9373. }
  9374. this._horizontalBarImage = value;
  9375. var hb = this._horizontalBar;
  9376. hb.thumbImage = value;
  9377. },
  9378. enumerable: false,
  9379. configurable: true
  9380. });
  9381. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9382. /** Gets or sets the vertical bar image */
  9383. get: function () {
  9384. return this._verticalBarImage;
  9385. },
  9386. set: function (value) {
  9387. if (this._verticalBarImage === value) {
  9388. return;
  9389. }
  9390. this._verticalBarImage = value;
  9391. var vb = this._verticalBar;
  9392. vb.thumbImage = value;
  9393. },
  9394. enumerable: false,
  9395. configurable: true
  9396. });
  9397. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9398. /** Gets or sets the size of the bar */
  9399. get: function () {
  9400. return this._barSize;
  9401. },
  9402. set: function (value) {
  9403. if (this._barSize === value) {
  9404. return;
  9405. }
  9406. this._barSize = value;
  9407. this._markAsDirty();
  9408. if (this._horizontalBar.isVisible) {
  9409. this._grid.setRowDefinition(1, this._barSize, true);
  9410. }
  9411. if (this._verticalBar.isVisible) {
  9412. this._grid.setColumnDefinition(1, this._barSize, true);
  9413. }
  9414. },
  9415. enumerable: false,
  9416. configurable: true
  9417. });
  9418. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9419. /** Gets or sets the length of the thumb */
  9420. get: function () {
  9421. return this._thumbLength;
  9422. },
  9423. set: function (value) {
  9424. if (this._thumbLength === value) {
  9425. return;
  9426. }
  9427. if (value <= 0) {
  9428. value = 0.1;
  9429. }
  9430. if (value > 1) {
  9431. value = 1;
  9432. }
  9433. this._thumbLength = value;
  9434. var hb = this._horizontalBar;
  9435. var vb = this._verticalBar;
  9436. hb.thumbLength = value;
  9437. vb.thumbLength = value;
  9438. this._markAsDirty();
  9439. },
  9440. enumerable: false,
  9441. configurable: true
  9442. });
  9443. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9444. /** Gets or sets the height of the thumb */
  9445. get: function () {
  9446. return this._thumbHeight;
  9447. },
  9448. set: function (value) {
  9449. if (this._thumbHeight === value) {
  9450. return;
  9451. }
  9452. if (value <= 0) {
  9453. value = 0.1;
  9454. }
  9455. if (value > 1) {
  9456. value = 1;
  9457. }
  9458. this._thumbHeight = value;
  9459. var hb = this._horizontalBar;
  9460. var vb = this._verticalBar;
  9461. hb.thumbHeight = value;
  9462. vb.thumbHeight = value;
  9463. this._markAsDirty();
  9464. },
  9465. enumerable: false,
  9466. configurable: true
  9467. });
  9468. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9469. /** Gets or sets the height of the bar image */
  9470. get: function () {
  9471. return this._barImageHeight;
  9472. },
  9473. set: function (value) {
  9474. if (this._barImageHeight === value) {
  9475. return;
  9476. }
  9477. if (value <= 0) {
  9478. value = 0.1;
  9479. }
  9480. if (value > 1) {
  9481. value = 1;
  9482. }
  9483. this._barImageHeight = value;
  9484. var hb = this._horizontalBar;
  9485. var vb = this._verticalBar;
  9486. hb.barImageHeight = value;
  9487. vb.barImageHeight = value;
  9488. this._markAsDirty();
  9489. },
  9490. enumerable: false,
  9491. configurable: true
  9492. });
  9493. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9494. /** Gets or sets the height of the horizontal bar image */
  9495. get: function () {
  9496. return this._horizontalBarImageHeight;
  9497. },
  9498. set: function (value) {
  9499. if (this._horizontalBarImageHeight === value) {
  9500. return;
  9501. }
  9502. if (value <= 0) {
  9503. value = 0.1;
  9504. }
  9505. if (value > 1) {
  9506. value = 1;
  9507. }
  9508. this._horizontalBarImageHeight = value;
  9509. var hb = this._horizontalBar;
  9510. hb.barImageHeight = value;
  9511. this._markAsDirty();
  9512. },
  9513. enumerable: false,
  9514. configurable: true
  9515. });
  9516. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9517. /** Gets or sets the height of the vertical bar image */
  9518. get: function () {
  9519. return this._verticalBarImageHeight;
  9520. },
  9521. set: function (value) {
  9522. if (this._verticalBarImageHeight === value) {
  9523. return;
  9524. }
  9525. if (value <= 0) {
  9526. value = 0.1;
  9527. }
  9528. if (value > 1) {
  9529. value = 1;
  9530. }
  9531. this._verticalBarImageHeight = value;
  9532. var vb = this._verticalBar;
  9533. vb.barImageHeight = value;
  9534. this._markAsDirty();
  9535. },
  9536. enumerable: false,
  9537. configurable: true
  9538. });
  9539. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9540. /** Gets or sets the bar background */
  9541. get: function () {
  9542. return this._barBackground;
  9543. },
  9544. set: function (color) {
  9545. if (this._barBackground === color) {
  9546. return;
  9547. }
  9548. this._barBackground = color;
  9549. var hb = this._horizontalBar;
  9550. var vb = this._verticalBar;
  9551. hb.background = color;
  9552. vb.background = color;
  9553. this._dragSpace.background = color;
  9554. },
  9555. enumerable: false,
  9556. configurable: true
  9557. });
  9558. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9559. /** Gets or sets the bar background image */
  9560. get: function () {
  9561. return this._barBackgroundImage;
  9562. },
  9563. set: function (value) {
  9564. if (this._barBackgroundImage === value) {
  9565. }
  9566. this._barBackgroundImage = value;
  9567. var hb = this._horizontalBar;
  9568. var vb = this._verticalBar;
  9569. hb.backgroundImage = value;
  9570. vb.backgroundImage = value;
  9571. },
  9572. enumerable: false,
  9573. configurable: true
  9574. });
  9575. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9576. /** Gets or sets the horizontal bar background image */
  9577. get: function () {
  9578. return this._horizontalBarBackgroundImage;
  9579. },
  9580. set: function (value) {
  9581. if (this._horizontalBarBackgroundImage === value) {
  9582. }
  9583. this._horizontalBarBackgroundImage = value;
  9584. var hb = this._horizontalBar;
  9585. hb.backgroundImage = value;
  9586. },
  9587. enumerable: false,
  9588. configurable: true
  9589. });
  9590. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9591. /** Gets or sets the vertical bar background image */
  9592. get: function () {
  9593. return this._verticalBarBackgroundImage;
  9594. },
  9595. set: function (value) {
  9596. if (this._verticalBarBackgroundImage === value) {
  9597. }
  9598. this._verticalBarBackgroundImage = value;
  9599. var vb = this._verticalBar;
  9600. vb.backgroundImage = value;
  9601. },
  9602. enumerable: false,
  9603. configurable: true
  9604. });
  9605. ScrollViewer.prototype._setWindowPosition = function (force) {
  9606. if (force === void 0) { force = true; }
  9607. var ratio = this.host.idealRatio;
  9608. var windowContentsWidth = this._window._currentMeasure.width;
  9609. var windowContentsHeight = this._window._currentMeasure.height;
  9610. if (!force && this._oldWindowContentsWidth === windowContentsWidth && this._oldWindowContentsHeight === windowContentsHeight) {
  9611. return;
  9612. }
  9613. this._oldWindowContentsWidth = windowContentsWidth;
  9614. this._oldWindowContentsHeight = windowContentsHeight;
  9615. var _endLeft = this._clientWidth - windowContentsWidth;
  9616. var _endTop = this._clientHeight - windowContentsHeight;
  9617. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9618. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9619. if (newLeft !== this._window.left) {
  9620. this._window.left = newLeft;
  9621. if (!this.freezeControls) {
  9622. this._rebuildLayout = true;
  9623. }
  9624. }
  9625. if (newTop !== this._window.top) {
  9626. this._window.top = newTop;
  9627. if (!this.freezeControls) {
  9628. this._rebuildLayout = true;
  9629. }
  9630. }
  9631. };
  9632. /** @hidden */
  9633. ScrollViewer.prototype._updateScroller = function () {
  9634. var windowContentsWidth = this._window._currentMeasure.width;
  9635. var windowContentsHeight = this._window._currentMeasure.height;
  9636. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9637. this._grid.setRowDefinition(1, 0, true);
  9638. this._horizontalBar.isVisible = false;
  9639. this._horizontalBar.value = 0;
  9640. this._rebuildLayout = true;
  9641. }
  9642. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9643. this._grid.setRowDefinition(1, this._barSize, true);
  9644. this._horizontalBar.isVisible = true;
  9645. this._rebuildLayout = true;
  9646. }
  9647. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9648. this._grid.setColumnDefinition(1, 0, true);
  9649. this._verticalBar.isVisible = false;
  9650. this._verticalBar.value = 0;
  9651. this._rebuildLayout = true;
  9652. }
  9653. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9654. this._grid.setColumnDefinition(1, this._barSize, true);
  9655. this._verticalBar.isVisible = true;
  9656. this._rebuildLayout = true;
  9657. }
  9658. this._buildClientSizes();
  9659. var ratio = this.host.idealRatio;
  9660. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9661. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9662. };
  9663. ScrollViewer.prototype._link = function (host) {
  9664. _super.prototype._link.call(this, host);
  9665. this._attachWheel();
  9666. };
  9667. /** @hidden */
  9668. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9669. var _this = this;
  9670. barControl.paddingLeft = 0;
  9671. barControl.width = "100%";
  9672. barControl.height = "100%";
  9673. barControl.barOffset = 0;
  9674. barControl.value = 0;
  9675. barControl.maximum = 1;
  9676. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9677. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9678. barControl.isVertical = isVertical;
  9679. barControl.rotation = rotation;
  9680. barControl.isVisible = false;
  9681. barContainer.addControl(barControl);
  9682. barControl.onValueChangedObservable.add(function (value) {
  9683. _this._setWindowPosition();
  9684. });
  9685. };
  9686. /** @hidden */
  9687. ScrollViewer.prototype._attachWheel = function () {
  9688. var _this = this;
  9689. if (!this._host || this._onWheelObserver) {
  9690. return;
  9691. }
  9692. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  9693. if (!_this._pointerIsOver) {
  9694. return;
  9695. }
  9696. if (_this._verticalBar.isVisible == true) {
  9697. if (pi.y < 0 && _this._verticalBar.value > 0) {
  9698. _this._verticalBar.value -= _this._wheelPrecision;
  9699. }
  9700. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9701. _this._verticalBar.value += _this._wheelPrecision;
  9702. }
  9703. }
  9704. if (_this._horizontalBar.isVisible == true) {
  9705. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9706. _this._horizontalBar.value += _this._wheelPrecision;
  9707. }
  9708. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  9709. _this._horizontalBar.value -= _this._wheelPrecision;
  9710. }
  9711. }
  9712. });
  9713. };
  9714. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9715. if (!this.isHighlighted) {
  9716. return;
  9717. }
  9718. _super.prototype._renderHighlightSpecific.call(this, context);
  9719. this._grid._renderHighlightSpecific(context);
  9720. context.restore();
  9721. };
  9722. /** Releases associated resources */
  9723. ScrollViewer.prototype.dispose = function () {
  9724. this.onWheelObservable.remove(this._onWheelObserver);
  9725. this._onWheelObserver = null;
  9726. _super.prototype.dispose.call(this);
  9727. };
  9728. return ScrollViewer;
  9729. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9730. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9731. /***/ }),
  9732. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9733. /*!*********************************************************!*\
  9734. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9735. \*********************************************************/
  9736. /*! exports provided: _ScrollViewerWindow */
  9737. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9738. "use strict";
  9739. __webpack_require__.r(__webpack_exports__);
  9740. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9741. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9742. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9743. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9744. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9745. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9746. /**
  9747. * Class used to hold a the container for ScrollViewer
  9748. * @hidden
  9749. */
  9750. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9751. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9752. /**
  9753. * Creates a new ScrollViewerWindow
  9754. * @param name of ScrollViewerWindow
  9755. */
  9756. function _ScrollViewerWindow(name) {
  9757. var _this = _super.call(this, name) || this;
  9758. _this._freezeControls = false;
  9759. _this._bucketWidth = 0;
  9760. _this._bucketHeight = 0;
  9761. _this._buckets = {};
  9762. return _this;
  9763. }
  9764. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9765. get: function () {
  9766. return this._freezeControls;
  9767. },
  9768. set: function (value) {
  9769. if (this._freezeControls === value) {
  9770. return;
  9771. }
  9772. if (!value) {
  9773. this._restoreMeasures();
  9774. }
  9775. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9776. this._freezeControls = false;
  9777. var textureSize = this.host.getSize();
  9778. var renderWidth = textureSize.width;
  9779. var renderHeight = textureSize.height;
  9780. var context = this.host.getContext();
  9781. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9782. this.host._numLayoutCalls = 0;
  9783. this.host._rootContainer._layout(measure, context);
  9784. // in freeze mode, prepare children measures accordingly
  9785. if (value) {
  9786. this._updateMeasures();
  9787. if (this._useBuckets()) {
  9788. this._makeBuckets();
  9789. }
  9790. }
  9791. this._freezeControls = value;
  9792. this.host.markAsDirty(); // redraw with the (new) current settings
  9793. },
  9794. enumerable: false,
  9795. configurable: true
  9796. });
  9797. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9798. get: function () {
  9799. return this._bucketWidth;
  9800. },
  9801. enumerable: false,
  9802. configurable: true
  9803. });
  9804. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9805. get: function () {
  9806. return this._bucketHeight;
  9807. },
  9808. enumerable: false,
  9809. configurable: true
  9810. });
  9811. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9812. this._bucketWidth = width;
  9813. this._bucketHeight = height;
  9814. if (this._useBuckets()) {
  9815. if (this._freezeControls) {
  9816. this._makeBuckets();
  9817. }
  9818. }
  9819. else {
  9820. this._buckets = {};
  9821. }
  9822. };
  9823. _ScrollViewerWindow.prototype._useBuckets = function () {
  9824. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9825. };
  9826. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9827. this._buckets = {};
  9828. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9829. this._dispatchInBuckets(this._children);
  9830. this._oldLeft = null;
  9831. this._oldTop = null;
  9832. };
  9833. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9834. for (var i = 0; i < children.length; ++i) {
  9835. var child = children[i];
  9836. 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);
  9837. while (bStartY <= bEndY) {
  9838. for (var x = bStartX; x <= bEndX; ++x) {
  9839. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9840. if (!lstc) {
  9841. lstc = [];
  9842. this._buckets[bucket] = lstc;
  9843. }
  9844. lstc.push(child);
  9845. }
  9846. bStartY++;
  9847. }
  9848. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9849. this._dispatchInBuckets(child._children);
  9850. }
  9851. }
  9852. };
  9853. // reset left and top measures for the window and all its children
  9854. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9855. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9856. this._measureForChildren.left -= left;
  9857. this._measureForChildren.top -= top;
  9858. this._currentMeasure.left -= left;
  9859. this._currentMeasure.top -= top;
  9860. this._customData.origLeftForChildren = this._measureForChildren.left;
  9861. this._customData.origTopForChildren = this._measureForChildren.top;
  9862. this._customData.origLeft = this._currentMeasure.left;
  9863. this._customData.origTop = this._currentMeasure.top;
  9864. this._updateChildrenMeasures(this._children, left, top);
  9865. };
  9866. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9867. for (var i = 0; i < children.length; ++i) {
  9868. var child = children[i];
  9869. child._currentMeasure.left -= left;
  9870. child._currentMeasure.top -= top;
  9871. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9872. child._customData._origTop = child._currentMeasure.top;
  9873. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9874. this._updateChildrenMeasures(child._children, left, top);
  9875. }
  9876. }
  9877. };
  9878. _ScrollViewerWindow.prototype._restoreMeasures = function () {
  9879. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9880. this._measureForChildren.left = this._customData.origLeftForChildren + left;
  9881. this._measureForChildren.top = this._customData.origTopForChildren + top;
  9882. this._currentMeasure.left = this._customData.origLeft + left;
  9883. this._currentMeasure.top = this._customData.origTop + top;
  9884. };
  9885. _ScrollViewerWindow.prototype._getTypeName = function () {
  9886. return "ScrollViewerWindow";
  9887. };
  9888. /** @hidden */
  9889. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9890. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9891. this._parentMeasure = parentMeasure;
  9892. this._measureForChildren.left = this._currentMeasure.left;
  9893. this._measureForChildren.top = this._currentMeasure.top;
  9894. this._measureForChildren.width = parentMeasure.width;
  9895. this._measureForChildren.height = parentMeasure.height;
  9896. };
  9897. /** @hidden */
  9898. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9899. if (this._freezeControls) {
  9900. this.invalidateRect(); // will trigger a redraw of the window
  9901. return false;
  9902. }
  9903. return _super.prototype._layout.call(this, parentMeasure, context);
  9904. };
  9905. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9906. for (var i = 0; i < children.length; ++i) {
  9907. var child = children[i];
  9908. child._currentMeasure.left = child._customData._origLeft + left;
  9909. child._currentMeasure.top = child._customData._origTop + top;
  9910. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9911. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9912. this._scrollChildren(child._children, left, top);
  9913. }
  9914. }
  9915. };
  9916. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9917. 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);
  9918. while (bStartY <= bEndY) {
  9919. for (var x = bStartX; x <= bEndX; ++x) {
  9920. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9921. if (lstc) {
  9922. for (var i = 0; i < lstc.length; ++i) {
  9923. var child = lstc[i];
  9924. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9925. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9926. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9927. }
  9928. }
  9929. }
  9930. bStartY++;
  9931. }
  9932. };
  9933. /** @hidden */
  9934. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9935. if (!this._freezeControls) {
  9936. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9937. return;
  9938. }
  9939. this._localDraw(context);
  9940. if (this.clipChildren) {
  9941. this._clipForChildren(context);
  9942. }
  9943. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9944. if (this._useBuckets()) {
  9945. if (this._oldLeft !== null && this._oldTop !== null) {
  9946. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  9947. this._scrollChildrenWithBuckets(left, top, left, top);
  9948. }
  9949. else {
  9950. this._scrollChildren(this._children, left, top);
  9951. }
  9952. }
  9953. else {
  9954. this._scrollChildren(this._children, left, top);
  9955. }
  9956. this._oldLeft = left;
  9957. this._oldTop = top;
  9958. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9959. var child = _a[_i];
  9960. if (!child._intersectsRect(this._parentMeasure)) {
  9961. continue;
  9962. }
  9963. child._render(context, this._parentMeasure);
  9964. }
  9965. };
  9966. _ScrollViewerWindow.prototype._postMeasure = function () {
  9967. if (this._freezeControls) {
  9968. _super.prototype._postMeasure.call(this);
  9969. return;
  9970. }
  9971. var maxWidth = this.parentClientWidth;
  9972. var maxHeight = this.parentClientHeight;
  9973. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9974. var child = _a[_i];
  9975. if (!child.isVisible || child.notRenderable) {
  9976. continue;
  9977. }
  9978. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9979. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9980. }
  9981. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9982. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9983. }
  9984. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width + child.paddingRightInPixels);
  9985. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height + child.paddingBottomInPixels);
  9986. }
  9987. if (this._currentMeasure.width !== maxWidth) {
  9988. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9989. this._currentMeasure.width = maxWidth;
  9990. this._rebuildLayout = true;
  9991. this._isDirty = true;
  9992. }
  9993. if (this._currentMeasure.height !== maxHeight) {
  9994. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  9995. this._currentMeasure.height = maxHeight;
  9996. this._rebuildLayout = true;
  9997. this._isDirty = true;
  9998. }
  9999. _super.prototype._postMeasure.call(this);
  10000. };
  10001. return _ScrollViewerWindow;
  10002. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10003. /***/ }),
  10004. /***/ "./2D/controls/selector.ts":
  10005. /*!*********************************!*\
  10006. !*** ./2D/controls/selector.ts ***!
  10007. \*********************************/
  10008. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  10009. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10010. "use strict";
  10011. __webpack_require__.r(__webpack_exports__);
  10012. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  10013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  10014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  10015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  10016. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  10017. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10018. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  10019. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10020. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10021. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10022. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  10023. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  10024. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  10025. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10026. /** Class used to create a RadioGroup
  10027. * which contains groups of radio buttons
  10028. */
  10029. var SelectorGroup = /** @class */ (function () {
  10030. /**
  10031. * Creates a new SelectorGroup
  10032. * @param name of group, used as a group heading
  10033. */
  10034. function SelectorGroup(
  10035. /** name of SelectorGroup */
  10036. name) {
  10037. this.name = name;
  10038. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10039. this._selectors = new Array();
  10040. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10041. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10042. this._groupHeader = this._addGroupHeader(name);
  10043. }
  10044. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  10045. /** Gets the groupPanel of the SelectorGroup */
  10046. get: function () {
  10047. return this._groupPanel;
  10048. },
  10049. enumerable: false,
  10050. configurable: true
  10051. });
  10052. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  10053. /** Gets the selectors array */
  10054. get: function () {
  10055. return this._selectors;
  10056. },
  10057. enumerable: false,
  10058. configurable: true
  10059. });
  10060. Object.defineProperty(SelectorGroup.prototype, "header", {
  10061. /** Gets and sets the group header */
  10062. get: function () {
  10063. return this._groupHeader.text;
  10064. },
  10065. set: function (label) {
  10066. if (this._groupHeader.text === "label") {
  10067. return;
  10068. }
  10069. this._groupHeader.text = label;
  10070. },
  10071. enumerable: false,
  10072. configurable: true
  10073. });
  10074. /** @hidden */
  10075. SelectorGroup.prototype._addGroupHeader = function (text) {
  10076. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  10077. groupHeading.width = 0.9;
  10078. groupHeading.height = "30px";
  10079. groupHeading.textWrapping = true;
  10080. groupHeading.color = "black";
  10081. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10082. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10083. groupHeading.left = "2px";
  10084. this._groupPanel.addControl(groupHeading);
  10085. return groupHeading;
  10086. };
  10087. /** @hidden*/
  10088. SelectorGroup.prototype._getSelector = function (selectorNb) {
  10089. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10090. return;
  10091. }
  10092. return this._selectors[selectorNb];
  10093. };
  10094. /** Removes the selector at the given position
  10095. * @param selectorNb the position of the selector within the group
  10096. */
  10097. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  10098. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10099. return;
  10100. }
  10101. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10102. this._selectors.splice(selectorNb, 1);
  10103. };
  10104. return SelectorGroup;
  10105. }());
  10106. /** Class used to create a CheckboxGroup
  10107. * which contains groups of checkbox buttons
  10108. */
  10109. var CheckboxGroup = /** @class */ (function (_super) {
  10110. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10111. function CheckboxGroup() {
  10112. return _super !== null && _super.apply(this, arguments) || this;
  10113. }
  10114. /** Adds a checkbox as a control
  10115. * @param text is the label for the selector
  10116. * @param func is the function called when the Selector is checked
  10117. * @param checked is true when Selector is checked
  10118. */
  10119. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10120. if (func === void 0) { func = function (s) { }; }
  10121. if (checked === void 0) { checked = false; }
  10122. var checked = checked || false;
  10123. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10124. button.width = "20px";
  10125. button.height = "20px";
  10126. button.color = "#364249";
  10127. button.background = "#CCCCCC";
  10128. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10129. button.onIsCheckedChangedObservable.add(function (state) {
  10130. func(state);
  10131. });
  10132. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10133. _selector.height = "30px";
  10134. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10135. _selector.left = "4px";
  10136. this.groupPanel.addControl(_selector);
  10137. this.selectors.push(_selector);
  10138. button.isChecked = checked;
  10139. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10140. button.color = this.groupPanel.parent.parent.buttonColor;
  10141. button.background = this.groupPanel.parent.parent.buttonBackground;
  10142. }
  10143. };
  10144. /** @hidden */
  10145. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10146. this.selectors[selectorNb].children[1].text = label;
  10147. };
  10148. /** @hidden */
  10149. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10150. this.selectors[selectorNb].children[1].color = color;
  10151. };
  10152. /** @hidden */
  10153. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10154. this.selectors[selectorNb].children[0].color = color;
  10155. };
  10156. /** @hidden */
  10157. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10158. this.selectors[selectorNb].children[0].background = color;
  10159. };
  10160. return CheckboxGroup;
  10161. }(SelectorGroup));
  10162. /** Class used to create a RadioGroup
  10163. * which contains groups of radio buttons
  10164. */
  10165. var RadioGroup = /** @class */ (function (_super) {
  10166. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10167. function RadioGroup() {
  10168. var _this = _super !== null && _super.apply(this, arguments) || this;
  10169. _this._selectNb = 0;
  10170. return _this;
  10171. }
  10172. /** Adds a radio button as a control
  10173. * @param label is the label for the selector
  10174. * @param func is the function called when the Selector is checked
  10175. * @param checked is true when Selector is checked
  10176. */
  10177. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10178. if (func === void 0) { func = function (n) { }; }
  10179. if (checked === void 0) { checked = false; }
  10180. var nb = this._selectNb++;
  10181. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10182. button.name = label;
  10183. button.width = "20px";
  10184. button.height = "20px";
  10185. button.color = "#364249";
  10186. button.background = "#CCCCCC";
  10187. button.group = this.name;
  10188. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10189. button.onIsCheckedChangedObservable.add(function (state) {
  10190. if (state) {
  10191. func(nb);
  10192. }
  10193. });
  10194. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10195. _selector.height = "30px";
  10196. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10197. _selector.left = "4px";
  10198. this.groupPanel.addControl(_selector);
  10199. this.selectors.push(_selector);
  10200. button.isChecked = checked;
  10201. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10202. button.color = this.groupPanel.parent.parent.buttonColor;
  10203. button.background = this.groupPanel.parent.parent.buttonBackground;
  10204. }
  10205. };
  10206. /** @hidden */
  10207. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10208. this.selectors[selectorNb].children[1].text = label;
  10209. };
  10210. /** @hidden */
  10211. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10212. this.selectors[selectorNb].children[1].color = color;
  10213. };
  10214. /** @hidden */
  10215. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10216. this.selectors[selectorNb].children[0].color = color;
  10217. };
  10218. /** @hidden */
  10219. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10220. this.selectors[selectorNb].children[0].background = color;
  10221. };
  10222. return RadioGroup;
  10223. }(SelectorGroup));
  10224. /** Class used to create a SliderGroup
  10225. * which contains groups of slider buttons
  10226. */
  10227. var SliderGroup = /** @class */ (function (_super) {
  10228. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10229. function SliderGroup() {
  10230. return _super !== null && _super.apply(this, arguments) || this;
  10231. }
  10232. /**
  10233. * Adds a slider to the SelectorGroup
  10234. * @param label is the label for the SliderBar
  10235. * @param func is the function called when the Slider moves
  10236. * @param unit is a string describing the units used, eg degrees or metres
  10237. * @param min is the minimum value for the Slider
  10238. * @param max is the maximum value for the Slider
  10239. * @param value is the start value for the Slider between min and max
  10240. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10241. */
  10242. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10243. if (func === void 0) { func = function (v) { }; }
  10244. if (unit === void 0) { unit = "Units"; }
  10245. if (min === void 0) { min = 0; }
  10246. if (max === void 0) { max = 0; }
  10247. if (value === void 0) { value = 0; }
  10248. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10249. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10250. button.name = unit;
  10251. button.value = value;
  10252. button.minimum = min;
  10253. button.maximum = max;
  10254. button.width = 0.9;
  10255. button.height = "20px";
  10256. button.color = "#364249";
  10257. button.background = "#CCCCCC";
  10258. button.borderColor = "black";
  10259. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10260. button.left = "4px";
  10261. button.paddingBottom = "4px";
  10262. button.onValueChangedObservable.add(function (value) {
  10263. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10264. func(value);
  10265. });
  10266. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10267. _selector.height = "60px";
  10268. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10269. _selector.left = "4px";
  10270. _selector.children[0].name = label;
  10271. this.groupPanel.addControl(_selector);
  10272. this.selectors.push(_selector);
  10273. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10274. button.color = this.groupPanel.parent.parent.buttonColor;
  10275. button.background = this.groupPanel.parent.parent.buttonBackground;
  10276. }
  10277. };
  10278. /** @hidden */
  10279. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10280. this.selectors[selectorNb].children[0].name = label;
  10281. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10282. };
  10283. /** @hidden */
  10284. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10285. this.selectors[selectorNb].children[0].color = color;
  10286. };
  10287. /** @hidden */
  10288. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10289. this.selectors[selectorNb].children[1].color = color;
  10290. };
  10291. /** @hidden */
  10292. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10293. this.selectors[selectorNb].children[1].background = color;
  10294. };
  10295. return SliderGroup;
  10296. }(SelectorGroup));
  10297. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10298. * @see https://doc.babylonjs.com/how_to/selector
  10299. */
  10300. var SelectionPanel = /** @class */ (function (_super) {
  10301. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10302. /**
  10303. * Creates a new SelectionPanel
  10304. * @param name of SelectionPanel
  10305. * @param groups is an array of SelectionGroups
  10306. */
  10307. function SelectionPanel(
  10308. /** name of SelectionPanel */
  10309. name,
  10310. /** an array of SelectionGroups */
  10311. groups) {
  10312. if (groups === void 0) { groups = []; }
  10313. var _this = _super.call(this, name) || this;
  10314. _this.name = name;
  10315. _this.groups = groups;
  10316. _this._buttonColor = "#364249";
  10317. _this._buttonBackground = "#CCCCCC";
  10318. _this._headerColor = "black";
  10319. _this._barColor = "white";
  10320. _this._barHeight = "2px";
  10321. _this._spacerHeight = "20px";
  10322. _this._bars = new Array();
  10323. _this._groups = groups;
  10324. _this.thickness = 2;
  10325. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10326. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10327. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10328. _this._panel.top = 5;
  10329. _this._panel.left = 5;
  10330. _this._panel.width = 0.95;
  10331. if (groups.length > 0) {
  10332. for (var i = 0; i < groups.length - 1; i++) {
  10333. _this._panel.addControl(groups[i].groupPanel);
  10334. _this._addSpacer();
  10335. }
  10336. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10337. }
  10338. _this.addControl(_this._panel);
  10339. return _this;
  10340. }
  10341. SelectionPanel.prototype._getTypeName = function () {
  10342. return "SelectionPanel";
  10343. };
  10344. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10345. /** Gets or sets the headerColor */
  10346. get: function () {
  10347. return this._headerColor;
  10348. },
  10349. set: function (color) {
  10350. if (this._headerColor === color) {
  10351. return;
  10352. }
  10353. this._headerColor = color;
  10354. this._setHeaderColor();
  10355. },
  10356. enumerable: false,
  10357. configurable: true
  10358. });
  10359. SelectionPanel.prototype._setHeaderColor = function () {
  10360. for (var i = 0; i < this._groups.length; i++) {
  10361. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10362. }
  10363. };
  10364. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10365. /** Gets or sets the button color */
  10366. get: function () {
  10367. return this._buttonColor;
  10368. },
  10369. set: function (color) {
  10370. if (this._buttonColor === color) {
  10371. return;
  10372. }
  10373. this._buttonColor = color;
  10374. this._setbuttonColor();
  10375. },
  10376. enumerable: false,
  10377. configurable: true
  10378. });
  10379. SelectionPanel.prototype._setbuttonColor = function () {
  10380. for (var i = 0; i < this._groups.length; i++) {
  10381. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10382. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10383. }
  10384. }
  10385. };
  10386. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10387. /** Gets or sets the label color */
  10388. get: function () {
  10389. return this._labelColor;
  10390. },
  10391. set: function (color) {
  10392. if (this._labelColor === color) {
  10393. return;
  10394. }
  10395. this._labelColor = color;
  10396. this._setLabelColor();
  10397. },
  10398. enumerable: false,
  10399. configurable: true
  10400. });
  10401. SelectionPanel.prototype._setLabelColor = function () {
  10402. for (var i = 0; i < this._groups.length; i++) {
  10403. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10404. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10405. }
  10406. }
  10407. };
  10408. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10409. /** Gets or sets the button background */
  10410. get: function () {
  10411. return this._buttonBackground;
  10412. },
  10413. set: function (color) {
  10414. if (this._buttonBackground === color) {
  10415. return;
  10416. }
  10417. this._buttonBackground = color;
  10418. this._setButtonBackground();
  10419. },
  10420. enumerable: false,
  10421. configurable: true
  10422. });
  10423. SelectionPanel.prototype._setButtonBackground = function () {
  10424. for (var i = 0; i < this._groups.length; i++) {
  10425. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10426. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10427. }
  10428. }
  10429. };
  10430. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10431. /** Gets or sets the color of separator bar */
  10432. get: function () {
  10433. return this._barColor;
  10434. },
  10435. set: function (color) {
  10436. if (this._barColor === color) {
  10437. return;
  10438. }
  10439. this._barColor = color;
  10440. this._setBarColor();
  10441. },
  10442. enumerable: false,
  10443. configurable: true
  10444. });
  10445. SelectionPanel.prototype._setBarColor = function () {
  10446. for (var i = 0; i < this._bars.length; i++) {
  10447. this._bars[i].children[0].background = this._barColor;
  10448. }
  10449. };
  10450. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10451. /** Gets or sets the height of separator bar */
  10452. get: function () {
  10453. return this._barHeight;
  10454. },
  10455. set: function (value) {
  10456. if (this._barHeight === value) {
  10457. return;
  10458. }
  10459. this._barHeight = value;
  10460. this._setBarHeight();
  10461. },
  10462. enumerable: false,
  10463. configurable: true
  10464. });
  10465. SelectionPanel.prototype._setBarHeight = function () {
  10466. for (var i = 0; i < this._bars.length; i++) {
  10467. this._bars[i].children[0].height = this._barHeight;
  10468. }
  10469. };
  10470. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10471. /** Gets or sets the height of spacers*/
  10472. get: function () {
  10473. return this._spacerHeight;
  10474. },
  10475. set: function (value) {
  10476. if (this._spacerHeight === value) {
  10477. return;
  10478. }
  10479. this._spacerHeight = value;
  10480. this._setSpacerHeight();
  10481. },
  10482. enumerable: false,
  10483. configurable: true
  10484. });
  10485. SelectionPanel.prototype._setSpacerHeight = function () {
  10486. for (var i = 0; i < this._bars.length; i++) {
  10487. this._bars[i].height = this._spacerHeight;
  10488. }
  10489. };
  10490. /** Adds a bar between groups */
  10491. SelectionPanel.prototype._addSpacer = function () {
  10492. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10493. separator.width = 1;
  10494. separator.height = this._spacerHeight;
  10495. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10496. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10497. bar.width = 1;
  10498. bar.height = this._barHeight;
  10499. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10500. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10501. bar.background = this._barColor;
  10502. bar.color = "transparent";
  10503. separator.addControl(bar);
  10504. this._panel.addControl(separator);
  10505. this._bars.push(separator);
  10506. };
  10507. /** Add a group to the selection panel
  10508. * @param group is the selector group to add
  10509. */
  10510. SelectionPanel.prototype.addGroup = function (group) {
  10511. if (this._groups.length > 0) {
  10512. this._addSpacer();
  10513. }
  10514. this._panel.addControl(group.groupPanel);
  10515. this._groups.push(group);
  10516. group.groupPanel.children[0].color = this._headerColor;
  10517. for (var j = 0; j < group.selectors.length; j++) {
  10518. group._setSelectorButtonColor(j, this._buttonColor);
  10519. group._setSelectorButtonBackground(j, this._buttonBackground);
  10520. }
  10521. };
  10522. /** Remove the group from the given position
  10523. * @param groupNb is the position of the group in the list
  10524. */
  10525. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10526. if (groupNb < 0 || groupNb >= this._groups.length) {
  10527. return;
  10528. }
  10529. var group = this._groups[groupNb];
  10530. this._panel.removeControl(group.groupPanel);
  10531. this._groups.splice(groupNb, 1);
  10532. if (groupNb < this._bars.length) {
  10533. this._panel.removeControl(this._bars[groupNb]);
  10534. this._bars.splice(groupNb, 1);
  10535. }
  10536. };
  10537. /** Change a group header label
  10538. * @param label is the new group header label
  10539. * @param groupNb is the number of the group to relabel
  10540. * */
  10541. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10542. if (groupNb < 0 || groupNb >= this._groups.length) {
  10543. return;
  10544. }
  10545. var group = this._groups[groupNb];
  10546. group.groupPanel.children[0].text = label;
  10547. };
  10548. /** Change selector label to the one given
  10549. * @param label is the new selector label
  10550. * @param groupNb is the number of the groupcontaining the selector
  10551. * @param selectorNb is the number of the selector within a group to relabel
  10552. * */
  10553. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10554. if (groupNb < 0 || groupNb >= this._groups.length) {
  10555. return;
  10556. }
  10557. var group = this._groups[groupNb];
  10558. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10559. return;
  10560. }
  10561. group._setSelectorLabel(selectorNb, label);
  10562. };
  10563. /** For a given group position remove the selector at the given position
  10564. * @param groupNb is the number of the group to remove the selector from
  10565. * @param selectorNb is the number of the selector within the group
  10566. */
  10567. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10568. if (groupNb < 0 || groupNb >= this._groups.length) {
  10569. return;
  10570. }
  10571. var group = this._groups[groupNb];
  10572. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10573. return;
  10574. }
  10575. group.removeSelector(selectorNb);
  10576. };
  10577. /** For a given group position of correct type add a checkbox button
  10578. * @param groupNb is the number of the group to remove the selector from
  10579. * @param label is the label for the selector
  10580. * @param func is the function called when the Selector is checked
  10581. * @param checked is true when Selector is checked
  10582. */
  10583. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10584. if (func === void 0) { func = function () { }; }
  10585. if (checked === void 0) { checked = false; }
  10586. if (groupNb < 0 || groupNb >= this._groups.length) {
  10587. return;
  10588. }
  10589. var group = this._groups[groupNb];
  10590. group.addCheckbox(label, func, checked);
  10591. };
  10592. /** For a given group position of correct type add a radio button
  10593. * @param groupNb is the number of the group to remove the selector from
  10594. * @param label is the label for the selector
  10595. * @param func is the function called when the Selector is checked
  10596. * @param checked is true when Selector is checked
  10597. */
  10598. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10599. if (func === void 0) { func = function () { }; }
  10600. if (checked === void 0) { checked = false; }
  10601. if (groupNb < 0 || groupNb >= this._groups.length) {
  10602. return;
  10603. }
  10604. var group = this._groups[groupNb];
  10605. group.addRadio(label, func, checked);
  10606. };
  10607. /**
  10608. * For a given slider group add a slider
  10609. * @param groupNb is the number of the group to add the slider to
  10610. * @param label is the label for the Slider
  10611. * @param func is the function called when the Slider moves
  10612. * @param unit is a string describing the units used, eg degrees or metres
  10613. * @param min is the minimum value for the Slider
  10614. * @param max is the maximum value for the Slider
  10615. * @param value is the start value for the Slider between min and max
  10616. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10617. */
  10618. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10619. if (func === void 0) { func = function () { }; }
  10620. if (unit === void 0) { unit = "Units"; }
  10621. if (min === void 0) { min = 0; }
  10622. if (max === void 0) { max = 0; }
  10623. if (value === void 0) { value = 0; }
  10624. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10625. if (groupNb < 0 || groupNb >= this._groups.length) {
  10626. return;
  10627. }
  10628. var group = this._groups[groupNb];
  10629. group.addSlider(label, func, unit, min, max, value, onVal);
  10630. };
  10631. return SelectionPanel;
  10632. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10633. /***/ }),
  10634. /***/ "./2D/controls/sliders/baseSlider.ts":
  10635. /*!*******************************************!*\
  10636. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10637. \*******************************************/
  10638. /*! exports provided: BaseSlider */
  10639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10640. "use strict";
  10641. __webpack_require__.r(__webpack_exports__);
  10642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10643. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10644. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  10645. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10646. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10647. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10648. /**
  10649. * Class used to create slider controls
  10650. */
  10651. var BaseSlider = /** @class */ (function (_super) {
  10652. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10653. /**
  10654. * Creates a new BaseSlider
  10655. * @param name defines the control name
  10656. */
  10657. function BaseSlider(name) {
  10658. var _this = _super.call(this, name) || this;
  10659. _this.name = name;
  10660. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10661. _this._minimum = 0;
  10662. _this._maximum = 100;
  10663. _this._value = 50;
  10664. _this._isVertical = false;
  10665. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10666. _this._isThumbClamped = false;
  10667. _this._displayThumb = true;
  10668. _this._step = 0;
  10669. _this._lastPointerDownID = -1;
  10670. // Shared rendering info
  10671. _this._effectiveBarOffset = 0;
  10672. /** Observable raised when the sldier value changes */
  10673. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10674. // Events
  10675. _this._pointerIsDown = false;
  10676. _this.isPointerBlocker = true;
  10677. return _this;
  10678. }
  10679. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10680. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10681. get: function () {
  10682. return this._displayThumb;
  10683. },
  10684. set: function (value) {
  10685. if (this._displayThumb === value) {
  10686. return;
  10687. }
  10688. this._displayThumb = value;
  10689. this._markAsDirty();
  10690. },
  10691. enumerable: false,
  10692. configurable: true
  10693. });
  10694. Object.defineProperty(BaseSlider.prototype, "step", {
  10695. /** Gets or sets a step to apply to values (0 by default) */
  10696. get: function () {
  10697. return this._step;
  10698. },
  10699. set: function (value) {
  10700. if (this._step === value) {
  10701. return;
  10702. }
  10703. this._step = value;
  10704. this._markAsDirty();
  10705. },
  10706. enumerable: false,
  10707. configurable: true
  10708. });
  10709. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10710. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10711. get: function () {
  10712. return this._barOffset.toString(this._host);
  10713. },
  10714. set: function (value) {
  10715. if (this._barOffset.toString(this._host) === value) {
  10716. return;
  10717. }
  10718. if (this._barOffset.fromString(value)) {
  10719. this._markAsDirty();
  10720. }
  10721. },
  10722. enumerable: false,
  10723. configurable: true
  10724. });
  10725. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10726. /** Gets main bar offset in pixels*/
  10727. get: function () {
  10728. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10729. },
  10730. enumerable: false,
  10731. configurable: true
  10732. });
  10733. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10734. /** Gets or sets thumb width */
  10735. get: function () {
  10736. return this._thumbWidth.toString(this._host);
  10737. },
  10738. set: function (value) {
  10739. if (this._thumbWidth.toString(this._host) === value) {
  10740. return;
  10741. }
  10742. if (this._thumbWidth.fromString(value)) {
  10743. this._markAsDirty();
  10744. }
  10745. },
  10746. enumerable: false,
  10747. configurable: true
  10748. });
  10749. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10750. /** Gets thumb width in pixels */
  10751. get: function () {
  10752. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10753. },
  10754. enumerable: false,
  10755. configurable: true
  10756. });
  10757. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10758. /** Gets or sets minimum value */
  10759. get: function () {
  10760. return this._minimum;
  10761. },
  10762. set: function (value) {
  10763. if (this._minimum === value) {
  10764. return;
  10765. }
  10766. this._minimum = value;
  10767. this._markAsDirty();
  10768. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10769. },
  10770. enumerable: false,
  10771. configurable: true
  10772. });
  10773. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10774. /** Gets or sets maximum value */
  10775. get: function () {
  10776. return this._maximum;
  10777. },
  10778. set: function (value) {
  10779. if (this._maximum === value) {
  10780. return;
  10781. }
  10782. this._maximum = value;
  10783. this._markAsDirty();
  10784. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10785. },
  10786. enumerable: false,
  10787. configurable: true
  10788. });
  10789. Object.defineProperty(BaseSlider.prototype, "value", {
  10790. /** Gets or sets current value */
  10791. get: function () {
  10792. return this._value;
  10793. },
  10794. set: function (value) {
  10795. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10796. if (this._value === value) {
  10797. return;
  10798. }
  10799. this._value = value;
  10800. this._markAsDirty();
  10801. this.onValueChangedObservable.notifyObservers(this._value);
  10802. },
  10803. enumerable: false,
  10804. configurable: true
  10805. });
  10806. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10807. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10808. get: function () {
  10809. return this._isVertical;
  10810. },
  10811. set: function (value) {
  10812. if (this._isVertical === value) {
  10813. return;
  10814. }
  10815. this._isVertical = value;
  10816. this._markAsDirty();
  10817. },
  10818. enumerable: false,
  10819. configurable: true
  10820. });
  10821. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10822. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10823. get: function () {
  10824. return this._isThumbClamped;
  10825. },
  10826. set: function (value) {
  10827. if (this._isThumbClamped === value) {
  10828. return;
  10829. }
  10830. this._isThumbClamped = value;
  10831. this._markAsDirty();
  10832. },
  10833. enumerable: false,
  10834. configurable: true
  10835. });
  10836. BaseSlider.prototype._getTypeName = function () {
  10837. return "BaseSlider";
  10838. };
  10839. BaseSlider.prototype._getThumbPosition = function () {
  10840. if (this.isVertical) {
  10841. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10842. }
  10843. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10844. };
  10845. BaseSlider.prototype._getThumbThickness = function (type) {
  10846. var thumbThickness = 0;
  10847. switch (type) {
  10848. case "circle":
  10849. if (this._thumbWidth.isPixel) {
  10850. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10851. }
  10852. else {
  10853. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10854. }
  10855. break;
  10856. case "rectangle":
  10857. if (this._thumbWidth.isPixel) {
  10858. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10859. }
  10860. else {
  10861. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10862. }
  10863. }
  10864. return thumbThickness;
  10865. };
  10866. BaseSlider.prototype._prepareRenderingData = function (type) {
  10867. // Main bar
  10868. this._effectiveBarOffset = 0;
  10869. this._renderLeft = this._currentMeasure.left;
  10870. this._renderTop = this._currentMeasure.top;
  10871. this._renderWidth = this._currentMeasure.width;
  10872. this._renderHeight = this._currentMeasure.height;
  10873. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10874. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10875. this._effectiveThumbThickness = this._getThumbThickness(type);
  10876. if (this.displayThumb) {
  10877. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10878. }
  10879. //throw error when height is less than width for vertical slider
  10880. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10881. console.error("Height should be greater than width");
  10882. return;
  10883. }
  10884. if (this._barOffset.isPixel) {
  10885. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10886. }
  10887. else {
  10888. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10889. }
  10890. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10891. if (this.isVertical) {
  10892. this._renderLeft += this._effectiveBarOffset;
  10893. if (!this.isThumbClamped && this.displayThumb) {
  10894. this._renderTop += (this._effectiveThumbThickness / 2);
  10895. }
  10896. this._renderHeight = this._backgroundBoxLength;
  10897. this._renderWidth = this._backgroundBoxThickness;
  10898. }
  10899. else {
  10900. this._renderTop += this._effectiveBarOffset;
  10901. if (!this.isThumbClamped && this.displayThumb) {
  10902. this._renderLeft += (this._effectiveThumbThickness / 2);
  10903. }
  10904. this._renderHeight = this._backgroundBoxThickness;
  10905. this._renderWidth = this._backgroundBoxLength;
  10906. }
  10907. };
  10908. /** @hidden */
  10909. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10910. if (this.rotation != 0) {
  10911. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10912. x = this._transformedPosition.x;
  10913. y = this._transformedPosition.y;
  10914. }
  10915. var value;
  10916. if (this._isVertical) {
  10917. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10918. }
  10919. else {
  10920. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10921. }
  10922. var mult = (1 / this._step) | 0;
  10923. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10924. };
  10925. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10926. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10927. return false;
  10928. }
  10929. this._pointerIsDown = true;
  10930. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10931. this._host._capturingControl[pointerId] = this;
  10932. this._lastPointerDownID = pointerId;
  10933. return true;
  10934. };
  10935. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10936. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10937. if (pointerId != this._lastPointerDownID) {
  10938. return;
  10939. }
  10940. if (this._pointerIsDown) {
  10941. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10942. }
  10943. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10944. };
  10945. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10946. this._pointerIsDown = false;
  10947. delete this._host._capturingControl[pointerId];
  10948. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10949. };
  10950. BaseSlider.prototype._onCanvasBlur = function () {
  10951. this._forcePointerUp();
  10952. _super.prototype._onCanvasBlur.call(this);
  10953. };
  10954. return BaseSlider;
  10955. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10956. /***/ }),
  10957. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10958. /*!*************************************************!*\
  10959. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10960. \*************************************************/
  10961. /*! exports provided: ImageBasedSlider */
  10962. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10963. "use strict";
  10964. __webpack_require__.r(__webpack_exports__);
  10965. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10966. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10967. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10968. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10969. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  10970. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10971. /**
  10972. * Class used to create slider controls based on images
  10973. */
  10974. var ImageBasedSlider = /** @class */ (function (_super) {
  10975. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10976. /**
  10977. * Creates a new ImageBasedSlider
  10978. * @param name defines the control name
  10979. */
  10980. function ImageBasedSlider(name) {
  10981. var _this = _super.call(this, name) || this;
  10982. _this.name = name;
  10983. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10984. return _this;
  10985. }
  10986. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10987. get: function () {
  10988. return this._displayThumb && this.thumbImage != null;
  10989. },
  10990. set: function (value) {
  10991. if (this._displayThumb === value) {
  10992. return;
  10993. }
  10994. this._displayThumb = value;
  10995. this._markAsDirty();
  10996. },
  10997. enumerable: false,
  10998. configurable: true
  10999. });
  11000. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  11001. /**
  11002. * Gets or sets the image used to render the background
  11003. */
  11004. get: function () {
  11005. return this._backgroundImage;
  11006. },
  11007. set: function (value) {
  11008. var _this = this;
  11009. if (this._backgroundImage === value) {
  11010. return;
  11011. }
  11012. this._backgroundImage = value;
  11013. if (value && !value.isLoaded) {
  11014. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11015. }
  11016. this._markAsDirty();
  11017. },
  11018. enumerable: false,
  11019. configurable: true
  11020. });
  11021. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  11022. /**
  11023. * Gets or sets the image used to render the value bar
  11024. */
  11025. get: function () {
  11026. return this._valueBarImage;
  11027. },
  11028. set: function (value) {
  11029. var _this = this;
  11030. if (this._valueBarImage === value) {
  11031. return;
  11032. }
  11033. this._valueBarImage = value;
  11034. if (value && !value.isLoaded) {
  11035. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11036. }
  11037. this._markAsDirty();
  11038. },
  11039. enumerable: false,
  11040. configurable: true
  11041. });
  11042. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  11043. /**
  11044. * Gets or sets the image used to render the thumb
  11045. */
  11046. get: function () {
  11047. return this._thumbImage;
  11048. },
  11049. set: function (value) {
  11050. var _this = this;
  11051. if (this._thumbImage === value) {
  11052. return;
  11053. }
  11054. this._thumbImage = value;
  11055. if (value && !value.isLoaded) {
  11056. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11057. }
  11058. this._markAsDirty();
  11059. },
  11060. enumerable: false,
  11061. configurable: true
  11062. });
  11063. ImageBasedSlider.prototype._getTypeName = function () {
  11064. return "ImageBasedSlider";
  11065. };
  11066. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  11067. context.save();
  11068. this._applyStates(context);
  11069. this._prepareRenderingData("rectangle");
  11070. var thumbPosition = this._getThumbPosition();
  11071. var left = this._renderLeft;
  11072. var top = this._renderTop;
  11073. var width = this._renderWidth;
  11074. var height = this._renderHeight;
  11075. // Background
  11076. if (this._backgroundImage) {
  11077. this._tempMeasure.copyFromFloats(left, top, width, height);
  11078. if (this.isThumbClamped && this.displayThumb) {
  11079. if (this.isVertical) {
  11080. this._tempMeasure.height += this._effectiveThumbThickness;
  11081. }
  11082. else {
  11083. this._tempMeasure.width += this._effectiveThumbThickness;
  11084. }
  11085. }
  11086. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11087. this._backgroundImage._draw(context);
  11088. }
  11089. // Bar
  11090. if (this._valueBarImage) {
  11091. if (this.isVertical) {
  11092. if (this.isThumbClamped && this.displayThumb) {
  11093. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11094. }
  11095. else {
  11096. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  11097. }
  11098. }
  11099. else {
  11100. if (this.isThumbClamped && this.displayThumb) {
  11101. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  11102. }
  11103. else {
  11104. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11105. }
  11106. }
  11107. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11108. this._valueBarImage._draw(context);
  11109. }
  11110. // Thumb
  11111. if (this.displayThumb) {
  11112. if (this.isVertical) {
  11113. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11114. }
  11115. else {
  11116. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11117. }
  11118. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11119. this._thumbImage._draw(context);
  11120. }
  11121. context.restore();
  11122. };
  11123. return ImageBasedSlider;
  11124. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11125. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11126. /***/ }),
  11127. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11128. /*!***********************************************!*\
  11129. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11130. \***********************************************/
  11131. /*! exports provided: ImageScrollBar */
  11132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11133. "use strict";
  11134. __webpack_require__.r(__webpack_exports__);
  11135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11136. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11137. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11138. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11139. /**
  11140. * Class used to create slider controls
  11141. */
  11142. var ImageScrollBar = /** @class */ (function (_super) {
  11143. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11144. /**
  11145. * Creates a new ImageScrollBar
  11146. * @param name defines the control name
  11147. */
  11148. function ImageScrollBar(name) {
  11149. var _this = _super.call(this, name) || this;
  11150. _this.name = name;
  11151. _this._thumbLength = 0.5;
  11152. _this._thumbHeight = 1;
  11153. _this._barImageHeight = 1;
  11154. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11155. /** Number of 90° rotation to apply on the images when in vertical mode */
  11156. _this.num90RotationInVerticalMode = 1;
  11157. return _this;
  11158. }
  11159. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11160. /**
  11161. * Gets or sets the image used to render the background for horizontal bar
  11162. */
  11163. get: function () {
  11164. return this._backgroundBaseImage;
  11165. },
  11166. set: function (value) {
  11167. var _this = this;
  11168. if (this._backgroundBaseImage === value) {
  11169. return;
  11170. }
  11171. this._backgroundBaseImage = value;
  11172. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11173. if (!value.isLoaded) {
  11174. value.onImageLoadedObservable.addOnce(function () {
  11175. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11176. _this._backgroundImage = rotatedValue;
  11177. if (!rotatedValue.isLoaded) {
  11178. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11179. _this._markAsDirty();
  11180. });
  11181. }
  11182. _this._markAsDirty();
  11183. });
  11184. }
  11185. else {
  11186. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11187. this._markAsDirty();
  11188. }
  11189. }
  11190. else {
  11191. this._backgroundImage = value;
  11192. if (value && !value.isLoaded) {
  11193. value.onImageLoadedObservable.addOnce(function () {
  11194. _this._markAsDirty();
  11195. });
  11196. }
  11197. this._markAsDirty();
  11198. }
  11199. },
  11200. enumerable: false,
  11201. configurable: true
  11202. });
  11203. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11204. /**
  11205. * Gets or sets the image used to render the thumb
  11206. */
  11207. get: function () {
  11208. return this._thumbBaseImage;
  11209. },
  11210. set: function (value) {
  11211. var _this = this;
  11212. if (this._thumbBaseImage === value) {
  11213. return;
  11214. }
  11215. this._thumbBaseImage = value;
  11216. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11217. if (!value.isLoaded) {
  11218. value.onImageLoadedObservable.addOnce(function () {
  11219. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11220. _this._thumbImage = rotatedValue;
  11221. if (!rotatedValue.isLoaded) {
  11222. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11223. _this._markAsDirty();
  11224. });
  11225. }
  11226. _this._markAsDirty();
  11227. });
  11228. }
  11229. else {
  11230. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11231. this._markAsDirty();
  11232. }
  11233. }
  11234. else {
  11235. this._thumbImage = value;
  11236. if (value && !value.isLoaded) {
  11237. value.onImageLoadedObservable.addOnce(function () {
  11238. _this._markAsDirty();
  11239. });
  11240. }
  11241. this._markAsDirty();
  11242. }
  11243. },
  11244. enumerable: false,
  11245. configurable: true
  11246. });
  11247. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11248. /**
  11249. * Gets or sets the length of the thumb
  11250. */
  11251. get: function () {
  11252. return this._thumbLength;
  11253. },
  11254. set: function (value) {
  11255. if (this._thumbLength === value) {
  11256. return;
  11257. }
  11258. this._thumbLength = value;
  11259. this._markAsDirty();
  11260. },
  11261. enumerable: false,
  11262. configurable: true
  11263. });
  11264. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11265. /**
  11266. * Gets or sets the height of the thumb
  11267. */
  11268. get: function () {
  11269. return this._thumbHeight;
  11270. },
  11271. set: function (value) {
  11272. if (this._thumbLength === value) {
  11273. return;
  11274. }
  11275. this._thumbHeight = value;
  11276. this._markAsDirty();
  11277. },
  11278. enumerable: false,
  11279. configurable: true
  11280. });
  11281. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11282. /**
  11283. * Gets or sets the height of the bar image
  11284. */
  11285. get: function () {
  11286. return this._barImageHeight;
  11287. },
  11288. set: function (value) {
  11289. if (this._barImageHeight === value) {
  11290. return;
  11291. }
  11292. this._barImageHeight = value;
  11293. this._markAsDirty();
  11294. },
  11295. enumerable: false,
  11296. configurable: true
  11297. });
  11298. ImageScrollBar.prototype._getTypeName = function () {
  11299. return "ImageScrollBar";
  11300. };
  11301. ImageScrollBar.prototype._getThumbThickness = function () {
  11302. var thumbThickness = 0;
  11303. if (this._thumbWidth.isPixel) {
  11304. thumbThickness = this._thumbWidth.getValue(this._host);
  11305. }
  11306. else {
  11307. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11308. }
  11309. return thumbThickness;
  11310. };
  11311. ImageScrollBar.prototype._draw = function (context) {
  11312. context.save();
  11313. this._applyStates(context);
  11314. this._prepareRenderingData("rectangle");
  11315. var thumbPosition = this._getThumbPosition();
  11316. var left = this._renderLeft;
  11317. var top = this._renderTop;
  11318. var width = this._renderWidth;
  11319. var height = this._renderHeight;
  11320. // Background
  11321. if (this._backgroundImage) {
  11322. this._tempMeasure.copyFromFloats(left, top, width, height);
  11323. if (this.isVertical) {
  11324. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11325. this._tempMeasure.height += this._effectiveThumbThickness;
  11326. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11327. }
  11328. else {
  11329. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11330. this._tempMeasure.width += this._effectiveThumbThickness;
  11331. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11332. }
  11333. this._backgroundImage._draw(context);
  11334. }
  11335. // Thumb
  11336. if (this.isVertical) {
  11337. 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);
  11338. }
  11339. else {
  11340. 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);
  11341. }
  11342. if (this._thumbImage) {
  11343. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11344. this._thumbImage._draw(context);
  11345. }
  11346. context.restore();
  11347. };
  11348. /** @hidden */
  11349. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11350. if (this.rotation != 0) {
  11351. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11352. x = this._transformedPosition.x;
  11353. y = this._transformedPosition.y;
  11354. }
  11355. if (this._first) {
  11356. this._first = false;
  11357. this._originX = x;
  11358. this._originY = y;
  11359. // Check if move is required
  11360. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11361. if (this.isVertical) {
  11362. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11363. }
  11364. else {
  11365. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11366. }
  11367. }
  11368. }
  11369. // Delta mode
  11370. var delta = 0;
  11371. if (this.isVertical) {
  11372. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11373. }
  11374. else {
  11375. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11376. }
  11377. this.value += delta * (this.maximum - this.minimum);
  11378. this._originX = x;
  11379. this._originY = y;
  11380. };
  11381. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11382. this._first = true;
  11383. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11384. };
  11385. return ImageScrollBar;
  11386. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11387. /***/ }),
  11388. /***/ "./2D/controls/sliders/scrollBar.ts":
  11389. /*!******************************************!*\
  11390. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11391. \******************************************/
  11392. /*! exports provided: ScrollBar */
  11393. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11394. "use strict";
  11395. __webpack_require__.r(__webpack_exports__);
  11396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11397. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11398. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11399. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11400. /**
  11401. * Class used to create slider controls
  11402. */
  11403. var ScrollBar = /** @class */ (function (_super) {
  11404. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11405. /**
  11406. * Creates a new Slider
  11407. * @param name defines the control name
  11408. */
  11409. function ScrollBar(name) {
  11410. var _this = _super.call(this, name) || this;
  11411. _this.name = name;
  11412. _this._background = "black";
  11413. _this._borderColor = "white";
  11414. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11415. return _this;
  11416. }
  11417. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11418. /** Gets or sets border color */
  11419. get: function () {
  11420. return this._borderColor;
  11421. },
  11422. set: function (value) {
  11423. if (this._borderColor === value) {
  11424. return;
  11425. }
  11426. this._borderColor = value;
  11427. this._markAsDirty();
  11428. },
  11429. enumerable: false,
  11430. configurable: true
  11431. });
  11432. Object.defineProperty(ScrollBar.prototype, "background", {
  11433. /** Gets or sets background color */
  11434. get: function () {
  11435. return this._background;
  11436. },
  11437. set: function (value) {
  11438. if (this._background === value) {
  11439. return;
  11440. }
  11441. this._background = value;
  11442. this._markAsDirty();
  11443. },
  11444. enumerable: false,
  11445. configurable: true
  11446. });
  11447. ScrollBar.prototype._getTypeName = function () {
  11448. return "Scrollbar";
  11449. };
  11450. ScrollBar.prototype._getThumbThickness = function () {
  11451. var thumbThickness = 0;
  11452. if (this._thumbWidth.isPixel) {
  11453. thumbThickness = this._thumbWidth.getValue(this._host);
  11454. }
  11455. else {
  11456. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11457. }
  11458. return thumbThickness;
  11459. };
  11460. ScrollBar.prototype._draw = function (context) {
  11461. context.save();
  11462. this._applyStates(context);
  11463. this._prepareRenderingData("rectangle");
  11464. var left = this._renderLeft;
  11465. var thumbPosition = this._getThumbPosition();
  11466. context.fillStyle = this._background;
  11467. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11468. // Value bar
  11469. context.fillStyle = this.color;
  11470. // Thumb
  11471. if (this.isVertical) {
  11472. this._tempMeasure.left = left - this._effectiveBarOffset;
  11473. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11474. this._tempMeasure.width = this._currentMeasure.width;
  11475. this._tempMeasure.height = this._effectiveThumbThickness;
  11476. }
  11477. else {
  11478. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11479. this._tempMeasure.top = this._currentMeasure.top;
  11480. this._tempMeasure.width = this._effectiveThumbThickness;
  11481. this._tempMeasure.height = this._currentMeasure.height;
  11482. }
  11483. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11484. context.restore();
  11485. };
  11486. /** @hidden */
  11487. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11488. if (this.rotation != 0) {
  11489. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11490. x = this._transformedPosition.x;
  11491. y = this._transformedPosition.y;
  11492. }
  11493. if (this._first) {
  11494. this._first = false;
  11495. this._originX = x;
  11496. this._originY = y;
  11497. // Check if move is required
  11498. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11499. if (this.isVertical) {
  11500. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11501. }
  11502. else {
  11503. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11504. }
  11505. }
  11506. }
  11507. // Delta mode
  11508. var delta = 0;
  11509. if (this.isVertical) {
  11510. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11511. }
  11512. else {
  11513. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11514. }
  11515. this.value += delta * (this.maximum - this.minimum);
  11516. this._originX = x;
  11517. this._originY = y;
  11518. };
  11519. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  11520. this._first = true;
  11521. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  11522. };
  11523. return ScrollBar;
  11524. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11525. /***/ }),
  11526. /***/ "./2D/controls/sliders/slider.ts":
  11527. /*!***************************************!*\
  11528. !*** ./2D/controls/sliders/slider.ts ***!
  11529. \***************************************/
  11530. /*! exports provided: Slider */
  11531. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11532. "use strict";
  11533. __webpack_require__.r(__webpack_exports__);
  11534. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11535. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11536. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11537. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  11538. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11539. /**
  11540. * Class used to create slider controls
  11541. */
  11542. var Slider = /** @class */ (function (_super) {
  11543. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11544. /**
  11545. * Creates a new Slider
  11546. * @param name defines the control name
  11547. */
  11548. function Slider(name) {
  11549. var _this = _super.call(this, name) || this;
  11550. _this.name = name;
  11551. _this._background = "black";
  11552. _this._borderColor = "white";
  11553. _this._thumbColor = "";
  11554. _this._isThumbCircle = false;
  11555. _this._displayValueBar = true;
  11556. return _this;
  11557. }
  11558. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11559. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11560. get: function () {
  11561. return this._displayValueBar;
  11562. },
  11563. set: function (value) {
  11564. if (this._displayValueBar === value) {
  11565. return;
  11566. }
  11567. this._displayValueBar = value;
  11568. this._markAsDirty();
  11569. },
  11570. enumerable: false,
  11571. configurable: true
  11572. });
  11573. Object.defineProperty(Slider.prototype, "borderColor", {
  11574. /** Gets or sets border color */
  11575. get: function () {
  11576. return this._borderColor;
  11577. },
  11578. set: function (value) {
  11579. if (this._borderColor === value) {
  11580. return;
  11581. }
  11582. this._borderColor = value;
  11583. this._markAsDirty();
  11584. },
  11585. enumerable: false,
  11586. configurable: true
  11587. });
  11588. Object.defineProperty(Slider.prototype, "background", {
  11589. /** Gets or sets background color */
  11590. get: function () {
  11591. return this._background;
  11592. },
  11593. set: function (value) {
  11594. if (this._background === value) {
  11595. return;
  11596. }
  11597. this._background = value;
  11598. this._markAsDirty();
  11599. },
  11600. enumerable: false,
  11601. configurable: true
  11602. });
  11603. Object.defineProperty(Slider.prototype, "thumbColor", {
  11604. /** Gets or sets thumb's color */
  11605. get: function () {
  11606. return this._thumbColor;
  11607. },
  11608. set: function (value) {
  11609. if (this._thumbColor === value) {
  11610. return;
  11611. }
  11612. this._thumbColor = value;
  11613. this._markAsDirty();
  11614. },
  11615. enumerable: false,
  11616. configurable: true
  11617. });
  11618. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11619. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11620. get: function () {
  11621. return this._isThumbCircle;
  11622. },
  11623. set: function (value) {
  11624. if (this._isThumbCircle === value) {
  11625. return;
  11626. }
  11627. this._isThumbCircle = value;
  11628. this._markAsDirty();
  11629. },
  11630. enumerable: false,
  11631. configurable: true
  11632. });
  11633. Slider.prototype._getTypeName = function () {
  11634. return "Slider";
  11635. };
  11636. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11637. context.save();
  11638. this._applyStates(context);
  11639. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11640. var left = this._renderLeft;
  11641. var top = this._renderTop;
  11642. var width = this._renderWidth;
  11643. var height = this._renderHeight;
  11644. var radius = 0;
  11645. if (this.isThumbClamped && this.isThumbCircle) {
  11646. if (this.isVertical) {
  11647. top += (this._effectiveThumbThickness / 2);
  11648. }
  11649. else {
  11650. left += (this._effectiveThumbThickness / 2);
  11651. }
  11652. radius = this._backgroundBoxThickness / 2;
  11653. }
  11654. else {
  11655. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11656. }
  11657. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11658. context.shadowColor = this.shadowColor;
  11659. context.shadowBlur = this.shadowBlur;
  11660. context.shadowOffsetX = this.shadowOffsetX;
  11661. context.shadowOffsetY = this.shadowOffsetY;
  11662. }
  11663. var thumbPosition = this._getThumbPosition();
  11664. context.fillStyle = this._background;
  11665. if (this.isVertical) {
  11666. if (this.isThumbClamped) {
  11667. if (this.isThumbCircle) {
  11668. context.beginPath();
  11669. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11670. context.fill();
  11671. context.fillRect(left, top, width, height);
  11672. }
  11673. else {
  11674. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11675. }
  11676. }
  11677. else {
  11678. context.fillRect(left, top, width, height);
  11679. }
  11680. }
  11681. else {
  11682. if (this.isThumbClamped) {
  11683. if (this.isThumbCircle) {
  11684. context.beginPath();
  11685. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11686. context.fill();
  11687. context.fillRect(left, top, width, height);
  11688. }
  11689. else {
  11690. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11691. }
  11692. }
  11693. else {
  11694. context.fillRect(left, top, width, height);
  11695. }
  11696. }
  11697. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11698. context.shadowBlur = 0;
  11699. context.shadowOffsetX = 0;
  11700. context.shadowOffsetY = 0;
  11701. }
  11702. // Value bar
  11703. context.fillStyle = this.color;
  11704. if (this._displayValueBar) {
  11705. if (this.isVertical) {
  11706. if (this.isThumbClamped) {
  11707. if (this.isThumbCircle) {
  11708. context.beginPath();
  11709. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11710. context.fill();
  11711. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11712. }
  11713. else {
  11714. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11715. }
  11716. }
  11717. else {
  11718. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11719. }
  11720. }
  11721. else {
  11722. if (this.isThumbClamped) {
  11723. if (this.isThumbCircle) {
  11724. context.beginPath();
  11725. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11726. context.fill();
  11727. context.fillRect(left, top, thumbPosition, height);
  11728. }
  11729. else {
  11730. context.fillRect(left, top, thumbPosition, height);
  11731. }
  11732. }
  11733. else {
  11734. context.fillRect(left, top, thumbPosition, height);
  11735. }
  11736. }
  11737. }
  11738. // Thumb
  11739. context.fillStyle = this._thumbColor || this.color;
  11740. if (this.displayThumb) {
  11741. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11742. context.shadowColor = this.shadowColor;
  11743. context.shadowBlur = this.shadowBlur;
  11744. context.shadowOffsetX = this.shadowOffsetX;
  11745. context.shadowOffsetY = this.shadowOffsetY;
  11746. }
  11747. if (this._isThumbCircle) {
  11748. context.beginPath();
  11749. if (this.isVertical) {
  11750. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11751. }
  11752. else {
  11753. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11754. }
  11755. context.fill();
  11756. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11757. context.shadowBlur = 0;
  11758. context.shadowOffsetX = 0;
  11759. context.shadowOffsetY = 0;
  11760. }
  11761. context.strokeStyle = this._borderColor;
  11762. context.stroke();
  11763. }
  11764. else {
  11765. if (this.isVertical) {
  11766. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11767. }
  11768. else {
  11769. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11770. }
  11771. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11772. context.shadowBlur = 0;
  11773. context.shadowOffsetX = 0;
  11774. context.shadowOffsetY = 0;
  11775. }
  11776. context.strokeStyle = this._borderColor;
  11777. if (this.isVertical) {
  11778. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11779. }
  11780. else {
  11781. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11782. }
  11783. }
  11784. }
  11785. context.restore();
  11786. };
  11787. return Slider;
  11788. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11789. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11790. /***/ }),
  11791. /***/ "./2D/controls/stackPanel.ts":
  11792. /*!***********************************!*\
  11793. !*** ./2D/controls/stackPanel.ts ***!
  11794. \***********************************/
  11795. /*! exports provided: StackPanel */
  11796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11797. "use strict";
  11798. __webpack_require__.r(__webpack_exports__);
  11799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11800. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11801. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  11802. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11803. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11804. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11805. /**
  11806. * Class used to create a 2D stack panel container
  11807. */
  11808. var StackPanel = /** @class */ (function (_super) {
  11809. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11810. /**
  11811. * Creates a new StackPanel
  11812. * @param name defines control name
  11813. */
  11814. function StackPanel(name) {
  11815. var _this = _super.call(this, name) || this;
  11816. _this.name = name;
  11817. _this._isVertical = true;
  11818. _this._manualWidth = false;
  11819. _this._manualHeight = false;
  11820. _this._doNotTrackManualChanges = false;
  11821. /**
  11822. * Gets or sets a boolean indicating that layou warnings should be ignored
  11823. */
  11824. _this.ignoreLayoutWarnings = false;
  11825. return _this;
  11826. }
  11827. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11828. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11829. get: function () {
  11830. return this._isVertical;
  11831. },
  11832. set: function (value) {
  11833. if (this._isVertical === value) {
  11834. return;
  11835. }
  11836. this._isVertical = value;
  11837. this._markAsDirty();
  11838. },
  11839. enumerable: false,
  11840. configurable: true
  11841. });
  11842. Object.defineProperty(StackPanel.prototype, "width", {
  11843. get: function () {
  11844. return this._width.toString(this._host);
  11845. },
  11846. /**
  11847. * Gets or sets panel width.
  11848. * This value should not be set when in horizontal mode as it will be computed automatically
  11849. */
  11850. set: function (value) {
  11851. if (!this._doNotTrackManualChanges) {
  11852. this._manualWidth = true;
  11853. }
  11854. if (this._width.toString(this._host) === value) {
  11855. return;
  11856. }
  11857. if (this._width.fromString(value)) {
  11858. this._markAsDirty();
  11859. }
  11860. },
  11861. enumerable: false,
  11862. configurable: true
  11863. });
  11864. Object.defineProperty(StackPanel.prototype, "height", {
  11865. get: function () {
  11866. return this._height.toString(this._host);
  11867. },
  11868. /**
  11869. * Gets or sets panel height.
  11870. * This value should not be set when in vertical mode as it will be computed automatically
  11871. */
  11872. set: function (value) {
  11873. if (!this._doNotTrackManualChanges) {
  11874. this._manualHeight = true;
  11875. }
  11876. if (this._height.toString(this._host) === value) {
  11877. return;
  11878. }
  11879. if (this._height.fromString(value)) {
  11880. this._markAsDirty();
  11881. }
  11882. },
  11883. enumerable: false,
  11884. configurable: true
  11885. });
  11886. StackPanel.prototype._getTypeName = function () {
  11887. return "StackPanel";
  11888. };
  11889. /** @hidden */
  11890. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11891. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11892. var child = _a[_i];
  11893. if (this._isVertical) {
  11894. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11895. }
  11896. else {
  11897. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11898. }
  11899. }
  11900. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11901. };
  11902. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11903. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11904. this._measureForChildren.copyFrom(parentMeasure);
  11905. this._measureForChildren.left = this._currentMeasure.left;
  11906. this._measureForChildren.top = this._currentMeasure.top;
  11907. if (!this.isVertical || this._manualWidth) {
  11908. this._measureForChildren.width = this._currentMeasure.width;
  11909. }
  11910. if (this.isVertical || this._manualHeight) {
  11911. this._measureForChildren.height = this._currentMeasure.height;
  11912. }
  11913. };
  11914. StackPanel.prototype._postMeasure = function () {
  11915. var stackWidth = 0;
  11916. var stackHeight = 0;
  11917. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11918. var child = _a[_i];
  11919. if (!child.isVisible || child.notRenderable) {
  11920. continue;
  11921. }
  11922. if (this._isVertical) {
  11923. if (child.top !== stackHeight + "px") {
  11924. child.top = stackHeight + "px";
  11925. this._rebuildLayout = true;
  11926. child._top.ignoreAdaptiveScaling = true;
  11927. }
  11928. if (child._height.isPercentage && !child._automaticSize) {
  11929. if (!this.ignoreLayoutWarnings) {
  11930. 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");
  11931. }
  11932. }
  11933. else {
  11934. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11935. }
  11936. }
  11937. else {
  11938. if (child.left !== stackWidth + "px") {
  11939. child.left = stackWidth + "px";
  11940. this._rebuildLayout = true;
  11941. child._left.ignoreAdaptiveScaling = true;
  11942. }
  11943. if (child._width.isPercentage && !child._automaticSize) {
  11944. if (!this.ignoreLayoutWarnings) {
  11945. 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");
  11946. }
  11947. }
  11948. else {
  11949. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11950. }
  11951. }
  11952. }
  11953. stackWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  11954. stackHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  11955. this._doNotTrackManualChanges = true;
  11956. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11957. // User can now define their own height and width for stack panel.
  11958. var panelWidthChanged = false;
  11959. var panelHeightChanged = false;
  11960. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11961. var previousHeight = this.height;
  11962. this.height = stackHeight + "px";
  11963. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11964. }
  11965. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11966. var previousWidth = this.width;
  11967. this.width = stackWidth + "px";
  11968. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11969. }
  11970. if (panelHeightChanged) {
  11971. this._height.ignoreAdaptiveScaling = true;
  11972. }
  11973. if (panelWidthChanged) {
  11974. this._width.ignoreAdaptiveScaling = true;
  11975. }
  11976. this._doNotTrackManualChanges = false;
  11977. if (panelWidthChanged || panelHeightChanged) {
  11978. this._rebuildLayout = true;
  11979. }
  11980. _super.prototype._postMeasure.call(this);
  11981. };
  11982. return StackPanel;
  11983. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11984. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11985. /***/ }),
  11986. /***/ "./2D/controls/statics.ts":
  11987. /*!********************************!*\
  11988. !*** ./2D/controls/statics.ts ***!
  11989. \********************************/
  11990. /*! exports provided: name */
  11991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11992. "use strict";
  11993. __webpack_require__.r(__webpack_exports__);
  11994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11995. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11996. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11997. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11998. /**
  11999. * Forcing an export so that this code will execute
  12000. * @hidden
  12001. */
  12002. var name = "Statics";
  12003. /**
  12004. * Creates a stack panel that can be used to render headers
  12005. * @param control defines the control to associate with the header
  12006. * @param text defines the text of the header
  12007. * @param size defines the size of the header
  12008. * @param options defines options used to configure the header
  12009. * @returns a new StackPanel
  12010. */
  12011. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  12012. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  12013. var isHorizontal = options ? options.isHorizontal : true;
  12014. var controlFirst = options ? options.controlFirst : true;
  12015. panel.isVertical = !isHorizontal;
  12016. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  12017. header.text = text;
  12018. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12019. if (isHorizontal) {
  12020. header.width = size;
  12021. }
  12022. else {
  12023. header.height = size;
  12024. }
  12025. if (controlFirst) {
  12026. panel.addControl(control);
  12027. panel.addControl(header);
  12028. header.paddingLeft = "5px";
  12029. }
  12030. else {
  12031. panel.addControl(header);
  12032. panel.addControl(control);
  12033. header.paddingRight = "5px";
  12034. }
  12035. header.shadowBlur = control.shadowBlur;
  12036. header.shadowColor = control.shadowColor;
  12037. header.shadowOffsetX = control.shadowOffsetX;
  12038. header.shadowOffsetY = control.shadowOffsetY;
  12039. return panel;
  12040. };
  12041. /***/ }),
  12042. /***/ "./2D/controls/textBlock.ts":
  12043. /*!**********************************!*\
  12044. !*** ./2D/controls/textBlock.ts ***!
  12045. \**********************************/
  12046. /*! exports provided: TextWrapping, TextBlock */
  12047. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12048. "use strict";
  12049. __webpack_require__.r(__webpack_exports__);
  12050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  12051. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  12052. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12053. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12054. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12055. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  12056. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12057. /**
  12058. * Enum that determines the text-wrapping mode to use.
  12059. */
  12060. var TextWrapping;
  12061. (function (TextWrapping) {
  12062. /**
  12063. * Clip the text when it's larger than Control.width; this is the default mode.
  12064. */
  12065. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  12066. /**
  12067. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  12068. */
  12069. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  12070. /**
  12071. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  12072. */
  12073. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  12074. })(TextWrapping || (TextWrapping = {}));
  12075. /**
  12076. * Class used to create text block control
  12077. */
  12078. var TextBlock = /** @class */ (function (_super) {
  12079. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  12080. /**
  12081. * Creates a new TextBlock object
  12082. * @param name defines the name of the control
  12083. * @param text defines the text to display (emptry string by default)
  12084. */
  12085. function TextBlock(
  12086. /**
  12087. * Defines the name of the control
  12088. */
  12089. name, text) {
  12090. if (text === void 0) { text = ""; }
  12091. var _this = _super.call(this, name) || this;
  12092. _this.name = name;
  12093. _this._text = "";
  12094. _this._textWrapping = TextWrapping.Clip;
  12095. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  12096. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  12097. _this._resizeToFit = false;
  12098. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  12099. _this._outlineWidth = 0;
  12100. _this._outlineColor = "white";
  12101. _this._underline = false;
  12102. _this._lineThrough = false;
  12103. /**
  12104. * An event triggered after the text is changed
  12105. */
  12106. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12107. /**
  12108. * An event triggered after the text was broken up into lines
  12109. */
  12110. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12111. _this.text = text;
  12112. return _this;
  12113. }
  12114. Object.defineProperty(TextBlock.prototype, "lines", {
  12115. /**
  12116. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  12117. */
  12118. get: function () {
  12119. return this._lines;
  12120. },
  12121. enumerable: false,
  12122. configurable: true
  12123. });
  12124. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12125. /**
  12126. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12127. */
  12128. get: function () {
  12129. return this._resizeToFit;
  12130. },
  12131. /**
  12132. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12133. */
  12134. set: function (value) {
  12135. if (this._resizeToFit === value) {
  12136. return;
  12137. }
  12138. this._resizeToFit = value;
  12139. if (this._resizeToFit) {
  12140. this._width.ignoreAdaptiveScaling = true;
  12141. this._height.ignoreAdaptiveScaling = true;
  12142. }
  12143. this._markAsDirty();
  12144. },
  12145. enumerable: false,
  12146. configurable: true
  12147. });
  12148. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12149. /**
  12150. * Gets or sets a boolean indicating if text must be wrapped
  12151. */
  12152. get: function () {
  12153. return this._textWrapping;
  12154. },
  12155. /**
  12156. * Gets or sets a boolean indicating if text must be wrapped
  12157. */
  12158. set: function (value) {
  12159. if (this._textWrapping === value) {
  12160. return;
  12161. }
  12162. this._textWrapping = +value;
  12163. this._markAsDirty();
  12164. },
  12165. enumerable: false,
  12166. configurable: true
  12167. });
  12168. Object.defineProperty(TextBlock.prototype, "text", {
  12169. /**
  12170. * Gets or sets text to display
  12171. */
  12172. get: function () {
  12173. return this._text;
  12174. },
  12175. /**
  12176. * Gets or sets text to display
  12177. */
  12178. set: function (value) {
  12179. if (this._text === value) {
  12180. return;
  12181. }
  12182. this._text = value;
  12183. this._markAsDirty();
  12184. this.onTextChangedObservable.notifyObservers(this);
  12185. },
  12186. enumerable: false,
  12187. configurable: true
  12188. });
  12189. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12190. /**
  12191. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12192. */
  12193. get: function () {
  12194. return this._textHorizontalAlignment;
  12195. },
  12196. /**
  12197. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12198. */
  12199. set: function (value) {
  12200. if (this._textHorizontalAlignment === value) {
  12201. return;
  12202. }
  12203. this._textHorizontalAlignment = value;
  12204. this._markAsDirty();
  12205. },
  12206. enumerable: false,
  12207. configurable: true
  12208. });
  12209. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12210. /**
  12211. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12212. */
  12213. get: function () {
  12214. return this._textVerticalAlignment;
  12215. },
  12216. /**
  12217. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12218. */
  12219. set: function (value) {
  12220. if (this._textVerticalAlignment === value) {
  12221. return;
  12222. }
  12223. this._textVerticalAlignment = value;
  12224. this._markAsDirty();
  12225. },
  12226. enumerable: false,
  12227. configurable: true
  12228. });
  12229. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12230. /**
  12231. * Gets or sets line spacing value
  12232. */
  12233. get: function () {
  12234. return this._lineSpacing.toString(this._host);
  12235. },
  12236. /**
  12237. * Gets or sets line spacing value
  12238. */
  12239. set: function (value) {
  12240. if (this._lineSpacing.fromString(value)) {
  12241. this._markAsDirty();
  12242. }
  12243. },
  12244. enumerable: false,
  12245. configurable: true
  12246. });
  12247. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12248. /**
  12249. * Gets or sets outlineWidth of the text to display
  12250. */
  12251. get: function () {
  12252. return this._outlineWidth;
  12253. },
  12254. /**
  12255. * Gets or sets outlineWidth of the text to display
  12256. */
  12257. set: function (value) {
  12258. if (this._outlineWidth === value) {
  12259. return;
  12260. }
  12261. this._outlineWidth = value;
  12262. this._markAsDirty();
  12263. },
  12264. enumerable: false,
  12265. configurable: true
  12266. });
  12267. Object.defineProperty(TextBlock.prototype, "underline", {
  12268. /**
  12269. * Gets or sets a boolean indicating that text must have underline
  12270. */
  12271. get: function () {
  12272. return this._underline;
  12273. },
  12274. /**
  12275. * Gets or sets a boolean indicating that text must have underline
  12276. */
  12277. set: function (value) {
  12278. if (this._underline === value) {
  12279. return;
  12280. }
  12281. this._underline = value;
  12282. this._markAsDirty();
  12283. },
  12284. enumerable: false,
  12285. configurable: true
  12286. });
  12287. Object.defineProperty(TextBlock.prototype, "lineThrough", {
  12288. /**
  12289. * Gets or sets an boolean indicating that text must be crossed out
  12290. */
  12291. get: function () {
  12292. return this._lineThrough;
  12293. },
  12294. /**
  12295. * Gets or sets an boolean indicating that text must be crossed out
  12296. */
  12297. set: function (value) {
  12298. if (this._lineThrough === value) {
  12299. return;
  12300. }
  12301. this._lineThrough = value;
  12302. this._markAsDirty();
  12303. },
  12304. enumerable: false,
  12305. configurable: true
  12306. });
  12307. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12308. /**
  12309. * Gets or sets outlineColor of the text to display
  12310. */
  12311. get: function () {
  12312. return this._outlineColor;
  12313. },
  12314. /**
  12315. * Gets or sets outlineColor of the text to display
  12316. */
  12317. set: function (value) {
  12318. if (this._outlineColor === value) {
  12319. return;
  12320. }
  12321. this._outlineColor = value;
  12322. this._markAsDirty();
  12323. },
  12324. enumerable: false,
  12325. configurable: true
  12326. });
  12327. TextBlock.prototype._getTypeName = function () {
  12328. return "TextBlock";
  12329. };
  12330. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12331. if (!this._fontOffset) {
  12332. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12333. }
  12334. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12335. // Prepare lines
  12336. this._lines = this._breakLines(this._currentMeasure.width, context);
  12337. this.onLinesReadyObservable.notifyObservers(this);
  12338. var maxLineWidth = 0;
  12339. for (var i = 0; i < this._lines.length; i++) {
  12340. var line = this._lines[i];
  12341. if (line.width > maxLineWidth) {
  12342. maxLineWidth = line.width;
  12343. }
  12344. }
  12345. if (this._resizeToFit) {
  12346. if (this._textWrapping === TextWrapping.Clip) {
  12347. var newWidth = (this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth) | 0;
  12348. if (newWidth !== this._width.internalValue) {
  12349. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12350. this._rebuildLayout = true;
  12351. }
  12352. }
  12353. var newHeight = (this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;
  12354. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12355. var lineSpacing = 0;
  12356. if (this._lineSpacing.isPixel) {
  12357. lineSpacing = this._lineSpacing.getValue(this._host);
  12358. }
  12359. else {
  12360. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12361. }
  12362. newHeight += (this._lines.length - 1) * lineSpacing;
  12363. }
  12364. if (newHeight !== this._height.internalValue) {
  12365. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12366. this._rebuildLayout = true;
  12367. }
  12368. }
  12369. };
  12370. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12371. var width = this._currentMeasure.width;
  12372. var x = 0;
  12373. switch (this._textHorizontalAlignment) {
  12374. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12375. x = 0;
  12376. break;
  12377. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12378. x = width - textWidth;
  12379. break;
  12380. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12381. x = (width - textWidth) / 2;
  12382. break;
  12383. }
  12384. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12385. context.shadowColor = this.shadowColor;
  12386. context.shadowBlur = this.shadowBlur;
  12387. context.shadowOffsetX = this.shadowOffsetX;
  12388. context.shadowOffsetY = this.shadowOffsetY;
  12389. }
  12390. if (this.outlineWidth) {
  12391. context.strokeText(text, this._currentMeasure.left + x, y);
  12392. }
  12393. context.fillText(text, this._currentMeasure.left + x, y);
  12394. if (this._underline) {
  12395. context.beginPath();
  12396. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  12397. context.moveTo(this._currentMeasure.left + x, y + 3);
  12398. context.lineTo(this._currentMeasure.left + x + textWidth, y + 3);
  12399. context.stroke();
  12400. context.closePath();
  12401. }
  12402. if (this._lineThrough) {
  12403. context.beginPath();
  12404. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  12405. context.moveTo(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3);
  12406. context.lineTo(this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3);
  12407. context.stroke();
  12408. context.closePath();
  12409. }
  12410. };
  12411. /** @hidden */
  12412. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12413. context.save();
  12414. this._applyStates(context);
  12415. // Render lines
  12416. this._renderLines(context);
  12417. context.restore();
  12418. };
  12419. TextBlock.prototype._applyStates = function (context) {
  12420. _super.prototype._applyStates.call(this, context);
  12421. if (this.outlineWidth) {
  12422. context.lineWidth = this.outlineWidth;
  12423. context.strokeStyle = this.outlineColor;
  12424. }
  12425. };
  12426. TextBlock.prototype._breakLines = function (refWidth, context) {
  12427. var lines = [];
  12428. var _lines = this.text.split("\n");
  12429. if (this._textWrapping === TextWrapping.Ellipsis) {
  12430. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12431. var _line = _lines_1[_i];
  12432. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12433. }
  12434. }
  12435. else if (this._textWrapping === TextWrapping.WordWrap) {
  12436. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12437. var _line = _lines_2[_a];
  12438. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12439. }
  12440. }
  12441. else {
  12442. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12443. var _line = _lines_3[_b];
  12444. lines.push(this._parseLine(_line, context));
  12445. }
  12446. }
  12447. return lines;
  12448. };
  12449. TextBlock.prototype._parseLine = function (line, context) {
  12450. if (line === void 0) { line = ""; }
  12451. return { text: line, width: context.measureText(line).width };
  12452. };
  12453. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12454. if (line === void 0) { line = ""; }
  12455. var lineWidth = context.measureText(line).width;
  12456. if (lineWidth > width) {
  12457. line += "…";
  12458. }
  12459. // unicode support. split('') does not work with unicode!
  12460. // make sure Array.from is available
  12461. var characters = Array.from && Array.from(line);
  12462. if (!characters) {
  12463. // no array.from, use the old method
  12464. while (line.length > 2 && lineWidth > width) {
  12465. line = line.slice(0, -2) + "…";
  12466. lineWidth = context.measureText(line).width;
  12467. }
  12468. }
  12469. else {
  12470. while (characters.length && lineWidth > width) {
  12471. characters.pop();
  12472. line = characters.join("") + "...";
  12473. lineWidth = context.measureText(line).width;
  12474. }
  12475. }
  12476. return { text: line, width: lineWidth };
  12477. };
  12478. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12479. if (line === void 0) { line = ""; }
  12480. var lines = [];
  12481. var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(" ");
  12482. var lineWidth = 0;
  12483. for (var n = 0; n < words.length; n++) {
  12484. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12485. var metrics = context.measureText(testLine);
  12486. var testWidth = metrics.width;
  12487. if (testWidth > width && n > 0) {
  12488. lines.push({ text: line, width: lineWidth });
  12489. line = words[n];
  12490. lineWidth = context.measureText(line).width;
  12491. }
  12492. else {
  12493. lineWidth = testWidth;
  12494. line = testLine;
  12495. }
  12496. }
  12497. lines.push({ text: line, width: lineWidth });
  12498. return lines;
  12499. };
  12500. TextBlock.prototype._renderLines = function (context) {
  12501. var height = this._currentMeasure.height;
  12502. var rootY = 0;
  12503. switch (this._textVerticalAlignment) {
  12504. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12505. rootY = this._fontOffset.ascent;
  12506. break;
  12507. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12508. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12509. break;
  12510. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12511. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12512. break;
  12513. }
  12514. rootY += this._currentMeasure.top;
  12515. for (var i = 0; i < this._lines.length; i++) {
  12516. var line = this._lines[i];
  12517. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12518. if (this._lineSpacing.isPixel) {
  12519. rootY += this._lineSpacing.getValue(this._host);
  12520. }
  12521. else {
  12522. rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12523. }
  12524. }
  12525. this._drawText(line.text, line.width, rootY, context);
  12526. rootY += this._fontOffset.height;
  12527. }
  12528. };
  12529. /**
  12530. * Given a width constraint applied on the text block, find the expected height
  12531. * @returns expected height
  12532. */
  12533. TextBlock.prototype.computeExpectedHeight = function () {
  12534. if (this.text && this.widthInPixels) {
  12535. var context_1 = document.createElement("canvas").getContext("2d");
  12536. if (context_1) {
  12537. this._applyStates(context_1);
  12538. if (!this._fontOffset) {
  12539. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12540. }
  12541. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12542. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12543. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12544. var lineSpacing = 0;
  12545. if (this._lineSpacing.isPixel) {
  12546. lineSpacing = this._lineSpacing.getValue(this._host);
  12547. }
  12548. else {
  12549. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12550. }
  12551. newHeight += (lines.length - 1) * lineSpacing;
  12552. }
  12553. return newHeight;
  12554. }
  12555. }
  12556. return 0;
  12557. };
  12558. TextBlock.prototype.dispose = function () {
  12559. _super.prototype.dispose.call(this);
  12560. this.onTextChangedObservable.clear();
  12561. };
  12562. return TextBlock;
  12563. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12564. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12565. /***/ }),
  12566. /***/ "./2D/controls/virtualKeyboard.ts":
  12567. /*!****************************************!*\
  12568. !*** ./2D/controls/virtualKeyboard.ts ***!
  12569. \****************************************/
  12570. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12571. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12572. "use strict";
  12573. __webpack_require__.r(__webpack_exports__);
  12574. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12575. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12576. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12577. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12578. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12579. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12580. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12581. /**
  12582. * Class used to store key control properties
  12583. */
  12584. var KeyPropertySet = /** @class */ (function () {
  12585. function KeyPropertySet() {
  12586. }
  12587. return KeyPropertySet;
  12588. }());
  12589. /**
  12590. * Class used to create virtual keyboard
  12591. */
  12592. var VirtualKeyboard = /** @class */ (function (_super) {
  12593. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12594. function VirtualKeyboard() {
  12595. var _this = _super !== null && _super.apply(this, arguments) || this;
  12596. /** Observable raised when a key is pressed */
  12597. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12598. /** Gets or sets default key button width */
  12599. _this.defaultButtonWidth = "40px";
  12600. /** Gets or sets default key button height */
  12601. _this.defaultButtonHeight = "40px";
  12602. /** Gets or sets default key button left padding */
  12603. _this.defaultButtonPaddingLeft = "2px";
  12604. /** Gets or sets default key button right padding */
  12605. _this.defaultButtonPaddingRight = "2px";
  12606. /** Gets or sets default key button top padding */
  12607. _this.defaultButtonPaddingTop = "2px";
  12608. /** Gets or sets default key button bottom padding */
  12609. _this.defaultButtonPaddingBottom = "2px";
  12610. /** Gets or sets default key button foreground color */
  12611. _this.defaultButtonColor = "#DDD";
  12612. /** Gets or sets default key button background color */
  12613. _this.defaultButtonBackground = "#070707";
  12614. /** Gets or sets shift button foreground color */
  12615. _this.shiftButtonColor = "#7799FF";
  12616. /** Gets or sets shift button thickness*/
  12617. _this.selectedShiftThickness = 1;
  12618. /** Gets shift key state */
  12619. _this.shiftState = 0;
  12620. _this._currentlyConnectedInputText = null;
  12621. _this._connectedInputTexts = [];
  12622. _this._onKeyPressObserver = null;
  12623. return _this;
  12624. }
  12625. VirtualKeyboard.prototype._getTypeName = function () {
  12626. return "VirtualKeyboard";
  12627. };
  12628. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12629. var _this = this;
  12630. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12631. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12632. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12633. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12634. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12635. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12636. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12637. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12638. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12639. button.thickness = 0;
  12640. button.isFocusInvisible = true;
  12641. button.shadowColor = this.shadowColor;
  12642. button.shadowBlur = this.shadowBlur;
  12643. button.shadowOffsetX = this.shadowOffsetX;
  12644. button.shadowOffsetY = this.shadowOffsetY;
  12645. button.onPointerUpObservable.add(function () {
  12646. _this.onKeyPressObservable.notifyObservers(key);
  12647. });
  12648. return button;
  12649. };
  12650. /**
  12651. * Adds a new row of keys
  12652. * @param keys defines the list of keys to add
  12653. * @param propertySets defines the associated property sets
  12654. */
  12655. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12656. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12657. panel.isVertical = false;
  12658. panel.isFocusInvisible = true;
  12659. var maxKey = null;
  12660. for (var i = 0; i < keys.length; i++) {
  12661. var properties = null;
  12662. if (propertySets && propertySets.length === keys.length) {
  12663. properties = propertySets[i];
  12664. }
  12665. var key = this._createKey(keys[i], properties);
  12666. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12667. maxKey = key;
  12668. }
  12669. panel.addControl(key);
  12670. }
  12671. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12672. this.addControl(panel);
  12673. };
  12674. /**
  12675. * Set the shift key to a specific state
  12676. * @param shiftState defines the new shift state
  12677. */
  12678. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12679. if (!this.children) {
  12680. return;
  12681. }
  12682. for (var i = 0; i < this.children.length; i++) {
  12683. var row = this.children[i];
  12684. if (!row || !row.children) {
  12685. continue;
  12686. }
  12687. var rowContainer = row;
  12688. for (var j = 0; j < rowContainer.children.length; j++) {
  12689. var button = rowContainer.children[j];
  12690. if (!button || !button.children[0]) {
  12691. continue;
  12692. }
  12693. var button_tblock = button.children[0];
  12694. if (button_tblock.text === "\u21E7") {
  12695. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12696. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12697. }
  12698. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12699. }
  12700. }
  12701. };
  12702. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12703. /** Gets the input text control currently attached to the keyboard */
  12704. get: function () {
  12705. return this._currentlyConnectedInputText;
  12706. },
  12707. enumerable: false,
  12708. configurable: true
  12709. });
  12710. /**
  12711. * Connects the keyboard with an input text control
  12712. *
  12713. * @param input defines the target control
  12714. */
  12715. VirtualKeyboard.prototype.connect = function (input) {
  12716. var _this = this;
  12717. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12718. if (inputTextAlreadyConnected) {
  12719. return;
  12720. }
  12721. if (this._onKeyPressObserver === null) {
  12722. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12723. if (!_this._currentlyConnectedInputText) {
  12724. return;
  12725. }
  12726. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12727. switch (key) {
  12728. case "\u21E7":
  12729. _this.shiftState++;
  12730. if (_this.shiftState > 2) {
  12731. _this.shiftState = 0;
  12732. }
  12733. _this.applyShiftState(_this.shiftState);
  12734. return;
  12735. case "\u2190":
  12736. _this._currentlyConnectedInputText.processKey(8);
  12737. return;
  12738. case "\u21B5":
  12739. _this._currentlyConnectedInputText.processKey(13);
  12740. return;
  12741. }
  12742. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12743. if (_this.shiftState === 1) {
  12744. _this.shiftState = 0;
  12745. _this.applyShiftState(_this.shiftState);
  12746. }
  12747. });
  12748. }
  12749. this.isVisible = false;
  12750. this._currentlyConnectedInputText = input;
  12751. input._connectedVirtualKeyboard = this;
  12752. // Events hooking
  12753. var onFocusObserver = input.onFocusObservable.add(function () {
  12754. _this._currentlyConnectedInputText = input;
  12755. input._connectedVirtualKeyboard = _this;
  12756. _this.isVisible = true;
  12757. });
  12758. var onBlurObserver = input.onBlurObservable.add(function () {
  12759. input._connectedVirtualKeyboard = null;
  12760. _this._currentlyConnectedInputText = null;
  12761. _this.isVisible = false;
  12762. });
  12763. this._connectedInputTexts.push({
  12764. input: input,
  12765. onBlurObserver: onBlurObserver,
  12766. onFocusObserver: onFocusObserver
  12767. });
  12768. };
  12769. /**
  12770. * Disconnects the keyboard from connected InputText controls
  12771. *
  12772. * @param input optionally defines a target control, otherwise all are disconnected
  12773. */
  12774. VirtualKeyboard.prototype.disconnect = function (input) {
  12775. var _this = this;
  12776. if (input) {
  12777. // .find not available on IE
  12778. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12779. if (filtered.length === 1) {
  12780. this._removeConnectedInputObservables(filtered[0]);
  12781. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12782. if (this._currentlyConnectedInputText === input) {
  12783. this._currentlyConnectedInputText = null;
  12784. }
  12785. }
  12786. }
  12787. else {
  12788. this._connectedInputTexts.forEach(function (connectedInputText) {
  12789. _this._removeConnectedInputObservables(connectedInputText);
  12790. });
  12791. this._connectedInputTexts = [];
  12792. }
  12793. if (this._connectedInputTexts.length === 0) {
  12794. this._currentlyConnectedInputText = null;
  12795. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12796. this._onKeyPressObserver = null;
  12797. }
  12798. };
  12799. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12800. connectedInputText.input._connectedVirtualKeyboard = null;
  12801. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12802. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12803. };
  12804. /**
  12805. * Release all resources
  12806. */
  12807. VirtualKeyboard.prototype.dispose = function () {
  12808. _super.prototype.dispose.call(this);
  12809. this.disconnect();
  12810. };
  12811. // Statics
  12812. /**
  12813. * Creates a new keyboard using a default layout
  12814. *
  12815. * @param name defines control name
  12816. * @returns a new VirtualKeyboard
  12817. */
  12818. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12819. var returnValue = new VirtualKeyboard(name);
  12820. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12821. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12822. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12823. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12824. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12825. return returnValue;
  12826. };
  12827. return VirtualKeyboard;
  12828. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12829. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12830. /***/ }),
  12831. /***/ "./2D/index.ts":
  12832. /*!*********************!*\
  12833. !*** ./2D/index.ts ***!
  12834. \*********************/
  12835. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader */
  12836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12837. "use strict";
  12838. __webpack_require__.r(__webpack_exports__);
  12839. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12846. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12848. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12850. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12852. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12862. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12872. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12874. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12876. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12879. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12881. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12882. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12883. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12885. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12886. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12887. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12888. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12889. /***/ }),
  12890. /***/ "./2D/math2D.ts":
  12891. /*!**********************!*\
  12892. !*** ./2D/math2D.ts ***!
  12893. \**********************/
  12894. /*! exports provided: Vector2WithInfo, Matrix2D */
  12895. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12896. "use strict";
  12897. __webpack_require__.r(__webpack_exports__);
  12898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12900. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12901. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  12902. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  12903. /**
  12904. * Class used to transport Vector2 information for pointer events
  12905. */
  12906. var Vector2WithInfo = /** @class */ (function (_super) {
  12907. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12908. /**
  12909. * Creates a new Vector2WithInfo
  12910. * @param source defines the vector2 data to transport
  12911. * @param buttonIndex defines the current mouse button index
  12912. */
  12913. function Vector2WithInfo(source,
  12914. /** defines the current mouse button index */
  12915. buttonIndex) {
  12916. if (buttonIndex === void 0) { buttonIndex = 0; }
  12917. var _this = _super.call(this, source.x, source.y) || this;
  12918. _this.buttonIndex = buttonIndex;
  12919. return _this;
  12920. }
  12921. return Vector2WithInfo;
  12922. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12923. /** Class used to provide 2D matrix features */
  12924. var Matrix2D = /** @class */ (function () {
  12925. /**
  12926. * Creates a new matrix
  12927. * @param m00 defines value for (0, 0)
  12928. * @param m01 defines value for (0, 1)
  12929. * @param m10 defines value for (1, 0)
  12930. * @param m11 defines value for (1, 1)
  12931. * @param m20 defines value for (2, 0)
  12932. * @param m21 defines value for (2, 1)
  12933. */
  12934. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12935. /** Gets the internal array of 6 floats used to store matrix data */
  12936. this.m = new Float32Array(6);
  12937. this.fromValues(m00, m01, m10, m11, m20, m21);
  12938. }
  12939. /**
  12940. * Fills the matrix from direct values
  12941. * @param m00 defines value for (0, 0)
  12942. * @param m01 defines value for (0, 1)
  12943. * @param m10 defines value for (1, 0)
  12944. * @param m11 defines value for (1, 1)
  12945. * @param m20 defines value for (2, 0)
  12946. * @param m21 defines value for (2, 1)
  12947. * @returns the current modified matrix
  12948. */
  12949. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12950. this.m[0] = m00;
  12951. this.m[1] = m01;
  12952. this.m[2] = m10;
  12953. this.m[3] = m11;
  12954. this.m[4] = m20;
  12955. this.m[5] = m21;
  12956. return this;
  12957. };
  12958. /**
  12959. * Gets matrix determinant
  12960. * @returns the determinant
  12961. */
  12962. Matrix2D.prototype.determinant = function () {
  12963. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12964. };
  12965. /**
  12966. * Inverses the matrix and stores it in a target matrix
  12967. * @param result defines the target matrix
  12968. * @returns the current matrix
  12969. */
  12970. Matrix2D.prototype.invertToRef = function (result) {
  12971. var l0 = this.m[0];
  12972. var l1 = this.m[1];
  12973. var l2 = this.m[2];
  12974. var l3 = this.m[3];
  12975. var l4 = this.m[4];
  12976. var l5 = this.m[5];
  12977. var det = this.determinant();
  12978. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12979. result.m[0] = 0;
  12980. result.m[1] = 0;
  12981. result.m[2] = 0;
  12982. result.m[3] = 0;
  12983. result.m[4] = 0;
  12984. result.m[5] = 0;
  12985. return this;
  12986. }
  12987. var detDiv = 1 / det;
  12988. var det4 = l2 * l5 - l3 * l4;
  12989. var det5 = l1 * l4 - l0 * l5;
  12990. result.m[0] = l3 * detDiv;
  12991. result.m[1] = -l1 * detDiv;
  12992. result.m[2] = -l2 * detDiv;
  12993. result.m[3] = l0 * detDiv;
  12994. result.m[4] = det4 * detDiv;
  12995. result.m[5] = det5 * detDiv;
  12996. return this;
  12997. };
  12998. /**
  12999. * Multiplies the current matrix with another one
  13000. * @param other defines the second operand
  13001. * @param result defines the target matrix
  13002. * @returns the current matrix
  13003. */
  13004. Matrix2D.prototype.multiplyToRef = function (other, result) {
  13005. var l0 = this.m[0];
  13006. var l1 = this.m[1];
  13007. var l2 = this.m[2];
  13008. var l3 = this.m[3];
  13009. var l4 = this.m[4];
  13010. var l5 = this.m[5];
  13011. var r0 = other.m[0];
  13012. var r1 = other.m[1];
  13013. var r2 = other.m[2];
  13014. var r3 = other.m[3];
  13015. var r4 = other.m[4];
  13016. var r5 = other.m[5];
  13017. result.m[0] = l0 * r0 + l1 * r2;
  13018. result.m[1] = l0 * r1 + l1 * r3;
  13019. result.m[2] = l2 * r0 + l3 * r2;
  13020. result.m[3] = l2 * r1 + l3 * r3;
  13021. result.m[4] = l4 * r0 + l5 * r2 + r4;
  13022. result.m[5] = l4 * r1 + l5 * r3 + r5;
  13023. return this;
  13024. };
  13025. /**
  13026. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  13027. * @param x defines the x coordinate to transform
  13028. * @param y defines the x coordinate to transform
  13029. * @param result defines the target vector2
  13030. * @returns the current matrix
  13031. */
  13032. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  13033. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  13034. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  13035. return this;
  13036. };
  13037. // Statics
  13038. /**
  13039. * Creates an identity matrix
  13040. * @returns a new matrix
  13041. */
  13042. Matrix2D.Identity = function () {
  13043. return new Matrix2D(1, 0, 0, 1, 0, 0);
  13044. };
  13045. /**
  13046. * Creates a translation matrix and stores it in a target matrix
  13047. * @param x defines the x coordinate of the translation
  13048. * @param y defines the y coordinate of the translation
  13049. * @param result defines the target matrix
  13050. */
  13051. Matrix2D.TranslationToRef = function (x, y, result) {
  13052. result.fromValues(1, 0, 0, 1, x, y);
  13053. };
  13054. /**
  13055. * Creates a scaling matrix and stores it in a target matrix
  13056. * @param x defines the x coordinate of the scaling
  13057. * @param y defines the y coordinate of the scaling
  13058. * @param result defines the target matrix
  13059. */
  13060. Matrix2D.ScalingToRef = function (x, y, result) {
  13061. result.fromValues(x, 0, 0, y, 0, 0);
  13062. };
  13063. /**
  13064. * Creates a rotation matrix and stores it in a target matrix
  13065. * @param angle defines the rotation angle
  13066. * @param result defines the target matrix
  13067. */
  13068. Matrix2D.RotationToRef = function (angle, result) {
  13069. var s = Math.sin(angle);
  13070. var c = Math.cos(angle);
  13071. result.fromValues(c, s, -s, c, 0, 0);
  13072. };
  13073. /**
  13074. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  13075. * @param tx defines the x coordinate of the translation
  13076. * @param ty defines the y coordinate of the translation
  13077. * @param angle defines the rotation angle
  13078. * @param scaleX defines the x coordinate of the scaling
  13079. * @param scaleY defines the y coordinate of the scaling
  13080. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  13081. * @param result defines the target matrix
  13082. */
  13083. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  13084. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  13085. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  13086. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  13087. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  13088. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  13089. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  13090. if (parentMatrix) {
  13091. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  13092. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  13093. }
  13094. else {
  13095. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  13096. }
  13097. };
  13098. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  13099. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  13100. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  13101. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  13102. Matrix2D._TempCompose0 = Matrix2D.Identity();
  13103. Matrix2D._TempCompose1 = Matrix2D.Identity();
  13104. Matrix2D._TempCompose2 = Matrix2D.Identity();
  13105. return Matrix2D;
  13106. }());
  13107. /***/ }),
  13108. /***/ "./2D/measure.ts":
  13109. /*!***********************!*\
  13110. !*** ./2D/measure.ts ***!
  13111. \***********************/
  13112. /*! exports provided: Measure */
  13113. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13114. "use strict";
  13115. __webpack_require__.r(__webpack_exports__);
  13116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  13117. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  13118. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13119. var tmpRect = [
  13120. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13121. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13122. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13123. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13124. ];
  13125. var tmpRect2 = [
  13126. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13127. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13128. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13129. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13130. ];
  13131. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13132. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13133. /**
  13134. * Class used to store 2D control sizes
  13135. */
  13136. var Measure = /** @class */ (function () {
  13137. /**
  13138. * Creates a new measure
  13139. * @param left defines left coordinate
  13140. * @param top defines top coordinate
  13141. * @param width defines width dimension
  13142. * @param height defines height dimension
  13143. */
  13144. function Measure(
  13145. /** defines left coordinate */
  13146. left,
  13147. /** defines top coordinate */
  13148. top,
  13149. /** defines width dimension */
  13150. width,
  13151. /** defines height dimension */
  13152. height) {
  13153. this.left = left;
  13154. this.top = top;
  13155. this.width = width;
  13156. this.height = height;
  13157. }
  13158. /**
  13159. * Copy from another measure
  13160. * @param other defines the other measure to copy from
  13161. */
  13162. Measure.prototype.copyFrom = function (other) {
  13163. this.left = other.left;
  13164. this.top = other.top;
  13165. this.width = other.width;
  13166. this.height = other.height;
  13167. };
  13168. /**
  13169. * Copy from a group of 4 floats
  13170. * @param left defines left coordinate
  13171. * @param top defines top coordinate
  13172. * @param width defines width dimension
  13173. * @param height defines height dimension
  13174. */
  13175. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  13176. this.left = left;
  13177. this.top = top;
  13178. this.width = width;
  13179. this.height = height;
  13180. };
  13181. /**
  13182. * Computes the axis aligned bounding box measure for two given measures
  13183. * @param a Input measure
  13184. * @param b Input measure
  13185. * @param result the resulting bounding measure
  13186. */
  13187. Measure.CombineToRef = function (a, b, result) {
  13188. var left = Math.min(a.left, b.left);
  13189. var top = Math.min(a.top, b.top);
  13190. var right = Math.max(a.left + a.width, b.left + b.width);
  13191. var bottom = Math.max(a.top + a.height, b.top + b.height);
  13192. result.left = left;
  13193. result.top = top;
  13194. result.width = right - left;
  13195. result.height = bottom - top;
  13196. };
  13197. /**
  13198. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13199. * @param transform the matrix to transform the measure before computing the AABB
  13200. * @param addX number to add to left
  13201. * @param addY number to add to top
  13202. * @param addWidth number to add to width
  13203. * @param addHeight number to add to height
  13204. * @param result the resulting AABB
  13205. */
  13206. Measure.prototype.addAndTransformToRef = function (transform, addX, addY, addWidth, addHeight, result) {
  13207. var left = this.left + addX;
  13208. var top = this.top + addY;
  13209. var width = this.width + addWidth;
  13210. var height = this.height + addHeight;
  13211. tmpRect[0].copyFromFloats(left, top);
  13212. tmpRect[1].copyFromFloats(left + width, top);
  13213. tmpRect[2].copyFromFloats(left + width, top + height);
  13214. tmpRect[3].copyFromFloats(left, top + height);
  13215. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  13216. tmpV2.copyFromFloats(0, 0);
  13217. for (var i = 0; i < 4; i++) {
  13218. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  13219. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  13220. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  13221. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  13222. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  13223. }
  13224. result.left = tmpV1.x;
  13225. result.top = tmpV1.y;
  13226. result.width = tmpV2.x - tmpV1.x;
  13227. result.height = tmpV2.y - tmpV1.y;
  13228. };
  13229. /**
  13230. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13231. * @param transform the matrix to transform the measure before computing the AABB
  13232. * @param result the resulting AABB
  13233. */
  13234. Measure.prototype.transformToRef = function (transform, result) {
  13235. this.addAndTransformToRef(transform, 0, 0, 0, 0, result);
  13236. };
  13237. /**
  13238. * Check equality between this measure and another one
  13239. * @param other defines the other measures
  13240. * @returns true if both measures are equals
  13241. */
  13242. Measure.prototype.isEqualsTo = function (other) {
  13243. if (this.left !== other.left) {
  13244. return false;
  13245. }
  13246. if (this.top !== other.top) {
  13247. return false;
  13248. }
  13249. if (this.width !== other.width) {
  13250. return false;
  13251. }
  13252. if (this.height !== other.height) {
  13253. return false;
  13254. }
  13255. return true;
  13256. };
  13257. /**
  13258. * Creates an empty measure
  13259. * @returns a new measure
  13260. */
  13261. Measure.Empty = function () {
  13262. return new Measure(0, 0, 0, 0);
  13263. };
  13264. return Measure;
  13265. }());
  13266. /***/ }),
  13267. /***/ "./2D/multiLinePoint.ts":
  13268. /*!******************************!*\
  13269. !*** ./2D/multiLinePoint.ts ***!
  13270. \******************************/
  13271. /*! exports provided: MultiLinePoint */
  13272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13273. "use strict";
  13274. __webpack_require__.r(__webpack_exports__);
  13275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13276. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  13277. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13278. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13279. /**
  13280. * Class used to store a point for a MultiLine object.
  13281. * The point can be pure 2D coordinates, a mesh or a control
  13282. */
  13283. var MultiLinePoint = /** @class */ (function () {
  13284. /**
  13285. * Creates a new MultiLinePoint
  13286. * @param multiLine defines the source MultiLine object
  13287. */
  13288. function MultiLinePoint(multiLine) {
  13289. this._multiLine = multiLine;
  13290. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13291. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13292. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13293. }
  13294. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13295. /** Gets or sets x coordinate */
  13296. get: function () {
  13297. return this._x.toString(this._multiLine._host);
  13298. },
  13299. set: function (value) {
  13300. if (this._x.toString(this._multiLine._host) === value) {
  13301. return;
  13302. }
  13303. if (this._x.fromString(value)) {
  13304. this._multiLine._markAsDirty();
  13305. }
  13306. },
  13307. enumerable: false,
  13308. configurable: true
  13309. });
  13310. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13311. /** Gets or sets y coordinate */
  13312. get: function () {
  13313. return this._y.toString(this._multiLine._host);
  13314. },
  13315. set: function (value) {
  13316. if (this._y.toString(this._multiLine._host) === value) {
  13317. return;
  13318. }
  13319. if (this._y.fromString(value)) {
  13320. this._multiLine._markAsDirty();
  13321. }
  13322. },
  13323. enumerable: false,
  13324. configurable: true
  13325. });
  13326. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13327. /** Gets or sets the control associated with this point */
  13328. get: function () {
  13329. return this._control;
  13330. },
  13331. set: function (value) {
  13332. if (this._control === value) {
  13333. return;
  13334. }
  13335. if (this._control && this._controlObserver) {
  13336. this._control.onDirtyObservable.remove(this._controlObserver);
  13337. this._controlObserver = null;
  13338. }
  13339. this._control = value;
  13340. if (this._control) {
  13341. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13342. }
  13343. this._multiLine._markAsDirty();
  13344. },
  13345. enumerable: false,
  13346. configurable: true
  13347. });
  13348. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13349. /** Gets or sets the mesh associated with this point */
  13350. get: function () {
  13351. return this._mesh;
  13352. },
  13353. set: function (value) {
  13354. if (this._mesh === value) {
  13355. return;
  13356. }
  13357. if (this._mesh && this._meshObserver) {
  13358. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13359. }
  13360. this._mesh = value;
  13361. if (this._mesh) {
  13362. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13363. }
  13364. this._multiLine._markAsDirty();
  13365. },
  13366. enumerable: false,
  13367. configurable: true
  13368. });
  13369. /** Resets links */
  13370. MultiLinePoint.prototype.resetLinks = function () {
  13371. this.control = null;
  13372. this.mesh = null;
  13373. };
  13374. /**
  13375. * Gets a translation vector
  13376. * @returns the translation vector
  13377. */
  13378. MultiLinePoint.prototype.translate = function () {
  13379. this._point = this._translatePoint();
  13380. return this._point;
  13381. };
  13382. MultiLinePoint.prototype._translatePoint = function () {
  13383. if (this._mesh != null) {
  13384. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13385. }
  13386. else if (this._control != null) {
  13387. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  13388. }
  13389. else {
  13390. var host = this._multiLine._host;
  13391. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13392. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13393. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  13394. }
  13395. };
  13396. /** Release associated resources */
  13397. MultiLinePoint.prototype.dispose = function () {
  13398. this.resetLinks();
  13399. };
  13400. return MultiLinePoint;
  13401. }());
  13402. /***/ }),
  13403. /***/ "./2D/style.ts":
  13404. /*!*********************!*\
  13405. !*** ./2D/style.ts ***!
  13406. \*********************/
  13407. /*! exports provided: Style */
  13408. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13409. "use strict";
  13410. __webpack_require__.r(__webpack_exports__);
  13411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13412. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  13413. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13414. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13415. /**
  13416. * Define a style used by control to automatically setup properties based on a template.
  13417. * Only support font related properties so far
  13418. */
  13419. var Style = /** @class */ (function () {
  13420. /**
  13421. * Creates a new style object
  13422. * @param host defines the AdvancedDynamicTexture which hosts this style
  13423. */
  13424. function Style(host) {
  13425. this._fontFamily = "Arial";
  13426. this._fontStyle = "";
  13427. this._fontWeight = "";
  13428. /** @hidden */
  13429. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13430. /**
  13431. * Observable raised when the style values are changed
  13432. */
  13433. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13434. this._host = host;
  13435. }
  13436. Object.defineProperty(Style.prototype, "fontSize", {
  13437. /**
  13438. * Gets or sets the font size
  13439. */
  13440. get: function () {
  13441. return this._fontSize.toString(this._host);
  13442. },
  13443. set: function (value) {
  13444. if (this._fontSize.toString(this._host) === value) {
  13445. return;
  13446. }
  13447. if (this._fontSize.fromString(value)) {
  13448. this.onChangedObservable.notifyObservers(this);
  13449. }
  13450. },
  13451. enumerable: false,
  13452. configurable: true
  13453. });
  13454. Object.defineProperty(Style.prototype, "fontFamily", {
  13455. /**
  13456. * Gets or sets the font family
  13457. */
  13458. get: function () {
  13459. return this._fontFamily;
  13460. },
  13461. set: function (value) {
  13462. if (this._fontFamily === value) {
  13463. return;
  13464. }
  13465. this._fontFamily = value;
  13466. this.onChangedObservable.notifyObservers(this);
  13467. },
  13468. enumerable: false,
  13469. configurable: true
  13470. });
  13471. Object.defineProperty(Style.prototype, "fontStyle", {
  13472. /**
  13473. * Gets or sets the font style
  13474. */
  13475. get: function () {
  13476. return this._fontStyle;
  13477. },
  13478. set: function (value) {
  13479. if (this._fontStyle === value) {
  13480. return;
  13481. }
  13482. this._fontStyle = value;
  13483. this.onChangedObservable.notifyObservers(this);
  13484. },
  13485. enumerable: false,
  13486. configurable: true
  13487. });
  13488. Object.defineProperty(Style.prototype, "fontWeight", {
  13489. /** Gets or sets font weight */
  13490. get: function () {
  13491. return this._fontWeight;
  13492. },
  13493. set: function (value) {
  13494. if (this._fontWeight === value) {
  13495. return;
  13496. }
  13497. this._fontWeight = value;
  13498. this.onChangedObservable.notifyObservers(this);
  13499. },
  13500. enumerable: false,
  13501. configurable: true
  13502. });
  13503. /** Dispose all associated resources */
  13504. Style.prototype.dispose = function () {
  13505. this.onChangedObservable.clear();
  13506. };
  13507. return Style;
  13508. }());
  13509. /***/ }),
  13510. /***/ "./2D/valueAndUnit.ts":
  13511. /*!****************************!*\
  13512. !*** ./2D/valueAndUnit.ts ***!
  13513. \****************************/
  13514. /*! exports provided: ValueAndUnit */
  13515. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13516. "use strict";
  13517. __webpack_require__.r(__webpack_exports__);
  13518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13519. /**
  13520. * Class used to specific a value and its associated unit
  13521. */
  13522. var ValueAndUnit = /** @class */ (function () {
  13523. /**
  13524. * Creates a new ValueAndUnit
  13525. * @param value defines the value to store
  13526. * @param unit defines the unit to store
  13527. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13528. */
  13529. function ValueAndUnit(value,
  13530. /** defines the unit to store */
  13531. unit,
  13532. /** defines a boolean indicating if the value can be negative */
  13533. negativeValueAllowed) {
  13534. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13535. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13536. this.unit = unit;
  13537. this.negativeValueAllowed = negativeValueAllowed;
  13538. this._value = 1;
  13539. /**
  13540. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13541. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13542. */
  13543. this.ignoreAdaptiveScaling = false;
  13544. this._value = value;
  13545. this._originalUnit = unit;
  13546. }
  13547. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13548. /** Gets a boolean indicating if the value is a percentage */
  13549. get: function () {
  13550. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13551. },
  13552. enumerable: false,
  13553. configurable: true
  13554. });
  13555. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13556. /** Gets a boolean indicating if the value is store as pixel */
  13557. get: function () {
  13558. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13559. },
  13560. enumerable: false,
  13561. configurable: true
  13562. });
  13563. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13564. /** Gets direct internal value */
  13565. get: function () {
  13566. return this._value;
  13567. },
  13568. enumerable: false,
  13569. configurable: true
  13570. });
  13571. /**
  13572. * Gets value as pixel
  13573. * @param host defines the root host
  13574. * @param refValue defines the reference value for percentages
  13575. * @returns the value as pixel
  13576. */
  13577. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13578. if (this.isPixel) {
  13579. return this.getValue(host);
  13580. }
  13581. return this.getValue(host) * refValue;
  13582. };
  13583. /**
  13584. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13585. * @param value defines the value to store
  13586. * @param unit defines the unit to store
  13587. * @returns the current ValueAndUnit
  13588. */
  13589. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13590. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13591. this._value = value;
  13592. this.unit = unit;
  13593. return this;
  13594. };
  13595. /**
  13596. * Gets the value accordingly to its unit
  13597. * @param host defines the root host
  13598. * @returns the value
  13599. */
  13600. ValueAndUnit.prototype.getValue = function (host) {
  13601. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13602. var width = 0;
  13603. var height = 0;
  13604. if (host.idealWidth) {
  13605. width = (this._value * host.getSize().width) / host.idealWidth;
  13606. }
  13607. if (host.idealHeight) {
  13608. height = (this._value * host.getSize().height) / host.idealHeight;
  13609. }
  13610. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13611. return window.innerWidth < window.innerHeight ? width : height;
  13612. }
  13613. if (host.idealWidth) { // horizontal
  13614. return width;
  13615. }
  13616. if (host.idealHeight) { // vertical
  13617. return height;
  13618. }
  13619. }
  13620. return this._value;
  13621. };
  13622. /**
  13623. * Gets a string representation of the value
  13624. * @param host defines the root host
  13625. * @param decimals defines an optional number of decimals to display
  13626. * @returns a string
  13627. */
  13628. ValueAndUnit.prototype.toString = function (host, decimals) {
  13629. switch (this.unit) {
  13630. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13631. var percentage = this.getValue(host) * 100;
  13632. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13633. case ValueAndUnit.UNITMODE_PIXEL:
  13634. var pixels = this.getValue(host);
  13635. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13636. }
  13637. return this.unit.toString();
  13638. };
  13639. /**
  13640. * Store a value parsed from a string
  13641. * @param source defines the source string
  13642. * @returns true if the value was successfully parsed
  13643. */
  13644. ValueAndUnit.prototype.fromString = function (source) {
  13645. var match = ValueAndUnit._Regex.exec(source.toString());
  13646. if (!match || match.length === 0) {
  13647. return false;
  13648. }
  13649. var sourceValue = parseFloat(match[1]);
  13650. var sourceUnit = this._originalUnit;
  13651. if (!this.negativeValueAllowed) {
  13652. if (sourceValue < 0) {
  13653. sourceValue = 0;
  13654. }
  13655. }
  13656. if (match.length === 4) {
  13657. switch (match[3]) {
  13658. case "px":
  13659. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13660. break;
  13661. case "%":
  13662. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13663. sourceValue /= 100.0;
  13664. break;
  13665. }
  13666. }
  13667. if (sourceValue === this._value && sourceUnit === this.unit) {
  13668. return false;
  13669. }
  13670. this._value = sourceValue;
  13671. this.unit = sourceUnit;
  13672. return true;
  13673. };
  13674. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13675. /** UNITMODE_PERCENTAGE */
  13676. get: function () {
  13677. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13678. },
  13679. enumerable: false,
  13680. configurable: true
  13681. });
  13682. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13683. /** UNITMODE_PIXEL */
  13684. get: function () {
  13685. return ValueAndUnit._UNITMODE_PIXEL;
  13686. },
  13687. enumerable: false,
  13688. configurable: true
  13689. });
  13690. // Static
  13691. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13692. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13693. ValueAndUnit._UNITMODE_PIXEL = 1;
  13694. return ValueAndUnit;
  13695. }());
  13696. /***/ }),
  13697. /***/ "./2D/xmlLoader.ts":
  13698. /*!*************************!*\
  13699. !*** ./2D/xmlLoader.ts ***!
  13700. \*************************/
  13701. /*! exports provided: XmlLoader */
  13702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13703. "use strict";
  13704. __webpack_require__.r(__webpack_exports__);
  13705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13706. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  13707. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13708. /**
  13709. * Class used to load GUI via XML.
  13710. */
  13711. var XmlLoader = /** @class */ (function () {
  13712. /**
  13713. * Create a new xml loader
  13714. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13715. */
  13716. function XmlLoader(parentClass) {
  13717. if (parentClass === void 0) { parentClass = null; }
  13718. this._nodes = {};
  13719. this._nodeTypes = {
  13720. element: 1,
  13721. attribute: 2,
  13722. text: 3
  13723. };
  13724. this._isLoaded = false;
  13725. this._objectAttributes = {
  13726. "textHorizontalAlignment": 1,
  13727. "textVerticalAlignment": 2,
  13728. "horizontalAlignment": 3,
  13729. "verticalAlignment": 4,
  13730. "stretch": 5,
  13731. };
  13732. if (parentClass) {
  13733. this._parentClass = parentClass;
  13734. }
  13735. }
  13736. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13737. var element = window;
  13738. if (this._parentClass) {
  13739. element = this._parentClass;
  13740. }
  13741. var value = attributeValue;
  13742. value = value.split(".");
  13743. for (var i = 0; i < value.length; i++) {
  13744. element = element[value[i]];
  13745. }
  13746. return element;
  13747. };
  13748. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13749. var attribute = attributeName.split(".");
  13750. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13751. return className[attribute[1]];
  13752. };
  13753. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13754. if (linkParent === void 0) { linkParent = true; }
  13755. try {
  13756. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13757. var guiNode = new className();
  13758. if (parent && linkParent) {
  13759. parent.addControl(guiNode);
  13760. }
  13761. for (var i = 0; i < node.attributes.length; i++) {
  13762. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13763. continue;
  13764. }
  13765. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13766. var element = this._getChainElement(node.attributes[i].value);
  13767. guiNode[node.attributes[i].name].add(element);
  13768. continue;
  13769. }
  13770. else if (node.attributes[i].name == "linkWithMesh") {
  13771. if (this._parentClass) {
  13772. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13773. }
  13774. else {
  13775. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13776. }
  13777. }
  13778. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13779. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13780. guiNode[node.attributes[i].name] = element;
  13781. }
  13782. else if (!this._objectAttributes[node.attributes[i].name]) {
  13783. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13784. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13785. }
  13786. else {
  13787. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13788. }
  13789. }
  13790. else {
  13791. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13792. }
  13793. }
  13794. if (!node.attributes.getNamedItem("id")) {
  13795. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13796. return guiNode;
  13797. }
  13798. var id = node.attributes.getNamedItem("id").value;
  13799. if (id.startsWith("{{") && id.endsWith("}}")) {
  13800. id = this._getChainElement(id.substring(2, id.length - 2));
  13801. }
  13802. if (!this._nodes[id]) {
  13803. this._nodes[id] = guiNode;
  13804. }
  13805. else {
  13806. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13807. }
  13808. return guiNode;
  13809. }
  13810. catch (e) {
  13811. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13812. }
  13813. };
  13814. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13815. var width;
  13816. var height;
  13817. var columns;
  13818. var rows = node.children;
  13819. var cells;
  13820. var isPixel = false;
  13821. var cellNode;
  13822. var rowNumber = -1;
  13823. var columnNumber = -1;
  13824. var totalColumnsNumber = 0;
  13825. for (var i = 0; i < rows.length; i++) {
  13826. if (rows[i].nodeType != this._nodeTypes.element) {
  13827. continue;
  13828. }
  13829. if (rows[i].nodeName != "Row") {
  13830. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13831. }
  13832. rowNumber += 1;
  13833. columns = rows[i].children;
  13834. if (!rows[i].attributes.getNamedItem("height")) {
  13835. throw "XmlLoader Exception : Height must be defined for grid rows";
  13836. }
  13837. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13838. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13839. guiNode.addRowDefinition(height, isPixel);
  13840. for (var j = 0; j < columns.length; j++) {
  13841. if (columns[j].nodeType != this._nodeTypes.element) {
  13842. continue;
  13843. }
  13844. if (columns[j].nodeName != "Column") {
  13845. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13846. }
  13847. columnNumber += 1;
  13848. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13849. 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.";
  13850. }
  13851. if (rowNumber == 0) {
  13852. if (!columns[j].attributes.getNamedItem("width")) {
  13853. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13854. }
  13855. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13856. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13857. guiNode.addColumnDefinition(width, isPixel);
  13858. }
  13859. cells = columns[j].children;
  13860. for (var k = 0; k < cells.length; k++) {
  13861. if (cells[k].nodeType != this._nodeTypes.element) {
  13862. continue;
  13863. }
  13864. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13865. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13866. if (cells[k].firstChild) {
  13867. this._parseXml(cells[k].firstChild, cellNode);
  13868. }
  13869. }
  13870. }
  13871. if (rowNumber == 0) {
  13872. totalColumnsNumber = columnNumber;
  13873. }
  13874. columnNumber = -1;
  13875. }
  13876. if (node.nextSibling) {
  13877. this._parseXml(node.nextSibling, parent);
  13878. }
  13879. };
  13880. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13881. if (node.firstChild) {
  13882. this._parseXml(node.firstChild, guiNode);
  13883. }
  13884. if (node.nextSibling) {
  13885. this._parseXml(node.nextSibling, parent);
  13886. }
  13887. };
  13888. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13889. if (this._parentClass) {
  13890. this._parentClass[variable] = source[iterator];
  13891. }
  13892. else {
  13893. window[variable] = source[iterator];
  13894. }
  13895. if (node.firstChild) {
  13896. this._parseXml(node.firstChild, guiNode, true);
  13897. }
  13898. };
  13899. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13900. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13901. if (!dataSource.includes(" in ")) {
  13902. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13903. }
  13904. else {
  13905. var isArray = true;
  13906. var splittedSource = dataSource.split(" in ");
  13907. if (splittedSource.length < 2) {
  13908. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13909. }
  13910. var source = splittedSource[1];
  13911. if (source.startsWith("{") && source.endsWith("}")) {
  13912. isArray = false;
  13913. }
  13914. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13915. source = source.substring(1, source.length - 1);
  13916. }
  13917. if (this._parentClass) {
  13918. source = this._parentClass[source];
  13919. }
  13920. else {
  13921. source = window[source];
  13922. }
  13923. if (isArray) {
  13924. for (var i = 0; i < source.length; i++) {
  13925. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13926. }
  13927. }
  13928. else {
  13929. for (var i in source) {
  13930. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13931. }
  13932. }
  13933. if (node.nextSibling) {
  13934. this._parseXml(node.nextSibling, parent);
  13935. }
  13936. }
  13937. };
  13938. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13939. if (generated === void 0) { generated = false; }
  13940. if (node.nodeType != this._nodeTypes.element) {
  13941. if (node.nextSibling) {
  13942. this._parseXml(node.nextSibling, parent, generated);
  13943. }
  13944. return;
  13945. }
  13946. if (generated) {
  13947. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13948. }
  13949. var guiNode = this._createGuiElement(node, parent);
  13950. if (node.nodeName == "Grid") {
  13951. this._parseGrid(node, guiNode, parent);
  13952. }
  13953. else if (!node.attributes.getNamedItem("dataSource")) {
  13954. this._parseElement(node, guiNode, parent);
  13955. }
  13956. else {
  13957. this._parseElementsFromSource(node, guiNode, parent);
  13958. }
  13959. };
  13960. /**
  13961. * Gets if the loading has finished.
  13962. * @returns whether the loading has finished or not
  13963. */
  13964. XmlLoader.prototype.isLoaded = function () {
  13965. return this._isLoaded;
  13966. };
  13967. /**
  13968. * Gets a loaded node / control by id.
  13969. * @param id the Controls id set in the xml
  13970. * @returns element of type Control
  13971. */
  13972. XmlLoader.prototype.getNodeById = function (id) {
  13973. return this._nodes[id];
  13974. };
  13975. /**
  13976. * Gets all loaded nodes / controls
  13977. * @returns Array of controls
  13978. */
  13979. XmlLoader.prototype.getNodes = function () {
  13980. return this._nodes;
  13981. };
  13982. /**
  13983. * Initiates the xml layout loading
  13984. * @param xmlFile defines the xml layout to load
  13985. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13986. * @param callback defines the callback called on layout load.
  13987. */
  13988. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13989. var xhttp = new XMLHttpRequest();
  13990. xhttp.onreadystatechange = function () {
  13991. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13992. if (!xhttp.responseXML) {
  13993. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13994. }
  13995. var xmlDoc = xhttp.responseXML.documentElement;
  13996. this._parseXml(xmlDoc.firstChild, rootNode);
  13997. this._isLoaded = true;
  13998. if (callback) {
  13999. callback();
  14000. }
  14001. }
  14002. }.bind(this);
  14003. xhttp.open("GET", xmlFile, true);
  14004. xhttp.send();
  14005. };
  14006. return XmlLoader;
  14007. }());
  14008. /***/ }),
  14009. /***/ "./3D/controls/abstractButton3D.ts":
  14010. /*!*****************************************!*\
  14011. !*** ./3D/controls/abstractButton3D.ts ***!
  14012. \*****************************************/
  14013. /*! exports provided: AbstractButton3D */
  14014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14015. "use strict";
  14016. __webpack_require__.r(__webpack_exports__);
  14017. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  14018. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14019. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  14020. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14021. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14022. /**
  14023. * Class used as a root to all buttons
  14024. */
  14025. var AbstractButton3D = /** @class */ (function (_super) {
  14026. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  14027. /**
  14028. * Creates a new button
  14029. * @param name defines the control name
  14030. */
  14031. function AbstractButton3D(name) {
  14032. return _super.call(this, name) || this;
  14033. }
  14034. AbstractButton3D.prototype._getTypeName = function () {
  14035. return "AbstractButton3D";
  14036. };
  14037. // Mesh association
  14038. AbstractButton3D.prototype._createNode = function (scene) {
  14039. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  14040. };
  14041. return AbstractButton3D;
  14042. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14043. /***/ }),
  14044. /***/ "./3D/controls/button3D.ts":
  14045. /*!*********************************!*\
  14046. !*** ./3D/controls/button3D.ts ***!
  14047. \*********************************/
  14048. /*! exports provided: Button3D */
  14049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14050. "use strict";
  14051. __webpack_require__.r(__webpack_exports__);
  14052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  14053. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14054. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  14055. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  14056. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14057. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14058. /**
  14059. * Class used to create a button in 3D
  14060. */
  14061. var Button3D = /** @class */ (function (_super) {
  14062. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  14063. /**
  14064. * Creates a new button
  14065. * @param name defines the control name
  14066. */
  14067. function Button3D(name) {
  14068. var _this = _super.call(this, name) || this;
  14069. _this._contentResolution = 512;
  14070. _this._contentScaleRatio = 2;
  14071. // Default animations
  14072. _this.pointerEnterAnimation = function () {
  14073. if (!_this.mesh) {
  14074. return;
  14075. }
  14076. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  14077. };
  14078. _this.pointerOutAnimation = function () {
  14079. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14080. };
  14081. _this.pointerDownAnimation = function () {
  14082. if (!_this.mesh) {
  14083. return;
  14084. }
  14085. _this.mesh.scaling.scaleInPlace(0.95);
  14086. };
  14087. _this.pointerUpAnimation = function () {
  14088. if (!_this.mesh) {
  14089. return;
  14090. }
  14091. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14092. };
  14093. return _this;
  14094. }
  14095. Object.defineProperty(Button3D.prototype, "contentResolution", {
  14096. /**
  14097. * Gets or sets the texture resolution used to render content (512 by default)
  14098. */
  14099. get: function () {
  14100. return this._contentResolution;
  14101. },
  14102. set: function (value) {
  14103. if (this._contentResolution === value) {
  14104. return;
  14105. }
  14106. this._contentResolution = value;
  14107. this._resetContent();
  14108. },
  14109. enumerable: false,
  14110. configurable: true
  14111. });
  14112. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  14113. /**
  14114. * Gets or sets the texture scale ratio used to render content (2 by default)
  14115. */
  14116. get: function () {
  14117. return this._contentScaleRatio;
  14118. },
  14119. set: function (value) {
  14120. if (this._contentScaleRatio === value) {
  14121. return;
  14122. }
  14123. this._contentScaleRatio = value;
  14124. this._resetContent();
  14125. },
  14126. enumerable: false,
  14127. configurable: true
  14128. });
  14129. Button3D.prototype._disposeFacadeTexture = function () {
  14130. if (this._facadeTexture) {
  14131. this._facadeTexture.dispose();
  14132. this._facadeTexture = null;
  14133. }
  14134. };
  14135. Button3D.prototype._resetContent = function () {
  14136. this._disposeFacadeTexture();
  14137. this.content = this._content;
  14138. };
  14139. Object.defineProperty(Button3D.prototype, "content", {
  14140. /**
  14141. * Gets or sets the GUI 2D content used to display the button's facade
  14142. */
  14143. get: function () {
  14144. return this._content;
  14145. },
  14146. set: function (value) {
  14147. this._content = value;
  14148. if (!this._host || !this._host.utilityLayer) {
  14149. return;
  14150. }
  14151. if (!this._facadeTexture) {
  14152. 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);
  14153. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  14154. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  14155. this._facadeTexture.premulAlpha = true;
  14156. }
  14157. else {
  14158. this._facadeTexture.rootContainer.clearControls();
  14159. }
  14160. this._facadeTexture.addControl(value);
  14161. this._applyFacade(this._facadeTexture);
  14162. },
  14163. enumerable: false,
  14164. configurable: true
  14165. });
  14166. /**
  14167. * Apply the facade texture (created from the content property).
  14168. * This function can be overloaded by child classes
  14169. * @param facadeTexture defines the AdvancedDynamicTexture to use
  14170. */
  14171. Button3D.prototype._applyFacade = function (facadeTexture) {
  14172. this._currentMaterial.emissiveTexture = facadeTexture;
  14173. };
  14174. Button3D.prototype._getTypeName = function () {
  14175. return "Button3D";
  14176. };
  14177. // Mesh association
  14178. Button3D.prototype._createNode = function (scene) {
  14179. var faceUV = new Array(6);
  14180. for (var i = 0; i < 6; i++) {
  14181. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  14182. }
  14183. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  14184. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  14185. width: 1.0,
  14186. height: 1.0,
  14187. depth: 0.08,
  14188. faceUV: faceUV
  14189. }, scene);
  14190. return mesh;
  14191. };
  14192. Button3D.prototype._affectMaterial = function (mesh) {
  14193. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  14194. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14195. mesh.material = material;
  14196. this._currentMaterial = material;
  14197. this._resetContent();
  14198. };
  14199. /**
  14200. * Releases all associated resources
  14201. */
  14202. Button3D.prototype.dispose = function () {
  14203. _super.prototype.dispose.call(this);
  14204. this._disposeFacadeTexture();
  14205. if (this._currentMaterial) {
  14206. this._currentMaterial.dispose();
  14207. }
  14208. };
  14209. return Button3D;
  14210. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  14211. /***/ }),
  14212. /***/ "./3D/controls/container3D.ts":
  14213. /*!************************************!*\
  14214. !*** ./3D/controls/container3D.ts ***!
  14215. \************************************/
  14216. /*! exports provided: Container3D */
  14217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14218. "use strict";
  14219. __webpack_require__.r(__webpack_exports__);
  14220. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  14221. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14222. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  14223. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14224. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14225. /**
  14226. * Class used to create containers for controls
  14227. */
  14228. var Container3D = /** @class */ (function (_super) {
  14229. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  14230. /**
  14231. * Creates a new container
  14232. * @param name defines the container name
  14233. */
  14234. function Container3D(name) {
  14235. var _this = _super.call(this, name) || this;
  14236. _this._blockLayout = false;
  14237. /**
  14238. * Gets the list of child controls
  14239. */
  14240. _this._children = new Array();
  14241. return _this;
  14242. }
  14243. Object.defineProperty(Container3D.prototype, "children", {
  14244. /**
  14245. * Gets the list of child controls
  14246. */
  14247. get: function () {
  14248. return this._children;
  14249. },
  14250. enumerable: false,
  14251. configurable: true
  14252. });
  14253. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14254. /**
  14255. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14256. * This is helpful to optimize layout operation when adding multiple children in a row
  14257. */
  14258. get: function () {
  14259. return this._blockLayout;
  14260. },
  14261. set: function (value) {
  14262. if (this._blockLayout === value) {
  14263. return;
  14264. }
  14265. this._blockLayout = value;
  14266. if (!this._blockLayout) {
  14267. this._arrangeChildren();
  14268. }
  14269. },
  14270. enumerable: false,
  14271. configurable: true
  14272. });
  14273. /**
  14274. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14275. * @returns the current container
  14276. */
  14277. Container3D.prototype.updateLayout = function () {
  14278. this._arrangeChildren();
  14279. return this;
  14280. };
  14281. /**
  14282. * Gets a boolean indicating if the given control is in the children of this control
  14283. * @param control defines the control to check
  14284. * @returns true if the control is in the child list
  14285. */
  14286. Container3D.prototype.containsControl = function (control) {
  14287. return this._children.indexOf(control) !== -1;
  14288. };
  14289. /**
  14290. * Adds a control to the children of this control
  14291. * @param control defines the control to add
  14292. * @returns the current container
  14293. */
  14294. Container3D.prototype.addControl = function (control) {
  14295. var index = this._children.indexOf(control);
  14296. if (index !== -1) {
  14297. return this;
  14298. }
  14299. control.parent = this;
  14300. control._host = this._host;
  14301. this._children.push(control);
  14302. if (this._host.utilityLayer) {
  14303. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14304. if (control.node) {
  14305. control.node.parent = this.node;
  14306. }
  14307. if (!this.blockLayout) {
  14308. this._arrangeChildren();
  14309. }
  14310. }
  14311. return this;
  14312. };
  14313. /**
  14314. * This function will be called everytime a new control is added
  14315. */
  14316. Container3D.prototype._arrangeChildren = function () {
  14317. };
  14318. Container3D.prototype._createNode = function (scene) {
  14319. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14320. };
  14321. /**
  14322. * Removes a control from the children of this control
  14323. * @param control defines the control to remove
  14324. * @returns the current container
  14325. */
  14326. Container3D.prototype.removeControl = function (control) {
  14327. var index = this._children.indexOf(control);
  14328. if (index !== -1) {
  14329. this._children.splice(index, 1);
  14330. control.parent = null;
  14331. control._disposeNode();
  14332. }
  14333. return this;
  14334. };
  14335. Container3D.prototype._getTypeName = function () {
  14336. return "Container3D";
  14337. };
  14338. /**
  14339. * Releases all associated resources
  14340. */
  14341. Container3D.prototype.dispose = function () {
  14342. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14343. var control = _a[_i];
  14344. control.dispose();
  14345. }
  14346. this._children = [];
  14347. _super.prototype.dispose.call(this);
  14348. };
  14349. /** Control rotation will remain unchanged */
  14350. Container3D.UNSET_ORIENTATION = 0;
  14351. /** Control will rotate to make it look at sphere central axis */
  14352. Container3D.FACEORIGIN_ORIENTATION = 1;
  14353. /** Control will rotate to make it look back at sphere central axis */
  14354. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14355. /** Control will rotate to look at z axis (0, 0, 1) */
  14356. Container3D.FACEFORWARD_ORIENTATION = 3;
  14357. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14358. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14359. return Container3D;
  14360. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14361. /***/ }),
  14362. /***/ "./3D/controls/control3D.ts":
  14363. /*!**********************************!*\
  14364. !*** ./3D/controls/control3D.ts ***!
  14365. \**********************************/
  14366. /*! exports provided: Control3D */
  14367. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14368. "use strict";
  14369. __webpack_require__.r(__webpack_exports__);
  14370. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14371. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  14372. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14373. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14374. /**
  14375. * Class used as base class for controls
  14376. */
  14377. var Control3D = /** @class */ (function () {
  14378. /**
  14379. * Creates a new control
  14380. * @param name defines the control name
  14381. */
  14382. function Control3D(
  14383. /** Defines the control name */
  14384. name) {
  14385. this.name = name;
  14386. this._downCount = 0;
  14387. this._enterCount = -1;
  14388. this._downPointerIds = {};
  14389. this._isVisible = true;
  14390. /**
  14391. * An event triggered when the pointer move over the control
  14392. */
  14393. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14394. /**
  14395. * An event triggered when the pointer move out of the control
  14396. */
  14397. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14398. /**
  14399. * An event triggered when the pointer taps the control
  14400. */
  14401. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14402. /**
  14403. * An event triggered when pointer is up
  14404. */
  14405. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14406. /**
  14407. * An event triggered when a control is clicked on (with a mouse)
  14408. */
  14409. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14410. /**
  14411. * An event triggered when pointer enters the control
  14412. */
  14413. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14414. // Behaviors
  14415. this._behaviors = new Array();
  14416. }
  14417. Object.defineProperty(Control3D.prototype, "position", {
  14418. /** Gets or sets the control position in world space */
  14419. get: function () {
  14420. if (!this._node) {
  14421. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14422. }
  14423. return this._node.position;
  14424. },
  14425. set: function (value) {
  14426. if (!this._node) {
  14427. return;
  14428. }
  14429. this._node.position = value;
  14430. },
  14431. enumerable: false,
  14432. configurable: true
  14433. });
  14434. Object.defineProperty(Control3D.prototype, "scaling", {
  14435. /** Gets or sets the control scaling in world space */
  14436. get: function () {
  14437. if (!this._node) {
  14438. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14439. }
  14440. return this._node.scaling;
  14441. },
  14442. set: function (value) {
  14443. if (!this._node) {
  14444. return;
  14445. }
  14446. this._node.scaling = value;
  14447. },
  14448. enumerable: false,
  14449. configurable: true
  14450. });
  14451. Object.defineProperty(Control3D.prototype, "behaviors", {
  14452. /**
  14453. * Gets the list of attached behaviors
  14454. * @see https://doc.babylonjs.com/features/behaviour
  14455. */
  14456. get: function () {
  14457. return this._behaviors;
  14458. },
  14459. enumerable: false,
  14460. configurable: true
  14461. });
  14462. /**
  14463. * Attach a behavior to the control
  14464. * @see https://doc.babylonjs.com/features/behaviour
  14465. * @param behavior defines the behavior to attach
  14466. * @returns the current control
  14467. */
  14468. Control3D.prototype.addBehavior = function (behavior) {
  14469. var _this = this;
  14470. var index = this._behaviors.indexOf(behavior);
  14471. if (index !== -1) {
  14472. return this;
  14473. }
  14474. behavior.init();
  14475. var scene = this._host.scene;
  14476. if (scene.isLoading) {
  14477. // We defer the attach when the scene will be loaded
  14478. scene.onDataLoadedObservable.addOnce(function () {
  14479. behavior.attach(_this);
  14480. });
  14481. }
  14482. else {
  14483. behavior.attach(this);
  14484. }
  14485. this._behaviors.push(behavior);
  14486. return this;
  14487. };
  14488. /**
  14489. * Remove an attached behavior
  14490. * @see https://doc.babylonjs.com/features/behaviour
  14491. * @param behavior defines the behavior to attach
  14492. * @returns the current control
  14493. */
  14494. Control3D.prototype.removeBehavior = function (behavior) {
  14495. var index = this._behaviors.indexOf(behavior);
  14496. if (index === -1) {
  14497. return this;
  14498. }
  14499. this._behaviors[index].detach();
  14500. this._behaviors.splice(index, 1);
  14501. return this;
  14502. };
  14503. /**
  14504. * Gets an attached behavior by name
  14505. * @param name defines the name of the behavior to look for
  14506. * @see https://doc.babylonjs.com/features/behaviour
  14507. * @returns null if behavior was not found else the requested behavior
  14508. */
  14509. Control3D.prototype.getBehaviorByName = function (name) {
  14510. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14511. var behavior = _a[_i];
  14512. if (behavior.name === name) {
  14513. return behavior;
  14514. }
  14515. }
  14516. return null;
  14517. };
  14518. Object.defineProperty(Control3D.prototype, "isVisible", {
  14519. /** Gets or sets a boolean indicating if the control is visible */
  14520. get: function () {
  14521. return this._isVisible;
  14522. },
  14523. set: function (value) {
  14524. if (this._isVisible === value) {
  14525. return;
  14526. }
  14527. this._isVisible = value;
  14528. var mesh = this.mesh;
  14529. if (mesh) {
  14530. mesh.setEnabled(value);
  14531. }
  14532. },
  14533. enumerable: false,
  14534. configurable: true
  14535. });
  14536. Object.defineProperty(Control3D.prototype, "typeName", {
  14537. /**
  14538. * Gets a string representing the class name
  14539. */
  14540. get: function () {
  14541. return this._getTypeName();
  14542. },
  14543. enumerable: false,
  14544. configurable: true
  14545. });
  14546. /**
  14547. * Get the current class name of the control.
  14548. * @returns current class name
  14549. */
  14550. Control3D.prototype.getClassName = function () {
  14551. return this._getTypeName();
  14552. };
  14553. Control3D.prototype._getTypeName = function () {
  14554. return "Control3D";
  14555. };
  14556. Object.defineProperty(Control3D.prototype, "node", {
  14557. /**
  14558. * Gets the transform node used by this control
  14559. */
  14560. get: function () {
  14561. return this._node;
  14562. },
  14563. enumerable: false,
  14564. configurable: true
  14565. });
  14566. Object.defineProperty(Control3D.prototype, "mesh", {
  14567. /**
  14568. * Gets the mesh used to render this control
  14569. */
  14570. get: function () {
  14571. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14572. return this._node;
  14573. }
  14574. return null;
  14575. },
  14576. enumerable: false,
  14577. configurable: true
  14578. });
  14579. /**
  14580. * Link the control as child of the given node
  14581. * @param node defines the node to link to. Use null to unlink the control
  14582. * @returns the current control
  14583. */
  14584. Control3D.prototype.linkToTransformNode = function (node) {
  14585. if (this._node) {
  14586. this._node.parent = node;
  14587. }
  14588. return this;
  14589. };
  14590. /** @hidden **/
  14591. Control3D.prototype._prepareNode = function (scene) {
  14592. if (!this._node) {
  14593. this._node = this._createNode(scene);
  14594. if (!this.node) {
  14595. return;
  14596. }
  14597. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14598. this._node.position = this.position;
  14599. this._node.scaling = this.scaling;
  14600. var mesh = this.mesh;
  14601. if (mesh) {
  14602. mesh.isPickable = true;
  14603. this._affectMaterial(mesh);
  14604. }
  14605. }
  14606. };
  14607. /**
  14608. * Node creation.
  14609. * Can be overriden by children
  14610. * @param scene defines the scene where the node must be attached
  14611. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14612. */
  14613. Control3D.prototype._createNode = function (scene) {
  14614. // Do nothing by default
  14615. return null;
  14616. };
  14617. /**
  14618. * Affect a material to the given mesh
  14619. * @param mesh defines the mesh which will represent the control
  14620. */
  14621. Control3D.prototype._affectMaterial = function (mesh) {
  14622. mesh.material = null;
  14623. };
  14624. // Pointers
  14625. /** @hidden */
  14626. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14627. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14628. };
  14629. /** @hidden */
  14630. Control3D.prototype._onPointerEnter = function (target) {
  14631. if (this._enterCount > 0) {
  14632. return false;
  14633. }
  14634. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14635. this._enterCount = 0;
  14636. }
  14637. this._enterCount++;
  14638. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14639. if (this.pointerEnterAnimation) {
  14640. this.pointerEnterAnimation();
  14641. }
  14642. return true;
  14643. };
  14644. /** @hidden */
  14645. Control3D.prototype._onPointerOut = function (target) {
  14646. this._enterCount = 0;
  14647. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14648. if (this.pointerOutAnimation) {
  14649. this.pointerOutAnimation();
  14650. }
  14651. };
  14652. /** @hidden */
  14653. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14654. if (this._downCount !== 0) {
  14655. this._downCount++;
  14656. return false;
  14657. }
  14658. this._downCount++;
  14659. this._downPointerIds[pointerId] = true;
  14660. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14661. if (this.pointerDownAnimation) {
  14662. this.pointerDownAnimation();
  14663. }
  14664. return true;
  14665. };
  14666. /** @hidden */
  14667. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14668. this._downCount--;
  14669. delete this._downPointerIds[pointerId];
  14670. if (this._downCount < 0) {
  14671. // Handle if forcePointerUp was called prior to this
  14672. this._downCount = 0;
  14673. return;
  14674. }
  14675. if (this._downCount == 0) {
  14676. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14677. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14678. }
  14679. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14680. if (this.pointerUpAnimation) {
  14681. this.pointerUpAnimation();
  14682. }
  14683. }
  14684. };
  14685. /** @hidden */
  14686. Control3D.prototype.forcePointerUp = function (pointerId) {
  14687. if (pointerId === void 0) { pointerId = null; }
  14688. if (pointerId !== null) {
  14689. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14690. }
  14691. else {
  14692. for (var key in this._downPointerIds) {
  14693. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14694. }
  14695. if (this._downCount > 0) {
  14696. this._downCount = 1;
  14697. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14698. }
  14699. }
  14700. };
  14701. /** @hidden */
  14702. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14703. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14704. this._onPointerMove(this, pickedPoint);
  14705. var previousControlOver = this._host._lastControlOver[pointerId];
  14706. if (previousControlOver && previousControlOver !== this) {
  14707. previousControlOver._onPointerOut(this);
  14708. }
  14709. if (previousControlOver !== this) {
  14710. this._onPointerEnter(this);
  14711. }
  14712. this._host._lastControlOver[pointerId] = this;
  14713. return true;
  14714. }
  14715. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14716. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14717. this._host._lastControlDown[pointerId] = this;
  14718. this._host._lastPickedControl = this;
  14719. return true;
  14720. }
  14721. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP || type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) {
  14722. if (this._host._lastControlDown[pointerId]) {
  14723. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14724. }
  14725. delete this._host._lastControlDown[pointerId];
  14726. return true;
  14727. }
  14728. return false;
  14729. };
  14730. /** @hidden */
  14731. Control3D.prototype._disposeNode = function () {
  14732. if (this._node) {
  14733. this._node.dispose();
  14734. this._node = null;
  14735. }
  14736. };
  14737. /**
  14738. * Releases all associated resources
  14739. */
  14740. Control3D.prototype.dispose = function () {
  14741. this.onPointerDownObservable.clear();
  14742. this.onPointerEnterObservable.clear();
  14743. this.onPointerMoveObservable.clear();
  14744. this.onPointerOutObservable.clear();
  14745. this.onPointerUpObservable.clear();
  14746. this.onPointerClickObservable.clear();
  14747. this._disposeNode();
  14748. // Behaviors
  14749. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14750. var behavior = _a[_i];
  14751. behavior.detach();
  14752. }
  14753. };
  14754. return Control3D;
  14755. }());
  14756. /***/ }),
  14757. /***/ "./3D/controls/cylinderPanel.ts":
  14758. /*!**************************************!*\
  14759. !*** ./3D/controls/cylinderPanel.ts ***!
  14760. \**************************************/
  14761. /*! exports provided: CylinderPanel */
  14762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14763. "use strict";
  14764. __webpack_require__.r(__webpack_exports__);
  14765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14766. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14767. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  14768. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14769. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14770. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14771. /**
  14772. * Class used to create a container panel deployed on the surface of a cylinder
  14773. */
  14774. var CylinderPanel = /** @class */ (function (_super) {
  14775. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14776. function CylinderPanel() {
  14777. var _this = _super !== null && _super.apply(this, arguments) || this;
  14778. _this._radius = 5.0;
  14779. return _this;
  14780. }
  14781. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14782. /**
  14783. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14784. */
  14785. get: function () {
  14786. return this._radius;
  14787. },
  14788. set: function (value) {
  14789. var _this = this;
  14790. if (this._radius === value) {
  14791. return;
  14792. }
  14793. this._radius = value;
  14794. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14795. _this._arrangeChildren();
  14796. });
  14797. },
  14798. enumerable: false,
  14799. configurable: true
  14800. });
  14801. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14802. var mesh = control.mesh;
  14803. if (!mesh) {
  14804. return;
  14805. }
  14806. var newPos = this._cylindricalMapping(nodePosition);
  14807. control.position = newPos;
  14808. switch (this.orientation) {
  14809. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14810. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14811. break;
  14812. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14813. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14814. break;
  14815. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14816. break;
  14817. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14818. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14819. break;
  14820. }
  14821. };
  14822. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14823. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14824. var yAngle = (source.x / this._radius);
  14825. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14826. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14827. };
  14828. return CylinderPanel;
  14829. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14830. /***/ }),
  14831. /***/ "./3D/controls/holographicButton.ts":
  14832. /*!******************************************!*\
  14833. !*** ./3D/controls/holographicButton.ts ***!
  14834. \******************************************/
  14835. /*! exports provided: HolographicButton */
  14836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14837. "use strict";
  14838. __webpack_require__.r(__webpack_exports__);
  14839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14840. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14841. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14842. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Misc/observable");
  14843. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  14844. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14845. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14846. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14847. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14848. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14849. /**
  14850. * Class used to create a holographic button in 3D
  14851. */
  14852. var HolographicButton = /** @class */ (function (_super) {
  14853. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14854. /**
  14855. * Creates a new button
  14856. * @param name defines the control name
  14857. */
  14858. function HolographicButton(name, shareMaterials) {
  14859. if (shareMaterials === void 0) { shareMaterials = true; }
  14860. var _this = _super.call(this, name) || this;
  14861. _this._shareMaterials = true;
  14862. _this._shareMaterials = shareMaterials;
  14863. // Default animations
  14864. _this.pointerEnterAnimation = function () {
  14865. if (!_this.mesh) {
  14866. return;
  14867. }
  14868. _this._frontPlate.setEnabled(true);
  14869. };
  14870. _this.pointerOutAnimation = function () {
  14871. if (!_this.mesh) {
  14872. return;
  14873. }
  14874. _this._frontPlate.setEnabled(false);
  14875. };
  14876. return _this;
  14877. }
  14878. HolographicButton.prototype._disposeTooltip = function () {
  14879. this._tooltipFade = null;
  14880. if (this._tooltipTextBlock) {
  14881. this._tooltipTextBlock.dispose();
  14882. }
  14883. if (this._tooltipTexture) {
  14884. this._tooltipTexture.dispose();
  14885. }
  14886. if (this._tooltipMesh) {
  14887. this._tooltipMesh.dispose();
  14888. }
  14889. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14890. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14891. };
  14892. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14893. get: function () {
  14894. return this._backPlate.renderingGroupId;
  14895. },
  14896. /**
  14897. * Rendering ground id of all the mesh in the button
  14898. */
  14899. set: function (id) {
  14900. this._backPlate.renderingGroupId = id;
  14901. this._textPlate.renderingGroupId = id;
  14902. this._frontPlate.renderingGroupId = id;
  14903. if (this._tooltipMesh) {
  14904. this._tooltipMesh.renderingGroupId = id;
  14905. }
  14906. },
  14907. enumerable: false,
  14908. configurable: true
  14909. });
  14910. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14911. get: function () {
  14912. if (this._tooltipTextBlock) {
  14913. return this._tooltipTextBlock.text;
  14914. }
  14915. return null;
  14916. },
  14917. /**
  14918. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14919. */
  14920. set: function (text) {
  14921. var _this = this;
  14922. if (!text) {
  14923. this._disposeTooltip();
  14924. return;
  14925. }
  14926. if (!this._tooltipFade) {
  14927. // Create tooltip with mesh and text
  14928. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14929. 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);
  14930. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14931. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14932. tooltipBackground.material = mat;
  14933. tooltipBackground.isPickable = false;
  14934. this._tooltipMesh.addChild(tooltipBackground);
  14935. tooltipBackground.position.z = 0.05;
  14936. this._tooltipMesh.scaling.y = 1 / 3;
  14937. this._tooltipMesh.position.y = 0.7;
  14938. this._tooltipMesh.position.z = -0.15;
  14939. this._tooltipMesh.isPickable = false;
  14940. this._tooltipMesh.parent = this._backPlate;
  14941. // Create text texture for the tooltip
  14942. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14943. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14944. this._tooltipTextBlock.scaleY = 3;
  14945. this._tooltipTextBlock.color = "white";
  14946. this._tooltipTextBlock.fontSize = 130;
  14947. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14948. // Add hover action to tooltip
  14949. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14950. this._tooltipFade.delay = 500;
  14951. this._tooltipMesh.addBehavior(this._tooltipFade);
  14952. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14953. if (_this._tooltipFade) {
  14954. _this._tooltipFade.fadeIn(true);
  14955. }
  14956. });
  14957. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14958. if (_this._tooltipFade) {
  14959. _this._tooltipFade.fadeIn(false);
  14960. }
  14961. });
  14962. }
  14963. if (this._tooltipTextBlock) {
  14964. this._tooltipTextBlock.text = text;
  14965. }
  14966. },
  14967. enumerable: false,
  14968. configurable: true
  14969. });
  14970. Object.defineProperty(HolographicButton.prototype, "text", {
  14971. /**
  14972. * Gets or sets text for the button
  14973. */
  14974. get: function () {
  14975. return this._text;
  14976. },
  14977. set: function (value) {
  14978. if (this._text === value) {
  14979. return;
  14980. }
  14981. this._text = value;
  14982. this._rebuildContent();
  14983. },
  14984. enumerable: false,
  14985. configurable: true
  14986. });
  14987. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14988. /**
  14989. * Gets or sets the image url for the button
  14990. */
  14991. get: function () {
  14992. return this._imageUrl;
  14993. },
  14994. set: function (value) {
  14995. if (this._imageUrl === value) {
  14996. return;
  14997. }
  14998. this._imageUrl = value;
  14999. this._rebuildContent();
  15000. },
  15001. enumerable: false,
  15002. configurable: true
  15003. });
  15004. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  15005. /**
  15006. * Gets the back material used by this button
  15007. */
  15008. get: function () {
  15009. return this._backMaterial;
  15010. },
  15011. enumerable: false,
  15012. configurable: true
  15013. });
  15014. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  15015. /**
  15016. * Gets the front material used by this button
  15017. */
  15018. get: function () {
  15019. return this._frontMaterial;
  15020. },
  15021. enumerable: false,
  15022. configurable: true
  15023. });
  15024. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  15025. /**
  15026. * Gets the plate material used by this button
  15027. */
  15028. get: function () {
  15029. return this._plateMaterial;
  15030. },
  15031. enumerable: false,
  15032. configurable: true
  15033. });
  15034. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  15035. /**
  15036. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  15037. */
  15038. get: function () {
  15039. return this._shareMaterials;
  15040. },
  15041. enumerable: false,
  15042. configurable: true
  15043. });
  15044. HolographicButton.prototype._getTypeName = function () {
  15045. return "HolographicButton";
  15046. };
  15047. HolographicButton.prototype._rebuildContent = function () {
  15048. this._disposeFacadeTexture();
  15049. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  15050. panel.isVertical = true;
  15051. if (this._imageUrl) {
  15052. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  15053. image.source = this._imageUrl;
  15054. image.paddingTop = "40px";
  15055. image.height = "180px";
  15056. image.width = "100px";
  15057. image.paddingBottom = "40px";
  15058. panel.addControl(image);
  15059. }
  15060. if (this._text) {
  15061. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  15062. text.text = this._text;
  15063. text.color = "white";
  15064. text.height = "30px";
  15065. text.fontSize = 24;
  15066. panel.addControl(text);
  15067. }
  15068. if (this._frontPlate) {
  15069. this.content = panel;
  15070. }
  15071. };
  15072. // Mesh association
  15073. HolographicButton.prototype._createNode = function (scene) {
  15074. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  15075. width: 1.0,
  15076. height: 1.0,
  15077. depth: 0.08
  15078. }, scene);
  15079. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  15080. width: 1.0,
  15081. height: 1.0,
  15082. depth: 0.08
  15083. }, scene);
  15084. this._frontPlate.parent = this._backPlate;
  15085. this._frontPlate.position.z = -0.08;
  15086. this._frontPlate.isPickable = false;
  15087. this._frontPlate.setEnabled(false);
  15088. this._textPlate = _super.prototype._createNode.call(this, scene);
  15089. this._textPlate.parent = this._backPlate;
  15090. this._textPlate.position.z = -0.08;
  15091. this._textPlate.isPickable = false;
  15092. return this._backPlate;
  15093. };
  15094. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  15095. this._plateMaterial.emissiveTexture = facadeTexture;
  15096. this._plateMaterial.opacityTexture = facadeTexture;
  15097. };
  15098. HolographicButton.prototype._createBackMaterial = function (mesh) {
  15099. var _this = this;
  15100. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  15101. this._backMaterial.renderHoverLight = true;
  15102. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  15103. if (pickedPoint) {
  15104. _this._backMaterial.hoverPosition = pickedPoint;
  15105. _this._backMaterial.hoverColor.a = 1.0;
  15106. }
  15107. else {
  15108. _this._backMaterial.hoverColor.a = 0;
  15109. }
  15110. });
  15111. };
  15112. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  15113. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  15114. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  15115. this._frontMaterial.alpha = 0.5; // Additive
  15116. this._frontMaterial.renderBorders = true;
  15117. };
  15118. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  15119. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  15120. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  15121. };
  15122. HolographicButton.prototype._affectMaterial = function (mesh) {
  15123. // Back
  15124. if (this._shareMaterials) {
  15125. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  15126. this._createBackMaterial(mesh);
  15127. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  15128. }
  15129. else {
  15130. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  15131. }
  15132. // Front
  15133. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  15134. this._createFrontMaterial(mesh);
  15135. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  15136. }
  15137. else {
  15138. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  15139. }
  15140. }
  15141. else {
  15142. this._createBackMaterial(mesh);
  15143. this._createFrontMaterial(mesh);
  15144. }
  15145. this._createPlateMaterial(mesh);
  15146. this._backPlate.material = this._backMaterial;
  15147. this._frontPlate.material = this._frontMaterial;
  15148. this._textPlate.material = this._plateMaterial;
  15149. this._rebuildContent();
  15150. };
  15151. /**
  15152. * Releases all associated resources
  15153. */
  15154. HolographicButton.prototype.dispose = function () {
  15155. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  15156. this._disposeTooltip();
  15157. if (!this.shareMaterials) {
  15158. this._backMaterial.dispose();
  15159. this._frontMaterial.dispose();
  15160. this._plateMaterial.dispose();
  15161. if (this._pickedPointObserver) {
  15162. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  15163. this._pickedPointObserver = null;
  15164. }
  15165. }
  15166. };
  15167. return HolographicButton;
  15168. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15169. /***/ }),
  15170. /***/ "./3D/controls/index.ts":
  15171. /*!******************************!*\
  15172. !*** ./3D/controls/index.ts ***!
  15173. \******************************/
  15174. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  15175. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15176. "use strict";
  15177. __webpack_require__.r(__webpack_exports__);
  15178. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  15179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15180. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15182. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  15184. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  15186. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  15187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  15188. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  15189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  15190. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  15191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  15192. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  15193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  15194. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  15195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  15196. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  15197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  15198. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  15199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  15200. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  15202. /***/ }),
  15203. /***/ "./3D/controls/meshButton3D.ts":
  15204. /*!*************************************!*\
  15205. !*** ./3D/controls/meshButton3D.ts ***!
  15206. \*************************************/
  15207. /*! exports provided: MeshButton3D */
  15208. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15209. "use strict";
  15210. __webpack_require__.r(__webpack_exports__);
  15211. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  15212. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15213. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15214. /**
  15215. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  15216. */
  15217. var MeshButton3D = /** @class */ (function (_super) {
  15218. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  15219. /**
  15220. * Creates a new 3D button based on a mesh
  15221. * @param mesh mesh to become a 3D button
  15222. * @param name defines the control name
  15223. */
  15224. function MeshButton3D(mesh, name) {
  15225. var _this = _super.call(this, name) || this;
  15226. _this._currentMesh = mesh;
  15227. /**
  15228. * Provides a default behavior on hover/out & up/down
  15229. * Override those function to create your own desired behavior specific to your mesh
  15230. */
  15231. _this.pointerEnterAnimation = function () {
  15232. if (!_this.mesh) {
  15233. return;
  15234. }
  15235. _this.mesh.scaling.scaleInPlace(1.1);
  15236. };
  15237. _this.pointerOutAnimation = function () {
  15238. if (!_this.mesh) {
  15239. return;
  15240. }
  15241. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  15242. };
  15243. _this.pointerDownAnimation = function () {
  15244. if (!_this.mesh) {
  15245. return;
  15246. }
  15247. _this.mesh.scaling.scaleInPlace(0.95);
  15248. };
  15249. _this.pointerUpAnimation = function () {
  15250. if (!_this.mesh) {
  15251. return;
  15252. }
  15253. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15254. };
  15255. return _this;
  15256. }
  15257. MeshButton3D.prototype._getTypeName = function () {
  15258. return "MeshButton3D";
  15259. };
  15260. // Mesh association
  15261. MeshButton3D.prototype._createNode = function (scene) {
  15262. var _this = this;
  15263. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15264. mesh.metadata = _this;
  15265. });
  15266. return this._currentMesh;
  15267. };
  15268. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15269. };
  15270. return MeshButton3D;
  15271. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15272. /***/ }),
  15273. /***/ "./3D/controls/planePanel.ts":
  15274. /*!***********************************!*\
  15275. !*** ./3D/controls/planePanel.ts ***!
  15276. \***********************************/
  15277. /*! exports provided: PlanePanel */
  15278. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15279. "use strict";
  15280. __webpack_require__.r(__webpack_exports__);
  15281. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15282. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15283. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  15284. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15285. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15286. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15287. /**
  15288. * Class used to create a container panel deployed on the surface of a plane
  15289. */
  15290. var PlanePanel = /** @class */ (function (_super) {
  15291. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15292. function PlanePanel() {
  15293. return _super !== null && _super.apply(this, arguments) || this;
  15294. }
  15295. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15296. var mesh = control.mesh;
  15297. if (!mesh) {
  15298. return;
  15299. }
  15300. control.position = nodePosition.clone();
  15301. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15302. target.copyFrom(nodePosition);
  15303. switch (this.orientation) {
  15304. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15305. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15306. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15307. mesh.lookAt(target);
  15308. break;
  15309. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15310. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15311. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15312. mesh.lookAt(target);
  15313. break;
  15314. }
  15315. };
  15316. return PlanePanel;
  15317. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15318. /***/ }),
  15319. /***/ "./3D/controls/scatterPanel.ts":
  15320. /*!*************************************!*\
  15321. !*** ./3D/controls/scatterPanel.ts ***!
  15322. \*************************************/
  15323. /*! exports provided: ScatterPanel */
  15324. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15325. "use strict";
  15326. __webpack_require__.r(__webpack_exports__);
  15327. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15328. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15329. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15330. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15331. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15332. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15333. /**
  15334. * Class used to create a container panel where items get randomized planar mapping
  15335. */
  15336. var ScatterPanel = /** @class */ (function (_super) {
  15337. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15338. function ScatterPanel() {
  15339. var _this = _super !== null && _super.apply(this, arguments) || this;
  15340. _this._iteration = 100.0;
  15341. return _this;
  15342. }
  15343. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15344. /**
  15345. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15346. */
  15347. get: function () {
  15348. return this._iteration;
  15349. },
  15350. set: function (value) {
  15351. var _this = this;
  15352. if (this._iteration === value) {
  15353. return;
  15354. }
  15355. this._iteration = value;
  15356. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15357. _this._arrangeChildren();
  15358. });
  15359. },
  15360. enumerable: false,
  15361. configurable: true
  15362. });
  15363. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15364. var mesh = control.mesh;
  15365. var newPos = this._scatterMapping(nodePosition);
  15366. if (!mesh) {
  15367. return;
  15368. }
  15369. switch (this.orientation) {
  15370. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15371. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15372. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15373. break;
  15374. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15375. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15376. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15377. break;
  15378. }
  15379. control.position = newPos;
  15380. };
  15381. ScatterPanel.prototype._scatterMapping = function (source) {
  15382. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15383. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15384. return source;
  15385. };
  15386. ScatterPanel.prototype._finalProcessing = function () {
  15387. var meshes = [];
  15388. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15389. var child = _a[_i];
  15390. if (!child.mesh) {
  15391. continue;
  15392. }
  15393. meshes.push(child.mesh);
  15394. }
  15395. for (var count = 0; count < this._iteration; count++) {
  15396. meshes.sort(function (a, b) {
  15397. var distance1 = a.position.lengthSquared();
  15398. var distance2 = b.position.lengthSquared();
  15399. if (distance1 < distance2) {
  15400. return 1;
  15401. }
  15402. else if (distance1 > distance2) {
  15403. return -1;
  15404. }
  15405. return 0;
  15406. });
  15407. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15408. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15409. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15410. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15411. for (var i = 0; i < meshes.length - 1; i++) {
  15412. for (var j = i + 1; j < meshes.length; j++) {
  15413. if (i != j) {
  15414. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15415. // Ignore Z axis
  15416. difference2D.x = difference.x;
  15417. difference2D.y = difference.y;
  15418. var combinedRadius = cellSize;
  15419. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15420. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15421. distance -= minSeparation;
  15422. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15423. difference2D.normalize();
  15424. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15425. meshes[j].position.addInPlace(difference);
  15426. meshes[i].position.subtractInPlace(difference);
  15427. }
  15428. }
  15429. }
  15430. }
  15431. }
  15432. };
  15433. return ScatterPanel;
  15434. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15435. /***/ }),
  15436. /***/ "./3D/controls/spherePanel.ts":
  15437. /*!************************************!*\
  15438. !*** ./3D/controls/spherePanel.ts ***!
  15439. \************************************/
  15440. /*! exports provided: SpherePanel */
  15441. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15442. "use strict";
  15443. __webpack_require__.r(__webpack_exports__);
  15444. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15445. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15446. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15447. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15448. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15449. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15450. /**
  15451. * Class used to create a container panel deployed on the surface of a sphere
  15452. */
  15453. var SpherePanel = /** @class */ (function (_super) {
  15454. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15455. function SpherePanel() {
  15456. var _this = _super !== null && _super.apply(this, arguments) || this;
  15457. _this._radius = 5.0;
  15458. return _this;
  15459. }
  15460. Object.defineProperty(SpherePanel.prototype, "radius", {
  15461. /**
  15462. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15463. */
  15464. get: function () {
  15465. return this._radius;
  15466. },
  15467. set: function (value) {
  15468. var _this = this;
  15469. if (this._radius === value) {
  15470. return;
  15471. }
  15472. this._radius = value;
  15473. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15474. _this._arrangeChildren();
  15475. });
  15476. },
  15477. enumerable: false,
  15478. configurable: true
  15479. });
  15480. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15481. var mesh = control.mesh;
  15482. if (!mesh) {
  15483. return;
  15484. }
  15485. var newPos = this._sphericalMapping(nodePosition);
  15486. control.position = newPos;
  15487. switch (this.orientation) {
  15488. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15489. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15490. break;
  15491. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15492. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15493. break;
  15494. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15495. break;
  15496. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15497. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15498. break;
  15499. }
  15500. };
  15501. SpherePanel.prototype._sphericalMapping = function (source) {
  15502. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15503. var xAngle = (source.y / this._radius);
  15504. var yAngle = -(source.x / this._radius);
  15505. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15506. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15507. };
  15508. return SpherePanel;
  15509. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15510. /***/ }),
  15511. /***/ "./3D/controls/stackPanel3D.ts":
  15512. /*!*************************************!*\
  15513. !*** ./3D/controls/stackPanel3D.ts ***!
  15514. \*************************************/
  15515. /*! exports provided: StackPanel3D */
  15516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15517. "use strict";
  15518. __webpack_require__.r(__webpack_exports__);
  15519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15520. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15521. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15522. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15523. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15524. /**
  15525. * Class used to create a stack panel in 3D on XY plane
  15526. */
  15527. var StackPanel3D = /** @class */ (function (_super) {
  15528. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15529. /**
  15530. * Creates new StackPanel
  15531. * @param isVertical
  15532. */
  15533. function StackPanel3D(isVertical) {
  15534. if (isVertical === void 0) { isVertical = false; }
  15535. var _this = _super.call(this) || this;
  15536. _this._isVertical = false;
  15537. /**
  15538. * Gets or sets the distance between elements
  15539. */
  15540. _this.margin = 0.1;
  15541. _this._isVertical = isVertical;
  15542. return _this;
  15543. }
  15544. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15545. /**
  15546. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15547. */
  15548. get: function () {
  15549. return this._isVertical;
  15550. },
  15551. set: function (value) {
  15552. var _this = this;
  15553. if (this._isVertical === value) {
  15554. return;
  15555. }
  15556. this._isVertical = value;
  15557. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15558. _this._arrangeChildren();
  15559. });
  15560. },
  15561. enumerable: false,
  15562. configurable: true
  15563. });
  15564. StackPanel3D.prototype._arrangeChildren = function () {
  15565. var width = 0;
  15566. var height = 0;
  15567. var controlCount = 0;
  15568. var extendSizes = [];
  15569. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15570. // Measure
  15571. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15572. var child = _a[_i];
  15573. if (!child.mesh) {
  15574. continue;
  15575. }
  15576. controlCount++;
  15577. child.mesh.computeWorldMatrix(true);
  15578. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15579. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15580. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15581. extendSizes.push(extendSize);
  15582. if (this._isVertical) {
  15583. height += extendSize.y;
  15584. }
  15585. else {
  15586. width += extendSize.x;
  15587. }
  15588. }
  15589. if (this._isVertical) {
  15590. height += (controlCount - 1) * this.margin / 2;
  15591. }
  15592. else {
  15593. width += (controlCount - 1) * this.margin / 2;
  15594. }
  15595. // Arrange
  15596. var offset;
  15597. if (this._isVertical) {
  15598. offset = -height;
  15599. }
  15600. else {
  15601. offset = -width;
  15602. }
  15603. var index = 0;
  15604. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15605. var child = _c[_b];
  15606. if (!child.mesh) {
  15607. continue;
  15608. }
  15609. controlCount--;
  15610. var extendSize = extendSizes[index++];
  15611. if (this._isVertical) {
  15612. child.position.y = offset + extendSize.y;
  15613. child.position.x = 0;
  15614. offset += extendSize.y * 2;
  15615. }
  15616. else {
  15617. child.position.x = offset + extendSize.x;
  15618. child.position.y = 0;
  15619. offset += extendSize.x * 2;
  15620. }
  15621. offset += (controlCount > 0 ? this.margin : 0);
  15622. }
  15623. };
  15624. return StackPanel3D;
  15625. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15626. /***/ }),
  15627. /***/ "./3D/controls/volumeBasedPanel.ts":
  15628. /*!*****************************************!*\
  15629. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15630. \*****************************************/
  15631. /*! exports provided: VolumeBasedPanel */
  15632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15633. "use strict";
  15634. __webpack_require__.r(__webpack_exports__);
  15635. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15636. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15637. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15638. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15639. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15640. /**
  15641. * Abstract class used to create a container panel deployed on the surface of a volume
  15642. */
  15643. var VolumeBasedPanel = /** @class */ (function (_super) {
  15644. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15645. /**
  15646. * Creates new VolumeBasedPanel
  15647. */
  15648. function VolumeBasedPanel() {
  15649. var _this = _super.call(this) || this;
  15650. _this._columns = 10;
  15651. _this._rows = 0;
  15652. _this._rowThenColum = true;
  15653. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15654. /**
  15655. * Gets or sets the distance between elements
  15656. */
  15657. _this.margin = 0;
  15658. return _this;
  15659. }
  15660. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15661. /**
  15662. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15663. * | Value | Type | Description |
  15664. * | ----- | ----------------------------------- | ----------- |
  15665. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15666. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15667. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15668. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15669. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15670. */
  15671. get: function () {
  15672. return this._orientation;
  15673. },
  15674. set: function (value) {
  15675. var _this = this;
  15676. if (this._orientation === value) {
  15677. return;
  15678. }
  15679. this._orientation = value;
  15680. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15681. _this._arrangeChildren();
  15682. });
  15683. },
  15684. enumerable: false,
  15685. configurable: true
  15686. });
  15687. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15688. /**
  15689. * Gets or sets the number of columns requested (10 by default).
  15690. * The panel will automatically compute the number of rows based on number of child controls.
  15691. */
  15692. get: function () {
  15693. return this._columns;
  15694. },
  15695. set: function (value) {
  15696. var _this = this;
  15697. if (this._columns === value) {
  15698. return;
  15699. }
  15700. this._columns = value;
  15701. this._rowThenColum = true;
  15702. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15703. _this._arrangeChildren();
  15704. });
  15705. },
  15706. enumerable: false,
  15707. configurable: true
  15708. });
  15709. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15710. /**
  15711. * Gets or sets a the number of rows requested.
  15712. * The panel will automatically compute the number of columns based on number of child controls.
  15713. */
  15714. get: function () {
  15715. return this._rows;
  15716. },
  15717. set: function (value) {
  15718. var _this = this;
  15719. if (this._rows === value) {
  15720. return;
  15721. }
  15722. this._rows = value;
  15723. this._rowThenColum = false;
  15724. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15725. _this._arrangeChildren();
  15726. });
  15727. },
  15728. enumerable: false,
  15729. configurable: true
  15730. });
  15731. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15732. this._cellWidth = 0;
  15733. this._cellHeight = 0;
  15734. var rows = 0;
  15735. var columns = 0;
  15736. var controlCount = 0;
  15737. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15738. // Measure
  15739. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15740. var child = _a[_i];
  15741. if (!child.mesh) {
  15742. continue;
  15743. }
  15744. controlCount++;
  15745. child.mesh.computeWorldMatrix(true);
  15746. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15747. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15748. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15749. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15750. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15751. diff.scaleInPlace(0.5);
  15752. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15753. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15754. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15755. }
  15756. this._cellWidth += this.margin * 2;
  15757. this._cellHeight += this.margin * 2;
  15758. // Arrange
  15759. if (this._rowThenColum) {
  15760. columns = this._columns;
  15761. rows = Math.ceil(controlCount / this._columns);
  15762. }
  15763. else {
  15764. rows = this._rows;
  15765. columns = Math.ceil(controlCount / this._rows);
  15766. }
  15767. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15768. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15769. var nodeGrid = [];
  15770. var cellCounter = 0;
  15771. if (this._rowThenColum) {
  15772. for (var r = 0; r < rows; r++) {
  15773. for (var c = 0; c < columns; c++) {
  15774. 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));
  15775. cellCounter++;
  15776. if (cellCounter > controlCount) {
  15777. break;
  15778. }
  15779. }
  15780. }
  15781. }
  15782. else {
  15783. for (var c = 0; c < columns; c++) {
  15784. for (var r = 0; r < rows; r++) {
  15785. 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));
  15786. cellCounter++;
  15787. if (cellCounter > controlCount) {
  15788. break;
  15789. }
  15790. }
  15791. }
  15792. }
  15793. cellCounter = 0;
  15794. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15795. var child = _c[_b];
  15796. if (!child.mesh) {
  15797. continue;
  15798. }
  15799. this._mapGridNode(child, nodeGrid[cellCounter]);
  15800. cellCounter++;
  15801. }
  15802. this._finalProcessing();
  15803. };
  15804. /** Child classes can implement this function to provide additional processing */
  15805. VolumeBasedPanel.prototype._finalProcessing = function () {
  15806. };
  15807. return VolumeBasedPanel;
  15808. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15809. /***/ }),
  15810. /***/ "./3D/gui3DManager.ts":
  15811. /*!****************************!*\
  15812. !*** ./3D/gui3DManager.ts ***!
  15813. \****************************/
  15814. /*! exports provided: GUI3DManager */
  15815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15816. "use strict";
  15817. __webpack_require__.r(__webpack_exports__);
  15818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15819. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  15820. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15821. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15822. /**
  15823. * Class used to manage 3D user interface
  15824. * @see https://doc.babylonjs.com/how_to/gui3d
  15825. */
  15826. var GUI3DManager = /** @class */ (function () {
  15827. /**
  15828. * Creates a new GUI3DManager
  15829. * @param scene
  15830. */
  15831. function GUI3DManager(scene) {
  15832. var _this = this;
  15833. /** @hidden */
  15834. this._lastControlOver = {};
  15835. /** @hidden */
  15836. this._lastControlDown = {};
  15837. /**
  15838. * Observable raised when the point picked by the pointer events changed
  15839. */
  15840. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15841. // Shared resources
  15842. /** @hidden */
  15843. this._sharedMaterials = {};
  15844. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15845. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15846. _this._sceneDisposeObserver = null;
  15847. _this._utilityLayer = null;
  15848. _this.dispose();
  15849. });
  15850. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15851. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15852. this._utilityLayer.pickUtilitySceneFirst = false;
  15853. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15854. return mesh && mesh.metadata && mesh.metadata._node;
  15855. };
  15856. // Root
  15857. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15858. this._rootContainer._host = this;
  15859. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15860. // Events
  15861. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15862. _this._handlePointerOut(pointerId, true);
  15863. });
  15864. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15865. _this._doPicking(pi);
  15866. });
  15867. // Scene
  15868. this._utilityLayer.utilityLayerScene.autoClear = false;
  15869. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15870. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15871. }
  15872. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15873. /** Gets the hosting scene */
  15874. get: function () {
  15875. return this._scene;
  15876. },
  15877. enumerable: false,
  15878. configurable: true
  15879. });
  15880. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15881. /** Gets associated utility layer */
  15882. get: function () {
  15883. return this._utilityLayer;
  15884. },
  15885. enumerable: false,
  15886. configurable: true
  15887. });
  15888. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15889. var previousControlOver = this._lastControlOver[pointerId];
  15890. if (previousControlOver) {
  15891. previousControlOver._onPointerOut(previousControlOver);
  15892. delete this._lastControlOver[pointerId];
  15893. }
  15894. if (isPointerUp) {
  15895. if (this._lastControlDown[pointerId]) {
  15896. this._lastControlDown[pointerId].forcePointerUp();
  15897. delete this._lastControlDown[pointerId];
  15898. }
  15899. }
  15900. this.onPickedPointChangedObservable.notifyObservers(null);
  15901. };
  15902. GUI3DManager.prototype._doPicking = function (pi) {
  15903. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15904. return false;
  15905. }
  15906. var pointerEvent = (pi.event);
  15907. var pointerId = pointerEvent.pointerId || 0;
  15908. var buttonIndex = pointerEvent.button;
  15909. var pickingInfo = pi.pickInfo;
  15910. if (!pickingInfo || !pickingInfo.hit) {
  15911. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15912. return false;
  15913. }
  15914. var control = (pickingInfo.pickedMesh.metadata);
  15915. if (pickingInfo.pickedPoint) {
  15916. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15917. }
  15918. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15919. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15920. if (this._lastControlOver[pointerId]) {
  15921. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15922. }
  15923. delete this._lastControlOver[pointerId];
  15924. }
  15925. }
  15926. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15927. if (this._lastControlDown[pointerEvent.pointerId]) {
  15928. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15929. delete this._lastControlDown[pointerEvent.pointerId];
  15930. }
  15931. if (pointerEvent.pointerType === "touch") {
  15932. this._handlePointerOut(pointerId, false);
  15933. }
  15934. }
  15935. return true;
  15936. };
  15937. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15938. /**
  15939. * Gets the root container
  15940. */
  15941. get: function () {
  15942. return this._rootContainer;
  15943. },
  15944. enumerable: false,
  15945. configurable: true
  15946. });
  15947. /**
  15948. * Gets a boolean indicating if the given control is in the root child list
  15949. * @param control defines the control to check
  15950. * @returns true if the control is in the root child list
  15951. */
  15952. GUI3DManager.prototype.containsControl = function (control) {
  15953. return this._rootContainer.containsControl(control);
  15954. };
  15955. /**
  15956. * Adds a control to the root child list
  15957. * @param control defines the control to add
  15958. * @returns the current manager
  15959. */
  15960. GUI3DManager.prototype.addControl = function (control) {
  15961. this._rootContainer.addControl(control);
  15962. return this;
  15963. };
  15964. /**
  15965. * Removes a control from the root child list
  15966. * @param control defines the control to remove
  15967. * @returns the current container
  15968. */
  15969. GUI3DManager.prototype.removeControl = function (control) {
  15970. this._rootContainer.removeControl(control);
  15971. return this;
  15972. };
  15973. /**
  15974. * Releases all associated resources
  15975. */
  15976. GUI3DManager.prototype.dispose = function () {
  15977. this._rootContainer.dispose();
  15978. for (var materialName in this._sharedMaterials) {
  15979. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15980. continue;
  15981. }
  15982. this._sharedMaterials[materialName].dispose();
  15983. }
  15984. this._sharedMaterials = {};
  15985. if (this._pointerOutObserver && this._utilityLayer) {
  15986. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15987. this._pointerOutObserver = null;
  15988. }
  15989. this.onPickedPointChangedObservable.clear();
  15990. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15991. if (utilityLayerScene) {
  15992. if (this._pointerObserver) {
  15993. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15994. this._pointerObserver = null;
  15995. }
  15996. }
  15997. if (this._scene) {
  15998. if (this._sceneDisposeObserver) {
  15999. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  16000. this._sceneDisposeObserver = null;
  16001. }
  16002. }
  16003. if (this._utilityLayer) {
  16004. this._utilityLayer.dispose();
  16005. }
  16006. };
  16007. return GUI3DManager;
  16008. }());
  16009. /***/ }),
  16010. /***/ "./3D/index.ts":
  16011. /*!*********************!*\
  16012. !*** ./3D/index.ts ***!
  16013. \*********************/
  16014. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16015. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16016. "use strict";
  16017. __webpack_require__.r(__webpack_exports__);
  16018. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  16019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16031. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  16032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16034. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  16035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  16036. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  16037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  16038. /***/ }),
  16039. /***/ "./3D/materials/fluentMaterial.ts":
  16040. /*!****************************************!*\
  16041. !*** ./3D/materials/fluentMaterial.ts ***!
  16042. \****************************************/
  16043. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16045. "use strict";
  16046. __webpack_require__.r(__webpack_exports__);
  16047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  16048. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  16049. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16050. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  16051. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  16052. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  16053. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  16054. /** @hidden */
  16055. var FluentMaterialDefines = /** @class */ (function (_super) {
  16056. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  16057. function FluentMaterialDefines() {
  16058. var _this = _super.call(this) || this;
  16059. _this.INNERGLOW = false;
  16060. _this.BORDER = false;
  16061. _this.HOVERLIGHT = false;
  16062. _this.TEXTURE = false;
  16063. _this.rebuild();
  16064. return _this;
  16065. }
  16066. return FluentMaterialDefines;
  16067. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  16068. /**
  16069. * Class used to render controls with fluent desgin
  16070. */
  16071. var FluentMaterial = /** @class */ (function (_super) {
  16072. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  16073. /**
  16074. * Creates a new Fluent material
  16075. * @param name defines the name of the material
  16076. * @param scene defines the hosting scene
  16077. */
  16078. function FluentMaterial(name, scene) {
  16079. var _this = _super.call(this, name, scene) || this;
  16080. /**
  16081. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  16082. */
  16083. _this.innerGlowColorIntensity = 0.5;
  16084. /**
  16085. * Gets or sets the inner glow color (white by default)
  16086. */
  16087. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  16088. /**
  16089. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  16090. */
  16091. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  16092. /**
  16093. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  16094. */
  16095. _this.renderBorders = false;
  16096. /**
  16097. * Gets or sets border width (default is 0.5)
  16098. */
  16099. _this.borderWidth = 0.5;
  16100. /**
  16101. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  16102. */
  16103. _this.edgeSmoothingValue = 0.02;
  16104. /**
  16105. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  16106. */
  16107. _this.borderMinValue = 0.1;
  16108. /**
  16109. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  16110. */
  16111. _this.renderHoverLight = false;
  16112. /**
  16113. * Gets or sets the radius used to render the hover light (default is 1.0)
  16114. */
  16115. _this.hoverRadius = 1.0;
  16116. /**
  16117. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  16118. */
  16119. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  16120. /**
  16121. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  16122. */
  16123. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  16124. return _this;
  16125. }
  16126. FluentMaterial.prototype.needAlphaBlending = function () {
  16127. return this.alpha !== 1.0;
  16128. };
  16129. FluentMaterial.prototype.needAlphaTesting = function () {
  16130. return false;
  16131. };
  16132. FluentMaterial.prototype.getAlphaTestTexture = function () {
  16133. return null;
  16134. };
  16135. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  16136. if (this.isFrozen) {
  16137. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  16138. return true;
  16139. }
  16140. }
  16141. if (!subMesh._materialDefines) {
  16142. subMesh._materialDefines = new FluentMaterialDefines();
  16143. }
  16144. var scene = this.getScene();
  16145. var defines = subMesh._materialDefines;
  16146. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  16147. if (defines._renderId === scene.getRenderId()) {
  16148. return true;
  16149. }
  16150. }
  16151. if (defines._areTexturesDirty) {
  16152. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  16153. defines.BORDER = this.renderBorders;
  16154. defines.HOVERLIGHT = this.renderHoverLight;
  16155. if (this._albedoTexture) {
  16156. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  16157. return false;
  16158. }
  16159. else {
  16160. defines.TEXTURE = true;
  16161. }
  16162. }
  16163. else {
  16164. defines.TEXTURE = false;
  16165. }
  16166. }
  16167. var engine = scene.getEngine();
  16168. // Get correct effect
  16169. if (defines.isDirty) {
  16170. defines.markAsProcessed();
  16171. scene.resetCachedMaterial();
  16172. //Attributes
  16173. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  16174. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  16175. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  16176. var shaderName = "fluent";
  16177. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  16178. "hoverColor", "hoverPosition", "hoverRadius"
  16179. ];
  16180. var samplers = ["albedoSampler"];
  16181. var uniformBuffers = new Array();
  16182. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  16183. uniformsNames: uniforms,
  16184. uniformBuffersNames: uniformBuffers,
  16185. samplers: samplers,
  16186. defines: defines,
  16187. maxSimultaneousLights: 4
  16188. });
  16189. var join = defines.toString();
  16190. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  16191. attributes: attribs,
  16192. uniformsNames: uniforms,
  16193. uniformBuffersNames: uniformBuffers,
  16194. samplers: samplers,
  16195. defines: join,
  16196. fallbacks: null,
  16197. onCompiled: this.onCompiled,
  16198. onError: this.onError,
  16199. indexParameters: { maxSimultaneousLights: 4 }
  16200. }, engine));
  16201. }
  16202. if (!subMesh.effect || !subMesh.effect.isReady()) {
  16203. return false;
  16204. }
  16205. defines._renderId = scene.getRenderId();
  16206. subMesh.effect._wasPreviouslyReady = true;
  16207. return true;
  16208. };
  16209. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  16210. var scene = this.getScene();
  16211. var defines = subMesh._materialDefines;
  16212. if (!defines) {
  16213. return;
  16214. }
  16215. var effect = subMesh.effect;
  16216. if (!effect) {
  16217. return;
  16218. }
  16219. this._activeEffect = effect;
  16220. // Matrices
  16221. this.bindOnlyWorldMatrix(world);
  16222. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  16223. if (this._mustRebind(scene, effect)) {
  16224. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  16225. if (defines.INNERGLOW) {
  16226. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  16227. }
  16228. if (defines.BORDER) {
  16229. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  16230. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  16231. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  16232. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16233. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16234. }
  16235. if (defines.HOVERLIGHT) {
  16236. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  16237. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  16238. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  16239. }
  16240. if (defines.TEXTURE) {
  16241. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  16242. }
  16243. }
  16244. this._afterBind(mesh, this._activeEffect);
  16245. };
  16246. FluentMaterial.prototype.getActiveTextures = function () {
  16247. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16248. return activeTextures;
  16249. };
  16250. FluentMaterial.prototype.hasTexture = function (texture) {
  16251. if (_super.prototype.hasTexture.call(this, texture)) {
  16252. return true;
  16253. }
  16254. return false;
  16255. };
  16256. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16257. _super.prototype.dispose.call(this, forceDisposeEffect);
  16258. };
  16259. FluentMaterial.prototype.clone = function (name) {
  16260. var _this = this;
  16261. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16262. };
  16263. FluentMaterial.prototype.serialize = function () {
  16264. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16265. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16266. return serializationObject;
  16267. };
  16268. FluentMaterial.prototype.getClassName = function () {
  16269. return "FluentMaterial";
  16270. };
  16271. // Statics
  16272. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16273. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16274. };
  16275. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16276. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16277. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16278. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16279. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16280. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16281. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16282. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16283. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16284. ], FluentMaterial.prototype, "albedoColor", void 0);
  16285. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16286. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16287. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16288. ], FluentMaterial.prototype, "renderBorders", void 0);
  16289. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16290. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16291. ], FluentMaterial.prototype, "borderWidth", void 0);
  16292. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16293. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16294. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16295. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16296. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16297. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16298. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16299. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16300. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16301. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16302. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16303. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16304. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16305. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16306. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16307. ], FluentMaterial.prototype, "hoverColor", void 0);
  16308. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16309. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16310. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16311. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16312. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16313. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16314. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16315. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16316. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16317. return FluentMaterial;
  16318. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16319. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16320. /***/ }),
  16321. /***/ "./3D/materials/index.ts":
  16322. /*!*******************************!*\
  16323. !*** ./3D/materials/index.ts ***!
  16324. \*******************************/
  16325. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16327. "use strict";
  16328. __webpack_require__.r(__webpack_exports__);
  16329. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16332. /***/ }),
  16333. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16334. /*!*************************************************!*\
  16335. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16336. \*************************************************/
  16337. /*! exports provided: fluentPixelShader */
  16338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16339. "use strict";
  16340. __webpack_require__.r(__webpack_exports__);
  16341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16342. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  16343. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16344. var name = 'fluentPixelShader';
  16345. 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}";
  16346. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16347. /** @hidden */
  16348. var fluentPixelShader = { name: name, shader: shader };
  16349. /***/ }),
  16350. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16351. /*!***********************************************!*\
  16352. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16353. \***********************************************/
  16354. /*! exports provided: fluentVertexShader */
  16355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16356. "use strict";
  16357. __webpack_require__.r(__webpack_exports__);
  16358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16359. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  16360. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16361. var name = 'fluentVertexShader';
  16362. 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";
  16363. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16364. /** @hidden */
  16365. var fluentVertexShader = { name: name, shader: shader };
  16366. /***/ }),
  16367. /***/ "./3D/vector3WithInfo.ts":
  16368. /*!*******************************!*\
  16369. !*** ./3D/vector3WithInfo.ts ***!
  16370. \*******************************/
  16371. /*! exports provided: Vector3WithInfo */
  16372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16373. "use strict";
  16374. __webpack_require__.r(__webpack_exports__);
  16375. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16376. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16377. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  16378. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16379. /**
  16380. * Class used to transport Vector3 information for pointer events
  16381. */
  16382. var Vector3WithInfo = /** @class */ (function (_super) {
  16383. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16384. /**
  16385. * Creates a new Vector3WithInfo
  16386. * @param source defines the vector3 data to transport
  16387. * @param buttonIndex defines the current mouse button index
  16388. */
  16389. function Vector3WithInfo(source,
  16390. /** defines the current mouse button index */
  16391. buttonIndex) {
  16392. if (buttonIndex === void 0) { buttonIndex = 0; }
  16393. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16394. _this.buttonIndex = buttonIndex;
  16395. return _this;
  16396. }
  16397. return Vector3WithInfo;
  16398. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16399. /***/ }),
  16400. /***/ "./index.ts":
  16401. /*!******************!*\
  16402. !*** ./index.ts ***!
  16403. \******************/
  16404. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16406. "use strict";
  16407. __webpack_require__.r(__webpack_exports__);
  16408. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16450. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16467. /***/ }),
  16468. /***/ "./legacy/legacy.ts":
  16469. /*!**************************!*\
  16470. !*** ./legacy/legacy.ts ***!
  16471. \**************************/
  16472. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16474. "use strict";
  16475. __webpack_require__.r(__webpack_exports__);
  16476. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16534. /**
  16535. * Legacy support, defining window.BABYLON.GUI (global variable).
  16536. *
  16537. * This is the entry point for the UMD module.
  16538. * The entry point for a future ESM package should be index.ts
  16539. */
  16540. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16541. if (typeof globalObject !== "undefined") {
  16542. globalObject.BABYLON = globalObject.BABYLON || {};
  16543. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16544. }
  16545. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16546. /***/ }),
  16547. /***/ "babylonjs/Misc/observable":
  16548. /*!****************************************************************************************************!*\
  16549. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16550. \****************************************************************************************************/
  16551. /*! no static exports found */
  16552. /***/ (function(module, exports) {
  16553. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  16554. /***/ })
  16555. /******/ });
  16556. });
  16557. //# sourceMappingURL=babylon.gui.js.map