babylon.gui.js 864 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("babylonjs"));
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs-gui", ["babylonjs"], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs-gui"] = factory(require("babylonjs"));
  8. else
  9. root["BABYLON"] = root["BABYLON"] || {}, root["BABYLON"]["GUI"] = factory(root["BABYLON"]);
  10. })((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), function(__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../../node_modules/tslib/tslib.es6.js":
  99. /*!***********************************************************!*\
  100. !*** C:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __createBinding, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault, __classPrivateFieldGet, __classPrivateFieldSet */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__createBinding", function() { return __createBinding; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldGet", function() { return __classPrivateFieldGet; });
  128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__classPrivateFieldSet", function() { return __classPrivateFieldSet; });
  129. /*! *****************************************************************************
  130. Copyright (c) Microsoft Corporation.
  131. Permission to use, copy, modify, and/or distribute this software for any
  132. purpose with or without fee is hereby granted.
  133. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  134. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  135. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  136. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  137. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  138. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  139. PERFORMANCE OF THIS SOFTWARE.
  140. ***************************************************************************** */
  141. /* global Reflect, Promise */
  142. var extendStatics = function(d, b) {
  143. extendStatics = Object.setPrototypeOf ||
  144. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  145. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  146. return extendStatics(d, b);
  147. };
  148. function __extends(d, b) {
  149. extendStatics(d, b);
  150. function __() { this.constructor = d; }
  151. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  152. }
  153. var __assign = function() {
  154. __assign = Object.assign || function __assign(t) {
  155. for (var s, i = 1, n = arguments.length; i < n; i++) {
  156. s = arguments[i];
  157. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  158. }
  159. return t;
  160. }
  161. return __assign.apply(this, arguments);
  162. }
  163. function __rest(s, e) {
  164. var t = {};
  165. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  166. t[p] = s[p];
  167. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  168. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  169. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  170. t[p[i]] = s[p[i]];
  171. }
  172. return t;
  173. }
  174. function __decorate(decorators, target, key, desc) {
  175. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  176. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  177. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  178. return c > 3 && r && Object.defineProperty(target, key, r), r;
  179. }
  180. function __param(paramIndex, decorator) {
  181. return function (target, key) { decorator(target, key, paramIndex); }
  182. }
  183. function __metadata(metadataKey, metadataValue) {
  184. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  185. }
  186. function __awaiter(thisArg, _arguments, P, generator) {
  187. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  188. return new (P || (P = Promise))(function (resolve, reject) {
  189. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  190. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  191. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  192. step((generator = generator.apply(thisArg, _arguments || [])).next());
  193. });
  194. }
  195. function __generator(thisArg, body) {
  196. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  197. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  198. function verb(n) { return function (v) { return step([n, v]); }; }
  199. function step(op) {
  200. if (f) throw new TypeError("Generator is already executing.");
  201. while (_) try {
  202. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  203. if (y = 0, t) op = [op[0] & 2, t.value];
  204. switch (op[0]) {
  205. case 0: case 1: t = op; break;
  206. case 4: _.label++; return { value: op[1], done: false };
  207. case 5: _.label++; y = op[1]; op = [0]; continue;
  208. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  209. default:
  210. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  211. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  212. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  213. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  214. if (t[2]) _.ops.pop();
  215. _.trys.pop(); continue;
  216. }
  217. op = body.call(thisArg, _);
  218. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  219. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  220. }
  221. }
  222. var __createBinding = Object.create ? (function(o, m, k, k2) {
  223. if (k2 === undefined) k2 = k;
  224. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  225. }) : (function(o, m, k, k2) {
  226. if (k2 === undefined) k2 = k;
  227. o[k2] = m[k];
  228. });
  229. function __exportStar(m, o) {
  230. for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
  231. }
  232. function __values(o) {
  233. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  234. if (m) return m.call(o);
  235. if (o && typeof o.length === "number") return {
  236. next: function () {
  237. if (o && i >= o.length) o = void 0;
  238. return { value: o && o[i++], done: !o };
  239. }
  240. };
  241. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  242. }
  243. function __read(o, n) {
  244. var m = typeof Symbol === "function" && o[Symbol.iterator];
  245. if (!m) return o;
  246. var i = m.call(o), r, ar = [], e;
  247. try {
  248. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  249. }
  250. catch (error) { e = { error: error }; }
  251. finally {
  252. try {
  253. if (r && !r.done && (m = i["return"])) m.call(i);
  254. }
  255. finally { if (e) throw e.error; }
  256. }
  257. return ar;
  258. }
  259. function __spread() {
  260. for (var ar = [], i = 0; i < arguments.length; i++)
  261. ar = ar.concat(__read(arguments[i]));
  262. return ar;
  263. }
  264. function __spreadArrays() {
  265. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  266. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  267. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  268. r[k] = a[j];
  269. return r;
  270. };
  271. function __await(v) {
  272. return this instanceof __await ? (this.v = v, this) : new __await(v);
  273. }
  274. function __asyncGenerator(thisArg, _arguments, generator) {
  275. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  276. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  277. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  278. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  279. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  280. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  281. function fulfill(value) { resume("next", value); }
  282. function reject(value) { resume("throw", value); }
  283. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  284. }
  285. function __asyncDelegator(o) {
  286. var i, p;
  287. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  288. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  289. }
  290. function __asyncValues(o) {
  291. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  292. var m = o[Symbol.asyncIterator], i;
  293. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  294. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  295. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  296. }
  297. function __makeTemplateObject(cooked, raw) {
  298. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  299. return cooked;
  300. };
  301. var __setModuleDefault = Object.create ? (function(o, v) {
  302. Object.defineProperty(o, "default", { enumerable: true, value: v });
  303. }) : function(o, v) {
  304. o["default"] = v;
  305. };
  306. function __importStar(mod) {
  307. if (mod && mod.__esModule) return mod;
  308. var result = {};
  309. if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  310. __setModuleDefault(result, mod);
  311. return result;
  312. }
  313. function __importDefault(mod) {
  314. return (mod && mod.__esModule) ? mod : { default: mod };
  315. }
  316. function __classPrivateFieldGet(receiver, privateMap) {
  317. if (!privateMap.has(receiver)) {
  318. throw new TypeError("attempted to get private field on non-instance");
  319. }
  320. return privateMap.get(receiver);
  321. }
  322. function __classPrivateFieldSet(receiver, privateMap, value) {
  323. if (!privateMap.has(receiver)) {
  324. throw new TypeError("attempted to set private field on non-instance");
  325. }
  326. privateMap.set(receiver, value);
  327. return value;
  328. }
  329. /***/ }),
  330. /***/ "../../node_modules/webpack/buildin/global.js":
  331. /*!***********************************!*\
  332. !*** (webpack)/buildin/global.js ***!
  333. \***********************************/
  334. /*! no static exports found */
  335. /***/ (function(module, exports) {
  336. var g;
  337. // This works in non-strict mode
  338. g = (function() {
  339. return this;
  340. })();
  341. try {
  342. // This works if eval is allowed (see CSP)
  343. g = g || new Function("return this")();
  344. } catch (e) {
  345. // This works if the window reference is available
  346. if (typeof window === "object") g = window;
  347. }
  348. // g can still be undefined, but nothing to do about it...
  349. // We return undefined, instead of nothing here, so it's
  350. // easier to handle this case. if(!global) { ...}
  351. module.exports = g;
  352. /***/ }),
  353. /***/ "./2D/adtInstrumentation.ts":
  354. /*!**********************************!*\
  355. !*** ./2D/adtInstrumentation.ts ***!
  356. \**********************************/
  357. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  359. "use strict";
  360. __webpack_require__.r(__webpack_exports__);
  361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  362. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/observable");
  363. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  364. /**
  365. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  366. */
  367. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  368. /**
  369. * Instantiates a new advanced dynamic texture instrumentation.
  370. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  371. * @param texture Defines the AdvancedDynamicTexture to instrument
  372. */
  373. function AdvancedDynamicTextureInstrumentation(
  374. /**
  375. * Define the instrumented AdvancedDynamicTexture.
  376. */
  377. texture) {
  378. this.texture = texture;
  379. this._captureRenderTime = false;
  380. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  381. this._captureLayoutTime = false;
  382. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  383. // Observers
  384. this._onBeginRenderObserver = null;
  385. this._onEndRenderObserver = null;
  386. this._onBeginLayoutObserver = null;
  387. this._onEndLayoutObserver = null;
  388. }
  389. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  390. // Properties
  391. /**
  392. * Gets the perf counter used to capture render time
  393. */
  394. get: function () {
  395. return this._renderTime;
  396. },
  397. enumerable: false,
  398. configurable: true
  399. });
  400. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  401. /**
  402. * Gets the perf counter used to capture layout time
  403. */
  404. get: function () {
  405. return this._layoutTime;
  406. },
  407. enumerable: false,
  408. configurable: true
  409. });
  410. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  411. /**
  412. * Enable or disable the render time capture
  413. */
  414. get: function () {
  415. return this._captureRenderTime;
  416. },
  417. set: function (value) {
  418. var _this = this;
  419. if (value === this._captureRenderTime) {
  420. return;
  421. }
  422. this._captureRenderTime = value;
  423. if (value) {
  424. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  425. _this._renderTime.beginMonitoring();
  426. });
  427. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  428. _this._renderTime.endMonitoring(true);
  429. });
  430. }
  431. else {
  432. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  433. this._onBeginRenderObserver = null;
  434. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  435. this._onEndRenderObserver = null;
  436. }
  437. },
  438. enumerable: false,
  439. configurable: true
  440. });
  441. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  442. /**
  443. * Enable or disable the layout time capture
  444. */
  445. get: function () {
  446. return this._captureLayoutTime;
  447. },
  448. set: function (value) {
  449. var _this = this;
  450. if (value === this._captureLayoutTime) {
  451. return;
  452. }
  453. this._captureLayoutTime = value;
  454. if (value) {
  455. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  456. _this._layoutTime.beginMonitoring();
  457. });
  458. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  459. _this._layoutTime.endMonitoring(true);
  460. });
  461. }
  462. else {
  463. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  464. this._onBeginLayoutObserver = null;
  465. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  466. this._onEndLayoutObserver = null;
  467. }
  468. },
  469. enumerable: false,
  470. configurable: true
  471. });
  472. /**
  473. * Dispose and release associated resources.
  474. */
  475. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  476. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  477. this._onBeginRenderObserver = null;
  478. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  479. this._onEndRenderObserver = null;
  480. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  481. this._onBeginLayoutObserver = null;
  482. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  483. this._onEndLayoutObserver = null;
  484. this.texture = null;
  485. };
  486. return AdvancedDynamicTextureInstrumentation;
  487. }());
  488. /***/ }),
  489. /***/ "./2D/advancedDynamicTexture.ts":
  490. /*!**************************************!*\
  491. !*** ./2D/advancedDynamicTexture.ts ***!
  492. \**************************************/
  493. /*! exports provided: AdvancedDynamicTexture */
  494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  495. "use strict";
  496. __webpack_require__.r(__webpack_exports__);
  497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  498. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  499. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  500. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  501. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  502. /* harmony import */ var _controls_control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./controls/control */ "./2D/controls/control.ts");
  503. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  504. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  505. /**
  506. * Class used to create texture to support 2D GUI elements
  507. * @see https://doc.babylonjs.com/how_to/gui
  508. */
  509. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  510. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  511. /**
  512. * Creates a new AdvancedDynamicTexture
  513. * @param name defines the name of the texture
  514. * @param width defines the width of the texture
  515. * @param height defines the height of the texture
  516. * @param scene defines the hosting scene
  517. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  518. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  519. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  520. */
  521. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode, invertY) {
  522. if (width === void 0) { width = 0; }
  523. if (height === void 0) { height = 0; }
  524. if (generateMipMaps === void 0) { generateMipMaps = false; }
  525. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  526. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA, invertY) || this;
  527. _this._isDirty = false;
  528. /** @hidden */
  529. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  530. /** @hidden */
  531. _this._lastControlOver = {};
  532. /** @hidden */
  533. _this._lastControlDown = {};
  534. /** @hidden */
  535. _this._capturingControl = {};
  536. /** @hidden */
  537. _this._linkedControls = new Array();
  538. _this._isFullscreen = false;
  539. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  540. _this._idealWidth = 0;
  541. _this._idealHeight = 0;
  542. _this._useSmallestIdeal = false;
  543. _this._renderAtIdealSize = false;
  544. _this._blockNextFocusCheck = false;
  545. _this._renderScale = 1;
  546. _this._cursorChanged = false;
  547. _this._defaultMousePointerId = 0;
  548. /** @hidden */
  549. _this._numLayoutCalls = 0;
  550. /** @hidden */
  551. _this._numRenderCalls = 0;
  552. /**
  553. * Define type to string to ensure compatibility across browsers
  554. * Safari doesn't support DataTransfer constructor
  555. */
  556. _this._clipboardData = "";
  557. /**
  558. * Observable event triggered each time an clipboard event is received from the rendering canvas
  559. */
  560. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  561. /**
  562. * Observable event triggered each time a pointer down is intercepted by a control
  563. */
  564. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  565. /**
  566. * Observable event triggered before layout is evaluated
  567. */
  568. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  569. /**
  570. * Observable event triggered after the layout was evaluated
  571. */
  572. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  573. /**
  574. * Observable event triggered before the texture is rendered
  575. */
  576. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  577. /**
  578. * Observable event triggered after the texture was rendered
  579. */
  580. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  581. /**
  582. * Gets or sets a boolean defining if alpha is stored as premultiplied
  583. */
  584. _this.premulAlpha = false;
  585. /**
  586. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  587. */
  588. _this.applyYInversionOnUpdate = true;
  589. _this._useInvalidateRectOptimization = true;
  590. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  591. _this._invalidatedRectangle = null;
  592. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_5__["Measure"](0, 0, 0, 0);
  593. /** @hidden */
  594. _this.onClipboardCopy = function (rawEvt) {
  595. var evt = rawEvt;
  596. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  597. _this.onClipboardObservable.notifyObservers(ev);
  598. evt.preventDefault();
  599. };
  600. /** @hidden */
  601. _this.onClipboardCut = function (rawEvt) {
  602. var evt = rawEvt;
  603. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  604. _this.onClipboardObservable.notifyObservers(ev);
  605. evt.preventDefault();
  606. };
  607. /** @hidden */
  608. _this.onClipboardPaste = function (rawEvt) {
  609. var evt = rawEvt;
  610. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  611. _this.onClipboardObservable.notifyObservers(ev);
  612. evt.preventDefault();
  613. };
  614. scene = _this.getScene();
  615. if (!scene || !_this._texture) {
  616. return _this;
  617. }
  618. _this._rootElement = scene.getEngine().getInputElement();
  619. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  620. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  621. if (!_this._focusedControl) {
  622. return;
  623. }
  624. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  625. _this._focusedControl.processKeyboard(info.event);
  626. }
  627. info.skipOnPointerObservable = true;
  628. });
  629. _this._rootContainer._link(_this);
  630. _this.hasAlpha = true;
  631. if (!width || !height) {
  632. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  633. _this._onResize();
  634. }
  635. _this._texture.isReady = true;
  636. return _this;
  637. }
  638. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  639. /** Gets the number of layout calls made the last time the ADT has been rendered */
  640. get: function () {
  641. return this._numLayoutCalls;
  642. },
  643. enumerable: false,
  644. configurable: true
  645. });
  646. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  647. /** Gets the number of render calls made the last time the ADT has been rendered */
  648. get: function () {
  649. return this._numRenderCalls;
  650. },
  651. enumerable: false,
  652. configurable: true
  653. });
  654. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  655. /**
  656. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  657. * Useful when you want more antialiasing
  658. */
  659. get: function () {
  660. return this._renderScale;
  661. },
  662. set: function (value) {
  663. if (value === this._renderScale) {
  664. return;
  665. }
  666. this._renderScale = value;
  667. this._onResize();
  668. },
  669. enumerable: false,
  670. configurable: true
  671. });
  672. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  673. /** Gets or sets the background color */
  674. get: function () {
  675. return this._background;
  676. },
  677. set: function (value) {
  678. if (this._background === value) {
  679. return;
  680. }
  681. this._background = value;
  682. this.markAsDirty();
  683. },
  684. enumerable: false,
  685. configurable: true
  686. });
  687. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  688. /**
  689. * Gets or sets the ideal width used to design controls.
  690. * The GUI will then rescale everything accordingly
  691. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  692. */
  693. get: function () {
  694. return this._idealWidth;
  695. },
  696. set: function (value) {
  697. if (this._idealWidth === value) {
  698. return;
  699. }
  700. this._idealWidth = value;
  701. this.markAsDirty();
  702. this._rootContainer._markAllAsDirty();
  703. },
  704. enumerable: false,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  708. /**
  709. * Gets or sets the ideal height used to design controls.
  710. * The GUI will then rescale everything accordingly
  711. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  712. */
  713. get: function () {
  714. return this._idealHeight;
  715. },
  716. set: function (value) {
  717. if (this._idealHeight === value) {
  718. return;
  719. }
  720. this._idealHeight = value;
  721. this.markAsDirty();
  722. this._rootContainer._markAllAsDirty();
  723. },
  724. enumerable: false,
  725. configurable: true
  726. });
  727. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  728. /**
  729. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  730. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  731. */
  732. get: function () {
  733. return this._useSmallestIdeal;
  734. },
  735. set: function (value) {
  736. if (this._useSmallestIdeal === value) {
  737. return;
  738. }
  739. this._useSmallestIdeal = value;
  740. this.markAsDirty();
  741. this._rootContainer._markAllAsDirty();
  742. },
  743. enumerable: false,
  744. configurable: true
  745. });
  746. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  747. /**
  748. * Gets or sets a boolean indicating if adaptive scaling must be used
  749. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  750. */
  751. get: function () {
  752. return this._renderAtIdealSize;
  753. },
  754. set: function (value) {
  755. if (this._renderAtIdealSize === value) {
  756. return;
  757. }
  758. this._renderAtIdealSize = value;
  759. this._onResize();
  760. },
  761. enumerable: false,
  762. configurable: true
  763. });
  764. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  765. /**
  766. * Gets the ratio used when in "ideal mode"
  767. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  768. * */
  769. get: function () {
  770. var rwidth = 0;
  771. var rheight = 0;
  772. if (this._idealWidth) {
  773. rwidth = (this.getSize().width) / this._idealWidth;
  774. }
  775. if (this._idealHeight) {
  776. rheight = (this.getSize().height) / this._idealHeight;
  777. }
  778. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  779. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  780. }
  781. if (this._idealWidth) { // horizontal
  782. return rwidth;
  783. }
  784. if (this._idealHeight) { // vertical
  785. return rheight;
  786. }
  787. return 1;
  788. },
  789. enumerable: false,
  790. configurable: true
  791. });
  792. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  793. /**
  794. * Gets the underlying layer used to render the texture when in fullscreen mode
  795. */
  796. get: function () {
  797. return this._layerToDispose;
  798. },
  799. enumerable: false,
  800. configurable: true
  801. });
  802. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  803. /**
  804. * Gets the root container control
  805. */
  806. get: function () {
  807. return this._rootContainer;
  808. },
  809. enumerable: false,
  810. configurable: true
  811. });
  812. /**
  813. * Returns an array containing the root container.
  814. * This is mostly used to let the Inspector introspects the ADT
  815. * @returns an array containing the rootContainer
  816. */
  817. AdvancedDynamicTexture.prototype.getChildren = function () {
  818. return [this._rootContainer];
  819. };
  820. /**
  821. * Will return all controls that are inside this texture
  822. * @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
  823. * @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
  824. * @return all child controls
  825. */
  826. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  827. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  828. };
  829. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  830. /**
  831. * Gets or sets the current focused control
  832. */
  833. get: function () {
  834. return this._focusedControl;
  835. },
  836. set: function (control) {
  837. if (this._focusedControl == control) {
  838. return;
  839. }
  840. if (this._focusedControl) {
  841. this._focusedControl.onBlur();
  842. }
  843. if (control) {
  844. control.onFocus();
  845. }
  846. this._focusedControl = control;
  847. },
  848. enumerable: false,
  849. configurable: true
  850. });
  851. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  852. /**
  853. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  854. */
  855. get: function () {
  856. if (!this.layer) {
  857. return true;
  858. }
  859. return (!this.layer.isBackground);
  860. },
  861. set: function (value) {
  862. if (!this.layer) {
  863. return;
  864. }
  865. if (this.layer.isBackground === !value) {
  866. return;
  867. }
  868. this.layer.isBackground = !value;
  869. },
  870. enumerable: false,
  871. configurable: true
  872. });
  873. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  874. /**
  875. * Gets or set information about clipboardData
  876. */
  877. get: function () {
  878. return this._clipboardData;
  879. },
  880. set: function (value) {
  881. this._clipboardData = value;
  882. },
  883. enumerable: false,
  884. configurable: true
  885. });
  886. /**
  887. * Get the current class name of the texture useful for serialization or dynamic coding.
  888. * @returns "AdvancedDynamicTexture"
  889. */
  890. AdvancedDynamicTexture.prototype.getClassName = function () {
  891. return "AdvancedDynamicTexture";
  892. };
  893. /**
  894. * Function used to execute a function on all controls
  895. * @param func defines the function to execute
  896. * @param container defines the container where controls belong. If null the root container will be used
  897. */
  898. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  899. if (!container) {
  900. container = this._rootContainer;
  901. }
  902. func(container);
  903. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  904. var child = _a[_i];
  905. if (child.children) {
  906. this.executeOnAllControls(func, child);
  907. continue;
  908. }
  909. func(child);
  910. }
  911. };
  912. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  913. /**
  914. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  915. */
  916. get: function () {
  917. return this._useInvalidateRectOptimization;
  918. },
  919. set: function (value) {
  920. this._useInvalidateRectOptimization = value;
  921. },
  922. enumerable: false,
  923. configurable: true
  924. });
  925. /**
  926. * Invalidates a rectangle area on the gui texture
  927. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  928. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  929. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  930. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  931. */
  932. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  933. if (!this._useInvalidateRectOptimization) {
  934. return;
  935. }
  936. if (!this._invalidatedRectangle) {
  937. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_5__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  938. }
  939. else {
  940. // Compute intersection
  941. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  942. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  943. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  944. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  945. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  946. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  947. }
  948. };
  949. /**
  950. * Marks the texture as dirty forcing a complete update
  951. */
  952. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  953. this._isDirty = true;
  954. };
  955. /**
  956. * Helper function used to create a new style
  957. * @returns a new style
  958. * @see https://doc.babylonjs.com/how_to/gui#styles
  959. */
  960. AdvancedDynamicTexture.prototype.createStyle = function () {
  961. return new _style__WEBPACK_IMPORTED_MODULE_4__["Style"](this);
  962. };
  963. /**
  964. * Adds a new control to the root container
  965. * @param control defines the control to add
  966. * @returns the current texture
  967. */
  968. AdvancedDynamicTexture.prototype.addControl = function (control) {
  969. this._rootContainer.addControl(control);
  970. return this;
  971. };
  972. /**
  973. * Removes a control from the root container
  974. * @param control defines the control to remove
  975. * @returns the current texture
  976. */
  977. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  978. this._rootContainer.removeControl(control);
  979. return this;
  980. };
  981. /**
  982. * Release all resources
  983. */
  984. AdvancedDynamicTexture.prototype.dispose = function () {
  985. var scene = this.getScene();
  986. if (!scene) {
  987. return;
  988. }
  989. this._rootElement = null;
  990. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  991. if (this._resizeObserver) {
  992. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  993. }
  994. if (this._pointerMoveObserver) {
  995. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  996. }
  997. if (this._pointerObserver) {
  998. scene.onPointerObservable.remove(this._pointerObserver);
  999. }
  1000. if (this._preKeyboardObserver) {
  1001. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  1002. }
  1003. if (this._canvasPointerOutObserver) {
  1004. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  1005. }
  1006. if (this._canvasBlurObserver) {
  1007. scene.getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver);
  1008. }
  1009. if (this._layerToDispose) {
  1010. this._layerToDispose.texture = null;
  1011. this._layerToDispose.dispose();
  1012. this._layerToDispose = null;
  1013. }
  1014. this._rootContainer.dispose();
  1015. this.onClipboardObservable.clear();
  1016. this.onControlPickedObservable.clear();
  1017. this.onBeginRenderObservable.clear();
  1018. this.onEndRenderObservable.clear();
  1019. this.onBeginLayoutObservable.clear();
  1020. this.onEndLayoutObservable.clear();
  1021. _super.prototype.dispose.call(this);
  1022. };
  1023. AdvancedDynamicTexture.prototype._onResize = function () {
  1024. var scene = this.getScene();
  1025. if (!scene) {
  1026. return;
  1027. }
  1028. // Check size
  1029. var engine = scene.getEngine();
  1030. var textureSize = this.getSize();
  1031. var renderWidth = engine.getRenderWidth() * this._renderScale;
  1032. var renderHeight = engine.getRenderHeight() * this._renderScale;
  1033. if (this._renderAtIdealSize) {
  1034. if (this._idealWidth) {
  1035. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  1036. renderWidth = this._idealWidth;
  1037. }
  1038. else if (this._idealHeight) {
  1039. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1040. renderHeight = this._idealHeight;
  1041. }
  1042. }
  1043. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1044. this.scaleTo(renderWidth, renderHeight);
  1045. this.markAsDirty();
  1046. if (this._idealWidth || this._idealHeight) {
  1047. this._rootContainer._markAllAsDirty();
  1048. }
  1049. }
  1050. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1051. };
  1052. /** @hidden */
  1053. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1054. var engine = scene.getEngine();
  1055. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1056. };
  1057. /**
  1058. * Get screen coordinates for a vector3
  1059. * @param position defines the position to project
  1060. * @param worldMatrix defines the world matrix to use
  1061. * @returns the projected position
  1062. */
  1063. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1064. var scene = this.getScene();
  1065. if (!scene) {
  1066. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1067. }
  1068. var globalViewport = this._getGlobalViewport(scene);
  1069. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1070. projectedPosition.scaleInPlace(this.renderScale);
  1071. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1072. };
  1073. /**
  1074. * Get screen coordinates for a vector3
  1075. * @param position defines the position to project
  1076. * @param worldMatrix defines the world matrix to use
  1077. * @returns the projected position with Z
  1078. */
  1079. AdvancedDynamicTexture.prototype.getProjectedPositionWithZ = function (position, worldMatrix) {
  1080. var scene = this.getScene();
  1081. if (!scene) {
  1082. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  1083. }
  1084. var globalViewport = this._getGlobalViewport(scene);
  1085. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1086. projectedPosition.scaleInPlace(this.renderScale);
  1087. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"](projectedPosition.x, projectedPosition.y, projectedPosition.z);
  1088. };
  1089. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1090. if (this._layerToDispose) {
  1091. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1092. return;
  1093. }
  1094. }
  1095. if (this._isFullscreen && this._linkedControls.length) {
  1096. var scene = this.getScene();
  1097. if (!scene) {
  1098. return;
  1099. }
  1100. var globalViewport = this._getGlobalViewport(scene);
  1101. var _loop_1 = function (control) {
  1102. if (!control.isVisible) {
  1103. return "continue";
  1104. }
  1105. var mesh = control._linkedMesh;
  1106. if (!mesh || mesh.isDisposed()) {
  1107. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1108. control.linkWithMesh(null);
  1109. });
  1110. return "continue";
  1111. }
  1112. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1113. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1114. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1115. control.notRenderable = true;
  1116. return "continue";
  1117. }
  1118. control.notRenderable = false;
  1119. // Account for RenderScale.
  1120. projectedPosition.scaleInPlace(this_1.renderScale);
  1121. control._moveToProjectedPosition(projectedPosition);
  1122. };
  1123. var this_1 = this;
  1124. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1125. var control = _a[_i];
  1126. _loop_1(control);
  1127. }
  1128. }
  1129. if (!this._isDirty && !this._rootContainer.isDirty) {
  1130. return;
  1131. }
  1132. this._isDirty = false;
  1133. this._render();
  1134. this.update(this.applyYInversionOnUpdate, this.premulAlpha);
  1135. };
  1136. AdvancedDynamicTexture.prototype._render = function () {
  1137. var textureSize = this.getSize();
  1138. var renderWidth = textureSize.width;
  1139. var renderHeight = textureSize.height;
  1140. var context = this.getContext();
  1141. context.font = "18px Arial";
  1142. context.strokeStyle = "white";
  1143. // Layout
  1144. this.onBeginLayoutObservable.notifyObservers(this);
  1145. var measure = new _measure__WEBPACK_IMPORTED_MODULE_5__["Measure"](0, 0, renderWidth, renderHeight);
  1146. this._numLayoutCalls = 0;
  1147. this._rootContainer._layout(measure, context);
  1148. this.onEndLayoutObservable.notifyObservers(this);
  1149. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1150. // Clear
  1151. if (this._invalidatedRectangle) {
  1152. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1153. }
  1154. else {
  1155. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1156. }
  1157. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1158. if (this._background) {
  1159. context.save();
  1160. context.fillStyle = this._background;
  1161. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1162. context.restore();
  1163. }
  1164. // Render
  1165. this.onBeginRenderObservable.notifyObservers(this);
  1166. this._numRenderCalls = 0;
  1167. this._rootContainer._render(context, this._invalidatedRectangle);
  1168. this.onEndRenderObservable.notifyObservers(this);
  1169. this._invalidatedRectangle = null;
  1170. };
  1171. /** @hidden */
  1172. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1173. if (this._rootElement) {
  1174. this._rootElement.style.cursor = cursor;
  1175. this._cursorChanged = true;
  1176. }
  1177. };
  1178. /** @hidden */
  1179. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1180. this._lastControlDown[pointerId] = control;
  1181. this.onControlPickedObservable.notifyObservers(control);
  1182. };
  1183. AdvancedDynamicTexture.prototype._doPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  1184. var scene = this.getScene();
  1185. if (!scene) {
  1186. return;
  1187. }
  1188. var engine = scene.getEngine();
  1189. var textureSize = this.getSize();
  1190. if (this._isFullscreen) {
  1191. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1192. var viewport = camera.viewport;
  1193. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1194. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1195. }
  1196. if (this._capturingControl[pointerId]) {
  1197. this._capturingControl[pointerId]._processObservables(type, x, y, pi, pointerId, buttonIndex);
  1198. return;
  1199. }
  1200. this._cursorChanged = false;
  1201. if (!this._rootContainer._processPicking(x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY)) {
  1202. this._changeCursor("");
  1203. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1204. if (this._lastControlOver[pointerId]) {
  1205. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId], pi);
  1206. delete this._lastControlOver[pointerId];
  1207. }
  1208. }
  1209. }
  1210. if (!this._cursorChanged) {
  1211. this._changeCursor("");
  1212. }
  1213. this._manageFocus();
  1214. };
  1215. /** @hidden */
  1216. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1217. for (var pointerId in list) {
  1218. if (!list.hasOwnProperty(pointerId)) {
  1219. continue;
  1220. }
  1221. var lastControlOver = list[pointerId];
  1222. if (lastControlOver === control) {
  1223. delete list[pointerId];
  1224. }
  1225. }
  1226. };
  1227. /** @hidden */
  1228. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1229. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1230. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1231. };
  1232. /** Attach to all scene events required to support pointer events */
  1233. AdvancedDynamicTexture.prototype.attach = function () {
  1234. var _this = this;
  1235. var scene = this.getScene();
  1236. if (!scene) {
  1237. return;
  1238. }
  1239. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1240. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1241. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1242. return;
  1243. }
  1244. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1245. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1246. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN
  1247. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  1248. return;
  1249. }
  1250. if (!scene) {
  1251. return;
  1252. }
  1253. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE && pi.event.pointerId) {
  1254. _this._defaultMousePointerId = pi.event.pointerId; // This is required to make sure we have the correct pointer ID for wheel
  1255. }
  1256. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1257. var engine = scene.getEngine();
  1258. if (!camera) {
  1259. tempViewport.x = 0;
  1260. tempViewport.y = 0;
  1261. tempViewport.width = engine.getRenderWidth();
  1262. tempViewport.height = engine.getRenderHeight();
  1263. }
  1264. else {
  1265. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1266. }
  1267. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1268. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1269. _this._shouldBlockPointer = false;
  1270. // Do picking modifies _shouldBlockPointer
  1271. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1272. _this._doPicking(x, y, pi, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
  1273. // Avoid overwriting a true skipOnPointerObservable to false
  1274. if (_this._shouldBlockPointer) {
  1275. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1276. }
  1277. });
  1278. this._attachToOnPointerOut(scene);
  1279. this._attachToOnBlur(scene);
  1280. };
  1281. /**
  1282. * Register the clipboard Events onto the canvas
  1283. */
  1284. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1285. self.addEventListener("copy", this.onClipboardCopy, false);
  1286. self.addEventListener("cut", this.onClipboardCut, false);
  1287. self.addEventListener("paste", this.onClipboardPaste, false);
  1288. };
  1289. /**
  1290. * Unregister the clipboard Events from the canvas
  1291. */
  1292. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1293. self.removeEventListener("copy", this.onClipboardCopy);
  1294. self.removeEventListener("cut", this.onClipboardCut);
  1295. self.removeEventListener("paste", this.onClipboardPaste);
  1296. };
  1297. /**
  1298. * Connect the texture to a hosting mesh to enable interactions
  1299. * @param mesh defines the mesh to attach to
  1300. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1301. */
  1302. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1303. var _this = this;
  1304. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1305. var scene = this.getScene();
  1306. if (!scene) {
  1307. return;
  1308. }
  1309. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1310. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1311. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1312. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1313. return;
  1314. }
  1315. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1316. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1317. var uv = pi.pickInfo.getTextureCoordinates();
  1318. if (uv) {
  1319. var size = _this.getSize();
  1320. _this._doPicking(uv.x * size.width, (_this.applyYInversionOnUpdate ? (1.0 - uv.y) : uv.y) * size.height, pi, pi.type, pointerId, pi.event.button);
  1321. }
  1322. }
  1323. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1324. if (_this._lastControlDown[pointerId]) {
  1325. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1326. }
  1327. delete _this._lastControlDown[pointerId];
  1328. if (_this.focusedControl) {
  1329. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1330. var canMoveFocus = true;
  1331. if (friendlyControls) {
  1332. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1333. var control = friendlyControls_1[_i];
  1334. // Same host, no need to keep the focus
  1335. if (_this === control._host) {
  1336. continue;
  1337. }
  1338. // Different hosts
  1339. var otherHost = control._host;
  1340. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1341. canMoveFocus = false;
  1342. break;
  1343. }
  1344. }
  1345. }
  1346. if (canMoveFocus) {
  1347. _this.focusedControl = null;
  1348. }
  1349. }
  1350. }
  1351. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1352. if (_this._lastControlOver[pointerId]) {
  1353. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], pi, true);
  1354. }
  1355. delete _this._lastControlOver[pointerId];
  1356. }
  1357. });
  1358. mesh.enablePointerMoveEvents = supportPointerMove;
  1359. this._attachToOnPointerOut(scene);
  1360. this._attachToOnBlur(scene);
  1361. };
  1362. /**
  1363. * Move the focus to a specific control
  1364. * @param control defines the control which will receive the focus
  1365. */
  1366. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1367. this.focusedControl = control;
  1368. this._lastPickedControl = control;
  1369. this._blockNextFocusCheck = true;
  1370. };
  1371. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1372. if (this._blockNextFocusCheck) {
  1373. this._blockNextFocusCheck = false;
  1374. this._lastPickedControl = this._focusedControl;
  1375. return;
  1376. }
  1377. // Focus management
  1378. if (this._focusedControl) {
  1379. if (this._focusedControl !== this._lastPickedControl) {
  1380. if (this._lastPickedControl.isFocusInvisible) {
  1381. return;
  1382. }
  1383. this.focusedControl = null;
  1384. }
  1385. }
  1386. };
  1387. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1388. var _this = this;
  1389. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1390. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1391. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId], null);
  1392. }
  1393. delete _this._lastControlOver[pointerEvent.pointerId];
  1394. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1395. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1396. delete _this._lastControlDown[pointerEvent.pointerId];
  1397. }
  1398. });
  1399. };
  1400. AdvancedDynamicTexture.prototype._attachToOnBlur = function (scene) {
  1401. var _this = this;
  1402. this._canvasBlurObserver = scene.getEngine().onCanvasBlurObservable.add(function (pointerEvent) {
  1403. Object.entries(_this._lastControlDown).forEach(function (_a) {
  1404. var key = _a[0], value = _a[1];
  1405. value._onCanvasBlur();
  1406. });
  1407. _this._lastControlDown = {};
  1408. });
  1409. };
  1410. /**
  1411. * Serializes the entire GUI system
  1412. * @returns an object with the JSON serialized data
  1413. */
  1414. AdvancedDynamicTexture.prototype.serializeContent = function () {
  1415. var serializationObject = {
  1416. root: {}
  1417. };
  1418. this._rootContainer.serialize(serializationObject.root);
  1419. return serializationObject;
  1420. };
  1421. /**
  1422. * Recreate the content of the ADT from a JSON object
  1423. * @param serializedObject define the JSON serialized object to restore from
  1424. */
  1425. AdvancedDynamicTexture.prototype.parseContent = function (serializedObject) {
  1426. this._rootContainer = _controls_control__WEBPACK_IMPORTED_MODULE_3__["Control"].Parse(serializedObject.root, this);
  1427. };
  1428. /**
  1429. * Recreate the content of the ADT from a snippet saved by the GUI editor
  1430. * @param snippetId defines the snippet to load
  1431. * @returns a promise that will resolve on success
  1432. */
  1433. AdvancedDynamicTexture.prototype.parseFromSnippetAsync = function (snippetId) {
  1434. var _this = this;
  1435. if (snippetId === "_BLANK") {
  1436. return Promise.resolve();
  1437. }
  1438. return new Promise(function (resolve, reject) {
  1439. var request = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["WebRequest"]();
  1440. request.addEventListener("readystatechange", function () {
  1441. if (request.readyState == 4) {
  1442. if (request.status == 200) {
  1443. var snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);
  1444. var serializationObject = JSON.parse(snippet.gui);
  1445. _this.parseContent(serializationObject);
  1446. _this.snippetId = snippetId;
  1447. resolve();
  1448. }
  1449. else {
  1450. reject("Unable to load the snippet " + snippetId);
  1451. }
  1452. }
  1453. });
  1454. request.open("GET", AdvancedDynamicTexture.SnippetUrl + "/" + snippetId.replace(/#/g, "/"));
  1455. request.send();
  1456. });
  1457. };
  1458. // Statics
  1459. /**
  1460. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1461. * @param mesh defines the mesh which will receive the texture
  1462. * @param width defines the texture width (1024 by default)
  1463. * @param height defines the texture height (1024 by default)
  1464. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1465. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1466. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  1467. * @returns a new AdvancedDynamicTexture
  1468. */
  1469. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting, invertY) {
  1470. if (width === void 0) { width = 1024; }
  1471. if (height === void 0) { height = 1024; }
  1472. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1473. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1474. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, invertY);
  1475. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1476. material.backFaceCulling = false;
  1477. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1478. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1479. if (onlyAlphaTesting) {
  1480. material.diffuseTexture = result;
  1481. material.emissiveTexture = result;
  1482. result.hasAlpha = true;
  1483. }
  1484. else {
  1485. material.emissiveTexture = result;
  1486. material.opacityTexture = result;
  1487. }
  1488. mesh.material = material;
  1489. result.attachToMesh(mesh, supportPointerMove);
  1490. return result;
  1491. };
  1492. /**
  1493. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh) BUT do not create a new material for the mesh. You will be responsible for connecting the texture
  1494. * @param mesh defines the mesh which will receive the texture
  1495. * @param width defines the texture width (1024 by default)
  1496. * @param height defines the texture height (1024 by default)
  1497. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1498. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  1499. * @returns a new AdvancedDynamicTexture
  1500. */
  1501. AdvancedDynamicTexture.CreateForMeshTexture = function (mesh, width, height, supportPointerMove, invertY) {
  1502. if (width === void 0) { width = 1024; }
  1503. if (height === void 0) { height = 1024; }
  1504. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1505. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, invertY);
  1506. result.attachToMesh(mesh, supportPointerMove);
  1507. return result;
  1508. };
  1509. /**
  1510. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1511. * In this mode the texture will rely on a layer for its rendering.
  1512. * This allows it to be treated like any other layer.
  1513. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1514. * LayerMask is set through advancedTexture.layer.layerMask
  1515. * @param name defines name for the texture
  1516. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1517. * @param scene defines the hsoting scene
  1518. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1519. * @returns a new AdvancedDynamicTexture
  1520. */
  1521. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1522. if (foreground === void 0) { foreground = true; }
  1523. if (scene === void 0) { scene = null; }
  1524. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1525. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1526. // Display
  1527. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1528. layer.texture = result;
  1529. result._layerToDispose = layer;
  1530. result._isFullscreen = true;
  1531. // Attach
  1532. result.attach();
  1533. return result;
  1534. };
  1535. /** Define the Uurl to load snippets */
  1536. AdvancedDynamicTexture.SnippetUrl = "https://snippet.babylonjs.com";
  1537. return AdvancedDynamicTexture;
  1538. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1539. /***/ }),
  1540. /***/ "./2D/controls/button.ts":
  1541. /*!*******************************!*\
  1542. !*** ./2D/controls/button.ts ***!
  1543. \*******************************/
  1544. /*! exports provided: Button */
  1545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1546. "use strict";
  1547. __webpack_require__.r(__webpack_exports__);
  1548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1549. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1550. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1551. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1552. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1553. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1554. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  1555. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1556. /**
  1557. * Class used to create 2D buttons
  1558. */
  1559. var Button = /** @class */ (function (_super) {
  1560. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1561. /**
  1562. * Creates a new Button
  1563. * @param name defines the name of the button
  1564. */
  1565. function Button(name) {
  1566. var _this = _super.call(this, name) || this;
  1567. _this.name = name;
  1568. /**
  1569. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1570. */
  1571. _this.delegatePickingToChildren = false;
  1572. _this.thickness = 1;
  1573. _this.isPointerBlocker = true;
  1574. var alphaStore = null;
  1575. _this.pointerEnterAnimation = function () {
  1576. alphaStore = _this.alpha;
  1577. _this.alpha -= 0.1;
  1578. };
  1579. _this.pointerOutAnimation = function () {
  1580. if (alphaStore !== null) {
  1581. _this.alpha = alphaStore;
  1582. }
  1583. };
  1584. _this.pointerDownAnimation = function () {
  1585. _this.scaleX -= 0.05;
  1586. _this.scaleY -= 0.05;
  1587. };
  1588. _this.pointerUpAnimation = function () {
  1589. _this.scaleX += 0.05;
  1590. _this.scaleY += 0.05;
  1591. };
  1592. return _this;
  1593. }
  1594. Object.defineProperty(Button.prototype, "image", {
  1595. /**
  1596. * Returns the image part of the button (if any)
  1597. */
  1598. get: function () {
  1599. return this._image;
  1600. },
  1601. enumerable: false,
  1602. configurable: true
  1603. });
  1604. Object.defineProperty(Button.prototype, "textBlock", {
  1605. /**
  1606. * Returns the image part of the button (if any)
  1607. */
  1608. get: function () {
  1609. return this._textBlock;
  1610. },
  1611. enumerable: false,
  1612. configurable: true
  1613. });
  1614. Button.prototype._getTypeName = function () {
  1615. return "Button";
  1616. };
  1617. // While being a container, the button behaves like a control.
  1618. /** @hidden */
  1619. Button.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  1620. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1621. return false;
  1622. }
  1623. if (!_super.prototype.contains.call(this, x, y)) {
  1624. return false;
  1625. }
  1626. if (this.delegatePickingToChildren) {
  1627. var contains = false;
  1628. for (var index = this._children.length - 1; index >= 0; index--) {
  1629. var child = this._children[index];
  1630. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1631. contains = true;
  1632. break;
  1633. }
  1634. }
  1635. if (!contains) {
  1636. return false;
  1637. }
  1638. }
  1639. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  1640. return true;
  1641. };
  1642. /** @hidden */
  1643. Button.prototype._onPointerEnter = function (target, pi) {
  1644. if (!_super.prototype._onPointerEnter.call(this, target, pi)) {
  1645. return false;
  1646. }
  1647. if (this.pointerEnterAnimation) {
  1648. this.pointerEnterAnimation();
  1649. }
  1650. return true;
  1651. };
  1652. /** @hidden */
  1653. Button.prototype._onPointerOut = function (target, pi, force) {
  1654. if (force === void 0) { force = false; }
  1655. if (this.pointerOutAnimation) {
  1656. this.pointerOutAnimation();
  1657. }
  1658. _super.prototype._onPointerOut.call(this, target, pi, force);
  1659. };
  1660. /** @hidden */
  1661. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  1662. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  1663. return false;
  1664. }
  1665. if (this.pointerDownAnimation) {
  1666. this.pointerDownAnimation();
  1667. }
  1668. return true;
  1669. };
  1670. /** @hidden */
  1671. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  1672. if (this.pointerUpAnimation) {
  1673. this.pointerUpAnimation();
  1674. }
  1675. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  1676. };
  1677. // Statics
  1678. /**
  1679. * Creates a new button made with an image and a text
  1680. * @param name defines the name of the button
  1681. * @param text defines the text of the button
  1682. * @param imageUrl defines the url of the image
  1683. * @returns a new Button
  1684. */
  1685. Button.CreateImageButton = function (name, text, imageUrl) {
  1686. var result = new this(name);
  1687. // Adding text
  1688. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1689. textBlock.textWrapping = true;
  1690. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1691. textBlock.paddingLeft = "20%";
  1692. result.addControl(textBlock);
  1693. // Adding image
  1694. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1695. iconImage.width = "20%";
  1696. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1697. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1698. result.addControl(iconImage);
  1699. // Store
  1700. result._image = iconImage;
  1701. result._textBlock = textBlock;
  1702. return result;
  1703. };
  1704. /**
  1705. * Creates a new button made with an image
  1706. * @param name defines the name of the button
  1707. * @param imageUrl defines the url of the image
  1708. * @returns a new Button
  1709. */
  1710. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1711. var result = new this(name);
  1712. // Adding image
  1713. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1714. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1715. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1716. result.addControl(iconImage);
  1717. // Store
  1718. result._image = iconImage;
  1719. return result;
  1720. };
  1721. /**
  1722. * Creates a new button made with a text
  1723. * @param name defines the name of the button
  1724. * @param text defines the text of the button
  1725. * @returns a new Button
  1726. */
  1727. Button.CreateSimpleButton = function (name, text) {
  1728. var result = new this(name);
  1729. // Adding text
  1730. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1731. textBlock.textWrapping = true;
  1732. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1733. result.addControl(textBlock);
  1734. // Store
  1735. result._textBlock = textBlock;
  1736. return result;
  1737. };
  1738. /**
  1739. * Creates a new button made with an image and a centered text
  1740. * @param name defines the name of the button
  1741. * @param text defines the text of the button
  1742. * @param imageUrl defines the url of the image
  1743. * @returns a new Button
  1744. */
  1745. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1746. var result = new this(name);
  1747. // Adding image
  1748. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1749. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1750. result.addControl(iconImage);
  1751. // Adding text
  1752. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1753. textBlock.textWrapping = true;
  1754. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1755. result.addControl(textBlock);
  1756. // Store
  1757. result._image = iconImage;
  1758. result._textBlock = textBlock;
  1759. return result;
  1760. };
  1761. return Button;
  1762. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1763. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1764. /***/ }),
  1765. /***/ "./2D/controls/checkbox.ts":
  1766. /*!*********************************!*\
  1767. !*** ./2D/controls/checkbox.ts ***!
  1768. \*********************************/
  1769. /*! exports provided: Checkbox */
  1770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1771. "use strict";
  1772. __webpack_require__.r(__webpack_exports__);
  1773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1774. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1775. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1776. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1777. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1778. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1779. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1780. /**
  1781. * Class used to represent a 2D checkbox
  1782. */
  1783. var Checkbox = /** @class */ (function (_super) {
  1784. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1785. /**
  1786. * Creates a new CheckBox
  1787. * @param name defines the control name
  1788. */
  1789. function Checkbox(name) {
  1790. var _this = _super.call(this, name) || this;
  1791. _this.name = name;
  1792. _this._isChecked = false;
  1793. _this._background = "black";
  1794. _this._checkSizeRatio = 0.8;
  1795. _this._thickness = 1;
  1796. /**
  1797. * Observable raised when isChecked property changes
  1798. */
  1799. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1800. _this.isPointerBlocker = true;
  1801. return _this;
  1802. }
  1803. Object.defineProperty(Checkbox.prototype, "thickness", {
  1804. /** Gets or sets border thickness */
  1805. get: function () {
  1806. return this._thickness;
  1807. },
  1808. set: function (value) {
  1809. if (this._thickness === value) {
  1810. return;
  1811. }
  1812. this._thickness = value;
  1813. this._markAsDirty();
  1814. },
  1815. enumerable: false,
  1816. configurable: true
  1817. });
  1818. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1819. /** Gets or sets a value indicating the ratio between overall size and check size */
  1820. get: function () {
  1821. return this._checkSizeRatio;
  1822. },
  1823. set: function (value) {
  1824. value = Math.max(Math.min(1, value), 0);
  1825. if (this._checkSizeRatio === value) {
  1826. return;
  1827. }
  1828. this._checkSizeRatio = value;
  1829. this._markAsDirty();
  1830. },
  1831. enumerable: false,
  1832. configurable: true
  1833. });
  1834. Object.defineProperty(Checkbox.prototype, "background", {
  1835. /** Gets or sets background color */
  1836. get: function () {
  1837. return this._background;
  1838. },
  1839. set: function (value) {
  1840. if (this._background === value) {
  1841. return;
  1842. }
  1843. this._background = value;
  1844. this._markAsDirty();
  1845. },
  1846. enumerable: false,
  1847. configurable: true
  1848. });
  1849. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1850. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1851. get: function () {
  1852. return this._isChecked;
  1853. },
  1854. set: function (value) {
  1855. if (this._isChecked === value) {
  1856. return;
  1857. }
  1858. this._isChecked = value;
  1859. this._markAsDirty();
  1860. this.onIsCheckedChangedObservable.notifyObservers(value);
  1861. },
  1862. enumerable: false,
  1863. configurable: true
  1864. });
  1865. Checkbox.prototype._getTypeName = function () {
  1866. return "Checkbox";
  1867. };
  1868. /** @hidden */
  1869. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1870. context.save();
  1871. this._applyStates(context);
  1872. var actualWidth = this._currentMeasure.width - this._thickness;
  1873. var actualHeight = this._currentMeasure.height - this._thickness;
  1874. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1875. context.shadowColor = this.shadowColor;
  1876. context.shadowBlur = this.shadowBlur;
  1877. context.shadowOffsetX = this.shadowOffsetX;
  1878. context.shadowOffsetY = this.shadowOffsetY;
  1879. }
  1880. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1881. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1882. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1883. context.shadowBlur = 0;
  1884. context.shadowOffsetX = 0;
  1885. context.shadowOffsetY = 0;
  1886. }
  1887. if (this._isChecked) {
  1888. context.fillStyle = this._isEnabled ? this.color : this._disabledColorItem;
  1889. var offsetWidth = actualWidth * this._checkSizeRatio;
  1890. var offseHeight = actualHeight * this._checkSizeRatio;
  1891. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1892. }
  1893. context.strokeStyle = this.color;
  1894. context.lineWidth = this._thickness;
  1895. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1896. context.restore();
  1897. };
  1898. // Events
  1899. /** @hidden */
  1900. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  1901. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  1902. return false;
  1903. }
  1904. this.isChecked = !this.isChecked;
  1905. return true;
  1906. };
  1907. /**
  1908. * Utility function to easily create a checkbox with a header
  1909. * @param title defines the label to use for the header
  1910. * @param onValueChanged defines the callback to call when value changes
  1911. * @returns a StackPanel containing the checkbox and a textBlock
  1912. */
  1913. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1914. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1915. panel.isVertical = false;
  1916. panel.height = "30px";
  1917. var checkbox = new Checkbox();
  1918. checkbox.width = "20px";
  1919. checkbox.height = "20px";
  1920. checkbox.isChecked = true;
  1921. checkbox.color = "green";
  1922. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1923. panel.addControl(checkbox);
  1924. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1925. header.text = title;
  1926. header.width = "180px";
  1927. header.paddingLeft = "5px";
  1928. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1929. header.color = "white";
  1930. panel.addControl(header);
  1931. return panel;
  1932. };
  1933. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  1934. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  1935. ], Checkbox.prototype, "thickness", null);
  1936. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  1937. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  1938. ], Checkbox.prototype, "checkSizeRatio", null);
  1939. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  1940. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  1941. ], Checkbox.prototype, "background", null);
  1942. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  1943. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  1944. ], Checkbox.prototype, "isChecked", null);
  1945. return Checkbox;
  1946. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1947. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1948. /***/ }),
  1949. /***/ "./2D/controls/colorpicker.ts":
  1950. /*!************************************!*\
  1951. !*** ./2D/controls/colorpicker.ts ***!
  1952. \************************************/
  1953. /*! exports provided: ColorPicker */
  1954. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1955. "use strict";
  1956. __webpack_require__.r(__webpack_exports__);
  1957. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1958. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1959. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1960. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1961. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1962. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1963. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1964. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1965. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1966. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1967. /** Class used to create color pickers */
  1968. var ColorPicker = /** @class */ (function (_super) {
  1969. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1970. /**
  1971. * Creates a new ColorPicker
  1972. * @param name defines the control name
  1973. */
  1974. function ColorPicker(name) {
  1975. var _this = _super.call(this, name) || this;
  1976. _this.name = name;
  1977. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1978. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1979. _this._pointerStartedOnSquare = false;
  1980. _this._pointerStartedOnWheel = false;
  1981. _this._squareLeft = 0;
  1982. _this._squareTop = 0;
  1983. _this._squareSize = 0;
  1984. _this._h = 360;
  1985. _this._s = 1;
  1986. _this._v = 1;
  1987. _this._lastPointerDownID = -1;
  1988. /**
  1989. * Observable raised when the value changes
  1990. */
  1991. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1992. // Events
  1993. _this._pointerIsDown = false;
  1994. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1995. _this.size = "200px";
  1996. _this.isPointerBlocker = true;
  1997. return _this;
  1998. }
  1999. Object.defineProperty(ColorPicker.prototype, "value", {
  2000. /** Gets or sets the color of the color picker */
  2001. get: function () {
  2002. return this._value;
  2003. },
  2004. set: function (value) {
  2005. if (this._value.equals(value)) {
  2006. return;
  2007. }
  2008. this._value.copyFrom(value);
  2009. this._value.toHSVToRef(this._tmpColor);
  2010. this._h = this._tmpColor.r;
  2011. this._s = Math.max(this._tmpColor.g, 0.00001);
  2012. this._v = Math.max(this._tmpColor.b, 0.00001);
  2013. this._markAsDirty();
  2014. if (this._value.r <= ColorPicker._Epsilon) {
  2015. this._value.r = 0;
  2016. }
  2017. if (this._value.g <= ColorPicker._Epsilon) {
  2018. this._value.g = 0;
  2019. }
  2020. if (this._value.b <= ColorPicker._Epsilon) {
  2021. this._value.b = 0;
  2022. }
  2023. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  2024. this._value.r = 1.0;
  2025. }
  2026. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  2027. this._value.g = 1.0;
  2028. }
  2029. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  2030. this._value.b = 1.0;
  2031. }
  2032. this.onValueChangedObservable.notifyObservers(this._value);
  2033. },
  2034. enumerable: false,
  2035. configurable: true
  2036. });
  2037. Object.defineProperty(ColorPicker.prototype, "width", {
  2038. /**
  2039. * Gets or sets control width
  2040. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  2041. */
  2042. get: function () {
  2043. return this._width.toString(this._host);
  2044. },
  2045. set: function (value) {
  2046. if (this._width.toString(this._host) === value) {
  2047. return;
  2048. }
  2049. if (this._width.fromString(value)) {
  2050. this._height.fromString(value);
  2051. this._markAsDirty();
  2052. }
  2053. },
  2054. enumerable: false,
  2055. configurable: true
  2056. });
  2057. Object.defineProperty(ColorPicker.prototype, "height", {
  2058. /**
  2059. * Gets or sets control height
  2060. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  2061. */
  2062. get: function () {
  2063. return this._height.toString(this._host);
  2064. },
  2065. /** Gets or sets control height */
  2066. set: function (value) {
  2067. if (this._height.toString(this._host) === value) {
  2068. return;
  2069. }
  2070. if (this._height.fromString(value)) {
  2071. this._width.fromString(value);
  2072. this._markAsDirty();
  2073. }
  2074. },
  2075. enumerable: false,
  2076. configurable: true
  2077. });
  2078. Object.defineProperty(ColorPicker.prototype, "size", {
  2079. /** Gets or sets control size */
  2080. get: function () {
  2081. return this.width;
  2082. },
  2083. set: function (value) {
  2084. this.width = value;
  2085. },
  2086. enumerable: false,
  2087. configurable: true
  2088. });
  2089. ColorPicker.prototype._getTypeName = function () {
  2090. return "ColorPicker";
  2091. };
  2092. /** @hidden */
  2093. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  2094. if (parentMeasure.width < parentMeasure.height) {
  2095. this._currentMeasure.height = parentMeasure.width;
  2096. }
  2097. else {
  2098. this._currentMeasure.width = parentMeasure.height;
  2099. }
  2100. };
  2101. ColorPicker.prototype._updateSquareProps = function () {
  2102. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2103. var wheelThickness = radius * .2;
  2104. var innerDiameter = (radius - wheelThickness) * 2;
  2105. var squareSize = innerDiameter / (Math.sqrt(2));
  2106. var offset = radius - squareSize * .5;
  2107. this._squareLeft = this._currentMeasure.left + offset;
  2108. this._squareTop = this._currentMeasure.top + offset;
  2109. this._squareSize = squareSize;
  2110. };
  2111. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  2112. var lgh = context.createLinearGradient(left, top, width + left, top);
  2113. lgh.addColorStop(0, '#fff');
  2114. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  2115. context.fillStyle = lgh;
  2116. context.fillRect(left, top, width, height);
  2117. var lgv = context.createLinearGradient(left, top, left, height + top);
  2118. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  2119. lgv.addColorStop(1, '#000');
  2120. context.fillStyle = lgv;
  2121. context.fillRect(left, top, width, height);
  2122. };
  2123. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  2124. context.beginPath();
  2125. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  2126. context.lineWidth = 3;
  2127. context.strokeStyle = '#333333';
  2128. context.stroke();
  2129. context.beginPath();
  2130. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  2131. context.lineWidth = 3;
  2132. context.strokeStyle = '#ffffff';
  2133. context.stroke();
  2134. };
  2135. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  2136. var canvas = document.createElement("canvas");
  2137. canvas.width = radius * 2;
  2138. canvas.height = radius * 2;
  2139. var context = canvas.getContext("2d");
  2140. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  2141. var data = image.data;
  2142. var color = this._tmpColor;
  2143. var maxDistSq = radius * radius;
  2144. var innerRadius = radius - thickness;
  2145. var minDistSq = innerRadius * innerRadius;
  2146. for (var x = -radius; x < radius; x++) {
  2147. for (var y = -radius; y < radius; y++) {
  2148. var distSq = x * x + y * y;
  2149. if (distSq > maxDistSq || distSq < minDistSq) {
  2150. continue;
  2151. }
  2152. var dist = Math.sqrt(distSq);
  2153. var ang = Math.atan2(y, x);
  2154. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  2155. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  2156. data[index] = color.r * 255;
  2157. data[index + 1] = color.g * 255;
  2158. data[index + 2] = color.b * 255;
  2159. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2160. //apply less alpha to bigger color pickers
  2161. var alphaAmount = .2;
  2162. var maxAlpha = .2;
  2163. var minAlpha = .04;
  2164. var lowerRadius = 50;
  2165. var upperRadius = 150;
  2166. if (radius < lowerRadius) {
  2167. alphaAmount = maxAlpha;
  2168. }
  2169. else if (radius > upperRadius) {
  2170. alphaAmount = minAlpha;
  2171. }
  2172. else {
  2173. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2174. }
  2175. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2176. if (alphaRatio < alphaAmount) {
  2177. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2178. }
  2179. else if (alphaRatio > 1 - alphaAmount) {
  2180. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2181. }
  2182. else {
  2183. data[index + 3] = 255;
  2184. }
  2185. }
  2186. }
  2187. context.putImageData(image, 0, 0);
  2188. return canvas;
  2189. };
  2190. /** @hidden */
  2191. ColorPicker.prototype._draw = function (context) {
  2192. context.save();
  2193. this._applyStates(context);
  2194. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2195. var wheelThickness = radius * .2;
  2196. var left = this._currentMeasure.left;
  2197. var top = this._currentMeasure.top;
  2198. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2199. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2200. }
  2201. this._updateSquareProps();
  2202. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2203. context.shadowColor = this.shadowColor;
  2204. context.shadowBlur = this.shadowBlur;
  2205. context.shadowOffsetX = this.shadowOffsetX;
  2206. context.shadowOffsetY = this.shadowOffsetY;
  2207. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2208. }
  2209. context.drawImage(this._colorWheelCanvas, left, top);
  2210. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2211. context.shadowBlur = 0;
  2212. context.shadowOffsetX = 0;
  2213. context.shadowOffsetY = 0;
  2214. }
  2215. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2216. var cx = this._squareLeft + this._squareSize * this._s;
  2217. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2218. this._drawCircle(cx, cy, radius * .04, context);
  2219. var dist = radius - wheelThickness * .5;
  2220. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2221. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2222. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2223. context.restore();
  2224. };
  2225. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2226. if (this._pointerStartedOnWheel) {
  2227. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2228. var centerX = radius + this._currentMeasure.left;
  2229. var centerY = radius + this._currentMeasure.top;
  2230. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2231. }
  2232. else if (this._pointerStartedOnSquare) {
  2233. this._updateSquareProps();
  2234. this._s = (x - this._squareLeft) / this._squareSize;
  2235. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2236. this._s = Math.min(this._s, 1);
  2237. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2238. this._v = Math.min(this._v, 1);
  2239. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2240. }
  2241. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2242. this.value = this._tmpColor;
  2243. };
  2244. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2245. this._updateSquareProps();
  2246. var left = this._squareLeft;
  2247. var top = this._squareTop;
  2248. var size = this._squareSize;
  2249. if (x >= left && x <= left + size &&
  2250. y >= top && y <= top + size) {
  2251. return true;
  2252. }
  2253. return false;
  2254. };
  2255. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2256. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2257. var centerX = radius + this._currentMeasure.left;
  2258. var centerY = radius + this._currentMeasure.top;
  2259. var wheelThickness = radius * .2;
  2260. var innerRadius = radius - wheelThickness;
  2261. var radiusSq = radius * radius;
  2262. var innerRadiusSq = innerRadius * innerRadius;
  2263. var dx = x - centerX;
  2264. var dy = y - centerY;
  2265. var distSq = dx * dx + dy * dy;
  2266. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2267. return true;
  2268. }
  2269. return false;
  2270. };
  2271. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  2272. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  2273. return false;
  2274. }
  2275. this._pointerIsDown = true;
  2276. this._pointerStartedOnSquare = false;
  2277. this._pointerStartedOnWheel = false;
  2278. // Invert transform
  2279. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2280. var x = this._transformedPosition.x;
  2281. var y = this._transformedPosition.y;
  2282. if (this._isPointOnSquare(x, y)) {
  2283. this._pointerStartedOnSquare = true;
  2284. }
  2285. else if (this._isPointOnWheel(x, y)) {
  2286. this._pointerStartedOnWheel = true;
  2287. }
  2288. this._updateValueFromPointer(x, y);
  2289. this._host._capturingControl[pointerId] = this;
  2290. this._lastPointerDownID = pointerId;
  2291. return true;
  2292. };
  2293. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  2294. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2295. if (pointerId != this._lastPointerDownID) {
  2296. return;
  2297. }
  2298. // Invert transform
  2299. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2300. var x = this._transformedPosition.x;
  2301. var y = this._transformedPosition.y;
  2302. if (this._pointerIsDown) {
  2303. this._updateValueFromPointer(x, y);
  2304. }
  2305. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  2306. };
  2307. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  2308. this._pointerIsDown = false;
  2309. delete this._host._capturingControl[pointerId];
  2310. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  2311. };
  2312. ColorPicker.prototype._onCanvasBlur = function () {
  2313. this._forcePointerUp();
  2314. _super.prototype._onCanvasBlur.call(this);
  2315. };
  2316. /**
  2317. * This function expands the color picker by creating a color picker dialog with manual
  2318. * color value input and the ability to save colors into an array to be used later in
  2319. * subsequent launches of the dialogue.
  2320. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2321. * @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.
  2322. * @returns picked color as a hex string and the saved colors array as hex strings.
  2323. */
  2324. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2325. return new Promise(function (resolve, reject) {
  2326. // Default options
  2327. options.pickerWidth = options.pickerWidth || "640px";
  2328. options.pickerHeight = options.pickerHeight || "400px";
  2329. options.headerHeight = options.headerHeight || "35px";
  2330. options.lastColor = options.lastColor || "#000000";
  2331. options.swatchLimit = options.swatchLimit || 20;
  2332. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2333. // Window size settings
  2334. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2335. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2336. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2337. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2338. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2339. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2340. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2341. // Button Colors
  2342. var buttonColor = "#c0c0c0";
  2343. var buttonBackgroundColor = "#535353";
  2344. var buttonBackgroundHoverColor = "#414141";
  2345. var buttonBackgroundClickColor = "515151";
  2346. var buttonDisabledColor = "#555555";
  2347. var buttonDisabledBackgroundColor = "#454545";
  2348. var currentSwatchesOutlineColor = "#404040";
  2349. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2350. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2351. var iconColorDark = "#aaaaaa";
  2352. var iconColorLight = "#ffffff";
  2353. var closeIconColor;
  2354. // Button settings
  2355. var buttonFontSize;
  2356. var butEdit;
  2357. var buttonWidth;
  2358. var buttonHeight;
  2359. // Input Text Colors
  2360. var inputFieldLabels = ["R", "G", "B"];
  2361. var inputTextBackgroundColor = "#454545";
  2362. var inputTextColor = "#f0f0f0";
  2363. // This is the current color as set by either the picker or by entering a value
  2364. var currentColor;
  2365. // This int is used for naming swatches and serves as the index for calling them from the list
  2366. var swatchNumber;
  2367. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2368. var swatchDrawer;
  2369. var editSwatchMode = false;
  2370. // Color InputText fields that will be updated upon value change
  2371. var picker;
  2372. var rValInt;
  2373. var gValInt;
  2374. var bValInt;
  2375. var rValDec;
  2376. var gValDec;
  2377. var bValDec;
  2378. var hexVal;
  2379. var newSwatch;
  2380. var lastVal;
  2381. var activeField;
  2382. /**
  2383. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2384. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2385. * are will receive no update. This is to prevent the input from the user being overwritten.
  2386. */
  2387. function updateValues(value, inputField) {
  2388. activeField = inputField;
  2389. var pickedColor = value.toHexString();
  2390. newSwatch.background = pickedColor;
  2391. if (rValInt.name != activeField) {
  2392. rValInt.text = Math.floor(value.r * 255).toString();
  2393. }
  2394. if (gValInt.name != activeField) {
  2395. gValInt.text = Math.floor(value.g * 255).toString();
  2396. }
  2397. if (bValInt.name != activeField) {
  2398. bValInt.text = Math.floor(value.b * 255).toString();
  2399. }
  2400. if (rValDec.name != activeField) {
  2401. rValDec.text = value.r.toString();
  2402. }
  2403. if (gValDec.name != activeField) {
  2404. gValDec.text = value.g.toString();
  2405. }
  2406. if (bValDec.name != activeField) {
  2407. bValDec.text = value.b.toString();
  2408. }
  2409. if (hexVal.name != activeField) {
  2410. var minusPound = pickedColor.split("#");
  2411. hexVal.text = minusPound[1];
  2412. }
  2413. if (picker.name != activeField) {
  2414. picker.value = value;
  2415. }
  2416. }
  2417. // 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.
  2418. function updateInt(field, channel) {
  2419. var newValue = field.text;
  2420. var checkVal = /[^0-9]/g.test(newValue);
  2421. if (checkVal) {
  2422. field.text = lastVal;
  2423. return;
  2424. }
  2425. else {
  2426. if (newValue != "") {
  2427. if (Math.floor(parseInt(newValue)) < 0) {
  2428. newValue = "0";
  2429. }
  2430. else if (Math.floor(parseInt(newValue)) > 255) {
  2431. newValue = "255";
  2432. }
  2433. else if (isNaN(parseInt(newValue))) {
  2434. newValue = "0";
  2435. }
  2436. }
  2437. if (activeField == field.name) {
  2438. lastVal = newValue;
  2439. }
  2440. }
  2441. if (newValue != "") {
  2442. newValue = parseInt(newValue).toString();
  2443. field.text = newValue;
  2444. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2445. if (activeField == field.name) {
  2446. if (channel == "r") {
  2447. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2448. }
  2449. else if (channel == "g") {
  2450. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2451. }
  2452. else {
  2453. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2454. }
  2455. }
  2456. }
  2457. }
  2458. // 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.
  2459. function updateFloat(field, channel) {
  2460. var newValue = field.text;
  2461. var checkVal = /[^0-9\.]/g.test(newValue);
  2462. if (checkVal) {
  2463. field.text = lastVal;
  2464. return;
  2465. }
  2466. else {
  2467. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2468. if (parseFloat(newValue) < 0.0) {
  2469. newValue = "0.0";
  2470. }
  2471. else if (parseFloat(newValue) > 1.0) {
  2472. newValue = "1.0";
  2473. }
  2474. else if (isNaN(parseFloat(newValue))) {
  2475. newValue = "0.0";
  2476. }
  2477. }
  2478. if (activeField == field.name) {
  2479. lastVal = newValue;
  2480. }
  2481. }
  2482. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2483. newValue = parseFloat(newValue).toString();
  2484. field.text = newValue;
  2485. }
  2486. else {
  2487. newValue = "0.0";
  2488. }
  2489. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2490. if (activeField == field.name) {
  2491. if (channel == "r") {
  2492. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2493. }
  2494. else if (channel == "g") {
  2495. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2496. }
  2497. else {
  2498. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2499. }
  2500. }
  2501. }
  2502. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2503. function deleteSwatch(index) {
  2504. if (options.savedColors) {
  2505. options.savedColors.splice(index, 1);
  2506. }
  2507. if (options.savedColors && options.savedColors.length == 0) {
  2508. setEditButtonVisibility(false);
  2509. editSwatchMode = false;
  2510. }
  2511. }
  2512. // Creates and styles an individual swatch when updateSwatches is called.
  2513. function createSwatch() {
  2514. if (options.savedColors && options.savedColors[swatchNumber]) {
  2515. if (editSwatchMode) {
  2516. var icon = "b";
  2517. }
  2518. else {
  2519. var icon = "";
  2520. }
  2521. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2522. swatch.fontFamily = "BabylonJSglyphs";
  2523. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2524. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2525. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2526. if (swatchLuminence > luminanceLimit) {
  2527. swatch.color = iconColorDark;
  2528. }
  2529. else {
  2530. swatch.color = iconColorLight;
  2531. }
  2532. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2533. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2534. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2535. swatch.background = options.savedColors[swatchNumber];
  2536. swatch.thickness = 2;
  2537. var metadata_1 = swatchNumber;
  2538. swatch.pointerDownAnimation = function () {
  2539. swatch.thickness = 4;
  2540. };
  2541. swatch.pointerUpAnimation = function () {
  2542. swatch.thickness = 3;
  2543. };
  2544. swatch.pointerEnterAnimation = function () {
  2545. swatch.thickness = 3;
  2546. };
  2547. swatch.pointerOutAnimation = function () {
  2548. swatch.thickness = 2;
  2549. };
  2550. swatch.onPointerClickObservable.add(function () {
  2551. if (!editSwatchMode) {
  2552. if (options.savedColors) {
  2553. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2554. }
  2555. }
  2556. else {
  2557. deleteSwatch(metadata_1);
  2558. updateSwatches("", butSave);
  2559. }
  2560. });
  2561. return swatch;
  2562. }
  2563. else {
  2564. return null;
  2565. }
  2566. }
  2567. // Mode switch to render button text and close symbols on swatch controls
  2568. function editSwatches(mode) {
  2569. if (mode !== undefined) {
  2570. editSwatchMode = mode;
  2571. }
  2572. if (editSwatchMode) {
  2573. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2574. var thisButton = swatchDrawer.children[i];
  2575. thisButton.textBlock.text = "b";
  2576. }
  2577. if (butEdit !== undefined) {
  2578. butEdit.textBlock.text = "Done";
  2579. }
  2580. }
  2581. else {
  2582. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2583. var thisButton = swatchDrawer.children[i];
  2584. thisButton.textBlock.text = "";
  2585. }
  2586. if (butEdit !== undefined) {
  2587. butEdit.textBlock.text = "Edit";
  2588. }
  2589. }
  2590. }
  2591. /**
  2592. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2593. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2594. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2595. * saved colors there are and how many can be stored per row.
  2596. */
  2597. function updateSwatches(color, button) {
  2598. if (options.savedColors) {
  2599. if (color != "") {
  2600. options.savedColors.push(color);
  2601. }
  2602. swatchNumber = 0;
  2603. swatchDrawer.clearControls();
  2604. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2605. if (rowCount == 0) {
  2606. var gutterCount = 0;
  2607. }
  2608. else {
  2609. var gutterCount = rowCount + 1;
  2610. }
  2611. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2612. var currentRows = swatchDrawer.rowCount;
  2613. for (var i = 0; i < currentRows; i++) {
  2614. swatchDrawer.removeRowDefinition(0);
  2615. }
  2616. for (var i = 0; i < rowCount + gutterCount; i++) {
  2617. if (i % 2) {
  2618. swatchDrawer.addRowDefinition(swatchSize, true);
  2619. }
  2620. else {
  2621. swatchDrawer.addRowDefinition(gutterSize, true);
  2622. }
  2623. }
  2624. }
  2625. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2626. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2627. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2628. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2629. var totalButtonsThisRow = options.numSwatchesPerLine;
  2630. }
  2631. else {
  2632. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2633. }
  2634. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2635. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2636. if (x > options.numSwatchesPerLine) {
  2637. continue;
  2638. }
  2639. var swatch = createSwatch();
  2640. if (swatch != null) {
  2641. swatchDrawer.addControl(swatch, y, w);
  2642. w += 2;
  2643. swatchNumber++;
  2644. }
  2645. else {
  2646. continue;
  2647. }
  2648. }
  2649. }
  2650. if (options.savedColors.length >= options.swatchLimit) {
  2651. disableButton(button, true);
  2652. }
  2653. else {
  2654. disableButton(button, false);
  2655. }
  2656. }
  2657. }
  2658. // Shows or hides edit swatches button depending on if there are saved swatches
  2659. function setEditButtonVisibility(enableButton) {
  2660. if (enableButton) {
  2661. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2662. butEdit.width = buttonWidth;
  2663. butEdit.height = buttonHeight;
  2664. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2665. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2666. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2667. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2668. butEdit.thickness = 2;
  2669. butEdit.color = buttonColor;
  2670. butEdit.fontSize = buttonFontSize;
  2671. butEdit.background = buttonBackgroundColor;
  2672. butEdit.onPointerEnterObservable.add(function () {
  2673. butEdit.background = buttonBackgroundHoverColor;
  2674. });
  2675. butEdit.onPointerOutObservable.add(function () {
  2676. butEdit.background = buttonBackgroundColor;
  2677. });
  2678. butEdit.pointerDownAnimation = function () {
  2679. butEdit.background = buttonBackgroundClickColor;
  2680. };
  2681. butEdit.pointerUpAnimation = function () {
  2682. butEdit.background = buttonBackgroundHoverColor;
  2683. };
  2684. butEdit.onPointerClickObservable.add(function () {
  2685. if (editSwatchMode) {
  2686. editSwatchMode = false;
  2687. }
  2688. else {
  2689. editSwatchMode = true;
  2690. }
  2691. editSwatches();
  2692. });
  2693. pickerGrid.addControl(butEdit, 1, 0);
  2694. }
  2695. else {
  2696. pickerGrid.removeControl(butEdit);
  2697. }
  2698. }
  2699. // Called when the user hits the limit of saved colors in the drawer.
  2700. function disableButton(button, disabled) {
  2701. if (disabled) {
  2702. button.color = buttonDisabledColor;
  2703. button.background = buttonDisabledBackgroundColor;
  2704. }
  2705. else {
  2706. button.color = buttonColor;
  2707. button.background = buttonBackgroundColor;
  2708. }
  2709. }
  2710. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2711. function closePicker(color) {
  2712. if (options.savedColors && options.savedColors.length > 0) {
  2713. resolve({
  2714. savedColors: options.savedColors,
  2715. pickedColor: color
  2716. });
  2717. }
  2718. else {
  2719. resolve({
  2720. pickedColor: color
  2721. });
  2722. }
  2723. advancedTexture.removeControl(dialogContainer);
  2724. }
  2725. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2726. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2727. dialogContainer.name = "Dialog Container";
  2728. dialogContainer.width = options.pickerWidth;
  2729. if (options.savedColors) {
  2730. dialogContainer.height = containerSize;
  2731. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2732. dialogContainer.addRowDefinition(topRow, false);
  2733. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2734. }
  2735. else {
  2736. dialogContainer.height = options.pickerHeight;
  2737. dialogContainer.addRowDefinition(1.0, false);
  2738. }
  2739. advancedTexture.addControl(dialogContainer);
  2740. // Swatch drawer which contains all saved color buttons
  2741. if (options.savedColors) {
  2742. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2743. swatchDrawer.name = "Swatch Drawer";
  2744. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2745. swatchDrawer.background = buttonBackgroundColor;
  2746. swatchDrawer.width = options.pickerWidth;
  2747. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2748. if (initialRows == 0) {
  2749. var gutterCount = 0;
  2750. }
  2751. else {
  2752. var gutterCount = initialRows + 1;
  2753. }
  2754. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2755. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2756. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2757. if (i % 2 != 0) {
  2758. swatchDrawer.addRowDefinition(swatchSize, true);
  2759. }
  2760. else {
  2761. swatchDrawer.addRowDefinition(gutterSize, true);
  2762. }
  2763. }
  2764. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2765. if (i % 2 != 0) {
  2766. swatchDrawer.addColumnDefinition(swatchSize, true);
  2767. }
  2768. else {
  2769. swatchDrawer.addColumnDefinition(gutterSize, true);
  2770. }
  2771. }
  2772. dialogContainer.addControl(swatchDrawer, 1, 0);
  2773. }
  2774. // Picker container
  2775. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2776. pickerPanel.name = "Picker Panel";
  2777. pickerPanel.height = options.pickerHeight;
  2778. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2779. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2780. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2781. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2782. dialogContainer.addControl(pickerPanel, 0, 0);
  2783. // Picker container header
  2784. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2785. header.name = "Dialogue Header Bar";
  2786. header.background = "#cccccc";
  2787. header.thickness = 0;
  2788. pickerPanel.addControl(header, 0, 0);
  2789. // Header close button
  2790. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2791. closeButton.fontFamily = "BabylonJSglyphs";
  2792. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2793. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2794. closeButton.color = closeIconColor.toHexString();
  2795. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2796. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2797. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2798. closeButton.height = closeButton.width = options.headerHeight;
  2799. closeButton.background = header.background;
  2800. closeButton.thickness = 0;
  2801. closeButton.pointerDownAnimation = function () {
  2802. };
  2803. closeButton.pointerUpAnimation = function () {
  2804. closeButton.background = header.background;
  2805. };
  2806. closeButton.pointerEnterAnimation = function () {
  2807. closeButton.color = header.background;
  2808. closeButton.background = "red";
  2809. };
  2810. closeButton.pointerOutAnimation = function () {
  2811. closeButton.color = closeIconColor.toHexString();
  2812. closeButton.background = header.background;
  2813. };
  2814. closeButton.onPointerClickObservable.add(function () {
  2815. closePicker(currentSwatch.background);
  2816. });
  2817. pickerPanel.addControl(closeButton, 0, 0);
  2818. // Dialog container body
  2819. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2820. dialogBody.name = "Dialogue Body";
  2821. dialogBody.background = buttonBackgroundColor;
  2822. var dialogBodyCols = [0.4375, 0.5625];
  2823. dialogBody.addRowDefinition(1.0, false);
  2824. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2825. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2826. pickerPanel.addControl(dialogBody, 1, 0);
  2827. // Picker grid
  2828. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2829. pickerGrid.name = "Picker Grid";
  2830. pickerGrid.addRowDefinition(0.85, false);
  2831. pickerGrid.addRowDefinition(0.15, false);
  2832. dialogBody.addControl(pickerGrid, 0, 0);
  2833. // Picker control
  2834. picker = new ColorPicker();
  2835. picker.name = "GUI Color Picker";
  2836. if (options.pickerHeight < options.pickerWidth) {
  2837. picker.width = 0.89;
  2838. }
  2839. else {
  2840. picker.height = 0.89;
  2841. }
  2842. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2843. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2844. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2845. picker.onPointerDownObservable.add(function () {
  2846. activeField = picker.name;
  2847. lastVal = "";
  2848. editSwatches(false);
  2849. });
  2850. picker.onValueChangedObservable.add(function (value) {
  2851. if (activeField == picker.name) {
  2852. updateValues(value, picker.name);
  2853. }
  2854. });
  2855. pickerGrid.addControl(picker, 0, 0);
  2856. // Picker body right quarant
  2857. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2858. pickerBodyRight.name = "Dialogue Right Half";
  2859. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2860. var pickerBodyRightRows = [0.514, 0.486];
  2861. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2862. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2863. dialogBody.addControl(pickerBodyRight, 1, 1);
  2864. // Picker container swatches and buttons
  2865. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2866. pickerSwatchesButtons.name = "Swatches and Buttons";
  2867. var pickerButtonsCol = [0.417, 0.583];
  2868. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2869. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2870. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2871. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2872. // Picker Swatches quadrant
  2873. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2874. pickerSwatches.name = "New and Current Swatches";
  2875. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2876. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2877. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2878. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2879. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2880. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2881. // Active swatches
  2882. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2883. activeSwatches.name = "Active Swatches";
  2884. activeSwatches.width = 0.67;
  2885. activeSwatches.addRowDefinition(0.5, false);
  2886. activeSwatches.addRowDefinition(0.5, false);
  2887. pickerSwatches.addControl(activeSwatches, 2, 0);
  2888. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2889. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2890. if (options.pickerWidth > options.pickerHeight) {
  2891. var labelTextSize = labelHeight;
  2892. }
  2893. else {
  2894. var labelTextSize = labelWidth;
  2895. }
  2896. // New color swatch and previous color button
  2897. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2898. newText.text = "new";
  2899. newText.name = "New Color Label";
  2900. newText.color = buttonColor;
  2901. newText.fontSize = labelTextSize;
  2902. pickerSwatches.addControl(newText, 1, 0);
  2903. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2904. newSwatch.name = "New Color Swatch";
  2905. newSwatch.background = options.lastColor;
  2906. newSwatch.thickness = 0;
  2907. activeSwatches.addControl(newSwatch, 0, 0);
  2908. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2909. currentSwatch.background = options.lastColor;
  2910. currentSwatch.thickness = 0;
  2911. currentSwatch.onPointerClickObservable.add(function () {
  2912. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2913. updateValues(revertColor, currentSwatch.name);
  2914. editSwatches(false);
  2915. });
  2916. currentSwatch.pointerDownAnimation = function () { };
  2917. currentSwatch.pointerUpAnimation = function () { };
  2918. currentSwatch.pointerEnterAnimation = function () { };
  2919. currentSwatch.pointerOutAnimation = function () { };
  2920. activeSwatches.addControl(currentSwatch, 1, 0);
  2921. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2922. swatchOutline.name = "Swatch Outline";
  2923. swatchOutline.width = 0.67;
  2924. swatchOutline.thickness = 2;
  2925. swatchOutline.color = currentSwatchesOutlineColor;
  2926. swatchOutline.isHitTestVisible = false;
  2927. pickerSwatches.addControl(swatchOutline, 2, 0);
  2928. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2929. currentText.name = "Current Color Label";
  2930. currentText.text = "current";
  2931. currentText.color = buttonColor;
  2932. currentText.fontSize = labelTextSize;
  2933. pickerSwatches.addControl(currentText, 3, 0);
  2934. // Buttons grid
  2935. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2936. buttonGrid.name = "Button Grid";
  2937. buttonGrid.height = 0.8;
  2938. var buttonGridRows = 1 / 3;
  2939. buttonGrid.addRowDefinition(buttonGridRows, false);
  2940. buttonGrid.addRowDefinition(buttonGridRows, false);
  2941. buttonGrid.addRowDefinition(buttonGridRows, false);
  2942. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2943. // Determine pixel width and height for all buttons from overall panel dimensions
  2944. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2945. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2946. // Determine button type size
  2947. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2948. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2949. }
  2950. else {
  2951. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2952. }
  2953. // Panel Buttons
  2954. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2955. butOK.width = buttonWidth;
  2956. butOK.height = buttonHeight;
  2957. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2958. butOK.thickness = 2;
  2959. butOK.color = buttonColor;
  2960. butOK.fontSize = buttonFontSize;
  2961. butOK.background = buttonBackgroundColor;
  2962. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2963. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2964. butOK.pointerDownAnimation = function () {
  2965. butOK.background = buttonBackgroundClickColor;
  2966. };
  2967. butOK.pointerUpAnimation = function () {
  2968. butOK.background = buttonBackgroundHoverColor;
  2969. };
  2970. butOK.onPointerClickObservable.add(function () {
  2971. editSwatches(false);
  2972. closePicker(newSwatch.background);
  2973. });
  2974. buttonGrid.addControl(butOK, 0, 0);
  2975. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2976. butCancel.width = buttonWidth;
  2977. butCancel.height = buttonHeight;
  2978. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2979. butCancel.thickness = 2;
  2980. butCancel.color = buttonColor;
  2981. butCancel.fontSize = buttonFontSize;
  2982. butCancel.background = buttonBackgroundColor;
  2983. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2984. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2985. butCancel.pointerDownAnimation = function () {
  2986. butCancel.background = buttonBackgroundClickColor;
  2987. };
  2988. butCancel.pointerUpAnimation = function () {
  2989. butCancel.background = buttonBackgroundHoverColor;
  2990. };
  2991. butCancel.onPointerClickObservable.add(function () {
  2992. editSwatches(false);
  2993. closePicker(currentSwatch.background);
  2994. });
  2995. buttonGrid.addControl(butCancel, 1, 0);
  2996. if (options.savedColors) {
  2997. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2998. butSave.width = buttonWidth;
  2999. butSave.height = buttonHeight;
  3000. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  3001. butSave.thickness = 2;
  3002. butSave.fontSize = buttonFontSize;
  3003. if (options.savedColors.length < options.swatchLimit) {
  3004. butSave.color = buttonColor;
  3005. butSave.background = buttonBackgroundColor;
  3006. }
  3007. else {
  3008. disableButton(butSave, true);
  3009. }
  3010. butSave.onPointerEnterObservable.add(function () {
  3011. if (options.savedColors) {
  3012. if (options.savedColors.length < options.swatchLimit) {
  3013. butSave.background = buttonBackgroundHoverColor;
  3014. }
  3015. }
  3016. });
  3017. butSave.onPointerOutObservable.add(function () {
  3018. if (options.savedColors) {
  3019. if (options.savedColors.length < options.swatchLimit) {
  3020. butSave.background = buttonBackgroundColor;
  3021. }
  3022. }
  3023. });
  3024. butSave.pointerDownAnimation = function () {
  3025. if (options.savedColors) {
  3026. if (options.savedColors.length < options.swatchLimit) {
  3027. butSave.background = buttonBackgroundClickColor;
  3028. }
  3029. }
  3030. };
  3031. butSave.pointerUpAnimation = function () {
  3032. if (options.savedColors) {
  3033. if (options.savedColors.length < options.swatchLimit) {
  3034. butSave.background = buttonBackgroundHoverColor;
  3035. }
  3036. }
  3037. };
  3038. butSave.onPointerClickObservable.add(function () {
  3039. if (options.savedColors) {
  3040. if (options.savedColors.length == 0) {
  3041. setEditButtonVisibility(true);
  3042. }
  3043. if (options.savedColors.length < options.swatchLimit) {
  3044. updateSwatches(newSwatch.background, butSave);
  3045. }
  3046. editSwatches(false);
  3047. }
  3048. });
  3049. if (options.savedColors.length > 0) {
  3050. setEditButtonVisibility(true);
  3051. }
  3052. buttonGrid.addControl(butSave, 2, 0);
  3053. }
  3054. // Picker color values input
  3055. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3056. pickerColorValues.name = "Dialog Lower Right";
  3057. pickerColorValues.addRowDefinition(0.02, false);
  3058. pickerColorValues.addRowDefinition(0.63, false);
  3059. pickerColorValues.addRowDefinition(0.21, false);
  3060. pickerColorValues.addRowDefinition(0.14, false);
  3061. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  3062. // RGB values text boxes
  3063. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  3064. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3065. rgbValuesQuadrant.name = "RGB Values";
  3066. rgbValuesQuadrant.width = 0.82;
  3067. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  3068. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  3069. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  3070. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  3071. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  3072. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  3073. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  3074. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  3075. for (var i = 0; i < inputFieldLabels.length; i++) {
  3076. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3077. labelText.text = inputFieldLabels[i];
  3078. labelText.color = buttonColor;
  3079. labelText.fontSize = buttonFontSize;
  3080. rgbValuesQuadrant.addControl(labelText, i, 0);
  3081. }
  3082. // Input fields for RGB values
  3083. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3084. rValInt.width = 0.83;
  3085. rValInt.height = 0.72;
  3086. rValInt.name = "rIntField";
  3087. rValInt.fontSize = buttonFontSize;
  3088. rValInt.text = (currentColor.r * 255).toString();
  3089. rValInt.color = inputTextColor;
  3090. rValInt.background = inputTextBackgroundColor;
  3091. rValInt.onFocusObservable.add(function () {
  3092. activeField = rValInt.name;
  3093. lastVal = rValInt.text;
  3094. editSwatches(false);
  3095. });
  3096. rValInt.onBlurObservable.add(function () {
  3097. if (rValInt.text == "") {
  3098. rValInt.text = "0";
  3099. }
  3100. updateInt(rValInt, "r");
  3101. if (activeField == rValInt.name) {
  3102. activeField = "";
  3103. }
  3104. });
  3105. rValInt.onTextChangedObservable.add(function () {
  3106. if (activeField == rValInt.name) {
  3107. updateInt(rValInt, "r");
  3108. }
  3109. });
  3110. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  3111. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3112. gValInt.width = 0.83;
  3113. gValInt.height = 0.72;
  3114. gValInt.name = "gIntField";
  3115. gValInt.fontSize = buttonFontSize;
  3116. gValInt.text = (currentColor.g * 255).toString();
  3117. gValInt.color = inputTextColor;
  3118. gValInt.background = inputTextBackgroundColor;
  3119. gValInt.onFocusObservable.add(function () {
  3120. activeField = gValInt.name;
  3121. lastVal = gValInt.text;
  3122. editSwatches(false);
  3123. });
  3124. gValInt.onBlurObservable.add(function () {
  3125. if (gValInt.text == "") {
  3126. gValInt.text = "0";
  3127. }
  3128. updateInt(gValInt, "g");
  3129. if (activeField == gValInt.name) {
  3130. activeField = "";
  3131. }
  3132. });
  3133. gValInt.onTextChangedObservable.add(function () {
  3134. if (activeField == gValInt.name) {
  3135. updateInt(gValInt, "g");
  3136. }
  3137. });
  3138. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  3139. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3140. bValInt.width = 0.83;
  3141. bValInt.height = 0.72;
  3142. bValInt.name = "bIntField";
  3143. bValInt.fontSize = buttonFontSize;
  3144. bValInt.text = (currentColor.b * 255).toString();
  3145. bValInt.color = inputTextColor;
  3146. bValInt.background = inputTextBackgroundColor;
  3147. bValInt.onFocusObservable.add(function () {
  3148. activeField = bValInt.name;
  3149. lastVal = bValInt.text;
  3150. editSwatches(false);
  3151. });
  3152. bValInt.onBlurObservable.add(function () {
  3153. if (bValInt.text == "") {
  3154. bValInt.text = "0";
  3155. }
  3156. updateInt(bValInt, "b");
  3157. if (activeField == bValInt.name) {
  3158. activeField = "";
  3159. }
  3160. });
  3161. bValInt.onTextChangedObservable.add(function () {
  3162. if (activeField == bValInt.name) {
  3163. updateInt(bValInt, "b");
  3164. }
  3165. });
  3166. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3167. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3168. rValDec.width = 0.95;
  3169. rValDec.height = 0.72;
  3170. rValDec.name = "rDecField";
  3171. rValDec.fontSize = buttonFontSize;
  3172. rValDec.text = currentColor.r.toString();
  3173. rValDec.color = inputTextColor;
  3174. rValDec.background = inputTextBackgroundColor;
  3175. rValDec.onFocusObservable.add(function () {
  3176. activeField = rValDec.name;
  3177. lastVal = rValDec.text;
  3178. editSwatches(false);
  3179. });
  3180. rValDec.onBlurObservable.add(function () {
  3181. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3182. rValDec.text = "0";
  3183. updateFloat(rValDec, "r");
  3184. }
  3185. if (activeField == rValDec.name) {
  3186. activeField = "";
  3187. }
  3188. });
  3189. rValDec.onTextChangedObservable.add(function () {
  3190. if (activeField == rValDec.name) {
  3191. updateFloat(rValDec, "r");
  3192. }
  3193. });
  3194. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3195. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3196. gValDec.width = 0.95;
  3197. gValDec.height = 0.72;
  3198. gValDec.name = "gDecField";
  3199. gValDec.fontSize = buttonFontSize;
  3200. gValDec.text = currentColor.g.toString();
  3201. gValDec.color = inputTextColor;
  3202. gValDec.background = inputTextBackgroundColor;
  3203. gValDec.onFocusObservable.add(function () {
  3204. activeField = gValDec.name;
  3205. lastVal = gValDec.text;
  3206. editSwatches(false);
  3207. });
  3208. gValDec.onBlurObservable.add(function () {
  3209. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3210. gValDec.text = "0";
  3211. updateFloat(gValDec, "g");
  3212. }
  3213. if (activeField == gValDec.name) {
  3214. activeField = "";
  3215. }
  3216. });
  3217. gValDec.onTextChangedObservable.add(function () {
  3218. if (activeField == gValDec.name) {
  3219. updateFloat(gValDec, "g");
  3220. }
  3221. });
  3222. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3223. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3224. bValDec.width = 0.95;
  3225. bValDec.height = 0.72;
  3226. bValDec.name = "bDecField";
  3227. bValDec.fontSize = buttonFontSize;
  3228. bValDec.text = currentColor.b.toString();
  3229. bValDec.color = inputTextColor;
  3230. bValDec.background = inputTextBackgroundColor;
  3231. bValDec.onFocusObservable.add(function () {
  3232. activeField = bValDec.name;
  3233. lastVal = bValDec.text;
  3234. editSwatches(false);
  3235. });
  3236. bValDec.onBlurObservable.add(function () {
  3237. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3238. bValDec.text = "0";
  3239. updateFloat(bValDec, "b");
  3240. }
  3241. if (activeField == bValDec.name) {
  3242. activeField = "";
  3243. }
  3244. });
  3245. bValDec.onTextChangedObservable.add(function () {
  3246. if (activeField == bValDec.name) {
  3247. updateFloat(bValDec, "b");
  3248. }
  3249. });
  3250. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3251. // Hex value input
  3252. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3253. hexValueQuadrant.name = "Hex Value";
  3254. hexValueQuadrant.width = 0.82;
  3255. hexValueQuadrant.addRowDefinition(1.0, false);
  3256. hexValueQuadrant.addColumnDefinition(0.1, false);
  3257. hexValueQuadrant.addColumnDefinition(0.9, false);
  3258. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3259. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3260. labelText.text = "#";
  3261. labelText.color = buttonColor;
  3262. labelText.fontSize = buttonFontSize;
  3263. hexValueQuadrant.addControl(labelText, 0, 0);
  3264. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3265. hexVal.width = 0.96;
  3266. hexVal.height = 0.72;
  3267. hexVal.name = "hexField";
  3268. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3269. hexVal.fontSize = buttonFontSize;
  3270. var minusPound = options.lastColor.split("#");
  3271. hexVal.text = minusPound[1];
  3272. hexVal.color = inputTextColor;
  3273. hexVal.background = inputTextBackgroundColor;
  3274. hexVal.onFocusObservable.add(function () {
  3275. activeField = hexVal.name;
  3276. lastVal = hexVal.text;
  3277. editSwatches(false);
  3278. });
  3279. hexVal.onBlurObservable.add(function () {
  3280. if (hexVal.text.length == 3) {
  3281. var val = hexVal.text.split("");
  3282. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3283. }
  3284. if (hexVal.text == "") {
  3285. hexVal.text = "000000";
  3286. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3287. }
  3288. if (activeField == hexVal.name) {
  3289. activeField = "";
  3290. }
  3291. });
  3292. hexVal.onTextChangedObservable.add(function () {
  3293. var newHexValue = hexVal.text;
  3294. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3295. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3296. hexVal.text = lastVal;
  3297. }
  3298. else {
  3299. if (hexVal.text.length < 6) {
  3300. var leadingZero = 6 - hexVal.text.length;
  3301. for (var i = 0; i < leadingZero; i++) {
  3302. newHexValue = "0" + newHexValue;
  3303. }
  3304. }
  3305. if (hexVal.text.length == 3) {
  3306. var val = hexVal.text.split("");
  3307. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3308. }
  3309. newHexValue = "#" + newHexValue;
  3310. if (activeField == hexVal.name) {
  3311. lastVal = hexVal.text;
  3312. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3313. }
  3314. }
  3315. });
  3316. hexValueQuadrant.addControl(hexVal, 0, 1);
  3317. if (options.savedColors && options.savedColors.length > 0) {
  3318. updateSwatches("", butSave);
  3319. }
  3320. });
  3321. };
  3322. ColorPicker._Epsilon = 0.000001;
  3323. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3324. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3325. ], ColorPicker.prototype, "value", null);
  3326. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3327. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3328. ], ColorPicker.prototype, "width", null);
  3329. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3330. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3331. ], ColorPicker.prototype, "height", null);
  3332. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3333. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3334. ], ColorPicker.prototype, "size", null);
  3335. return ColorPicker;
  3336. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3337. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3338. /***/ }),
  3339. /***/ "./2D/controls/container.ts":
  3340. /*!**********************************!*\
  3341. !*** ./2D/controls/container.ts ***!
  3342. \**********************************/
  3343. /*! exports provided: Container */
  3344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3345. "use strict";
  3346. __webpack_require__.r(__webpack_exports__);
  3347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3348. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3349. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable");
  3350. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3351. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3352. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3353. /**
  3354. * Root class for 2D containers
  3355. * @see https://doc.babylonjs.com/how_to/gui#containers
  3356. */
  3357. var Container = /** @class */ (function (_super) {
  3358. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3359. /**
  3360. * Creates a new Container
  3361. * @param name defines the name of the container
  3362. */
  3363. function Container(name) {
  3364. var _this = _super.call(this, name) || this;
  3365. _this.name = name;
  3366. /** @hidden */
  3367. _this._children = new Array();
  3368. /** @hidden */
  3369. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3370. /** @hidden */
  3371. _this._background = "";
  3372. /** @hidden */
  3373. _this._adaptWidthToChildren = false;
  3374. /** @hidden */
  3375. _this._adaptHeightToChildren = false;
  3376. /**
  3377. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3378. */
  3379. _this.logLayoutCycleErrors = false;
  3380. /**
  3381. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3382. */
  3383. _this.maxLayoutCycle = 3;
  3384. return _this;
  3385. }
  3386. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3387. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3388. get: function () {
  3389. return this._adaptHeightToChildren;
  3390. },
  3391. set: function (value) {
  3392. if (this._adaptHeightToChildren === value) {
  3393. return;
  3394. }
  3395. this._adaptHeightToChildren = value;
  3396. if (value) {
  3397. this.height = "100%";
  3398. }
  3399. this._markAsDirty();
  3400. },
  3401. enumerable: false,
  3402. configurable: true
  3403. });
  3404. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3405. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3406. get: function () {
  3407. return this._adaptWidthToChildren;
  3408. },
  3409. set: function (value) {
  3410. if (this._adaptWidthToChildren === value) {
  3411. return;
  3412. }
  3413. this._adaptWidthToChildren = value;
  3414. if (value) {
  3415. this.width = "100%";
  3416. }
  3417. this._markAsDirty();
  3418. },
  3419. enumerable: false,
  3420. configurable: true
  3421. });
  3422. Object.defineProperty(Container.prototype, "background", {
  3423. /** Gets or sets background color */
  3424. get: function () {
  3425. return this._background;
  3426. },
  3427. set: function (value) {
  3428. if (this._background === value) {
  3429. return;
  3430. }
  3431. this._background = value;
  3432. this._markAsDirty();
  3433. },
  3434. enumerable: false,
  3435. configurable: true
  3436. });
  3437. Object.defineProperty(Container.prototype, "children", {
  3438. /** Gets the list of children */
  3439. get: function () {
  3440. return this._children;
  3441. },
  3442. enumerable: false,
  3443. configurable: true
  3444. });
  3445. Container.prototype._getTypeName = function () {
  3446. return "Container";
  3447. };
  3448. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3449. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3450. var child = _a[_i];
  3451. child._markMatrixAsDirty();
  3452. }
  3453. };
  3454. /**
  3455. * Gets a child using its name
  3456. * @param name defines the child name to look for
  3457. * @returns the child control if found
  3458. */
  3459. Container.prototype.getChildByName = function (name) {
  3460. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3461. var child = _a[_i];
  3462. if (child.name === name) {
  3463. return child;
  3464. }
  3465. }
  3466. return null;
  3467. };
  3468. /**
  3469. * Gets a child using its type and its name
  3470. * @param name defines the child name to look for
  3471. * @param type defines the child type to look for
  3472. * @returns the child control if found
  3473. */
  3474. Container.prototype.getChildByType = function (name, type) {
  3475. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3476. var child = _a[_i];
  3477. if (child.typeName === type) {
  3478. return child;
  3479. }
  3480. }
  3481. return null;
  3482. };
  3483. /**
  3484. * Search for a specific control in children
  3485. * @param control defines the control to look for
  3486. * @returns true if the control is in child list
  3487. */
  3488. Container.prototype.containsControl = function (control) {
  3489. return this.children.indexOf(control) !== -1;
  3490. };
  3491. /**
  3492. * Adds a new control to the current container
  3493. * @param control defines the control to add
  3494. * @returns the current container
  3495. */
  3496. Container.prototype.addControl = function (control) {
  3497. if (!control) {
  3498. return this;
  3499. }
  3500. var index = this._children.indexOf(control);
  3501. if (index !== -1) {
  3502. return this;
  3503. }
  3504. control._link(this._host);
  3505. control._markAllAsDirty();
  3506. this._reOrderControl(control);
  3507. this._markAsDirty();
  3508. return this;
  3509. };
  3510. /**
  3511. * Removes all controls from the current container
  3512. * @returns the current container
  3513. */
  3514. Container.prototype.clearControls = function () {
  3515. var children = this.children.slice();
  3516. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3517. var child = children_1[_i];
  3518. this.removeControl(child);
  3519. }
  3520. return this;
  3521. };
  3522. /**
  3523. * Removes a control from the current container
  3524. * @param control defines the control to remove
  3525. * @returns the current container
  3526. */
  3527. Container.prototype.removeControl = function (control) {
  3528. var index = this._children.indexOf(control);
  3529. if (index !== -1) {
  3530. this._children.splice(index, 1);
  3531. control.parent = null;
  3532. }
  3533. control.linkWithMesh(null);
  3534. if (this._host) {
  3535. this._host._cleanControlAfterRemoval(control);
  3536. }
  3537. this._markAsDirty();
  3538. return this;
  3539. };
  3540. /** @hidden */
  3541. Container.prototype._reOrderControl = function (control) {
  3542. this.removeControl(control);
  3543. var wasAdded = false;
  3544. for (var index = 0; index < this._children.length; index++) {
  3545. if (this._children[index].zIndex > control.zIndex) {
  3546. this._children.splice(index, 0, control);
  3547. wasAdded = true;
  3548. break;
  3549. }
  3550. }
  3551. if (!wasAdded) {
  3552. this._children.push(control);
  3553. }
  3554. control.parent = this;
  3555. this._markAsDirty();
  3556. };
  3557. /** @hidden */
  3558. Container.prototype._offsetLeft = function (offset) {
  3559. _super.prototype._offsetLeft.call(this, offset);
  3560. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3561. var child = _a[_i];
  3562. child._offsetLeft(offset);
  3563. }
  3564. };
  3565. /** @hidden */
  3566. Container.prototype._offsetTop = function (offset) {
  3567. _super.prototype._offsetTop.call(this, offset);
  3568. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3569. var child = _a[_i];
  3570. child._offsetTop(offset);
  3571. }
  3572. };
  3573. /** @hidden */
  3574. Container.prototype._markAllAsDirty = function () {
  3575. _super.prototype._markAllAsDirty.call(this);
  3576. for (var index = 0; index < this._children.length; index++) {
  3577. this._children[index]._markAllAsDirty();
  3578. }
  3579. };
  3580. /** @hidden */
  3581. Container.prototype._localDraw = function (context) {
  3582. if (this._background) {
  3583. context.save();
  3584. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3585. context.shadowColor = this.shadowColor;
  3586. context.shadowBlur = this.shadowBlur;
  3587. context.shadowOffsetX = this.shadowOffsetX;
  3588. context.shadowOffsetY = this.shadowOffsetY;
  3589. }
  3590. context.fillStyle = this._background;
  3591. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3592. context.restore();
  3593. }
  3594. };
  3595. /** @hidden */
  3596. Container.prototype._link = function (host) {
  3597. _super.prototype._link.call(this, host);
  3598. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3599. var child = _a[_i];
  3600. child._link(host);
  3601. }
  3602. };
  3603. /** @hidden */
  3604. Container.prototype._beforeLayout = function () {
  3605. // Do nothing
  3606. };
  3607. /** @hidden */
  3608. Container.prototype._processMeasures = function (parentMeasure, context) {
  3609. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3610. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3611. this._evaluateClippingState(parentMeasure);
  3612. }
  3613. };
  3614. /** @hidden */
  3615. Container.prototype._layout = function (parentMeasure, context) {
  3616. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3617. return false;
  3618. }
  3619. this.host._numLayoutCalls++;
  3620. if (this._isDirty) {
  3621. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3622. }
  3623. var rebuildCount = 0;
  3624. context.save();
  3625. this._applyStates(context);
  3626. this._beforeLayout();
  3627. do {
  3628. var computedWidth = -1;
  3629. var computedHeight = -1;
  3630. this._rebuildLayout = false;
  3631. this._processMeasures(parentMeasure, context);
  3632. if (!this._isClipped) {
  3633. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3634. var child = _a[_i];
  3635. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3636. if (child._layout(this._measureForChildren, context)) {
  3637. if (this.adaptWidthToChildren && child._width.isPixel) {
  3638. computedWidth = Math.max(computedWidth, child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels);
  3639. }
  3640. if (this.adaptHeightToChildren && child._height.isPixel) {
  3641. computedHeight = Math.max(computedHeight, child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels);
  3642. }
  3643. }
  3644. }
  3645. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3646. computedWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  3647. if (this.width !== computedWidth + "px") {
  3648. this.width = computedWidth + "px";
  3649. this._rebuildLayout = true;
  3650. }
  3651. }
  3652. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3653. computedHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  3654. if (this.height !== computedHeight + "px") {
  3655. this.height = computedHeight + "px";
  3656. this._rebuildLayout = true;
  3657. }
  3658. }
  3659. this._postMeasure();
  3660. }
  3661. rebuildCount++;
  3662. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3663. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3664. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3665. }
  3666. context.restore();
  3667. if (this._isDirty) {
  3668. this.invalidateRect();
  3669. this._isDirty = false;
  3670. }
  3671. return true;
  3672. };
  3673. Container.prototype._postMeasure = function () {
  3674. // Do nothing by default
  3675. };
  3676. /** @hidden */
  3677. Container.prototype._draw = function (context, invalidatedRectangle) {
  3678. this._localDraw(context);
  3679. if (this.clipChildren) {
  3680. this._clipForChildren(context);
  3681. }
  3682. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3683. var child = _a[_i];
  3684. // Only redraw parts of the screen that are invalidated
  3685. if (invalidatedRectangle) {
  3686. if (!child._intersectsRect(invalidatedRectangle)) {
  3687. continue;
  3688. }
  3689. }
  3690. child._render(context, invalidatedRectangle);
  3691. }
  3692. };
  3693. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3694. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3695. if (!this.children) {
  3696. return;
  3697. }
  3698. for (var index = 0; index < this.children.length; index++) {
  3699. var item = this.children[index];
  3700. if (!predicate || predicate(item)) {
  3701. results.push(item);
  3702. }
  3703. if (!directDescendantsOnly) {
  3704. item.getDescendantsToRef(results, false, predicate);
  3705. }
  3706. }
  3707. };
  3708. /** @hidden */
  3709. Container.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  3710. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3711. return false;
  3712. }
  3713. if (!_super.prototype.contains.call(this, x, y)) {
  3714. return false;
  3715. }
  3716. // Checking backwards to pick closest first
  3717. for (var index = this._children.length - 1; index >= 0; index--) {
  3718. var child = this._children[index];
  3719. if (child._processPicking(x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY)) {
  3720. if (child.hoverCursor) {
  3721. this._host._changeCursor(child.hoverCursor);
  3722. }
  3723. return true;
  3724. }
  3725. }
  3726. if (!this.isHitTestVisible) {
  3727. return false;
  3728. }
  3729. return this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  3730. };
  3731. /** @hidden */
  3732. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3733. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3734. this._measureForChildren.copyFrom(this._currentMeasure);
  3735. };
  3736. /**
  3737. * Serializes the current control
  3738. * @param serializationObject defined the JSON serialized object
  3739. */
  3740. Container.prototype.serialize = function (serializationObject) {
  3741. _super.prototype.serialize.call(this, serializationObject);
  3742. if (!this.children.length) {
  3743. return;
  3744. }
  3745. serializationObject.children = [];
  3746. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3747. var child = _a[_i];
  3748. var childSerializationObject = {};
  3749. child.serialize(childSerializationObject);
  3750. serializationObject.children.push(childSerializationObject);
  3751. }
  3752. };
  3753. /** Releases associated resources */
  3754. Container.prototype.dispose = function () {
  3755. _super.prototype.dispose.call(this);
  3756. for (var index = this.children.length - 1; index >= 0; index--) {
  3757. this.children[index].dispose();
  3758. }
  3759. };
  3760. /** @hidden */
  3761. Container.prototype._parseFromContent = function (serializedObject, host) {
  3762. _super.prototype._parseFromContent.call(this, serializedObject, host);
  3763. this._link(host);
  3764. if (!serializedObject.children) {
  3765. return;
  3766. }
  3767. for (var _i = 0, _a = serializedObject.children; _i < _a.length; _i++) {
  3768. var childData = _a[_i];
  3769. this.addControl(_control__WEBPACK_IMPORTED_MODULE_2__["Control"].Parse(childData, host));
  3770. }
  3771. };
  3772. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3773. Object(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3774. ], Container.prototype, "maxLayoutCycle", void 0);
  3775. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3776. Object(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3777. ], Container.prototype, "adaptHeightToChildren", null);
  3778. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3779. Object(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3780. ], Container.prototype, "adaptWidthToChildren", null);
  3781. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  3782. Object(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  3783. ], Container.prototype, "background", null);
  3784. return Container;
  3785. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3786. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3787. /***/ }),
  3788. /***/ "./2D/controls/control.ts":
  3789. /*!********************************!*\
  3790. !*** ./2D/controls/control.ts ***!
  3791. \********************************/
  3792. /*! exports provided: Control */
  3793. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3794. "use strict";
  3795. __webpack_require__.r(__webpack_exports__);
  3796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3797. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3798. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  3799. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  3800. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3801. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3802. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3803. /**
  3804. * Root class used for all 2D controls
  3805. * @see https://doc.babylonjs.com/how_to/gui#controls
  3806. */
  3807. var Control = /** @class */ (function () {
  3808. // Functions
  3809. /**
  3810. * Creates a new control
  3811. * @param name defines the name of the control
  3812. */
  3813. function Control(
  3814. /** defines the name of the control */
  3815. name) {
  3816. this.name = name;
  3817. this._alpha = 1;
  3818. this._alphaSet = false;
  3819. this._zIndex = 0;
  3820. /** @hidden */
  3821. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3822. this._fontFamily = "Arial";
  3823. this._fontStyle = "";
  3824. this._fontWeight = "";
  3825. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3826. /** @hidden */
  3827. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3828. /** @hidden */
  3829. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3830. this._color = "";
  3831. this._style = null;
  3832. /** @hidden */
  3833. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3834. /** @hidden */
  3835. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3836. /** @hidden */
  3837. this._isDirty = true;
  3838. /** @hidden */
  3839. this._wasDirty = false;
  3840. /** @hidden */
  3841. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3842. /** @hidden */
  3843. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3844. /** @hidden */
  3845. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3846. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3847. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3848. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3849. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3850. /** @hidden */
  3851. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3852. /** @hidden */
  3853. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3854. this._scaleX = 1.0;
  3855. this._scaleY = 1.0;
  3856. this._rotation = 0;
  3857. this._transformCenterX = 0.5;
  3858. this._transformCenterY = 0.5;
  3859. /** @hidden */
  3860. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_4__["Matrix2D"].Identity();
  3861. /** @hidden */
  3862. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_4__["Matrix2D"].Identity();
  3863. /** @hidden */
  3864. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  3865. this._isMatrixDirty = true;
  3866. this._isVisible = true;
  3867. this._isHighlighted = false;
  3868. this._fontSet = false;
  3869. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  3870. this._downCount = 0;
  3871. this._enterCount = -1;
  3872. this._doNotRender = false;
  3873. this._downPointerIds = {};
  3874. this._isEnabled = true;
  3875. this._disabledColor = "#9a9a9a";
  3876. this._disabledColorItem = "#6a6a6a";
  3877. /** @hidden */
  3878. this._rebuildLayout = false;
  3879. /** @hidden */
  3880. this._customData = {};
  3881. /** @hidden */
  3882. this._isClipped = false;
  3883. /** @hidden */
  3884. this._automaticSize = false;
  3885. /**
  3886. * Gets or sets an object used to store user defined information for the node
  3887. */
  3888. this.metadata = null;
  3889. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3890. this.isHitTestVisible = true;
  3891. /** Gets or sets a boolean indicating if the control can block pointer events */
  3892. this.isPointerBlocker = false;
  3893. /** Gets or sets a boolean indicating if the control can be focusable */
  3894. this.isFocusInvisible = false;
  3895. /**
  3896. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3897. * 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
  3898. */
  3899. this.clipChildren = true;
  3900. /**
  3901. * Gets or sets a boolean indicating that control content must be clipped
  3902. * 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
  3903. */
  3904. this.clipContent = true;
  3905. /**
  3906. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3907. */
  3908. this.useBitmapCache = false;
  3909. this._shadowOffsetX = 0;
  3910. this._shadowOffsetY = 0;
  3911. this._shadowBlur = 0;
  3912. this._shadowColor = 'black';
  3913. /** Gets or sets the cursor to use when the control is hovered */
  3914. this.hoverCursor = "";
  3915. /** @hidden */
  3916. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3917. /** @hidden */
  3918. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  3919. /**
  3920. * An event triggered when pointer wheel is scrolled
  3921. */
  3922. this.onWheelObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3923. /**
  3924. * An event triggered when the pointer move over the control.
  3925. */
  3926. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3927. /**
  3928. * An event triggered when the pointer move out of the control.
  3929. */
  3930. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3931. /**
  3932. * An event triggered when the pointer taps the control
  3933. */
  3934. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3935. /**
  3936. * An event triggered when pointer up
  3937. */
  3938. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3939. /**
  3940. * An event triggered when a control is clicked on
  3941. */
  3942. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3943. /**
  3944. * An event triggered when pointer enters the control
  3945. */
  3946. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3947. /**
  3948. * An event triggered when the control is marked as dirty
  3949. */
  3950. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3951. /**
  3952. * An event triggered before drawing the control
  3953. */
  3954. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3955. /**
  3956. * An event triggered after the control was drawn
  3957. */
  3958. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3959. /**
  3960. * An event triggered when the control has been disposed
  3961. */
  3962. this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  3963. /**
  3964. * Gets or sets a fixed ratio for this control.
  3965. * When different from 0, the ratio is used to compute the "second" dimension.
  3966. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  3967. * second dimension is computed as first dimension * fixedRatio
  3968. */
  3969. this.fixedRatio = 0;
  3970. this._fixedRatioMasterIsWidth = true;
  3971. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"](0, 0, 0, 0);
  3972. }
  3973. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3974. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3975. get: function () {
  3976. return this._shadowOffsetX;
  3977. },
  3978. set: function (value) {
  3979. if (this._shadowOffsetX === value) {
  3980. return;
  3981. }
  3982. this._shadowOffsetX = value;
  3983. this._markAsDirty();
  3984. },
  3985. enumerable: false,
  3986. configurable: true
  3987. });
  3988. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3989. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3990. get: function () {
  3991. return this._shadowOffsetY;
  3992. },
  3993. set: function (value) {
  3994. if (this._shadowOffsetY === value) {
  3995. return;
  3996. }
  3997. this._shadowOffsetY = value;
  3998. this._markAsDirty();
  3999. },
  4000. enumerable: false,
  4001. configurable: true
  4002. });
  4003. Object.defineProperty(Control.prototype, "shadowBlur", {
  4004. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  4005. get: function () {
  4006. return this._shadowBlur;
  4007. },
  4008. set: function (value) {
  4009. if (this._shadowBlur === value) {
  4010. return;
  4011. }
  4012. this._shadowBlur = value;
  4013. this._markAsDirty();
  4014. },
  4015. enumerable: false,
  4016. configurable: true
  4017. });
  4018. Object.defineProperty(Control.prototype, "shadowColor", {
  4019. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  4020. get: function () {
  4021. return this._shadowColor;
  4022. },
  4023. set: function (value) {
  4024. if (this._shadowColor === value) {
  4025. return;
  4026. }
  4027. this._shadowColor = value;
  4028. this._markAsDirty();
  4029. },
  4030. enumerable: false,
  4031. configurable: true
  4032. });
  4033. Object.defineProperty(Control.prototype, "typeName", {
  4034. // Properties
  4035. /** Gets the control type name */
  4036. get: function () {
  4037. return this._getTypeName();
  4038. },
  4039. enumerable: false,
  4040. configurable: true
  4041. });
  4042. /**
  4043. * Get the current class name of the control.
  4044. * @returns current class name
  4045. */
  4046. Control.prototype.getClassName = function () {
  4047. return this._getTypeName();
  4048. };
  4049. Object.defineProperty(Control.prototype, "host", {
  4050. /**
  4051. * Get the hosting AdvancedDynamicTexture
  4052. */
  4053. get: function () {
  4054. return this._host;
  4055. },
  4056. enumerable: false,
  4057. configurable: true
  4058. });
  4059. Object.defineProperty(Control.prototype, "fontOffset", {
  4060. /** Gets or set information about font offsets (used to render and align text) */
  4061. get: function () {
  4062. return this._fontOffset;
  4063. },
  4064. set: function (offset) {
  4065. this._fontOffset = offset;
  4066. },
  4067. enumerable: false,
  4068. configurable: true
  4069. });
  4070. Object.defineProperty(Control.prototype, "alpha", {
  4071. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  4072. get: function () {
  4073. return this._alpha;
  4074. },
  4075. set: function (value) {
  4076. if (this._alpha === value) {
  4077. return;
  4078. }
  4079. this._alphaSet = true;
  4080. this._alpha = value;
  4081. this._markAsDirty();
  4082. },
  4083. enumerable: false,
  4084. configurable: true
  4085. });
  4086. Object.defineProperty(Control.prototype, "isHighlighted", {
  4087. /**
  4088. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  4089. */
  4090. get: function () {
  4091. return this._isHighlighted;
  4092. },
  4093. set: function (value) {
  4094. if (this._isHighlighted === value) {
  4095. return;
  4096. }
  4097. this._isHighlighted = value;
  4098. this._markAsDirty();
  4099. },
  4100. enumerable: false,
  4101. configurable: true
  4102. });
  4103. Object.defineProperty(Control.prototype, "scaleX", {
  4104. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  4105. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4106. */
  4107. get: function () {
  4108. return this._scaleX;
  4109. },
  4110. set: function (value) {
  4111. if (this._scaleX === value) {
  4112. return;
  4113. }
  4114. this._scaleX = value;
  4115. this._markAsDirty();
  4116. this._markMatrixAsDirty();
  4117. },
  4118. enumerable: false,
  4119. configurable: true
  4120. });
  4121. Object.defineProperty(Control.prototype, "scaleY", {
  4122. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  4123. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4124. */
  4125. get: function () {
  4126. return this._scaleY;
  4127. },
  4128. set: function (value) {
  4129. if (this._scaleY === value) {
  4130. return;
  4131. }
  4132. this._scaleY = value;
  4133. this._markAsDirty();
  4134. this._markMatrixAsDirty();
  4135. },
  4136. enumerable: false,
  4137. configurable: true
  4138. });
  4139. Object.defineProperty(Control.prototype, "rotation", {
  4140. /** Gets or sets the rotation angle (0 by default)
  4141. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4142. */
  4143. get: function () {
  4144. return this._rotation;
  4145. },
  4146. set: function (value) {
  4147. if (this._rotation === value) {
  4148. return;
  4149. }
  4150. this._rotation = value;
  4151. this._markAsDirty();
  4152. this._markMatrixAsDirty();
  4153. },
  4154. enumerable: false,
  4155. configurable: true
  4156. });
  4157. Object.defineProperty(Control.prototype, "transformCenterY", {
  4158. /** Gets or sets the transformation center on Y axis (0 by default)
  4159. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4160. */
  4161. get: function () {
  4162. return this._transformCenterY;
  4163. },
  4164. set: function (value) {
  4165. if (this._transformCenterY === value) {
  4166. return;
  4167. }
  4168. this._transformCenterY = value;
  4169. this._markAsDirty();
  4170. this._markMatrixAsDirty();
  4171. },
  4172. enumerable: false,
  4173. configurable: true
  4174. });
  4175. Object.defineProperty(Control.prototype, "transformCenterX", {
  4176. /** Gets or sets the transformation center on X axis (0 by default)
  4177. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4178. */
  4179. get: function () {
  4180. return this._transformCenterX;
  4181. },
  4182. set: function (value) {
  4183. if (this._transformCenterX === value) {
  4184. return;
  4185. }
  4186. this._transformCenterX = value;
  4187. this._markAsDirty();
  4188. this._markMatrixAsDirty();
  4189. },
  4190. enumerable: false,
  4191. configurable: true
  4192. });
  4193. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  4194. /**
  4195. * Gets or sets the horizontal alignment
  4196. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4197. */
  4198. get: function () {
  4199. return this._horizontalAlignment;
  4200. },
  4201. set: function (value) {
  4202. if (this._horizontalAlignment === value) {
  4203. return;
  4204. }
  4205. this._horizontalAlignment = value;
  4206. this._markAsDirty();
  4207. },
  4208. enumerable: false,
  4209. configurable: true
  4210. });
  4211. Object.defineProperty(Control.prototype, "verticalAlignment", {
  4212. /**
  4213. * Gets or sets the vertical alignment
  4214. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4215. */
  4216. get: function () {
  4217. return this._verticalAlignment;
  4218. },
  4219. set: function (value) {
  4220. if (this._verticalAlignment === value) {
  4221. return;
  4222. }
  4223. this._verticalAlignment = value;
  4224. this._markAsDirty();
  4225. },
  4226. enumerable: false,
  4227. configurable: true
  4228. });
  4229. Object.defineProperty(Control.prototype, "width", {
  4230. /**
  4231. * Gets or sets control width
  4232. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4233. */
  4234. get: function () {
  4235. return this._width.toString(this._host);
  4236. },
  4237. set: function (value) {
  4238. this._fixedRatioMasterIsWidth = true;
  4239. if (this._width.toString(this._host) === value) {
  4240. return;
  4241. }
  4242. if (this._width.fromString(value)) {
  4243. this._markAsDirty();
  4244. }
  4245. },
  4246. enumerable: false,
  4247. configurable: true
  4248. });
  4249. Object.defineProperty(Control.prototype, "widthInPixels", {
  4250. /**
  4251. * Gets or sets the control width in pixel
  4252. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4253. */
  4254. get: function () {
  4255. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4256. },
  4257. set: function (value) {
  4258. if (isNaN(value)) {
  4259. return;
  4260. }
  4261. this._fixedRatioMasterIsWidth = true;
  4262. this.width = value + "px";
  4263. },
  4264. enumerable: false,
  4265. configurable: true
  4266. });
  4267. Object.defineProperty(Control.prototype, "height", {
  4268. /**
  4269. * Gets or sets control height
  4270. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4271. */
  4272. get: function () {
  4273. return this._height.toString(this._host);
  4274. },
  4275. set: function (value) {
  4276. this._fixedRatioMasterIsWidth = false;
  4277. if (this._height.toString(this._host) === value) {
  4278. return;
  4279. }
  4280. if (this._height.fromString(value)) {
  4281. this._markAsDirty();
  4282. }
  4283. },
  4284. enumerable: false,
  4285. configurable: true
  4286. });
  4287. Object.defineProperty(Control.prototype, "heightInPixels", {
  4288. /**
  4289. * Gets or sets control height in pixel
  4290. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4291. */
  4292. get: function () {
  4293. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4294. },
  4295. set: function (value) {
  4296. if (isNaN(value)) {
  4297. return;
  4298. }
  4299. this._fixedRatioMasterIsWidth = false;
  4300. this.height = value + "px";
  4301. },
  4302. enumerable: false,
  4303. configurable: true
  4304. });
  4305. Object.defineProperty(Control.prototype, "fontFamily", {
  4306. /** Gets or set font family */
  4307. get: function () {
  4308. if (!this._fontSet) {
  4309. return "";
  4310. }
  4311. return this._fontFamily;
  4312. },
  4313. set: function (value) {
  4314. if (this._fontFamily === value) {
  4315. return;
  4316. }
  4317. this._fontFamily = value;
  4318. this._resetFontCache();
  4319. },
  4320. enumerable: false,
  4321. configurable: true
  4322. });
  4323. Object.defineProperty(Control.prototype, "fontStyle", {
  4324. /** Gets or sets font style */
  4325. get: function () {
  4326. return this._fontStyle;
  4327. },
  4328. set: function (value) {
  4329. if (this._fontStyle === value) {
  4330. return;
  4331. }
  4332. this._fontStyle = value;
  4333. this._resetFontCache();
  4334. },
  4335. enumerable: false,
  4336. configurable: true
  4337. });
  4338. Object.defineProperty(Control.prototype, "fontWeight", {
  4339. /** Gets or sets font weight */
  4340. get: function () {
  4341. return this._fontWeight;
  4342. },
  4343. set: function (value) {
  4344. if (this._fontWeight === value) {
  4345. return;
  4346. }
  4347. this._fontWeight = value;
  4348. this._resetFontCache();
  4349. },
  4350. enumerable: false,
  4351. configurable: true
  4352. });
  4353. Object.defineProperty(Control.prototype, "style", {
  4354. /**
  4355. * Gets or sets style
  4356. * @see https://doc.babylonjs.com/how_to/gui#styles
  4357. */
  4358. get: function () {
  4359. return this._style;
  4360. },
  4361. set: function (value) {
  4362. var _this = this;
  4363. if (this._style) {
  4364. this._style.onChangedObservable.remove(this._styleObserver);
  4365. this._styleObserver = null;
  4366. }
  4367. this._style = value;
  4368. if (this._style) {
  4369. this._styleObserver = this._style.onChangedObservable.add(function () {
  4370. _this._markAsDirty();
  4371. _this._resetFontCache();
  4372. });
  4373. }
  4374. this._markAsDirty();
  4375. this._resetFontCache();
  4376. },
  4377. enumerable: false,
  4378. configurable: true
  4379. });
  4380. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4381. /** @hidden */
  4382. get: function () {
  4383. return this._fontSize.isPercentage;
  4384. },
  4385. enumerable: false,
  4386. configurable: true
  4387. });
  4388. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4389. /** Gets or sets font size in pixels */
  4390. get: function () {
  4391. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4392. if (fontSizeToUse.isPixel) {
  4393. return fontSizeToUse.getValue(this._host);
  4394. }
  4395. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4396. },
  4397. set: function (value) {
  4398. if (isNaN(value)) {
  4399. return;
  4400. }
  4401. this.fontSize = value + "px";
  4402. },
  4403. enumerable: false,
  4404. configurable: true
  4405. });
  4406. Object.defineProperty(Control.prototype, "fontSize", {
  4407. /** Gets or sets font size */
  4408. get: function () {
  4409. return this._fontSize.toString(this._host);
  4410. },
  4411. set: function (value) {
  4412. if (this._fontSize.toString(this._host) === value) {
  4413. return;
  4414. }
  4415. if (this._fontSize.fromString(value)) {
  4416. this._markAsDirty();
  4417. this._resetFontCache();
  4418. }
  4419. },
  4420. enumerable: false,
  4421. configurable: true
  4422. });
  4423. Object.defineProperty(Control.prototype, "color", {
  4424. /** Gets or sets foreground color */
  4425. get: function () {
  4426. return this._color;
  4427. },
  4428. set: function (value) {
  4429. if (this._color === value) {
  4430. return;
  4431. }
  4432. this._color = value;
  4433. this._markAsDirty();
  4434. },
  4435. enumerable: false,
  4436. configurable: true
  4437. });
  4438. Object.defineProperty(Control.prototype, "zIndex", {
  4439. /** Gets or sets z index which is used to reorder controls on the z axis */
  4440. get: function () {
  4441. return this._zIndex;
  4442. },
  4443. set: function (value) {
  4444. if (this.zIndex === value) {
  4445. return;
  4446. }
  4447. this._zIndex = value;
  4448. if (this.parent) {
  4449. this.parent._reOrderControl(this);
  4450. }
  4451. },
  4452. enumerable: false,
  4453. configurable: true
  4454. });
  4455. Object.defineProperty(Control.prototype, "notRenderable", {
  4456. /** Gets or sets a boolean indicating if the control can be rendered */
  4457. get: function () {
  4458. return this._doNotRender;
  4459. },
  4460. set: function (value) {
  4461. if (this._doNotRender === value) {
  4462. return;
  4463. }
  4464. this._doNotRender = value;
  4465. this._markAsDirty();
  4466. },
  4467. enumerable: false,
  4468. configurable: true
  4469. });
  4470. Object.defineProperty(Control.prototype, "isVisible", {
  4471. /** Gets or sets a boolean indicating if the control is visible */
  4472. get: function () {
  4473. return this._isVisible;
  4474. },
  4475. set: function (value) {
  4476. if (this._isVisible === value) {
  4477. return;
  4478. }
  4479. this._isVisible = value;
  4480. this._markAsDirty(true);
  4481. },
  4482. enumerable: false,
  4483. configurable: true
  4484. });
  4485. Object.defineProperty(Control.prototype, "isDirty", {
  4486. /** Gets a boolean indicating that the control needs to update its rendering */
  4487. get: function () {
  4488. return this._isDirty;
  4489. },
  4490. enumerable: false,
  4491. configurable: true
  4492. });
  4493. Object.defineProperty(Control.prototype, "linkedMesh", {
  4494. /**
  4495. * Gets the current linked mesh (or null if none)
  4496. */
  4497. get: function () {
  4498. return this._linkedMesh;
  4499. },
  4500. enumerable: false,
  4501. configurable: true
  4502. });
  4503. Object.defineProperty(Control.prototype, "paddingLeft", {
  4504. /**
  4505. * Gets or sets a value indicating the padding to use on the left of the control
  4506. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4507. */
  4508. get: function () {
  4509. return this._paddingLeft.toString(this._host);
  4510. },
  4511. set: function (value) {
  4512. if (this._paddingLeft.fromString(value)) {
  4513. this._markAsDirty();
  4514. }
  4515. },
  4516. enumerable: false,
  4517. configurable: true
  4518. });
  4519. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4520. /**
  4521. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4522. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4523. */
  4524. get: function () {
  4525. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4526. },
  4527. set: function (value) {
  4528. if (isNaN(value)) {
  4529. return;
  4530. }
  4531. this.paddingLeft = value + "px";
  4532. },
  4533. enumerable: false,
  4534. configurable: true
  4535. });
  4536. Object.defineProperty(Control.prototype, "paddingRight", {
  4537. /**
  4538. * Gets or sets a value indicating the padding to use on the right of the control
  4539. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4540. */
  4541. get: function () {
  4542. return this._paddingRight.toString(this._host);
  4543. },
  4544. set: function (value) {
  4545. if (this._paddingRight.fromString(value)) {
  4546. this._markAsDirty();
  4547. }
  4548. },
  4549. enumerable: false,
  4550. configurable: true
  4551. });
  4552. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4553. /**
  4554. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4555. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4556. */
  4557. get: function () {
  4558. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4559. },
  4560. set: function (value) {
  4561. if (isNaN(value)) {
  4562. return;
  4563. }
  4564. this.paddingRight = value + "px";
  4565. },
  4566. enumerable: false,
  4567. configurable: true
  4568. });
  4569. Object.defineProperty(Control.prototype, "paddingTop", {
  4570. /**
  4571. * Gets or sets a value indicating the padding to use on the top of the control
  4572. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4573. */
  4574. get: function () {
  4575. return this._paddingTop.toString(this._host);
  4576. },
  4577. set: function (value) {
  4578. if (this._paddingTop.fromString(value)) {
  4579. this._markAsDirty();
  4580. }
  4581. },
  4582. enumerable: false,
  4583. configurable: true
  4584. });
  4585. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4586. /**
  4587. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4588. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4589. */
  4590. get: function () {
  4591. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4592. },
  4593. set: function (value) {
  4594. if (isNaN(value)) {
  4595. return;
  4596. }
  4597. this.paddingTop = value + "px";
  4598. },
  4599. enumerable: false,
  4600. configurable: true
  4601. });
  4602. Object.defineProperty(Control.prototype, "paddingBottom", {
  4603. /**
  4604. * Gets or sets a value indicating the padding to use on the bottom of the control
  4605. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4606. */
  4607. get: function () {
  4608. return this._paddingBottom.toString(this._host);
  4609. },
  4610. set: function (value) {
  4611. if (this._paddingBottom.fromString(value)) {
  4612. this._markAsDirty();
  4613. }
  4614. },
  4615. enumerable: false,
  4616. configurable: true
  4617. });
  4618. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4619. /**
  4620. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4621. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4622. */
  4623. get: function () {
  4624. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4625. },
  4626. set: function (value) {
  4627. if (isNaN(value)) {
  4628. return;
  4629. }
  4630. this.paddingBottom = value + "px";
  4631. },
  4632. enumerable: false,
  4633. configurable: true
  4634. });
  4635. Object.defineProperty(Control.prototype, "left", {
  4636. /**
  4637. * Gets or sets a value indicating the left coordinate of the control
  4638. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4639. */
  4640. get: function () {
  4641. return this._left.toString(this._host);
  4642. },
  4643. set: function (value) {
  4644. if (this._left.fromString(value)) {
  4645. this._markAsDirty();
  4646. }
  4647. },
  4648. enumerable: false,
  4649. configurable: true
  4650. });
  4651. Object.defineProperty(Control.prototype, "leftInPixels", {
  4652. /**
  4653. * Gets or sets a value indicating the left coordinate in pixels of the control
  4654. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4655. */
  4656. get: function () {
  4657. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4658. },
  4659. set: function (value) {
  4660. if (isNaN(value)) {
  4661. return;
  4662. }
  4663. this.left = value + "px";
  4664. },
  4665. enumerable: false,
  4666. configurable: true
  4667. });
  4668. Object.defineProperty(Control.prototype, "top", {
  4669. /**
  4670. * Gets or sets a value indicating the top coordinate of the control
  4671. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4672. */
  4673. get: function () {
  4674. return this._top.toString(this._host);
  4675. },
  4676. set: function (value) {
  4677. if (this._top.fromString(value)) {
  4678. this._markAsDirty();
  4679. }
  4680. },
  4681. enumerable: false,
  4682. configurable: true
  4683. });
  4684. Object.defineProperty(Control.prototype, "topInPixels", {
  4685. /**
  4686. * Gets or sets a value indicating the top coordinate in pixels of the control
  4687. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4688. */
  4689. get: function () {
  4690. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4691. },
  4692. set: function (value) {
  4693. if (isNaN(value)) {
  4694. return;
  4695. }
  4696. this.top = value + "px";
  4697. },
  4698. enumerable: false,
  4699. configurable: true
  4700. });
  4701. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4702. /**
  4703. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4704. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4705. */
  4706. get: function () {
  4707. return this._linkOffsetX.toString(this._host);
  4708. },
  4709. set: function (value) {
  4710. if (this._linkOffsetX.fromString(value)) {
  4711. this._markAsDirty();
  4712. }
  4713. },
  4714. enumerable: false,
  4715. configurable: true
  4716. });
  4717. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4718. /**
  4719. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4720. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4721. */
  4722. get: function () {
  4723. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4724. },
  4725. set: function (value) {
  4726. if (isNaN(value)) {
  4727. return;
  4728. }
  4729. this.linkOffsetX = value + "px";
  4730. },
  4731. enumerable: false,
  4732. configurable: true
  4733. });
  4734. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4735. /**
  4736. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4737. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4738. */
  4739. get: function () {
  4740. return this._linkOffsetY.toString(this._host);
  4741. },
  4742. set: function (value) {
  4743. if (this._linkOffsetY.fromString(value)) {
  4744. this._markAsDirty();
  4745. }
  4746. },
  4747. enumerable: false,
  4748. configurable: true
  4749. });
  4750. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4751. /**
  4752. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4753. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4754. */
  4755. get: function () {
  4756. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4757. },
  4758. set: function (value) {
  4759. if (isNaN(value)) {
  4760. return;
  4761. }
  4762. this.linkOffsetY = value + "px";
  4763. },
  4764. enumerable: false,
  4765. configurable: true
  4766. });
  4767. Object.defineProperty(Control.prototype, "centerX", {
  4768. /** Gets the center coordinate on X axis */
  4769. get: function () {
  4770. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4771. },
  4772. enumerable: false,
  4773. configurable: true
  4774. });
  4775. Object.defineProperty(Control.prototype, "centerY", {
  4776. /** Gets the center coordinate on Y axis */
  4777. get: function () {
  4778. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4779. },
  4780. enumerable: false,
  4781. configurable: true
  4782. });
  4783. Object.defineProperty(Control.prototype, "isEnabled", {
  4784. /** Gets or sets if control is Enabled */
  4785. get: function () {
  4786. return this._isEnabled;
  4787. },
  4788. set: function (value) {
  4789. if (this._isEnabled === value) {
  4790. return;
  4791. }
  4792. this._isEnabled = value;
  4793. this._markAsDirty();
  4794. },
  4795. enumerable: false,
  4796. configurable: true
  4797. });
  4798. Object.defineProperty(Control.prototype, "disabledColor", {
  4799. /** Gets or sets background color of control if it's disabled */
  4800. get: function () {
  4801. return this._disabledColor;
  4802. },
  4803. set: function (value) {
  4804. if (this._disabledColor === value) {
  4805. return;
  4806. }
  4807. this._disabledColor = value;
  4808. this._markAsDirty();
  4809. },
  4810. enumerable: false,
  4811. configurable: true
  4812. });
  4813. Object.defineProperty(Control.prototype, "disabledColorItem", {
  4814. /** Gets or sets front color of control if it's disabled */
  4815. get: function () {
  4816. return this._disabledColorItem;
  4817. },
  4818. set: function (value) {
  4819. if (this._disabledColorItem === value) {
  4820. return;
  4821. }
  4822. this._disabledColorItem = value;
  4823. this._markAsDirty();
  4824. },
  4825. enumerable: false,
  4826. configurable: true
  4827. });
  4828. /** @hidden */
  4829. Control.prototype._getTypeName = function () {
  4830. return "Control";
  4831. };
  4832. /**
  4833. * Gets the first ascendant in the hierarchy of the given type
  4834. * @param className defines the required type
  4835. * @returns the ascendant or null if not found
  4836. */
  4837. Control.prototype.getAscendantOfClass = function (className) {
  4838. if (!this.parent) {
  4839. return null;
  4840. }
  4841. if (this.parent.getClassName() === className) {
  4842. return this.parent;
  4843. }
  4844. return this.parent.getAscendantOfClass(className);
  4845. };
  4846. /** @hidden */
  4847. Control.prototype._resetFontCache = function () {
  4848. this._fontSet = true;
  4849. this._markAsDirty();
  4850. };
  4851. /**
  4852. * Determines if a container is an ascendant of the current control
  4853. * @param container defines the container to look for
  4854. * @returns true if the container is one of the ascendant of the control
  4855. */
  4856. Control.prototype.isAscendant = function (container) {
  4857. if (!this.parent) {
  4858. return false;
  4859. }
  4860. if (this.parent === container) {
  4861. return true;
  4862. }
  4863. return this.parent.isAscendant(container);
  4864. };
  4865. /**
  4866. * Gets coordinates in local control space
  4867. * @param globalCoordinates defines the coordinates to transform
  4868. * @returns the new coordinates in local space
  4869. */
  4870. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4871. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  4872. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4873. return result;
  4874. };
  4875. /**
  4876. * Gets coordinates in local control space
  4877. * @param globalCoordinates defines the coordinates to transform
  4878. * @param result defines the target vector2 where to store the result
  4879. * @returns the current control
  4880. */
  4881. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4882. result.x = globalCoordinates.x - this._currentMeasure.left;
  4883. result.y = globalCoordinates.y - this._currentMeasure.top;
  4884. return this;
  4885. };
  4886. /**
  4887. * Gets coordinates in parent local control space
  4888. * @param globalCoordinates defines the coordinates to transform
  4889. * @returns the new coordinates in parent local space
  4890. */
  4891. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4892. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  4893. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4894. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4895. return result;
  4896. };
  4897. /**
  4898. * Move the current control to a vector3 position projected onto the screen.
  4899. * @param position defines the target position
  4900. * @param scene defines the hosting scene
  4901. */
  4902. Control.prototype.moveToVector3 = function (position, scene) {
  4903. if (!this._host || this.parent !== this._host._rootContainer) {
  4904. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4905. return;
  4906. }
  4907. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4908. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4909. var globalViewport = this._host._getGlobalViewport(scene);
  4910. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4911. this._moveToProjectedPosition(projectedPosition);
  4912. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4913. this.notRenderable = true;
  4914. return;
  4915. }
  4916. this.notRenderable = false;
  4917. };
  4918. /**
  4919. * Will store all controls that have this control as ascendant in a given array
  4920. * @param results defines the array where to store the descendants
  4921. * @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
  4922. * @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
  4923. */
  4924. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4925. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4926. // Do nothing by default
  4927. };
  4928. /**
  4929. * Will return all controls that have this control as ascendant
  4930. * @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
  4931. * @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
  4932. * @return all child controls
  4933. */
  4934. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4935. var results = new Array();
  4936. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4937. return results;
  4938. };
  4939. /**
  4940. * Link current control with a target mesh
  4941. * @param mesh defines the mesh to link with
  4942. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4943. */
  4944. Control.prototype.linkWithMesh = function (mesh) {
  4945. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4946. if (mesh) {
  4947. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4948. }
  4949. return;
  4950. }
  4951. var index = this._host._linkedControls.indexOf(this);
  4952. if (index !== -1) {
  4953. this._linkedMesh = mesh;
  4954. if (!mesh) {
  4955. this._host._linkedControls.splice(index, 1);
  4956. }
  4957. return;
  4958. }
  4959. else if (!mesh) {
  4960. return;
  4961. }
  4962. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4963. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4964. this._linkedMesh = mesh;
  4965. this._host._linkedControls.push(this);
  4966. };
  4967. /**
  4968. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  4969. * @param { string | number} paddingTop - The value of the top padding.
  4970. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  4971. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  4972. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  4973. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4974. */
  4975. Control.prototype.setPadding = function (paddingTop, paddingRight, paddingBottom, paddingLeft) {
  4976. var top = paddingTop;
  4977. var right = paddingRight !== null && paddingRight !== void 0 ? paddingRight : top;
  4978. var bottom = paddingBottom !== null && paddingBottom !== void 0 ? paddingBottom : top;
  4979. var left = paddingLeft !== null && paddingLeft !== void 0 ? paddingLeft : right;
  4980. this.paddingTop = top;
  4981. this.paddingRight = right;
  4982. this.paddingBottom = bottom;
  4983. this.paddingLeft = left;
  4984. };
  4985. /**
  4986. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  4987. * @param { number} paddingTop - The value in pixels of the top padding.
  4988. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  4989. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  4990. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  4991. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4992. */
  4993. Control.prototype.setPaddingInPixels = function (paddingTop, paddingRight, paddingBottom, paddingLeft) {
  4994. var top = paddingTop;
  4995. var right = paddingRight !== null && paddingRight !== void 0 ? paddingRight : top;
  4996. var bottom = paddingBottom !== null && paddingBottom !== void 0 ? paddingBottom : top;
  4997. var left = paddingLeft !== null && paddingLeft !== void 0 ? paddingLeft : right;
  4998. this.paddingTopInPixels = top;
  4999. this.paddingRightInPixels = right;
  5000. this.paddingBottomInPixels = bottom;
  5001. this.paddingLeftInPixels = left;
  5002. };
  5003. /** @hidden */
  5004. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  5005. var oldLeft = this._left.getValue(this._host);
  5006. var oldTop = this._top.getValue(this._host);
  5007. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  5008. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  5009. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  5010. if (Math.abs(newLeft - oldLeft) < 0.5) {
  5011. newLeft = oldLeft;
  5012. }
  5013. if (Math.abs(newTop - oldTop) < 0.5) {
  5014. newTop = oldTop;
  5015. }
  5016. }
  5017. this.left = newLeft + "px";
  5018. this.top = newTop + "px";
  5019. this._left.ignoreAdaptiveScaling = true;
  5020. this._top.ignoreAdaptiveScaling = true;
  5021. this._markAsDirty();
  5022. };
  5023. /** @hidden */
  5024. Control.prototype._offsetLeft = function (offset) {
  5025. this._isDirty = true;
  5026. this._currentMeasure.left += offset;
  5027. };
  5028. /** @hidden */
  5029. Control.prototype._offsetTop = function (offset) {
  5030. this._isDirty = true;
  5031. this._currentMeasure.top += offset;
  5032. };
  5033. /** @hidden */
  5034. Control.prototype._markMatrixAsDirty = function () {
  5035. this._isMatrixDirty = true;
  5036. this._flagDescendantsAsMatrixDirty();
  5037. };
  5038. /** @hidden */
  5039. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  5040. // No child
  5041. };
  5042. /** @hidden */
  5043. Control.prototype._intersectsRect = function (rect) {
  5044. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  5045. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  5046. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  5047. return false;
  5048. }
  5049. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  5050. return false;
  5051. }
  5052. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  5053. return false;
  5054. }
  5055. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  5056. return false;
  5057. }
  5058. return true;
  5059. };
  5060. /** @hidden */
  5061. Control.prototype.invalidateRect = function () {
  5062. this._transform();
  5063. if (this.host && this.host.useInvalidateRectOptimization) {
  5064. // Rotate by transform to get the measure transformed to global space
  5065. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  5066. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  5067. // the previous measure is used to properly clear a control that is scaled down
  5068. _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  5069. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5070. // Expand rect based on shadows
  5071. var shadowOffsetX = this.shadowOffsetX;
  5072. var shadowOffsetY = this.shadowOffsetY;
  5073. var shadowBlur = this.shadowBlur;
  5074. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5075. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5076. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5077. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5078. 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));
  5079. }
  5080. else {
  5081. 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));
  5082. }
  5083. }
  5084. };
  5085. /** @hidden */
  5086. Control.prototype._markAsDirty = function (force) {
  5087. if (force === void 0) { force = false; }
  5088. if (!this._isVisible && !force) {
  5089. return;
  5090. }
  5091. this._isDirty = true;
  5092. // Redraw only this rectangle
  5093. if (this._host) {
  5094. this._host.markAsDirty();
  5095. }
  5096. };
  5097. /** @hidden */
  5098. Control.prototype._markAllAsDirty = function () {
  5099. this._markAsDirty();
  5100. if (this._font) {
  5101. this._prepareFont();
  5102. }
  5103. };
  5104. /** @hidden */
  5105. Control.prototype._link = function (host) {
  5106. this._host = host;
  5107. if (this._host) {
  5108. this.uniqueId = this._host.getScene().getUniqueId();
  5109. }
  5110. };
  5111. /** @hidden */
  5112. Control.prototype._transform = function (context) {
  5113. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  5114. return;
  5115. }
  5116. // postTranslate
  5117. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  5118. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  5119. if (context) {
  5120. context.translate(offsetX, offsetY);
  5121. // rotate
  5122. context.rotate(this._rotation);
  5123. // scale
  5124. context.scale(this._scaleX, this._scaleY);
  5125. // preTranslate
  5126. context.translate(-offsetX, -offsetY);
  5127. }
  5128. // Need to update matrices?
  5129. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  5130. this._cachedOffsetX = offsetX;
  5131. this._cachedOffsetY = offsetY;
  5132. this._isMatrixDirty = false;
  5133. this._flagDescendantsAsMatrixDirty();
  5134. _math2D__WEBPACK_IMPORTED_MODULE_4__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  5135. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  5136. }
  5137. };
  5138. /** @hidden */
  5139. Control.prototype._renderHighlight = function (context) {
  5140. if (!this.isHighlighted) {
  5141. return;
  5142. }
  5143. context.save();
  5144. context.strokeStyle = "#4affff";
  5145. context.lineWidth = 2;
  5146. this._renderHighlightSpecific(context);
  5147. context.restore();
  5148. };
  5149. /** @hidden */
  5150. Control.prototype._renderHighlightSpecific = function (context) {
  5151. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5152. };
  5153. /** @hidden */
  5154. Control.prototype._applyStates = function (context) {
  5155. if (this._isFontSizeInPercentage) {
  5156. this._fontSet = true;
  5157. }
  5158. if (this._fontSet) {
  5159. this._prepareFont();
  5160. this._fontSet = false;
  5161. }
  5162. if (this._font) {
  5163. context.font = this._font;
  5164. }
  5165. if (this._color) {
  5166. context.fillStyle = this._color;
  5167. }
  5168. if (Control.AllowAlphaInheritance) {
  5169. context.globalAlpha *= this._alpha;
  5170. }
  5171. else if (this._alphaSet) {
  5172. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  5173. }
  5174. };
  5175. /** @hidden */
  5176. Control.prototype._layout = function (parentMeasure, context) {
  5177. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  5178. return false;
  5179. }
  5180. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  5181. this.host._numLayoutCalls++;
  5182. this._currentMeasure.addAndTransformToRef(this._transformMatrix, -this.paddingLeftInPixels | 0, -this.paddingTopInPixels | 0, this.paddingRightInPixels | 0, this.paddingBottomInPixels | 0, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  5183. context.save();
  5184. this._applyStates(context);
  5185. var rebuildCount = 0;
  5186. do {
  5187. this._rebuildLayout = false;
  5188. this._processMeasures(parentMeasure, context);
  5189. rebuildCount++;
  5190. } while (this._rebuildLayout && rebuildCount < 3);
  5191. if (rebuildCount >= 3) {
  5192. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  5193. }
  5194. context.restore();
  5195. this.invalidateRect();
  5196. this._evaluateClippingState(parentMeasure);
  5197. }
  5198. this._wasDirty = this._isDirty;
  5199. this._isDirty = false;
  5200. return true;
  5201. };
  5202. /** @hidden */
  5203. Control.prototype._processMeasures = function (parentMeasure, context) {
  5204. this._currentMeasure.copyFrom(parentMeasure);
  5205. // Let children take some pre-measurement actions
  5206. this._preMeasure(parentMeasure, context);
  5207. this._measure();
  5208. this._computeAlignment(parentMeasure, context);
  5209. // Convert to int values
  5210. this._currentMeasure.left = this._currentMeasure.left | 0;
  5211. this._currentMeasure.top = this._currentMeasure.top | 0;
  5212. this._currentMeasure.width = this._currentMeasure.width | 0;
  5213. this._currentMeasure.height = this._currentMeasure.height | 0;
  5214. // Let children add more features
  5215. this._additionalProcessing(parentMeasure, context);
  5216. this._cachedParentMeasure.copyFrom(parentMeasure);
  5217. if (this.onDirtyObservable.hasObservers()) {
  5218. this.onDirtyObservable.notifyObservers(this);
  5219. }
  5220. };
  5221. Control.prototype._evaluateClippingState = function (parentMeasure) {
  5222. if (this.parent && this.parent.clipChildren) {
  5223. // Early clip
  5224. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  5225. this._isClipped = true;
  5226. return;
  5227. }
  5228. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  5229. this._isClipped = true;
  5230. return;
  5231. }
  5232. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  5233. this._isClipped = true;
  5234. return;
  5235. }
  5236. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  5237. this._isClipped = true;
  5238. return;
  5239. }
  5240. }
  5241. this._isClipped = false;
  5242. };
  5243. /** @hidden */
  5244. Control.prototype._measure = function () {
  5245. // Width / Height
  5246. if (this._width.isPixel) {
  5247. this._currentMeasure.width = this._width.getValue(this._host);
  5248. }
  5249. else {
  5250. this._currentMeasure.width *= this._width.getValue(this._host);
  5251. }
  5252. if (this._height.isPixel) {
  5253. this._currentMeasure.height = this._height.getValue(this._host);
  5254. }
  5255. else {
  5256. this._currentMeasure.height *= this._height.getValue(this._host);
  5257. }
  5258. if (this.fixedRatio !== 0) {
  5259. if (this._fixedRatioMasterIsWidth) {
  5260. this._currentMeasure.height = this._currentMeasure.width * this.fixedRatio;
  5261. }
  5262. else {
  5263. this._currentMeasure.width = this._currentMeasure.height * this.fixedRatio;
  5264. }
  5265. }
  5266. };
  5267. /** @hidden */
  5268. Control.prototype._computeAlignment = function (parentMeasure, context) {
  5269. var width = this._currentMeasure.width;
  5270. var height = this._currentMeasure.height;
  5271. var parentWidth = parentMeasure.width;
  5272. var parentHeight = parentMeasure.height;
  5273. // Left / top
  5274. var x = 0;
  5275. var y = 0;
  5276. switch (this.horizontalAlignment) {
  5277. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  5278. x = 0;
  5279. break;
  5280. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  5281. x = parentWidth - width;
  5282. break;
  5283. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  5284. x = (parentWidth - width) / 2;
  5285. break;
  5286. }
  5287. switch (this.verticalAlignment) {
  5288. case Control.VERTICAL_ALIGNMENT_TOP:
  5289. y = 0;
  5290. break;
  5291. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5292. y = parentHeight - height;
  5293. break;
  5294. case Control.VERTICAL_ALIGNMENT_CENTER:
  5295. y = (parentHeight - height) / 2;
  5296. break;
  5297. }
  5298. if (this._paddingLeft.isPixel) {
  5299. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5300. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5301. }
  5302. else {
  5303. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5304. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5305. }
  5306. if (this._paddingRight.isPixel) {
  5307. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5308. }
  5309. else {
  5310. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5311. }
  5312. if (this._paddingTop.isPixel) {
  5313. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5314. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5315. }
  5316. else {
  5317. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5318. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5319. }
  5320. if (this._paddingBottom.isPixel) {
  5321. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5322. }
  5323. else {
  5324. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5325. }
  5326. if (this._left.isPixel) {
  5327. this._currentMeasure.left += this._left.getValue(this._host);
  5328. }
  5329. else {
  5330. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5331. }
  5332. if (this._top.isPixel) {
  5333. this._currentMeasure.top += this._top.getValue(this._host);
  5334. }
  5335. else {
  5336. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5337. }
  5338. this._currentMeasure.left += x;
  5339. this._currentMeasure.top += y;
  5340. };
  5341. /** @hidden */
  5342. Control.prototype._preMeasure = function (parentMeasure, context) {
  5343. // Do nothing
  5344. };
  5345. /** @hidden */
  5346. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5347. // Do nothing
  5348. };
  5349. /** @hidden */
  5350. Control.prototype._clipForChildren = function (context) {
  5351. // DO nothing
  5352. };
  5353. Control.prototype._clip = function (context, invalidatedRectangle) {
  5354. context.beginPath();
  5355. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5356. if (invalidatedRectangle) {
  5357. // Rotate the invalidated rect into the control's space
  5358. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5359. // Get the intersection of the rect in context space and the current context
  5360. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"](0, 0, 0, 0);
  5361. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5362. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5363. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5364. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5365. Control._ClipMeasure.copyFrom(intersection);
  5366. }
  5367. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5368. var shadowOffsetX = this.shadowOffsetX;
  5369. var shadowOffsetY = this.shadowOffsetY;
  5370. var shadowBlur = this.shadowBlur;
  5371. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5372. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5373. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5374. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5375. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5376. }
  5377. else {
  5378. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5379. }
  5380. context.clip();
  5381. };
  5382. /** @hidden */
  5383. Control.prototype._render = function (context, invalidatedRectangle) {
  5384. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5385. this._isDirty = false;
  5386. return false;
  5387. }
  5388. this.host._numRenderCalls++;
  5389. context.save();
  5390. this._applyStates(context);
  5391. // Transform
  5392. this._transform(context);
  5393. // Clip
  5394. if (this.clipContent) {
  5395. this._clip(context, invalidatedRectangle);
  5396. }
  5397. if (this.onBeforeDrawObservable.hasObservers()) {
  5398. this.onBeforeDrawObservable.notifyObservers(this);
  5399. }
  5400. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5401. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5402. }
  5403. else {
  5404. this._draw(context, invalidatedRectangle);
  5405. }
  5406. if (this.useBitmapCache && this._wasDirty) {
  5407. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5408. }
  5409. this._renderHighlight(context);
  5410. if (this.onAfterDrawObservable.hasObservers()) {
  5411. this.onAfterDrawObservable.notifyObservers(this);
  5412. }
  5413. context.restore();
  5414. return true;
  5415. };
  5416. /** @hidden */
  5417. Control.prototype._draw = function (context, invalidatedRectangle) {
  5418. // Do nothing
  5419. };
  5420. /**
  5421. * Tests if a given coordinates belong to the current control
  5422. * @param x defines x coordinate to test
  5423. * @param y defines y coordinate to test
  5424. * @returns true if the coordinates are inside the control
  5425. */
  5426. Control.prototype.contains = function (x, y) {
  5427. // Invert transform
  5428. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5429. x = this._transformedPosition.x;
  5430. y = this._transformedPosition.y;
  5431. // Check
  5432. if (x < this._currentMeasure.left) {
  5433. return false;
  5434. }
  5435. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5436. return false;
  5437. }
  5438. if (y < this._currentMeasure.top) {
  5439. return false;
  5440. }
  5441. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5442. return false;
  5443. }
  5444. if (this.isPointerBlocker) {
  5445. this._host._shouldBlockPointer = true;
  5446. }
  5447. return true;
  5448. };
  5449. /** @hidden */
  5450. Control.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  5451. if (!this._isEnabled) {
  5452. return false;
  5453. }
  5454. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5455. return false;
  5456. }
  5457. if (!this.contains(x, y)) {
  5458. return false;
  5459. }
  5460. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  5461. return true;
  5462. };
  5463. /** @hidden */
  5464. Control.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  5465. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this, pi);
  5466. if (canNotify && this.parent != null) {
  5467. this.parent._onPointerMove(target, coordinates, pointerId, pi);
  5468. }
  5469. };
  5470. /** @hidden */
  5471. Control.prototype._onPointerEnter = function (target, pi) {
  5472. if (!this._isEnabled) {
  5473. return false;
  5474. }
  5475. if (this._enterCount > 0) {
  5476. return false;
  5477. }
  5478. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5479. this._enterCount = 0;
  5480. }
  5481. this._enterCount++;
  5482. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this, pi);
  5483. if (canNotify && this.parent != null) {
  5484. this.parent._onPointerEnter(target, pi);
  5485. }
  5486. return true;
  5487. };
  5488. /** @hidden */
  5489. Control.prototype._onPointerOut = function (target, pi, force) {
  5490. if (force === void 0) { force = false; }
  5491. if (!force && (!this._isEnabled || target === this)) {
  5492. return;
  5493. }
  5494. this._enterCount = 0;
  5495. var canNotify = true;
  5496. if (!target.isAscendant(this)) {
  5497. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this, pi);
  5498. }
  5499. if (canNotify && this.parent != null) {
  5500. this.parent._onPointerOut(target, pi, force);
  5501. }
  5502. };
  5503. /** @hidden */
  5504. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  5505. // Prevent pointerout to lose control context.
  5506. // Event redundancy is checked inside the function.
  5507. this._onPointerEnter(this, pi);
  5508. if (this._downCount !== 0) {
  5509. return false;
  5510. }
  5511. this._downCount++;
  5512. this._downPointerIds[pointerId] = true;
  5513. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_4__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5514. if (canNotify && this.parent != null) {
  5515. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);
  5516. }
  5517. return true;
  5518. };
  5519. /** @hidden */
  5520. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  5521. if (!this._isEnabled) {
  5522. return;
  5523. }
  5524. this._downCount = 0;
  5525. delete this._downPointerIds[pointerId];
  5526. var canNotifyClick = notifyClick;
  5527. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5528. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_4__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5529. }
  5530. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_4__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5531. if (canNotify && this.parent != null) {
  5532. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick, pi);
  5533. }
  5534. };
  5535. /** @hidden */
  5536. Control.prototype._forcePointerUp = function (pointerId) {
  5537. if (pointerId === void 0) { pointerId = null; }
  5538. if (pointerId !== null) {
  5539. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero(), pointerId, 0, true);
  5540. }
  5541. else {
  5542. for (var key in this._downPointerIds) {
  5543. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero(), +key, 0, true);
  5544. }
  5545. }
  5546. };
  5547. /** @hidden */
  5548. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5549. if (!this._isEnabled) {
  5550. return;
  5551. }
  5552. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](deltaX, deltaY));
  5553. if (canNotify && this.parent != null) {
  5554. this.parent._onWheelScroll(deltaX, deltaY);
  5555. }
  5556. };
  5557. /** @hidden */
  5558. Control.prototype._onCanvasBlur = function () { };
  5559. /** @hidden */
  5560. Control.prototype._processObservables = function (type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY) {
  5561. if (!this._isEnabled) {
  5562. return false;
  5563. }
  5564. this._dummyVector2.copyFromFloats(x, y);
  5565. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  5566. this._onPointerMove(this, this._dummyVector2, pointerId, pi);
  5567. var previousControlOver = this._host._lastControlOver[pointerId];
  5568. if (previousControlOver && previousControlOver !== this) {
  5569. previousControlOver._onPointerOut(this, pi);
  5570. }
  5571. if (previousControlOver !== this) {
  5572. this._onPointerEnter(this, pi);
  5573. }
  5574. this._host._lastControlOver[pointerId] = this;
  5575. return true;
  5576. }
  5577. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  5578. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex, pi);
  5579. this._host._registerLastControlDown(this, pointerId);
  5580. this._host._lastPickedControl = this;
  5581. return true;
  5582. }
  5583. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  5584. if (this._host._lastControlDown[pointerId]) {
  5585. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true, pi);
  5586. }
  5587. delete this._host._lastControlDown[pointerId];
  5588. return true;
  5589. }
  5590. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  5591. if (this._host._lastControlOver[pointerId]) {
  5592. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5593. return true;
  5594. }
  5595. }
  5596. return false;
  5597. };
  5598. Control.prototype._prepareFont = function () {
  5599. if (!this._font && !this._fontSet) {
  5600. return;
  5601. }
  5602. if (this._style) {
  5603. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5604. }
  5605. else {
  5606. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5607. }
  5608. this._fontOffset = Control._GetFontOffset(this._font);
  5609. };
  5610. /**
  5611. * Serializes the current control
  5612. * @param serializationObject defined the JSON serialized object
  5613. */
  5614. Control.prototype.serialize = function (serializationObject) {
  5615. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, serializationObject);
  5616. serializationObject.name = this.name;
  5617. serializationObject.className = this.getClassName();
  5618. if (this._font) {
  5619. serializationObject.fontFamily = this.fontFamily;
  5620. serializationObject.fontSize = this.fontSize;
  5621. serializationObject.fontWeight = this.fontWeight;
  5622. serializationObject.fontStyle = this.fontStyle;
  5623. }
  5624. };
  5625. /** @hidden */
  5626. Control.prototype._parseFromContent = function (serializedObject, host) {
  5627. if (serializedObject.fontFamily) {
  5628. this.fontFamily = serializedObject.fontFamily;
  5629. }
  5630. if (serializedObject.fontSize) {
  5631. this.fontSize = serializedObject.fontSize;
  5632. }
  5633. if (serializedObject.fontWeight) {
  5634. this.fontWeight = serializedObject.fontWeight;
  5635. }
  5636. if (serializedObject.fontStyle) {
  5637. this.fontStyle = serializedObject.fontStyle;
  5638. }
  5639. };
  5640. /** Releases associated resources */
  5641. Control.prototype.dispose = function () {
  5642. this.onDirtyObservable.clear();
  5643. this.onBeforeDrawObservable.clear();
  5644. this.onAfterDrawObservable.clear();
  5645. this.onPointerDownObservable.clear();
  5646. this.onPointerEnterObservable.clear();
  5647. this.onPointerMoveObservable.clear();
  5648. this.onPointerOutObservable.clear();
  5649. this.onPointerUpObservable.clear();
  5650. this.onPointerClickObservable.clear();
  5651. this.onWheelObservable.clear();
  5652. if (this._styleObserver && this._style) {
  5653. this._style.onChangedObservable.remove(this._styleObserver);
  5654. this._styleObserver = null;
  5655. }
  5656. if (this.parent) {
  5657. this.parent.removeControl(this);
  5658. this.parent = null;
  5659. }
  5660. if (this._host) {
  5661. var index = this._host._linkedControls.indexOf(this);
  5662. if (index > -1) {
  5663. this.linkWithMesh(null);
  5664. }
  5665. }
  5666. // Callback
  5667. this.onDisposeObservable.notifyObservers(this);
  5668. this.onDisposeObservable.clear();
  5669. };
  5670. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5671. /** HORIZONTAL_ALIGNMENT_LEFT */
  5672. get: function () {
  5673. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5674. },
  5675. enumerable: false,
  5676. configurable: true
  5677. });
  5678. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5679. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5680. get: function () {
  5681. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5682. },
  5683. enumerable: false,
  5684. configurable: true
  5685. });
  5686. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5687. /** HORIZONTAL_ALIGNMENT_CENTER */
  5688. get: function () {
  5689. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5690. },
  5691. enumerable: false,
  5692. configurable: true
  5693. });
  5694. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5695. /** VERTICAL_ALIGNMENT_TOP */
  5696. get: function () {
  5697. return Control._VERTICAL_ALIGNMENT_TOP;
  5698. },
  5699. enumerable: false,
  5700. configurable: true
  5701. });
  5702. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5703. /** VERTICAL_ALIGNMENT_BOTTOM */
  5704. get: function () {
  5705. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5706. },
  5707. enumerable: false,
  5708. configurable: true
  5709. });
  5710. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5711. /** VERTICAL_ALIGNMENT_CENTER */
  5712. get: function () {
  5713. return Control._VERTICAL_ALIGNMENT_CENTER;
  5714. },
  5715. enumerable: false,
  5716. configurable: true
  5717. });
  5718. /** @hidden */
  5719. Control._GetFontOffset = function (font) {
  5720. if (Control._FontHeightSizes[font]) {
  5721. return Control._FontHeightSizes[font];
  5722. }
  5723. var text = document.createElement("span");
  5724. text.innerHTML = "Hg";
  5725. text.style.font = font;
  5726. var block = document.createElement("div");
  5727. block.style.display = "inline-block";
  5728. block.style.width = "1px";
  5729. block.style.height = "0px";
  5730. block.style.verticalAlign = "bottom";
  5731. var div = document.createElement("div");
  5732. div.style.whiteSpace = "nowrap";
  5733. div.appendChild(text);
  5734. div.appendChild(block);
  5735. document.body.appendChild(div);
  5736. var fontAscent = 0;
  5737. var fontHeight = 0;
  5738. try {
  5739. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5740. block.style.verticalAlign = "baseline";
  5741. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5742. }
  5743. finally {
  5744. document.body.removeChild(div);
  5745. }
  5746. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5747. Control._FontHeightSizes[font] = result;
  5748. return result;
  5749. };
  5750. /**
  5751. * Creates a Control from parsed data
  5752. * @param serializedObject defines parsed data
  5753. * @param host defines the hosting AdvancedDynamicTexture
  5754. * @returns a new Control
  5755. */
  5756. Control.Parse = function (serializedObject, host) {
  5757. var controlType = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].Instantiate("BABYLON.GUI." + serializedObject.className);
  5758. var control = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new controlType(); }, serializedObject, null);
  5759. control.name = serializedObject.name;
  5760. control._parseFromContent(serializedObject, host);
  5761. return control;
  5762. };
  5763. /** @hidden */
  5764. Control.drawEllipse = function (x, y, width, height, context) {
  5765. context.translate(x, y);
  5766. context.scale(width, height);
  5767. context.beginPath();
  5768. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5769. context.closePath();
  5770. context.scale(1 / width, 1 / height);
  5771. context.translate(-x, -y);
  5772. };
  5773. /**
  5774. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5775. */
  5776. Control.AllowAlphaInheritance = false;
  5777. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"](0, 0, 0, 0);
  5778. // Statics
  5779. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5780. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5781. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5782. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5783. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5784. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5785. Control._FontHeightSizes = {};
  5786. /**
  5787. * Creates a stack panel that can be used to render headers
  5788. * @param control defines the control to associate with the header
  5789. * @param text defines the text of the header
  5790. * @param size defines the size of the header
  5791. * @param options defines options used to configure the header
  5792. * @returns a new StackPanel
  5793. * @ignore
  5794. * @hidden
  5795. */
  5796. Control.AddHeader = function () { };
  5797. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5798. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5799. ], Control.prototype, "metadata", void 0);
  5800. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5801. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5802. ], Control.prototype, "isHitTestVisible", void 0);
  5803. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5804. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5805. ], Control.prototype, "isPointerBlocker", void 0);
  5806. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5807. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5808. ], Control.prototype, "isFocusInvisible", void 0);
  5809. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5810. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5811. ], Control.prototype, "clipChildren", void 0);
  5812. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5813. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5814. ], Control.prototype, "clipContent", void 0);
  5815. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5816. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5817. ], Control.prototype, "useBitmapCache", void 0);
  5818. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5819. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5820. ], Control.prototype, "shadowOffsetX", null);
  5821. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5822. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5823. ], Control.prototype, "shadowOffsetY", null);
  5824. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5825. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5826. ], Control.prototype, "shadowBlur", null);
  5827. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5828. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5829. ], Control.prototype, "shadowColor", null);
  5830. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5831. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5832. ], Control.prototype, "hoverCursor", void 0);
  5833. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5834. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5835. ], Control.prototype, "fontOffset", null);
  5836. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5837. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5838. ], Control.prototype, "alpha", null);
  5839. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5840. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5841. ], Control.prototype, "scaleX", null);
  5842. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5843. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5844. ], Control.prototype, "scaleY", null);
  5845. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5846. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5847. ], Control.prototype, "rotation", null);
  5848. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5849. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5850. ], Control.prototype, "transformCenterY", null);
  5851. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5852. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5853. ], Control.prototype, "transformCenterX", null);
  5854. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5855. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5856. ], Control.prototype, "horizontalAlignment", null);
  5857. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5858. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5859. ], Control.prototype, "verticalAlignment", null);
  5860. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5861. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5862. ], Control.prototype, "fixedRatio", void 0);
  5863. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5864. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5865. ], Control.prototype, "width", null);
  5866. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5867. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5868. ], Control.prototype, "height", null);
  5869. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5870. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5871. ], Control.prototype, "style", null);
  5872. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5873. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5874. ], Control.prototype, "color", null);
  5875. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5876. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5877. ], Control.prototype, "zIndex", null);
  5878. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5879. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5880. ], Control.prototype, "notRenderable", null);
  5881. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5882. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5883. ], Control.prototype, "isVisible", null);
  5884. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5885. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5886. ], Control.prototype, "paddingLeft", null);
  5887. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5888. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5889. ], Control.prototype, "paddingRight", null);
  5890. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5891. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5892. ], Control.prototype, "paddingTop", null);
  5893. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5894. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5895. ], Control.prototype, "paddingBottom", null);
  5896. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5897. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5898. ], Control.prototype, "left", null);
  5899. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5900. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5901. ], Control.prototype, "top", null);
  5902. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5903. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5904. ], Control.prototype, "linkOffsetX", null);
  5905. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5906. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5907. ], Control.prototype, "linkOffsetY", null);
  5908. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5909. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5910. ], Control.prototype, "isEnabled", null);
  5911. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5912. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5913. ], Control.prototype, "disabledColor", null);
  5914. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  5915. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  5916. ], Control.prototype, "disabledColorItem", null);
  5917. return Control;
  5918. }());
  5919. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5920. /***/ }),
  5921. /***/ "./2D/controls/displayGrid.ts":
  5922. /*!************************************!*\
  5923. !*** ./2D/controls/displayGrid.ts ***!
  5924. \************************************/
  5925. /*! exports provided: DisplayGrid */
  5926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5927. "use strict";
  5928. __webpack_require__.r(__webpack_exports__);
  5929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5930. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5931. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5932. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  5933. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5934. /** Class used to render a grid */
  5935. var DisplayGrid = /** @class */ (function (_super) {
  5936. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5937. /**
  5938. * Creates a new GridDisplayRectangle
  5939. * @param name defines the control name
  5940. */
  5941. function DisplayGrid(name) {
  5942. var _this = _super.call(this, name) || this;
  5943. _this.name = name;
  5944. _this._cellWidth = 20;
  5945. _this._cellHeight = 20;
  5946. _this._minorLineTickness = 1;
  5947. _this._minorLineColor = "DarkGray";
  5948. _this._majorLineTickness = 2;
  5949. _this._majorLineColor = "White";
  5950. _this._majorLineFrequency = 5;
  5951. _this._background = "Black";
  5952. _this._displayMajorLines = true;
  5953. _this._displayMinorLines = true;
  5954. return _this;
  5955. }
  5956. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5957. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5958. get: function () {
  5959. return this._displayMinorLines;
  5960. },
  5961. set: function (value) {
  5962. if (this._displayMinorLines === value) {
  5963. return;
  5964. }
  5965. this._displayMinorLines = value;
  5966. this._markAsDirty();
  5967. },
  5968. enumerable: false,
  5969. configurable: true
  5970. });
  5971. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5972. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5973. get: function () {
  5974. return this._displayMajorLines;
  5975. },
  5976. set: function (value) {
  5977. if (this._displayMajorLines === value) {
  5978. return;
  5979. }
  5980. this._displayMajorLines = value;
  5981. this._markAsDirty();
  5982. },
  5983. enumerable: false,
  5984. configurable: true
  5985. });
  5986. Object.defineProperty(DisplayGrid.prototype, "background", {
  5987. /** Gets or sets background color (Black by default) */
  5988. get: function () {
  5989. return this._background;
  5990. },
  5991. set: function (value) {
  5992. if (this._background === value) {
  5993. return;
  5994. }
  5995. this._background = value;
  5996. this._markAsDirty();
  5997. },
  5998. enumerable: false,
  5999. configurable: true
  6000. });
  6001. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  6002. /** Gets or sets the width of each cell (20 by default) */
  6003. get: function () {
  6004. return this._cellWidth;
  6005. },
  6006. set: function (value) {
  6007. this._cellWidth = value;
  6008. this._markAsDirty();
  6009. },
  6010. enumerable: false,
  6011. configurable: true
  6012. });
  6013. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  6014. /** Gets or sets the height of each cell (20 by default) */
  6015. get: function () {
  6016. return this._cellHeight;
  6017. },
  6018. set: function (value) {
  6019. this._cellHeight = value;
  6020. this._markAsDirty();
  6021. },
  6022. enumerable: false,
  6023. configurable: true
  6024. });
  6025. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  6026. /** Gets or sets the tickness of minor lines (1 by default) */
  6027. get: function () {
  6028. return this._minorLineTickness;
  6029. },
  6030. set: function (value) {
  6031. this._minorLineTickness = value;
  6032. this._markAsDirty();
  6033. },
  6034. enumerable: false,
  6035. configurable: true
  6036. });
  6037. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  6038. /** Gets or sets the color of minor lines (DarkGray by default) */
  6039. get: function () {
  6040. return this._minorLineColor;
  6041. },
  6042. set: function (value) {
  6043. this._minorLineColor = value;
  6044. this._markAsDirty();
  6045. },
  6046. enumerable: false,
  6047. configurable: true
  6048. });
  6049. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  6050. /** Gets or sets the tickness of major lines (2 by default) */
  6051. get: function () {
  6052. return this._majorLineTickness;
  6053. },
  6054. set: function (value) {
  6055. this._majorLineTickness = value;
  6056. this._markAsDirty();
  6057. },
  6058. enumerable: false,
  6059. configurable: true
  6060. });
  6061. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  6062. /** Gets or sets the color of major lines (White by default) */
  6063. get: function () {
  6064. return this._majorLineColor;
  6065. },
  6066. set: function (value) {
  6067. this._majorLineColor = value;
  6068. this._markAsDirty();
  6069. },
  6070. enumerable: false,
  6071. configurable: true
  6072. });
  6073. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  6074. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  6075. get: function () {
  6076. return this._majorLineFrequency;
  6077. },
  6078. set: function (value) {
  6079. this._majorLineFrequency = value;
  6080. this._markAsDirty();
  6081. },
  6082. enumerable: false,
  6083. configurable: true
  6084. });
  6085. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  6086. context.save();
  6087. this._applyStates(context);
  6088. if (this._isEnabled) {
  6089. if (this._background) {
  6090. context.fillStyle = this._background;
  6091. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6092. }
  6093. var cellCountX = this._currentMeasure.width / this._cellWidth;
  6094. var cellCountY = this._currentMeasure.height / this._cellHeight;
  6095. // Minor lines
  6096. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  6097. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  6098. if (this._displayMinorLines) {
  6099. context.strokeStyle = this._minorLineColor;
  6100. context.lineWidth = this._minorLineTickness;
  6101. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  6102. var cellX = left + x * this.cellWidth;
  6103. context.beginPath();
  6104. context.moveTo(cellX, this._currentMeasure.top);
  6105. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  6106. context.stroke();
  6107. }
  6108. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  6109. var cellY = top_1 + y * this.cellHeight;
  6110. context.beginPath();
  6111. context.moveTo(this._currentMeasure.left, cellY);
  6112. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  6113. context.stroke();
  6114. }
  6115. }
  6116. // Major lines
  6117. if (this._displayMajorLines) {
  6118. context.strokeStyle = this._majorLineColor;
  6119. context.lineWidth = this._majorLineTickness;
  6120. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  6121. var cellX = left + x * this.cellWidth;
  6122. context.beginPath();
  6123. context.moveTo(cellX, this._currentMeasure.top);
  6124. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  6125. context.stroke();
  6126. }
  6127. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  6128. var cellY = top_1 + y * this.cellHeight;
  6129. context.moveTo(this._currentMeasure.left, cellY);
  6130. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  6131. context.closePath();
  6132. context.stroke();
  6133. }
  6134. }
  6135. }
  6136. context.restore();
  6137. };
  6138. DisplayGrid.prototype._getTypeName = function () {
  6139. return "DisplayGrid";
  6140. };
  6141. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6142. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6143. ], DisplayGrid.prototype, "displayMinorLines", null);
  6144. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6145. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6146. ], DisplayGrid.prototype, "displayMajorLines", null);
  6147. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6148. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6149. ], DisplayGrid.prototype, "background", null);
  6150. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6151. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6152. ], DisplayGrid.prototype, "cellWidth", null);
  6153. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6154. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6155. ], DisplayGrid.prototype, "cellHeight", null);
  6156. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6157. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6158. ], DisplayGrid.prototype, "minorLineTickness", null);
  6159. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6160. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6161. ], DisplayGrid.prototype, "minorLineColor", null);
  6162. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6163. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6164. ], DisplayGrid.prototype, "majorLineTickness", null);
  6165. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6166. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6167. ], DisplayGrid.prototype, "majorLineColor", null);
  6168. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6169. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  6170. ], DisplayGrid.prototype, "majorLineFrequency", null);
  6171. return DisplayGrid;
  6172. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  6173. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  6174. /***/ }),
  6175. /***/ "./2D/controls/ellipse.ts":
  6176. /*!********************************!*\
  6177. !*** ./2D/controls/ellipse.ts ***!
  6178. \********************************/
  6179. /*! exports provided: Ellipse */
  6180. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6181. "use strict";
  6182. __webpack_require__.r(__webpack_exports__);
  6183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  6184. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6185. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6186. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6187. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  6188. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  6189. /** Class used to create 2D ellipse containers */
  6190. var Ellipse = /** @class */ (function (_super) {
  6191. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  6192. /**
  6193. * Creates a new Ellipse
  6194. * @param name defines the control name
  6195. */
  6196. function Ellipse(name) {
  6197. var _this = _super.call(this, name) || this;
  6198. _this.name = name;
  6199. _this._thickness = 1;
  6200. return _this;
  6201. }
  6202. Object.defineProperty(Ellipse.prototype, "thickness", {
  6203. /** Gets or sets border thickness */
  6204. get: function () {
  6205. return this._thickness;
  6206. },
  6207. set: function (value) {
  6208. if (this._thickness === value) {
  6209. return;
  6210. }
  6211. this._thickness = value;
  6212. this._markAsDirty();
  6213. },
  6214. enumerable: false,
  6215. configurable: true
  6216. });
  6217. Ellipse.prototype._getTypeName = function () {
  6218. return "Ellipse";
  6219. };
  6220. Ellipse.prototype._localDraw = function (context) {
  6221. context.save();
  6222. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6223. context.shadowColor = this.shadowColor;
  6224. context.shadowBlur = this.shadowBlur;
  6225. context.shadowOffsetX = this.shadowOffsetX;
  6226. context.shadowOffsetY = this.shadowOffsetY;
  6227. }
  6228. _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);
  6229. if (this._background) {
  6230. context.fillStyle = this._background;
  6231. context.fill();
  6232. }
  6233. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6234. context.shadowBlur = 0;
  6235. context.shadowOffsetX = 0;
  6236. context.shadowOffsetY = 0;
  6237. }
  6238. if (this._thickness) {
  6239. if (this.color) {
  6240. context.strokeStyle = this.color;
  6241. }
  6242. context.lineWidth = this._thickness;
  6243. context.stroke();
  6244. }
  6245. context.restore();
  6246. };
  6247. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  6248. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6249. this._measureForChildren.width -= 2 * this._thickness;
  6250. this._measureForChildren.height -= 2 * this._thickness;
  6251. this._measureForChildren.left += this._thickness;
  6252. this._measureForChildren.top += this._thickness;
  6253. };
  6254. Ellipse.prototype._clipForChildren = function (context) {
  6255. _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);
  6256. context.clip();
  6257. };
  6258. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  6259. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  6260. ], Ellipse.prototype, "thickness", null);
  6261. return Ellipse;
  6262. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6263. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  6264. /***/ }),
  6265. /***/ "./2D/controls/focusableButton.ts":
  6266. /*!****************************************!*\
  6267. !*** ./2D/controls/focusableButton.ts ***!
  6268. \****************************************/
  6269. /*! exports provided: FocusableButton */
  6270. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6271. "use strict";
  6272. __webpack_require__.r(__webpack_exports__);
  6273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return FocusableButton; });
  6274. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6275. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6276. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  6277. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  6278. /**
  6279. * Class used to create a focusable button that can easily handle keyboard events
  6280. */
  6281. var FocusableButton = /** @class */ (function (_super) {
  6282. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FocusableButton, _super);
  6283. function FocusableButton(name) {
  6284. var _this = _super.call(this, name) || this;
  6285. _this.name = name;
  6286. /** Highlight color when button is focused */
  6287. _this.focusedColor = null;
  6288. _this._isFocused = false;
  6289. _this._unfocusedColor = null;
  6290. /** Observable raised when the control gets the focus */
  6291. _this.onFocusObservable = new babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  6292. /** Observable raised when the control loses the focus */
  6293. _this.onBlurObservable = new babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  6294. /** Observable raised when a key event was processed */
  6295. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  6296. _this._unfocusedColor = _this.color;
  6297. return _this;
  6298. }
  6299. /** @hidden */
  6300. FocusableButton.prototype.onBlur = function () {
  6301. if (this._isFocused) {
  6302. this._isFocused = false;
  6303. if (this.focusedColor && this._unfocusedColor != null) {
  6304. // Set color back to saved unfocused color
  6305. this.color = this._unfocusedColor;
  6306. }
  6307. this.onBlurObservable.notifyObservers(this);
  6308. }
  6309. };
  6310. /** @hidden */
  6311. FocusableButton.prototype.onFocus = function () {
  6312. this._isFocused = true;
  6313. if (this.focusedColor) {
  6314. // Save the unfocused color
  6315. this._unfocusedColor = this.color;
  6316. this.color = this.focusedColor;
  6317. }
  6318. this.onFocusObservable.notifyObservers(this);
  6319. };
  6320. /**
  6321. * Function called to get the list of controls that should not steal the focus from this control
  6322. * @returns an array of controls
  6323. */
  6324. FocusableButton.prototype.keepsFocusWith = function () {
  6325. return null;
  6326. };
  6327. /**
  6328. * Function to focus a button programmatically
  6329. */
  6330. FocusableButton.prototype.focus = function () {
  6331. this._host.moveFocusToControl(this);
  6332. };
  6333. /**
  6334. * Function to unfocus a button programmatically
  6335. */
  6336. FocusableButton.prototype.blur = function () {
  6337. this._host.focusedControl = null;
  6338. };
  6339. /**
  6340. * Handles the keyboard event
  6341. * @param evt Defines the KeyboardEvent
  6342. */
  6343. FocusableButton.prototype.processKeyboard = function (evt) {
  6344. this.onKeyboardEventProcessedObservable.notifyObservers(evt, -1, this);
  6345. };
  6346. /** @hidden */
  6347. FocusableButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  6348. // Clicking on button should focus
  6349. this.focus();
  6350. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  6351. };
  6352. /** @hidden */
  6353. FocusableButton.prototype.displose = function () {
  6354. _super.prototype.dispose.call(this);
  6355. this.onBlurObservable.clear();
  6356. this.onFocusObservable.clear();
  6357. this.onKeyboardEventProcessedObservable.clear();
  6358. };
  6359. return FocusableButton;
  6360. }(_button__WEBPACK_IMPORTED_MODULE_1__["Button"]));
  6361. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FocusableButton"] = FocusableButton;
  6362. /***/ }),
  6363. /***/ "./2D/controls/grid.ts":
  6364. /*!*****************************!*\
  6365. !*** ./2D/controls/grid.ts ***!
  6366. \*****************************/
  6367. /*! exports provided: Grid */
  6368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6369. "use strict";
  6370. __webpack_require__.r(__webpack_exports__);
  6371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  6372. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6373. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6374. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6375. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6376. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  6377. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  6378. /**
  6379. * Class used to create a 2D grid container
  6380. */
  6381. var Grid = /** @class */ (function (_super) {
  6382. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  6383. /**
  6384. * Creates a new Grid
  6385. * @param name defines control name
  6386. */
  6387. function Grid(name) {
  6388. var _this = _super.call(this, name) || this;
  6389. _this.name = name;
  6390. _this._rowDefinitions = new Array();
  6391. _this._columnDefinitions = new Array();
  6392. _this._cells = {};
  6393. _this._childControls = new Array();
  6394. return _this;
  6395. }
  6396. Object.defineProperty(Grid.prototype, "columnCount", {
  6397. /**
  6398. * Gets the number of columns
  6399. */
  6400. get: function () {
  6401. return this._columnDefinitions.length;
  6402. },
  6403. enumerable: false,
  6404. configurable: true
  6405. });
  6406. Object.defineProperty(Grid.prototype, "rowCount", {
  6407. /**
  6408. * Gets the number of rows
  6409. */
  6410. get: function () {
  6411. return this._rowDefinitions.length;
  6412. },
  6413. enumerable: false,
  6414. configurable: true
  6415. });
  6416. Object.defineProperty(Grid.prototype, "children", {
  6417. /** Gets the list of children */
  6418. get: function () {
  6419. return this._childControls;
  6420. },
  6421. enumerable: false,
  6422. configurable: true
  6423. });
  6424. Object.defineProperty(Grid.prototype, "cells", {
  6425. /** Gets the list of cells (e.g. the containers) */
  6426. get: function () {
  6427. return this._cells;
  6428. },
  6429. enumerable: false,
  6430. configurable: true
  6431. });
  6432. /**
  6433. * Gets the definition of a specific row
  6434. * @param index defines the index of the row
  6435. * @returns the row definition
  6436. */
  6437. Grid.prototype.getRowDefinition = function (index) {
  6438. if (index < 0 || index >= this._rowDefinitions.length) {
  6439. return null;
  6440. }
  6441. return this._rowDefinitions[index];
  6442. };
  6443. /**
  6444. * Gets the definition of a specific column
  6445. * @param index defines the index of the column
  6446. * @returns the column definition
  6447. */
  6448. Grid.prototype.getColumnDefinition = function (index) {
  6449. if (index < 0 || index >= this._columnDefinitions.length) {
  6450. return null;
  6451. }
  6452. return this._columnDefinitions[index];
  6453. };
  6454. /**
  6455. * Adds a new row to the grid
  6456. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  6457. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  6458. * @returns the current grid
  6459. */
  6460. Grid.prototype.addRowDefinition = function (height, isPixel) {
  6461. if (isPixel === void 0) { isPixel = false; }
  6462. 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));
  6463. this._markAsDirty();
  6464. return this;
  6465. };
  6466. /**
  6467. * Adds a new column to the grid
  6468. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6469. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6470. * @returns the current grid
  6471. */
  6472. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  6473. if (isPixel === void 0) { isPixel = false; }
  6474. 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));
  6475. this._markAsDirty();
  6476. return this;
  6477. };
  6478. /**
  6479. * Update a row definition
  6480. * @param index defines the index of the row to update
  6481. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  6482. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  6483. * @returns the current grid
  6484. */
  6485. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  6486. if (isPixel === void 0) { isPixel = false; }
  6487. if (index < 0 || index >= this._rowDefinitions.length) {
  6488. return this;
  6489. }
  6490. var current = this._rowDefinitions[index];
  6491. if (current && current.isPixel === isPixel && current.internalValue === height) {
  6492. return this;
  6493. }
  6494. 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);
  6495. this._markAsDirty();
  6496. return this;
  6497. };
  6498. /**
  6499. * Update a column definition
  6500. * @param index defines the index of the column to update
  6501. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6502. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6503. * @returns the current grid
  6504. */
  6505. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  6506. if (isPixel === void 0) { isPixel = false; }
  6507. if (index < 0 || index >= this._columnDefinitions.length) {
  6508. return this;
  6509. }
  6510. var current = this._columnDefinitions[index];
  6511. if (current && current.isPixel === isPixel && current.internalValue === width) {
  6512. return this;
  6513. }
  6514. 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);
  6515. this._markAsDirty();
  6516. return this;
  6517. };
  6518. /**
  6519. * Gets the list of children stored in a specific cell
  6520. * @param row defines the row to check
  6521. * @param column defines the column to check
  6522. * @returns the list of controls
  6523. */
  6524. Grid.prototype.getChildrenAt = function (row, column) {
  6525. var cell = this._cells[row + ":" + column];
  6526. if (!cell) {
  6527. return null;
  6528. }
  6529. return cell.children;
  6530. };
  6531. /**
  6532. * Gets a string representing the child cell info (row x column)
  6533. * @param child defines the control to get info from
  6534. * @returns a string containing the child cell info (row x column)
  6535. */
  6536. Grid.prototype.getChildCellInfo = function (child) {
  6537. return child._tag;
  6538. };
  6539. Grid.prototype._removeCell = function (cell, key) {
  6540. if (!cell) {
  6541. return;
  6542. }
  6543. _super.prototype.removeControl.call(this, cell);
  6544. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  6545. var control = _a[_i];
  6546. var childIndex = this._childControls.indexOf(control);
  6547. if (childIndex !== -1) {
  6548. this._childControls.splice(childIndex, 1);
  6549. }
  6550. }
  6551. delete this._cells[key];
  6552. };
  6553. Grid.prototype._offsetCell = function (previousKey, key) {
  6554. if (!this._cells[key]) {
  6555. return;
  6556. }
  6557. this._cells[previousKey] = this._cells[key];
  6558. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  6559. var control = _a[_i];
  6560. control._tag = previousKey;
  6561. }
  6562. delete this._cells[key];
  6563. };
  6564. /**
  6565. * Remove a column definition at specified index
  6566. * @param index defines the index of the column to remove
  6567. * @returns the current grid
  6568. */
  6569. Grid.prototype.removeColumnDefinition = function (index) {
  6570. if (index < 0 || index >= this._columnDefinitions.length) {
  6571. return this;
  6572. }
  6573. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6574. var key = x + ":" + index;
  6575. var cell = this._cells[key];
  6576. this._removeCell(cell, key);
  6577. }
  6578. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6579. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6580. var previousKey = x + ":" + (y - 1);
  6581. var key = x + ":" + y;
  6582. this._offsetCell(previousKey, key);
  6583. }
  6584. }
  6585. this._columnDefinitions.splice(index, 1);
  6586. this._markAsDirty();
  6587. return this;
  6588. };
  6589. /**
  6590. * Remove a row definition at specified index
  6591. * @param index defines the index of the row to remove
  6592. * @returns the current grid
  6593. */
  6594. Grid.prototype.removeRowDefinition = function (index) {
  6595. if (index < 0 || index >= this._rowDefinitions.length) {
  6596. return this;
  6597. }
  6598. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6599. var key = index + ":" + y;
  6600. var cell = this._cells[key];
  6601. this._removeCell(cell, key);
  6602. }
  6603. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6604. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6605. var previousKey = x - 1 + ":" + y;
  6606. var key = x + ":" + y;
  6607. this._offsetCell(previousKey, key);
  6608. }
  6609. }
  6610. this._rowDefinitions.splice(index, 1);
  6611. this._markAsDirty();
  6612. return this;
  6613. };
  6614. /**
  6615. * Adds a new control to the current grid
  6616. * @param control defines the control to add
  6617. * @param row defines the row where to add the control (0 by default)
  6618. * @param column defines the column where to add the control (0 by default)
  6619. * @returns the current grid
  6620. */
  6621. Grid.prototype.addControl = function (control, row, column) {
  6622. if (row === void 0) { row = 0; }
  6623. if (column === void 0) { column = 0; }
  6624. if (this._rowDefinitions.length === 0) {
  6625. // Add default row definition
  6626. this.addRowDefinition(1, false);
  6627. }
  6628. if (this._columnDefinitions.length === 0) {
  6629. // Add default column definition
  6630. this.addColumnDefinition(1, false);
  6631. }
  6632. if (this._childControls.indexOf(control) !== -1) {
  6633. 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");
  6634. return this;
  6635. }
  6636. var x = Math.min(row, this._rowDefinitions.length - 1);
  6637. var y = Math.min(column, this._columnDefinitions.length - 1);
  6638. var key = x + ":" + y;
  6639. var goodContainer = this._cells[key];
  6640. if (!goodContainer) {
  6641. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6642. this._cells[key] = goodContainer;
  6643. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6644. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6645. _super.prototype.addControl.call(this, goodContainer);
  6646. }
  6647. goodContainer.addControl(control);
  6648. this._childControls.push(control);
  6649. control._tag = key;
  6650. control.parent = this;
  6651. this._markAsDirty();
  6652. return this;
  6653. };
  6654. /**
  6655. * Removes a control from the current container
  6656. * @param control defines the control to remove
  6657. * @returns the current container
  6658. */
  6659. Grid.prototype.removeControl = function (control) {
  6660. var index = this._childControls.indexOf(control);
  6661. if (index !== -1) {
  6662. this._childControls.splice(index, 1);
  6663. }
  6664. var cell = this._cells[control._tag];
  6665. if (cell) {
  6666. cell.removeControl(control);
  6667. control._tag = null;
  6668. }
  6669. this._markAsDirty();
  6670. return this;
  6671. };
  6672. Grid.prototype._getTypeName = function () {
  6673. return "Grid";
  6674. };
  6675. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6676. var widths = [];
  6677. var heights = [];
  6678. var lefts = [];
  6679. var tops = [];
  6680. var availableWidth = this._currentMeasure.width;
  6681. var globalWidthPercentage = 0;
  6682. var availableHeight = this._currentMeasure.height;
  6683. var globalHeightPercentage = 0;
  6684. // Heights
  6685. var index = 0;
  6686. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6687. var value = _a[_i];
  6688. if (value.isPixel) {
  6689. var height = value.getValue(this._host);
  6690. availableHeight -= height;
  6691. heights[index] = height;
  6692. }
  6693. else {
  6694. globalHeightPercentage += value.internalValue;
  6695. }
  6696. index++;
  6697. }
  6698. var top = 0;
  6699. index = 0;
  6700. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6701. var value = _c[_b];
  6702. tops.push(top);
  6703. if (!value.isPixel) {
  6704. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6705. top += height;
  6706. heights[index] = height;
  6707. }
  6708. else {
  6709. top += value.getValue(this._host);
  6710. }
  6711. index++;
  6712. }
  6713. // Widths
  6714. index = 0;
  6715. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6716. var value = _e[_d];
  6717. if (value.isPixel) {
  6718. var width = value.getValue(this._host);
  6719. availableWidth -= width;
  6720. widths[index] = width;
  6721. }
  6722. else {
  6723. globalWidthPercentage += value.internalValue;
  6724. }
  6725. index++;
  6726. }
  6727. var left = 0;
  6728. index = 0;
  6729. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6730. var value = _g[_f];
  6731. lefts.push(left);
  6732. if (!value.isPixel) {
  6733. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6734. left += width;
  6735. widths[index] = width;
  6736. }
  6737. else {
  6738. left += value.getValue(this._host);
  6739. }
  6740. index++;
  6741. }
  6742. definitionCallback(lefts, tops, widths, heights);
  6743. };
  6744. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6745. var _this = this;
  6746. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6747. // Setting child sizes
  6748. for (var key in _this._cells) {
  6749. if (!_this._cells.hasOwnProperty(key)) {
  6750. continue;
  6751. }
  6752. var split = key.split(":");
  6753. var x = parseInt(split[0]);
  6754. var y = parseInt(split[1]);
  6755. var cell = _this._cells[key];
  6756. cell.left = lefts[y] + "px";
  6757. cell.top = tops[x] + "px";
  6758. cell.width = widths[y] + "px";
  6759. cell.height = heights[x] + "px";
  6760. cell._left.ignoreAdaptiveScaling = true;
  6761. cell._top.ignoreAdaptiveScaling = true;
  6762. cell._width.ignoreAdaptiveScaling = true;
  6763. cell._height.ignoreAdaptiveScaling = true;
  6764. }
  6765. });
  6766. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6767. };
  6768. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6769. for (var key in this._cells) {
  6770. if (!this._cells.hasOwnProperty(key)) {
  6771. continue;
  6772. }
  6773. var child = this._cells[key];
  6774. child._markMatrixAsDirty();
  6775. }
  6776. };
  6777. Grid.prototype._renderHighlightSpecific = function (context) {
  6778. var _this = this;
  6779. _super.prototype._renderHighlightSpecific.call(this, context);
  6780. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6781. // Columns
  6782. for (var index = 0; index < lefts.length; index++) {
  6783. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6784. context.beginPath();
  6785. context.moveTo(left, _this._currentMeasure.top);
  6786. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6787. context.stroke();
  6788. }
  6789. // Rows
  6790. for (var index = 0; index < tops.length; index++) {
  6791. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6792. context.beginPath();
  6793. context.moveTo(_this._currentMeasure.left, top_1);
  6794. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6795. context.stroke();
  6796. }
  6797. });
  6798. context.restore();
  6799. };
  6800. /** Releases associated resources */
  6801. Grid.prototype.dispose = function () {
  6802. _super.prototype.dispose.call(this);
  6803. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6804. var control = _a[_i];
  6805. control.dispose();
  6806. }
  6807. this._childControls = [];
  6808. };
  6809. return Grid;
  6810. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6811. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6812. /***/ }),
  6813. /***/ "./2D/controls/image.ts":
  6814. /*!******************************!*\
  6815. !*** ./2D/controls/image.ts ***!
  6816. \******************************/
  6817. /*! exports provided: Image */
  6818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6819. "use strict";
  6820. __webpack_require__.r(__webpack_exports__);
  6821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6822. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6823. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6824. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6825. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6826. /**
  6827. * Class used to create 2D images
  6828. */
  6829. var Image = /** @class */ (function (_super) {
  6830. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6831. /**
  6832. * Creates a new Image
  6833. * @param name defines the control name
  6834. * @param url defines the image url
  6835. */
  6836. function Image(name, url) {
  6837. if (url === void 0) { url = null; }
  6838. var _this = _super.call(this, name) || this;
  6839. _this.name = name;
  6840. _this._workingCanvas = null;
  6841. _this._loaded = false;
  6842. _this._stretch = Image.STRETCH_FILL;
  6843. _this._autoScale = false;
  6844. _this._sourceLeft = 0;
  6845. _this._sourceTop = 0;
  6846. _this._sourceWidth = 0;
  6847. _this._sourceHeight = 0;
  6848. _this._svgAttributesComputationCompleted = false;
  6849. _this._isSVG = false;
  6850. _this._cellWidth = 0;
  6851. _this._cellHeight = 0;
  6852. _this._cellId = -1;
  6853. _this._populateNinePatchSlicesFromImage = false;
  6854. _this._imageDataCache = { data: null, key: "" };
  6855. /**
  6856. * Observable notified when the content is loaded
  6857. */
  6858. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6859. /**
  6860. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6861. */
  6862. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6863. _this.source = url;
  6864. return _this;
  6865. }
  6866. Object.defineProperty(Image.prototype, "isLoaded", {
  6867. /**
  6868. * Gets a boolean indicating that the content is loaded
  6869. */
  6870. get: function () {
  6871. return this._loaded;
  6872. },
  6873. enumerable: false,
  6874. configurable: true
  6875. });
  6876. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6877. /**
  6878. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6879. * Beware using this as this will comsume more memory as the image has to be stored twice
  6880. */
  6881. get: function () {
  6882. return this._detectPointerOnOpaqueOnly;
  6883. },
  6884. set: function (value) {
  6885. if (this._detectPointerOnOpaqueOnly === value) {
  6886. return;
  6887. }
  6888. this._detectPointerOnOpaqueOnly = value;
  6889. },
  6890. enumerable: false,
  6891. configurable: true
  6892. });
  6893. Object.defineProperty(Image.prototype, "sliceLeft", {
  6894. /**
  6895. * Gets or sets the left value for slicing (9-patch)
  6896. */
  6897. get: function () {
  6898. return this._sliceLeft;
  6899. },
  6900. set: function (value) {
  6901. if (this._sliceLeft === value) {
  6902. return;
  6903. }
  6904. this._sliceLeft = value;
  6905. this._markAsDirty();
  6906. },
  6907. enumerable: false,
  6908. configurable: true
  6909. });
  6910. Object.defineProperty(Image.prototype, "sliceRight", {
  6911. /**
  6912. * Gets or sets the right value for slicing (9-patch)
  6913. */
  6914. get: function () {
  6915. return this._sliceRight;
  6916. },
  6917. set: function (value) {
  6918. if (this._sliceRight === value) {
  6919. return;
  6920. }
  6921. this._sliceRight = value;
  6922. this._markAsDirty();
  6923. },
  6924. enumerable: false,
  6925. configurable: true
  6926. });
  6927. Object.defineProperty(Image.prototype, "sliceTop", {
  6928. /**
  6929. * Gets or sets the top value for slicing (9-patch)
  6930. */
  6931. get: function () {
  6932. return this._sliceTop;
  6933. },
  6934. set: function (value) {
  6935. if (this._sliceTop === value) {
  6936. return;
  6937. }
  6938. this._sliceTop = value;
  6939. this._markAsDirty();
  6940. },
  6941. enumerable: false,
  6942. configurable: true
  6943. });
  6944. Object.defineProperty(Image.prototype, "sliceBottom", {
  6945. /**
  6946. * Gets or sets the bottom value for slicing (9-patch)
  6947. */
  6948. get: function () {
  6949. return this._sliceBottom;
  6950. },
  6951. set: function (value) {
  6952. if (this._sliceBottom === value) {
  6953. return;
  6954. }
  6955. this._sliceBottom = value;
  6956. this._markAsDirty();
  6957. },
  6958. enumerable: false,
  6959. configurable: true
  6960. });
  6961. Object.defineProperty(Image.prototype, "sourceLeft", {
  6962. /**
  6963. * Gets or sets the left coordinate in the source image
  6964. */
  6965. get: function () {
  6966. return this._sourceLeft;
  6967. },
  6968. set: function (value) {
  6969. if (this._sourceLeft === value) {
  6970. return;
  6971. }
  6972. this._sourceLeft = value;
  6973. this._markAsDirty();
  6974. },
  6975. enumerable: false,
  6976. configurable: true
  6977. });
  6978. Object.defineProperty(Image.prototype, "sourceTop", {
  6979. /**
  6980. * Gets or sets the top coordinate in the source image
  6981. */
  6982. get: function () {
  6983. return this._sourceTop;
  6984. },
  6985. set: function (value) {
  6986. if (this._sourceTop === value) {
  6987. return;
  6988. }
  6989. this._sourceTop = value;
  6990. this._markAsDirty();
  6991. },
  6992. enumerable: false,
  6993. configurable: true
  6994. });
  6995. Object.defineProperty(Image.prototype, "sourceWidth", {
  6996. /**
  6997. * Gets or sets the width to capture in the source image
  6998. */
  6999. get: function () {
  7000. return this._sourceWidth;
  7001. },
  7002. set: function (value) {
  7003. if (this._sourceWidth === value) {
  7004. return;
  7005. }
  7006. this._sourceWidth = value;
  7007. this._markAsDirty();
  7008. },
  7009. enumerable: false,
  7010. configurable: true
  7011. });
  7012. Object.defineProperty(Image.prototype, "sourceHeight", {
  7013. /**
  7014. * Gets or sets the height to capture in the source image
  7015. */
  7016. get: function () {
  7017. return this._sourceHeight;
  7018. },
  7019. set: function (value) {
  7020. if (this._sourceHeight === value) {
  7021. return;
  7022. }
  7023. this._sourceHeight = value;
  7024. this._markAsDirty();
  7025. },
  7026. enumerable: false,
  7027. configurable: true
  7028. });
  7029. Object.defineProperty(Image.prototype, "imageWidth", {
  7030. /**
  7031. * Gets the image width
  7032. */
  7033. get: function () {
  7034. return this._imageWidth;
  7035. },
  7036. enumerable: false,
  7037. configurable: true
  7038. });
  7039. Object.defineProperty(Image.prototype, "imageHeight", {
  7040. /**
  7041. * Gets the image height
  7042. */
  7043. get: function () {
  7044. return this._imageHeight;
  7045. },
  7046. enumerable: false,
  7047. configurable: true
  7048. });
  7049. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  7050. /**
  7051. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  7052. */
  7053. get: function () {
  7054. return this._populateNinePatchSlicesFromImage;
  7055. },
  7056. set: function (value) {
  7057. if (this._populateNinePatchSlicesFromImage === value) {
  7058. return;
  7059. }
  7060. this._populateNinePatchSlicesFromImage = value;
  7061. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  7062. this._extractNinePatchSliceDataFromImage();
  7063. }
  7064. },
  7065. enumerable: false,
  7066. configurable: true
  7067. });
  7068. Object.defineProperty(Image.prototype, "isSVG", {
  7069. /** Indicates if the format of the image is SVG */
  7070. get: function () {
  7071. return this._isSVG;
  7072. },
  7073. enumerable: false,
  7074. configurable: true
  7075. });
  7076. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  7077. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  7078. get: function () {
  7079. return this._svgAttributesComputationCompleted;
  7080. },
  7081. enumerable: false,
  7082. configurable: true
  7083. });
  7084. Object.defineProperty(Image.prototype, "autoScale", {
  7085. /**
  7086. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  7087. * @see https://doc.babylonjs.com/how_to/gui#image
  7088. */
  7089. get: function () {
  7090. return this._autoScale;
  7091. },
  7092. set: function (value) {
  7093. if (this._autoScale === value) {
  7094. return;
  7095. }
  7096. this._autoScale = value;
  7097. if (value && this._loaded) {
  7098. this.synchronizeSizeWithContent();
  7099. }
  7100. },
  7101. enumerable: false,
  7102. configurable: true
  7103. });
  7104. Object.defineProperty(Image.prototype, "stretch", {
  7105. /** Gets or sets the streching mode used by the image */
  7106. get: function () {
  7107. return this._stretch;
  7108. },
  7109. set: function (value) {
  7110. if (this._stretch === value) {
  7111. return;
  7112. }
  7113. this._stretch = value;
  7114. this._markAsDirty();
  7115. },
  7116. enumerable: false,
  7117. configurable: true
  7118. });
  7119. /** @hidden */
  7120. Image.prototype._rotate90 = function (n, preserveProperties) {
  7121. if (preserveProperties === void 0) { preserveProperties = false; }
  7122. var canvas = document.createElement("canvas");
  7123. var context = canvas.getContext("2d");
  7124. var width = this._domImage.width;
  7125. var height = this._domImage.height;
  7126. canvas.width = height;
  7127. canvas.height = width;
  7128. context.translate(canvas.width / 2, canvas.height / 2);
  7129. context.rotate((n * Math.PI) / 2);
  7130. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  7131. var dataUrl = canvas.toDataURL("image/jpg");
  7132. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  7133. if (preserveProperties) {
  7134. rotatedImage._stretch = this._stretch;
  7135. rotatedImage._autoScale = this._autoScale;
  7136. rotatedImage._cellId = this._cellId;
  7137. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  7138. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  7139. }
  7140. this._handleRotationForSVGImage(this, rotatedImage, n);
  7141. this._imageDataCache.data = null;
  7142. return rotatedImage;
  7143. };
  7144. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  7145. var _this = this;
  7146. if (!srcImage._isSVG) {
  7147. return;
  7148. }
  7149. if (srcImage._svgAttributesComputationCompleted) {
  7150. this._rotate90SourceProperties(srcImage, dstImage, n);
  7151. this._markAsDirty();
  7152. }
  7153. else {
  7154. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  7155. _this._rotate90SourceProperties(srcImage, dstImage, n);
  7156. _this._markAsDirty();
  7157. });
  7158. }
  7159. };
  7160. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  7161. var _a, _b;
  7162. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  7163. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  7164. if (n != 0) {
  7165. var mult = n < 0 ? -1 : 1;
  7166. n = n % 4;
  7167. for (var i = 0; i < Math.abs(n); ++i) {
  7168. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  7169. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  7170. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  7171. if (n < 0) {
  7172. dstTop -= dstHeight;
  7173. }
  7174. else {
  7175. dstLeft -= dstWidth;
  7176. }
  7177. srcLeft = dstLeft;
  7178. srcTop = dstTop;
  7179. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  7180. }
  7181. }
  7182. dstImage.sourceLeft = dstLeft;
  7183. dstImage.sourceTop = dstTop;
  7184. dstImage.sourceWidth = dstWidth;
  7185. dstImage.sourceHeight = dstHeight;
  7186. };
  7187. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  7188. if (!this._workingCanvas) {
  7189. this._workingCanvas = document.createElement("canvas");
  7190. }
  7191. var canvas = this._workingCanvas;
  7192. var context = canvas.getContext("2d");
  7193. var width = this._domImage.width;
  7194. var height = this._domImage.height;
  7195. canvas.width = width;
  7196. canvas.height = height;
  7197. context.drawImage(this._domImage, 0, 0, width, height);
  7198. var imageData = context.getImageData(0, 0, width, height);
  7199. // Left and right
  7200. this._sliceLeft = -1;
  7201. this._sliceRight = -1;
  7202. for (var x = 0; x < width; x++) {
  7203. var alpha = imageData.data[x * 4 + 3];
  7204. if (alpha > 127 && this._sliceLeft === -1) {
  7205. this._sliceLeft = x;
  7206. continue;
  7207. }
  7208. if (alpha < 127 && this._sliceLeft > -1) {
  7209. this._sliceRight = x;
  7210. break;
  7211. }
  7212. }
  7213. // top and bottom
  7214. this._sliceTop = -1;
  7215. this._sliceBottom = -1;
  7216. for (var y = 0; y < height; y++) {
  7217. var alpha = imageData.data[y * width * 4 + 3];
  7218. if (alpha > 127 && this._sliceTop === -1) {
  7219. this._sliceTop = y;
  7220. continue;
  7221. }
  7222. if (alpha < 127 && this._sliceTop > -1) {
  7223. this._sliceBottom = y;
  7224. break;
  7225. }
  7226. }
  7227. };
  7228. Object.defineProperty(Image.prototype, "domImage", {
  7229. get: function () {
  7230. return this._domImage;
  7231. },
  7232. /**
  7233. * Gets or sets the internal DOM image used to render the control
  7234. */
  7235. set: function (value) {
  7236. var _this = this;
  7237. this._domImage = value;
  7238. this._loaded = false;
  7239. this._imageDataCache.data = null;
  7240. if (this._domImage.width) {
  7241. this._onImageLoaded();
  7242. }
  7243. else {
  7244. this._domImage.onload = function () {
  7245. _this._onImageLoaded();
  7246. };
  7247. }
  7248. },
  7249. enumerable: false,
  7250. configurable: true
  7251. });
  7252. Image.prototype._onImageLoaded = function () {
  7253. this._imageDataCache.data = null;
  7254. this._imageWidth = this._domImage.width;
  7255. this._imageHeight = this._domImage.height;
  7256. this._loaded = true;
  7257. if (this._populateNinePatchSlicesFromImage) {
  7258. this._extractNinePatchSliceDataFromImage();
  7259. }
  7260. if (this._autoScale) {
  7261. this.synchronizeSizeWithContent();
  7262. }
  7263. this.onImageLoadedObservable.notifyObservers(this);
  7264. this._markAsDirty();
  7265. };
  7266. Object.defineProperty(Image.prototype, "source", {
  7267. /**
  7268. * Gets the image source url
  7269. */
  7270. get: function () {
  7271. return this._source;
  7272. },
  7273. /**
  7274. * Gets or sets image source url
  7275. */
  7276. set: function (value) {
  7277. var _this = this;
  7278. if (this._source === value) {
  7279. return;
  7280. }
  7281. this._loaded = false;
  7282. this._source = value;
  7283. this._imageDataCache.data = null;
  7284. if (value) {
  7285. value = this._svgCheck(value);
  7286. }
  7287. this._domImage = document.createElement("img");
  7288. this._domImage.onload = function () {
  7289. _this._onImageLoaded();
  7290. };
  7291. if (value) {
  7292. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  7293. this._domImage.src = value;
  7294. }
  7295. },
  7296. enumerable: false,
  7297. configurable: true
  7298. });
  7299. /**
  7300. * Checks for svg document with icon id present
  7301. */
  7302. Image.prototype._svgCheck = function (value) {
  7303. var _this = this;
  7304. if (window.SVGSVGElement && value.search(/.svg#/gi) !== -1 && value.indexOf("#") === value.lastIndexOf("#")) {
  7305. this._isSVG = true;
  7306. var svgsrc = value.split("#")[0];
  7307. var elemid = value.split("#")[1];
  7308. // check if object alr exist in document
  7309. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  7310. if (svgExist) {
  7311. var svgDoc = svgExist.contentDocument;
  7312. // get viewbox width and height, get svg document width and height in px
  7313. if (svgDoc && svgDoc.documentElement) {
  7314. var vb = svgDoc.documentElement.getAttribute("viewBox");
  7315. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  7316. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  7317. var elem = svgDoc.getElementById(elemid);
  7318. if (elem && vb && docwidth && docheight) {
  7319. this._getSVGAttribs(svgExist, elemid);
  7320. return value;
  7321. }
  7322. }
  7323. // wait for object to load
  7324. svgExist.addEventListener("load", function () {
  7325. _this._getSVGAttribs(svgExist, elemid);
  7326. });
  7327. }
  7328. else {
  7329. // create document object
  7330. var svgImage = document.createElement("object");
  7331. svgImage.data = svgsrc;
  7332. svgImage.type = "image/svg+xml";
  7333. svgImage.width = "0%";
  7334. svgImage.height = "0%";
  7335. document.body.appendChild(svgImage);
  7336. // when the object has loaded, get the element attribs
  7337. svgImage.onload = function () {
  7338. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  7339. if (svgobj) {
  7340. _this._getSVGAttribs(svgobj, elemid);
  7341. }
  7342. };
  7343. }
  7344. return svgsrc;
  7345. }
  7346. else {
  7347. return value;
  7348. }
  7349. };
  7350. /**
  7351. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  7352. * given external svg file and icon id
  7353. */
  7354. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  7355. var svgDoc = svgsrc.contentDocument;
  7356. // get viewbox width and height, get svg document width and height in px
  7357. if (svgDoc && svgDoc.documentElement) {
  7358. var vb = svgDoc.documentElement.getAttribute("viewBox");
  7359. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  7360. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  7361. // get element bbox and matrix transform
  7362. var elem = svgDoc.getElementById(elemid);
  7363. if (vb && docwidth && docheight && elem) {
  7364. var vb_width = Number(vb.split(" ")[2]);
  7365. var vb_height = Number(vb.split(" ")[3]);
  7366. var elem_bbox = elem.getBBox();
  7367. var elem_matrix_a = 1;
  7368. var elem_matrix_d = 1;
  7369. var elem_matrix_e = 0;
  7370. var elem_matrix_f = 0;
  7371. if (elem.transform && elem.transform.baseVal.consolidate()) {
  7372. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  7373. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  7374. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  7375. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  7376. }
  7377. // compute source coordinates and dimensions
  7378. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  7379. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  7380. this.sourceWidth = elem_bbox.width * elem_matrix_a * (docwidth / vb_width);
  7381. this.sourceHeight = elem_bbox.height * elem_matrix_d * (docheight / vb_height);
  7382. this._svgAttributesComputationCompleted = true;
  7383. this.onSVGAttributesComputedObservable.notifyObservers(this);
  7384. }
  7385. }
  7386. };
  7387. Object.defineProperty(Image.prototype, "cellWidth", {
  7388. /**
  7389. * Gets or sets the cell width to use when animation sheet is enabled
  7390. * @see https://doc.babylonjs.com/how_to/gui#image
  7391. */
  7392. get: function () {
  7393. return this._cellWidth;
  7394. },
  7395. set: function (value) {
  7396. if (this._cellWidth === value) {
  7397. return;
  7398. }
  7399. this._cellWidth = value;
  7400. this._markAsDirty();
  7401. },
  7402. enumerable: false,
  7403. configurable: true
  7404. });
  7405. Object.defineProperty(Image.prototype, "cellHeight", {
  7406. /**
  7407. * Gets or sets the cell height to use when animation sheet is enabled
  7408. * @see https://doc.babylonjs.com/how_to/gui#image
  7409. */
  7410. get: function () {
  7411. return this._cellHeight;
  7412. },
  7413. set: function (value) {
  7414. if (this._cellHeight === value) {
  7415. return;
  7416. }
  7417. this._cellHeight = value;
  7418. this._markAsDirty();
  7419. },
  7420. enumerable: false,
  7421. configurable: true
  7422. });
  7423. Object.defineProperty(Image.prototype, "cellId", {
  7424. /**
  7425. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  7426. * @see https://doc.babylonjs.com/how_to/gui#image
  7427. */
  7428. get: function () {
  7429. return this._cellId;
  7430. },
  7431. set: function (value) {
  7432. if (this._cellId === value) {
  7433. return;
  7434. }
  7435. this._cellId = value;
  7436. this._markAsDirty();
  7437. },
  7438. enumerable: false,
  7439. configurable: true
  7440. });
  7441. /**
  7442. * Tests if a given coordinates belong to the current control
  7443. * @param x defines x coordinate to test
  7444. * @param y defines y coordinate to test
  7445. * @returns true if the coordinates are inside the control
  7446. */
  7447. Image.prototype.contains = function (x, y) {
  7448. if (!_super.prototype.contains.call(this, x, y)) {
  7449. return false;
  7450. }
  7451. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  7452. return true;
  7453. }
  7454. var width = this._currentMeasure.width | 0;
  7455. var height = this._currentMeasure.height | 0;
  7456. var key = width + "_" + height;
  7457. var imageData = this._imageDataCache.data;
  7458. if (!imageData || this._imageDataCache.key !== key) {
  7459. var canvas = this._workingCanvas;
  7460. var context_1 = canvas.getContext("2d");
  7461. this._imageDataCache.data = imageData = context_1.getImageData(0, 0, width, height).data;
  7462. this._imageDataCache.key = key;
  7463. }
  7464. x = (x - this._currentMeasure.left) | 0;
  7465. y = (y - this._currentMeasure.top) | 0;
  7466. var pickedPixel = imageData[(x + y * width) * 4 + 3];
  7467. return pickedPixel > 0;
  7468. };
  7469. Image.prototype._getTypeName = function () {
  7470. return "Image";
  7471. };
  7472. /** Force the control to synchronize with its content */
  7473. Image.prototype.synchronizeSizeWithContent = function () {
  7474. if (!this._loaded) {
  7475. return;
  7476. }
  7477. this.width = this._domImage.width + "px";
  7478. this.height = this._domImage.height + "px";
  7479. };
  7480. Image.prototype._processMeasures = function (parentMeasure, context) {
  7481. if (this._loaded) {
  7482. switch (this._stretch) {
  7483. case Image.STRETCH_NONE:
  7484. break;
  7485. case Image.STRETCH_FILL:
  7486. break;
  7487. case Image.STRETCH_UNIFORM:
  7488. break;
  7489. case Image.STRETCH_NINE_PATCH:
  7490. break;
  7491. case Image.STRETCH_EXTEND:
  7492. if (this._autoScale) {
  7493. this.synchronizeSizeWithContent();
  7494. }
  7495. if (this.parent && this.parent.parent) {
  7496. // Will update root size if root is not the top root
  7497. this.parent.adaptWidthToChildren = true;
  7498. this.parent.adaptHeightToChildren = true;
  7499. }
  7500. break;
  7501. }
  7502. }
  7503. _super.prototype._processMeasures.call(this, parentMeasure, context);
  7504. };
  7505. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  7506. if (!this._detectPointerOnOpaqueOnly) {
  7507. return;
  7508. }
  7509. if (!this._workingCanvas) {
  7510. this._workingCanvas = document.createElement("canvas");
  7511. }
  7512. var canvas = this._workingCanvas;
  7513. var width = this._currentMeasure.width;
  7514. var height = this._currentMeasure.height;
  7515. var context = canvas.getContext("2d");
  7516. canvas.width = width;
  7517. canvas.height = height;
  7518. context.clearRect(0, 0, width, height);
  7519. };
  7520. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  7521. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  7522. if (!this._detectPointerOnOpaqueOnly) {
  7523. return;
  7524. }
  7525. var canvas = this._workingCanvas;
  7526. context = canvas.getContext("2d");
  7527. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  7528. };
  7529. Image.prototype._draw = function (context) {
  7530. context.save();
  7531. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7532. context.shadowColor = this.shadowColor;
  7533. context.shadowBlur = this.shadowBlur;
  7534. context.shadowOffsetX = this.shadowOffsetX;
  7535. context.shadowOffsetY = this.shadowOffsetY;
  7536. }
  7537. var x, y, width, height;
  7538. if (this.cellId == -1) {
  7539. x = this._sourceLeft;
  7540. y = this._sourceTop;
  7541. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  7542. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  7543. }
  7544. else {
  7545. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  7546. var column = (this.cellId / rowCount) >> 0;
  7547. var row = this.cellId % rowCount;
  7548. x = this.cellWidth * row;
  7549. y = this.cellHeight * column;
  7550. width = this.cellWidth;
  7551. height = this.cellHeight;
  7552. }
  7553. this._prepareWorkingCanvasForOpaqueDetection();
  7554. this._applyStates(context);
  7555. if (this._loaded) {
  7556. switch (this._stretch) {
  7557. case Image.STRETCH_NONE:
  7558. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7559. break;
  7560. case Image.STRETCH_FILL:
  7561. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7562. break;
  7563. case Image.STRETCH_UNIFORM:
  7564. var hRatio = this._currentMeasure.width / width;
  7565. var vRatio = this._currentMeasure.height / height;
  7566. var ratio = Math.min(hRatio, vRatio);
  7567. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  7568. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  7569. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  7570. break;
  7571. case Image.STRETCH_EXTEND:
  7572. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7573. break;
  7574. case Image.STRETCH_NINE_PATCH:
  7575. this._renderNinePatch(context);
  7576. break;
  7577. }
  7578. }
  7579. context.restore();
  7580. };
  7581. Image.prototype._renderNinePatch = function (context) {
  7582. var leftWidth = this._sliceLeft;
  7583. var topHeight = this._sliceTop;
  7584. var bottomHeight = this._imageHeight - this._sliceBottom;
  7585. var rightWidth = this._imageWidth - this._sliceRight;
  7586. var centerWidth = this._sliceRight - this._sliceLeft;
  7587. var centerHeight = this._sliceBottom - this._sliceTop;
  7588. var targetCenterWidth = (this._currentMeasure.width - rightWidth - leftWidth) + 2;
  7589. var targetCenterHeight = (this._currentMeasure.height - bottomHeight - topHeight) + 2;
  7590. var centerLeftOffset = this._currentMeasure.left + leftWidth - 1;
  7591. var centerTopOffset = this._currentMeasure.top + topHeight - 1;
  7592. var rightOffset = this._currentMeasure.left + this._currentMeasure.width - rightWidth;
  7593. var bottomOffset = this._currentMeasure.top + this._currentMeasure.height - bottomHeight;
  7594. //Top Left
  7595. this._drawImage(context, 0, 0, leftWidth, topHeight, this._currentMeasure.left, this._currentMeasure.top, leftWidth, topHeight);
  7596. //Top
  7597. this._drawImage(context, this._sliceLeft, 0, centerWidth, topHeight, centerLeftOffset, this._currentMeasure.top, targetCenterWidth, topHeight);
  7598. //Top Right
  7599. this._drawImage(context, this.sliceRight, 0, rightWidth, topHeight, rightOffset, this._currentMeasure.top, rightWidth, topHeight);
  7600. //Left
  7601. this._drawImage(context, 0, this._sliceTop, leftWidth, centerHeight, this._currentMeasure.left, centerTopOffset, leftWidth, targetCenterHeight);
  7602. // Center
  7603. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, centerHeight, centerLeftOffset, centerTopOffset, targetCenterWidth, targetCenterHeight);
  7604. //Right
  7605. this._drawImage(context, this._sliceRight, this._sliceTop, rightWidth, centerHeight, rightOffset, centerTopOffset, rightWidth, targetCenterHeight);
  7606. //Bottom Left
  7607. this._drawImage(context, 0, this._sliceBottom, leftWidth, bottomHeight, this._currentMeasure.left, bottomOffset, leftWidth, bottomHeight);
  7608. //Bottom
  7609. this._drawImage(context, this.sliceLeft, this._sliceBottom, centerWidth, bottomHeight, centerLeftOffset, bottomOffset, targetCenterWidth, bottomHeight);
  7610. //Bottom Right
  7611. this._drawImage(context, this._sliceRight, this._sliceBottom, rightWidth, bottomHeight, rightOffset, bottomOffset, rightWidth, bottomHeight);
  7612. };
  7613. Image.prototype.dispose = function () {
  7614. _super.prototype.dispose.call(this);
  7615. this.onImageLoadedObservable.clear();
  7616. this.onSVGAttributesComputedObservable.clear();
  7617. };
  7618. // Static
  7619. /** STRETCH_NONE */
  7620. Image.STRETCH_NONE = 0;
  7621. /** STRETCH_FILL */
  7622. Image.STRETCH_FILL = 1;
  7623. /** STRETCH_UNIFORM */
  7624. Image.STRETCH_UNIFORM = 2;
  7625. /** STRETCH_EXTEND */
  7626. Image.STRETCH_EXTEND = 3;
  7627. /** NINE_PATCH */
  7628. Image.STRETCH_NINE_PATCH = 4;
  7629. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7630. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7631. ], Image.prototype, "detectPointerOnOpaqueOnly", null);
  7632. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7633. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7634. ], Image.prototype, "sliceLeft", null);
  7635. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7636. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7637. ], Image.prototype, "sliceRight", null);
  7638. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7639. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7640. ], Image.prototype, "sliceTop", null);
  7641. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7642. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7643. ], Image.prototype, "sliceBottom", null);
  7644. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7645. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7646. ], Image.prototype, "sourceLeft", null);
  7647. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7648. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7649. ], Image.prototype, "sourceTop", null);
  7650. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7651. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7652. ], Image.prototype, "sourceWidth", null);
  7653. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7654. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7655. ], Image.prototype, "sourceHeight", null);
  7656. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7657. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7658. ], Image.prototype, "imageWidth", null);
  7659. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7660. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7661. ], Image.prototype, "imageHeight", null);
  7662. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7663. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7664. ], Image.prototype, "populateNinePatchSlicesFromImage", null);
  7665. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7666. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7667. ], Image.prototype, "autoScale", null);
  7668. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7669. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7670. ], Image.prototype, "stretch", null);
  7671. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  7672. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  7673. ], Image.prototype, "source", null);
  7674. return Image;
  7675. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7676. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7677. /***/ }),
  7678. /***/ "./2D/controls/index.ts":
  7679. /*!******************************!*\
  7680. !*** ./2D/controls/index.ts ***!
  7681. \******************************/
  7682. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, FocusableButton, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, ToggleButton, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  7683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7684. "use strict";
  7685. __webpack_require__.r(__webpack_exports__);
  7686. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7688. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7690. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7692. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7694. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7696. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7698. /* harmony import */ var _focusableButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./focusableButton */ "./2D/controls/focusableButton.ts");
  7699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _focusableButton__WEBPACK_IMPORTED_MODULE_6__["FocusableButton"]; });
  7700. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_7__["Grid"]; });
  7702. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_8__["Image"]; });
  7704. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_9__["InputText"]; });
  7706. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_10__["InputPassword"]; });
  7708. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_11__["Line"]; });
  7710. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_12__["MultiLine"]; });
  7712. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_13__["RadioButton"]; });
  7714. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_14__["StackPanel"]; });
  7716. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["SelectorGroup"]; });
  7718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["CheckboxGroup"]; });
  7719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["RadioGroup"]; });
  7720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["SliderGroup"]; });
  7721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_15__["SelectionPanel"]; });
  7722. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_16__["ScrollViewer"]; });
  7724. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_17__["TextWrapping"]; });
  7726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_17__["TextBlock"]; });
  7727. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _textWrapper__WEBPACK_IMPORTED_MODULE_18__["TextWrapper"]; });
  7729. /* harmony import */ var _toggleButton__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./toggleButton */ "./2D/controls/toggleButton.ts");
  7730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _toggleButton__WEBPACK_IMPORTED_MODULE_19__["ToggleButton"]; });
  7731. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_20__["KeyPropertySet"]; });
  7733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_20__["VirtualKeyboard"]; });
  7734. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_21__["Rectangle"]; });
  7736. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_22__["DisplayGrid"]; });
  7738. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_23__["BaseSlider"]; });
  7740. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_24__["Slider"]; });
  7742. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_25__["ImageBasedSlider"]; });
  7744. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_26__["ScrollBar"]; });
  7746. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_27__["ImageScrollBar"]; });
  7748. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_28__["name"]; });
  7750. /***/ }),
  7751. /***/ "./2D/controls/inputPassword.ts":
  7752. /*!**************************************!*\
  7753. !*** ./2D/controls/inputPassword.ts ***!
  7754. \**************************************/
  7755. /*! exports provided: InputPassword */
  7756. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7757. "use strict";
  7758. __webpack_require__.r(__webpack_exports__);
  7759. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7760. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7761. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7762. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  7763. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7764. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7765. /**
  7766. * Class used to create a password control
  7767. */
  7768. var InputPassword = /** @class */ (function (_super) {
  7769. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7770. function InputPassword() {
  7771. return _super !== null && _super.apply(this, arguments) || this;
  7772. }
  7773. InputPassword.prototype._beforeRenderText = function (textWrapper) {
  7774. var pwdTextWrapper = new _textWrapper__WEBPACK_IMPORTED_MODULE_3__["TextWrapper"]();
  7775. var txt = "";
  7776. for (var i = 0; i < textWrapper.length; i++) {
  7777. txt += "\u2022";
  7778. }
  7779. pwdTextWrapper.text = txt;
  7780. return pwdTextWrapper;
  7781. };
  7782. return InputPassword;
  7783. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7784. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7785. /***/ }),
  7786. /***/ "./2D/controls/inputText.ts":
  7787. /*!**********************************!*\
  7788. !*** ./2D/controls/inputText.ts ***!
  7789. \**********************************/
  7790. /*! exports provided: InputText */
  7791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7792. "use strict";
  7793. __webpack_require__.r(__webpack_exports__);
  7794. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7795. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7796. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  7797. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7798. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7799. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7800. /* harmony import */ var _textWrapper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textWrapper */ "./2D/controls/textWrapper.ts");
  7801. /**
  7802. * Class used to create input text control
  7803. */
  7804. var InputText = /** @class */ (function (_super) {
  7805. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7806. /**
  7807. * Creates a new InputText
  7808. * @param name defines the control name
  7809. * @param text defines the text of the control
  7810. */
  7811. function InputText(name, text) {
  7812. if (text === void 0) { text = ""; }
  7813. var _this = _super.call(this, name) || this;
  7814. _this.name = name;
  7815. _this._placeholderText = "";
  7816. _this._background = "#222222";
  7817. _this._focusedBackground = "#000000";
  7818. _this._focusedColor = "white";
  7819. _this._placeholderColor = "gray";
  7820. _this._thickness = 1;
  7821. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7822. _this._autoStretchWidth = true;
  7823. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7824. _this._isFocused = false;
  7825. _this._blinkIsEven = false;
  7826. _this._cursorOffset = 0;
  7827. _this._deadKey = false;
  7828. _this._addKey = true;
  7829. _this._currentKey = "";
  7830. _this._isTextHighlightOn = false;
  7831. _this._textHighlightColor = "#d5e0ff";
  7832. _this._highligherOpacity = 0.4;
  7833. _this._highlightedText = "";
  7834. _this._startHighlightIndex = 0;
  7835. _this._endHighlightIndex = 0;
  7836. _this._cursorIndex = -1;
  7837. _this._onFocusSelectAll = false;
  7838. _this._isPointerDown = false;
  7839. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7840. _this.promptMessage = "Please enter text:";
  7841. /** Force disable prompt on mobile device */
  7842. _this.disableMobilePrompt = false;
  7843. /** Observable raised when the text changes */
  7844. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7845. /** Observable raised just before an entered character is to be added */
  7846. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7847. /** Observable raised when the control gets the focus */
  7848. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7849. /** Observable raised when the control loses the focus */
  7850. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7851. /**Observable raised when the text is highlighted */
  7852. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7853. /**Observable raised when copy event is triggered */
  7854. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7855. /** Observable raised when cut event is triggered */
  7856. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7857. /** Observable raised when paste event is triggered */
  7858. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7859. /** Observable raised when a key event was processed */
  7860. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7861. _this.text = text;
  7862. _this.isPointerBlocker = true;
  7863. return _this;
  7864. }
  7865. Object.defineProperty(InputText.prototype, "maxWidth", {
  7866. /** Gets or sets the maximum width allowed by the control */
  7867. get: function () {
  7868. return this._maxWidth.toString(this._host);
  7869. },
  7870. set: function (value) {
  7871. if (this._maxWidth.toString(this._host) === value) {
  7872. return;
  7873. }
  7874. if (this._maxWidth.fromString(value)) {
  7875. this._markAsDirty();
  7876. }
  7877. },
  7878. enumerable: false,
  7879. configurable: true
  7880. });
  7881. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7882. /** Gets the maximum width allowed by the control in pixels */
  7883. get: function () {
  7884. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7885. },
  7886. enumerable: false,
  7887. configurable: true
  7888. });
  7889. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7890. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7891. get: function () {
  7892. return this._highligherOpacity;
  7893. },
  7894. set: function (value) {
  7895. if (this._highligherOpacity === value) {
  7896. return;
  7897. }
  7898. this._highligherOpacity = value;
  7899. this._markAsDirty();
  7900. },
  7901. enumerable: false,
  7902. configurable: true
  7903. });
  7904. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7905. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7906. get: function () {
  7907. return this._onFocusSelectAll;
  7908. },
  7909. set: function (value) {
  7910. if (this._onFocusSelectAll === value) {
  7911. return;
  7912. }
  7913. this._onFocusSelectAll = value;
  7914. this._markAsDirty();
  7915. },
  7916. enumerable: false,
  7917. configurable: true
  7918. });
  7919. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7920. /** Gets or sets the text hightlight color */
  7921. get: function () {
  7922. return this._textHighlightColor;
  7923. },
  7924. set: function (value) {
  7925. if (this._textHighlightColor === value) {
  7926. return;
  7927. }
  7928. this._textHighlightColor = value;
  7929. this._markAsDirty();
  7930. },
  7931. enumerable: false,
  7932. configurable: true
  7933. });
  7934. Object.defineProperty(InputText.prototype, "margin", {
  7935. /** Gets or sets control margin */
  7936. get: function () {
  7937. return this._margin.toString(this._host);
  7938. },
  7939. set: function (value) {
  7940. if (this._margin.toString(this._host) === value) {
  7941. return;
  7942. }
  7943. if (this._margin.fromString(value)) {
  7944. this._markAsDirty();
  7945. }
  7946. },
  7947. enumerable: false,
  7948. configurable: true
  7949. });
  7950. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7951. /** Gets control margin in pixels */
  7952. get: function () {
  7953. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7954. },
  7955. enumerable: false,
  7956. configurable: true
  7957. });
  7958. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7959. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7960. get: function () {
  7961. return this._autoStretchWidth;
  7962. },
  7963. set: function (value) {
  7964. if (this._autoStretchWidth === value) {
  7965. return;
  7966. }
  7967. this._autoStretchWidth = value;
  7968. this._markAsDirty();
  7969. },
  7970. enumerable: false,
  7971. configurable: true
  7972. });
  7973. Object.defineProperty(InputText.prototype, "thickness", {
  7974. /** Gets or sets border thickness */
  7975. get: function () {
  7976. return this._thickness;
  7977. },
  7978. set: function (value) {
  7979. if (this._thickness === value) {
  7980. return;
  7981. }
  7982. this._thickness = value;
  7983. this._markAsDirty();
  7984. },
  7985. enumerable: false,
  7986. configurable: true
  7987. });
  7988. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7989. /** Gets or sets the background color when focused */
  7990. get: function () {
  7991. return this._focusedBackground;
  7992. },
  7993. set: function (value) {
  7994. if (this._focusedBackground === value) {
  7995. return;
  7996. }
  7997. this._focusedBackground = value;
  7998. this._markAsDirty();
  7999. },
  8000. enumerable: false,
  8001. configurable: true
  8002. });
  8003. Object.defineProperty(InputText.prototype, "focusedColor", {
  8004. /** Gets or sets the background color when focused */
  8005. get: function () {
  8006. return this._focusedColor;
  8007. },
  8008. set: function (value) {
  8009. if (this._focusedColor === value) {
  8010. return;
  8011. }
  8012. this._focusedColor = value;
  8013. this._markAsDirty();
  8014. },
  8015. enumerable: false,
  8016. configurable: true
  8017. });
  8018. Object.defineProperty(InputText.prototype, "background", {
  8019. /** Gets or sets the background color */
  8020. get: function () {
  8021. return this._background;
  8022. },
  8023. set: function (value) {
  8024. if (this._background === value) {
  8025. return;
  8026. }
  8027. this._background = value;
  8028. this._markAsDirty();
  8029. },
  8030. enumerable: false,
  8031. configurable: true
  8032. });
  8033. Object.defineProperty(InputText.prototype, "placeholderColor", {
  8034. /** Gets or sets the placeholder color */
  8035. get: function () {
  8036. return this._placeholderColor;
  8037. },
  8038. set: function (value) {
  8039. if (this._placeholderColor === value) {
  8040. return;
  8041. }
  8042. this._placeholderColor = value;
  8043. this._markAsDirty();
  8044. },
  8045. enumerable: false,
  8046. configurable: true
  8047. });
  8048. Object.defineProperty(InputText.prototype, "placeholderText", {
  8049. /** Gets or sets the text displayed when the control is empty */
  8050. get: function () {
  8051. return this._placeholderText;
  8052. },
  8053. set: function (value) {
  8054. if (this._placeholderText === value) {
  8055. return;
  8056. }
  8057. this._placeholderText = value;
  8058. this._markAsDirty();
  8059. },
  8060. enumerable: false,
  8061. configurable: true
  8062. });
  8063. Object.defineProperty(InputText.prototype, "deadKey", {
  8064. /** Gets or sets the dead key flag */
  8065. get: function () {
  8066. return this._deadKey;
  8067. },
  8068. set: function (flag) {
  8069. this._deadKey = flag;
  8070. },
  8071. enumerable: false,
  8072. configurable: true
  8073. });
  8074. Object.defineProperty(InputText.prototype, "highlightedText", {
  8075. /** Gets or sets the highlight text */
  8076. get: function () {
  8077. return this._highlightedText;
  8078. },
  8079. set: function (text) {
  8080. if (this._highlightedText === text) {
  8081. return;
  8082. }
  8083. this._highlightedText = text;
  8084. this._markAsDirty();
  8085. },
  8086. enumerable: false,
  8087. configurable: true
  8088. });
  8089. Object.defineProperty(InputText.prototype, "addKey", {
  8090. /** Gets or sets if the current key should be added */
  8091. get: function () {
  8092. return this._addKey;
  8093. },
  8094. set: function (flag) {
  8095. this._addKey = flag;
  8096. },
  8097. enumerable: false,
  8098. configurable: true
  8099. });
  8100. Object.defineProperty(InputText.prototype, "currentKey", {
  8101. /** Gets or sets the value of the current key being entered */
  8102. get: function () {
  8103. return this._currentKey;
  8104. },
  8105. set: function (key) {
  8106. this._currentKey = key;
  8107. },
  8108. enumerable: false,
  8109. configurable: true
  8110. });
  8111. Object.defineProperty(InputText.prototype, "text", {
  8112. /** Gets or sets the text displayed in the control */
  8113. get: function () {
  8114. return this._textWrapper.text;
  8115. },
  8116. set: function (value) {
  8117. var valueAsString = value.toString(); // Forcing convertion
  8118. if (!this._textWrapper) {
  8119. this._textWrapper = new _textWrapper__WEBPACK_IMPORTED_MODULE_4__["TextWrapper"]();
  8120. }
  8121. if (this._textWrapper.text === valueAsString) {
  8122. return;
  8123. }
  8124. this._textWrapper.text = valueAsString;
  8125. this._textHasChanged();
  8126. },
  8127. enumerable: false,
  8128. configurable: true
  8129. });
  8130. InputText.prototype._textHasChanged = function () {
  8131. this._markAsDirty();
  8132. this.onTextChangedObservable.notifyObservers(this);
  8133. };
  8134. Object.defineProperty(InputText.prototype, "width", {
  8135. /** Gets or sets control width */
  8136. get: function () {
  8137. return this._width.toString(this._host);
  8138. },
  8139. set: function (value) {
  8140. if (this._width.toString(this._host) === value) {
  8141. return;
  8142. }
  8143. if (this._width.fromString(value)) {
  8144. this._markAsDirty();
  8145. }
  8146. this.autoStretchWidth = false;
  8147. },
  8148. enumerable: false,
  8149. configurable: true
  8150. });
  8151. /** @hidden */
  8152. InputText.prototype.onBlur = function () {
  8153. this._isFocused = false;
  8154. this._scrollLeft = null;
  8155. this._cursorOffset = 0;
  8156. clearTimeout(this._blinkTimeout);
  8157. this._markAsDirty();
  8158. this.onBlurObservable.notifyObservers(this);
  8159. this._host.unRegisterClipboardEvents();
  8160. if (this._onClipboardObserver) {
  8161. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  8162. }
  8163. var scene = this._host.getScene();
  8164. if (this._onPointerDblTapObserver && scene) {
  8165. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  8166. }
  8167. };
  8168. /** @hidden */
  8169. InputText.prototype.onFocus = function () {
  8170. var _this = this;
  8171. if (!this._isEnabled) {
  8172. return;
  8173. }
  8174. this._scrollLeft = null;
  8175. this._isFocused = true;
  8176. this._blinkIsEven = false;
  8177. this._cursorOffset = 0;
  8178. this._markAsDirty();
  8179. this.onFocusObservable.notifyObservers(this);
  8180. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  8181. var value = prompt(this.promptMessage);
  8182. if (value !== null) {
  8183. this.text = value;
  8184. }
  8185. this._host.focusedControl = null;
  8186. return;
  8187. }
  8188. this._host.registerClipboardEvents();
  8189. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  8190. // process clipboard event, can be configured.
  8191. switch (clipboardInfo.type) {
  8192. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  8193. _this._onCopyText(clipboardInfo.event);
  8194. _this.onTextCopyObservable.notifyObservers(_this);
  8195. break;
  8196. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  8197. _this._onCutText(clipboardInfo.event);
  8198. _this.onTextCutObservable.notifyObservers(_this);
  8199. break;
  8200. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  8201. _this._onPasteText(clipboardInfo.event);
  8202. _this.onTextPasteObservable.notifyObservers(_this);
  8203. break;
  8204. default: return;
  8205. }
  8206. });
  8207. var scene = this._host.getScene();
  8208. if (scene) {
  8209. //register the pointer double tap event
  8210. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  8211. if (!_this._isFocused) {
  8212. return;
  8213. }
  8214. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  8215. _this._processDblClick(pointerInfo);
  8216. }
  8217. });
  8218. }
  8219. if (this._onFocusSelectAll) {
  8220. this._selectAllText();
  8221. }
  8222. };
  8223. /**
  8224. * Function to focus an inputText programmatically
  8225. */
  8226. InputText.prototype.focus = function () {
  8227. this._host.moveFocusToControl(this);
  8228. };
  8229. /**
  8230. * Function to unfocus an inputText programmatically
  8231. */
  8232. InputText.prototype.blur = function () {
  8233. this._host.focusedControl = null;
  8234. };
  8235. InputText.prototype._getTypeName = function () {
  8236. return "InputText";
  8237. };
  8238. /**
  8239. * Function called to get the list of controls that should not steal the focus from this control
  8240. * @returns an array of controls
  8241. */
  8242. InputText.prototype.keepsFocusWith = function () {
  8243. if (!this._connectedVirtualKeyboard) {
  8244. return null;
  8245. }
  8246. return [this._connectedVirtualKeyboard];
  8247. };
  8248. /** @hidden */
  8249. InputText.prototype.processKey = function (keyCode, key, evt) {
  8250. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  8251. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  8252. return;
  8253. }
  8254. //select all
  8255. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  8256. this._selectAllText();
  8257. evt.preventDefault();
  8258. return;
  8259. }
  8260. // Specific cases
  8261. switch (keyCode) {
  8262. case 32: //SPACE
  8263. key = " "; //ie11 key for space is "Spacebar"
  8264. break;
  8265. case 191: //SLASH
  8266. if (evt) {
  8267. evt.preventDefault();
  8268. }
  8269. break;
  8270. case 8: // BACKSPACE
  8271. if (this._textWrapper.text && this._textWrapper.length > 0) {
  8272. //delete the highlighted text
  8273. if (this._isTextHighlightOn) {
  8274. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  8275. this._textHasChanged();
  8276. this._isTextHighlightOn = false;
  8277. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8278. this._blinkIsEven = false;
  8279. if (evt) {
  8280. evt.preventDefault();
  8281. }
  8282. return;
  8283. }
  8284. //delete single character
  8285. if (this._cursorOffset === 0) {
  8286. this.text = this._textWrapper.substr(0, this._textWrapper.length - 1);
  8287. }
  8288. else {
  8289. var deletePosition = this._textWrapper.length - this._cursorOffset;
  8290. if (deletePosition > 0) {
  8291. this._textWrapper.removePart(deletePosition - 1, deletePosition);
  8292. this._textHasChanged();
  8293. }
  8294. }
  8295. }
  8296. if (evt) {
  8297. evt.preventDefault();
  8298. }
  8299. return;
  8300. case 46: // DELETE
  8301. if (this._isTextHighlightOn) {
  8302. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  8303. this._textHasChanged();
  8304. this._isTextHighlightOn = false;
  8305. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8306. if (evt) {
  8307. evt.preventDefault();
  8308. }
  8309. return;
  8310. }
  8311. if (this._textWrapper.text && this._textWrapper.length > 0 && this._cursorOffset > 0) {
  8312. var deletePosition = this._textWrapper.length - this._cursorOffset;
  8313. this._textWrapper.removePart(deletePosition, deletePosition + 1);
  8314. this._textHasChanged();
  8315. this._cursorOffset--;
  8316. }
  8317. if (evt) {
  8318. evt.preventDefault();
  8319. }
  8320. return;
  8321. case 13: // RETURN
  8322. this._host.focusedControl = null;
  8323. this._isTextHighlightOn = false;
  8324. return;
  8325. case 35: // END
  8326. this._cursorOffset = 0;
  8327. this._blinkIsEven = false;
  8328. this._isTextHighlightOn = false;
  8329. this._markAsDirty();
  8330. return;
  8331. case 36: // HOME
  8332. this._cursorOffset = this._textWrapper.length;
  8333. this._blinkIsEven = false;
  8334. this._isTextHighlightOn = false;
  8335. this._markAsDirty();
  8336. return;
  8337. case 37: // LEFT
  8338. this._cursorOffset++;
  8339. if (this._cursorOffset > this._textWrapper.length) {
  8340. this._cursorOffset = this._textWrapper.length;
  8341. }
  8342. if (evt && evt.shiftKey) {
  8343. // update the cursor
  8344. this._blinkIsEven = false;
  8345. // shift + ctrl/cmd + <-
  8346. if (evt.ctrlKey || evt.metaKey) {
  8347. if (!this._isTextHighlightOn) {
  8348. if (this._textWrapper.length === this._cursorOffset) {
  8349. return;
  8350. }
  8351. else {
  8352. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset + 1;
  8353. }
  8354. }
  8355. this._startHighlightIndex = 0;
  8356. this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
  8357. this._cursorOffset = this._textWrapper.length;
  8358. this._isTextHighlightOn = true;
  8359. this._markAsDirty();
  8360. return;
  8361. }
  8362. //store the starting point
  8363. if (!this._isTextHighlightOn) {
  8364. this._isTextHighlightOn = true;
  8365. this._cursorIndex = (this._cursorOffset >= this._textWrapper.length) ? this._textWrapper.length : this._cursorOffset - 1;
  8366. }
  8367. //if text is already highlighted
  8368. else if (this._cursorIndex === -1) {
  8369. this._cursorIndex = this._textWrapper.length - this._endHighlightIndex;
  8370. this._cursorOffset = (this._startHighlightIndex === 0) ? this._textWrapper.length : this._textWrapper.length - this._startHighlightIndex + 1;
  8371. }
  8372. //set the highlight indexes
  8373. if (this._cursorIndex < this._cursorOffset) {
  8374. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8375. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8376. }
  8377. else if (this._cursorIndex > this._cursorOffset) {
  8378. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8379. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8380. }
  8381. else {
  8382. this._isTextHighlightOn = false;
  8383. }
  8384. this._markAsDirty();
  8385. return;
  8386. }
  8387. if (this._isTextHighlightOn) {
  8388. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8389. this._isTextHighlightOn = false;
  8390. }
  8391. if (evt && (evt.ctrlKey || evt.metaKey)) {
  8392. this._cursorOffset = this._textWrapper.length;
  8393. evt.preventDefault();
  8394. }
  8395. this._blinkIsEven = false;
  8396. this._isTextHighlightOn = false;
  8397. this._cursorIndex = -1;
  8398. this._markAsDirty();
  8399. return;
  8400. case 39: // RIGHT
  8401. this._cursorOffset--;
  8402. if (this._cursorOffset < 0) {
  8403. this._cursorOffset = 0;
  8404. }
  8405. if (evt && evt.shiftKey) {
  8406. //update the cursor
  8407. this._blinkIsEven = false;
  8408. //shift + ctrl/cmd + ->
  8409. if (evt.ctrlKey || evt.metaKey) {
  8410. if (!this._isTextHighlightOn) {
  8411. if (this._cursorOffset === 0) {
  8412. return;
  8413. }
  8414. else {
  8415. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset - 1;
  8416. }
  8417. }
  8418. this._endHighlightIndex = this._textWrapper.length;
  8419. this._isTextHighlightOn = true;
  8420. this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
  8421. this._cursorOffset = 0;
  8422. this._markAsDirty();
  8423. return;
  8424. }
  8425. if (!this._isTextHighlightOn) {
  8426. this._isTextHighlightOn = true;
  8427. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  8428. }
  8429. //if text is already highlighted
  8430. else if (this._cursorIndex === -1) {
  8431. this._cursorIndex = this._textWrapper.length - this._startHighlightIndex;
  8432. this._cursorOffset = (this._textWrapper.length === this._endHighlightIndex) ? 0 : this._textWrapper.length - this._endHighlightIndex - 1;
  8433. }
  8434. //set the highlight indexes
  8435. if (this._cursorIndex < this._cursorOffset) {
  8436. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8437. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8438. }
  8439. else if (this._cursorIndex > this._cursorOffset) {
  8440. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8441. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8442. }
  8443. else {
  8444. this._isTextHighlightOn = false;
  8445. }
  8446. this._markAsDirty();
  8447. return;
  8448. }
  8449. if (this._isTextHighlightOn) {
  8450. this._cursorOffset = this._textWrapper.length - this._endHighlightIndex;
  8451. this._isTextHighlightOn = false;
  8452. }
  8453. //ctr + ->
  8454. if (evt && (evt.ctrlKey || evt.metaKey)) {
  8455. this._cursorOffset = 0;
  8456. evt.preventDefault();
  8457. }
  8458. this._blinkIsEven = false;
  8459. this._isTextHighlightOn = false;
  8460. this._cursorIndex = -1;
  8461. this._markAsDirty();
  8462. return;
  8463. case 222: // Dead
  8464. if (evt) {
  8465. evt.preventDefault();
  8466. }
  8467. this._cursorIndex = -1;
  8468. this.deadKey = true;
  8469. break;
  8470. }
  8471. // Printable characters
  8472. if (key &&
  8473. ((keyCode === -1) || // Direct access
  8474. (keyCode === 32) || // Space
  8475. (keyCode > 47 && keyCode < 64) || // Numbers
  8476. (keyCode > 64 && keyCode < 91) || // Letters
  8477. (keyCode > 159 && keyCode < 193) || // Special characters
  8478. (keyCode > 218 && keyCode < 223) || // Special characters
  8479. (keyCode > 95 && keyCode < 112))) { // Numpad
  8480. this._currentKey = key;
  8481. this.onBeforeKeyAddObservable.notifyObservers(this);
  8482. key = this._currentKey;
  8483. if (this._addKey) {
  8484. if (this._isTextHighlightOn) {
  8485. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex, key);
  8486. this._textHasChanged();
  8487. this._cursorOffset = this._textWrapper.length - (this._startHighlightIndex + 1);
  8488. this._isTextHighlightOn = false;
  8489. this._blinkIsEven = false;
  8490. this._markAsDirty();
  8491. }
  8492. else if (this._cursorOffset === 0) {
  8493. this.text += key;
  8494. }
  8495. else {
  8496. var insertPosition = this._textWrapper.length - this._cursorOffset;
  8497. this._textWrapper.removePart(insertPosition, insertPosition, key);
  8498. this._textHasChanged();
  8499. }
  8500. }
  8501. }
  8502. };
  8503. /** @hidden */
  8504. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  8505. //update the cursor
  8506. this._blinkIsEven = false;
  8507. if (this._cursorIndex === -1) {
  8508. this._cursorIndex = offset;
  8509. }
  8510. else {
  8511. if (this._cursorIndex < this._cursorOffset) {
  8512. this._endHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8513. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8514. }
  8515. else if (this._cursorIndex > this._cursorOffset) {
  8516. this._endHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8517. this._startHighlightIndex = this._textWrapper.length - this._cursorIndex;
  8518. }
  8519. else {
  8520. this._isTextHighlightOn = false;
  8521. this._markAsDirty();
  8522. return;
  8523. }
  8524. }
  8525. this._isTextHighlightOn = true;
  8526. this._markAsDirty();
  8527. };
  8528. /** @hidden */
  8529. InputText.prototype._processDblClick = function (evt) {
  8530. //pre-find the start and end index of the word under cursor, speeds up the rendering
  8531. this._startHighlightIndex = this._textWrapper.length - this._cursorOffset;
  8532. this._endHighlightIndex = this._startHighlightIndex;
  8533. var moveLeft, moveRight;
  8534. do {
  8535. moveRight = this._endHighlightIndex < this._textWrapper.length && this._textWrapper.isWord(this._endHighlightIndex) ? ++this._endHighlightIndex : 0;
  8536. moveLeft = this._startHighlightIndex > 0 && this._textWrapper.isWord(this._startHighlightIndex - 1) ? --this._startHighlightIndex : 0;
  8537. } while (moveLeft || moveRight);
  8538. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8539. this.onTextHighlightObservable.notifyObservers(this);
  8540. this._isTextHighlightOn = true;
  8541. this._clickedCoordinate = null;
  8542. this._blinkIsEven = true;
  8543. this._cursorIndex = -1;
  8544. this._markAsDirty();
  8545. };
  8546. /** @hidden */
  8547. InputText.prototype._selectAllText = function () {
  8548. this._blinkIsEven = true;
  8549. this._isTextHighlightOn = true;
  8550. this._startHighlightIndex = 0;
  8551. this._endHighlightIndex = this._textWrapper.length;
  8552. this._cursorOffset = this._textWrapper.length;
  8553. this._cursorIndex = -1;
  8554. this._markAsDirty();
  8555. };
  8556. /**
  8557. * Handles the keyboard event
  8558. * @param evt Defines the KeyboardEvent
  8559. */
  8560. InputText.prototype.processKeyboard = function (evt) {
  8561. // process pressed key
  8562. this.processKey(evt.keyCode, evt.key, evt);
  8563. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  8564. };
  8565. /** @hidden */
  8566. InputText.prototype._onCopyText = function (ev) {
  8567. this._isTextHighlightOn = false;
  8568. //when write permission to clipbaord data is denied
  8569. try {
  8570. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8571. }
  8572. catch (_a) { } //pass
  8573. this._host.clipboardData = this._highlightedText;
  8574. };
  8575. /** @hidden */
  8576. InputText.prototype._onCutText = function (ev) {
  8577. if (!this._highlightedText) {
  8578. return;
  8579. }
  8580. this._textWrapper.removePart(this._startHighlightIndex, this._endHighlightIndex);
  8581. this._textHasChanged();
  8582. this._isTextHighlightOn = false;
  8583. this._cursorOffset = this._textWrapper.length - this._startHighlightIndex;
  8584. //when write permission to clipbaord data is denied
  8585. try {
  8586. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8587. }
  8588. catch (_a) { } //pass
  8589. this._host.clipboardData = this._highlightedText;
  8590. this._highlightedText = "";
  8591. };
  8592. /** @hidden */
  8593. InputText.prototype._onPasteText = function (ev) {
  8594. var data = "";
  8595. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  8596. data = ev.clipboardData.getData("text/plain");
  8597. }
  8598. else {
  8599. //get the cached data; returns blank string by default
  8600. data = this._host.clipboardData;
  8601. }
  8602. var insertPosition = this._textWrapper.length - this._cursorOffset;
  8603. this._textWrapper.removePart(insertPosition, insertPosition, data);
  8604. this._textHasChanged();
  8605. };
  8606. InputText.prototype._draw = function (context, invalidatedRectangle) {
  8607. var _this = this;
  8608. context.save();
  8609. this._applyStates(context);
  8610. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8611. context.shadowColor = this.shadowColor;
  8612. context.shadowBlur = this.shadowBlur;
  8613. context.shadowOffsetX = this.shadowOffsetX;
  8614. context.shadowOffsetY = this.shadowOffsetY;
  8615. }
  8616. // Background
  8617. if (this._isFocused) {
  8618. if (this._focusedBackground) {
  8619. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  8620. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8621. }
  8622. }
  8623. else if (this._background) {
  8624. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8625. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8626. }
  8627. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8628. context.shadowBlur = 0;
  8629. context.shadowOffsetX = 0;
  8630. context.shadowOffsetY = 0;
  8631. }
  8632. if (!this._fontOffset) {
  8633. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  8634. }
  8635. // Text
  8636. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  8637. if (this.color) {
  8638. context.fillStyle = this.color;
  8639. }
  8640. var text = this._beforeRenderText(this._textWrapper);
  8641. if (!this._isFocused && !this._textWrapper.text && this._placeholderText) {
  8642. text = new _textWrapper__WEBPACK_IMPORTED_MODULE_4__["TextWrapper"]();
  8643. text.text = this._placeholderText;
  8644. if (this._placeholderColor) {
  8645. context.fillStyle = this._placeholderColor;
  8646. }
  8647. }
  8648. this._textWidth = context.measureText(text.text).width;
  8649. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  8650. if (this._autoStretchWidth) {
  8651. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  8652. }
  8653. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  8654. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  8655. context.save();
  8656. context.beginPath();
  8657. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  8658. context.clip();
  8659. if (this._isFocused && this._textWidth > availableWidth) {
  8660. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  8661. if (!this._scrollLeft) {
  8662. this._scrollLeft = textLeft;
  8663. }
  8664. }
  8665. else {
  8666. this._scrollLeft = clipTextLeft;
  8667. }
  8668. context.fillText(text.text, this._scrollLeft, this._currentMeasure.top + rootY);
  8669. // Cursor
  8670. if (this._isFocused) {
  8671. // Need to move cursor
  8672. if (this._clickedCoordinate) {
  8673. var rightPosition = this._scrollLeft + this._textWidth;
  8674. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  8675. var currentSize = 0;
  8676. this._cursorOffset = 0;
  8677. var previousDist = 0;
  8678. do {
  8679. if (this._cursorOffset) {
  8680. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  8681. }
  8682. this._cursorOffset++;
  8683. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  8684. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  8685. // Find closest move
  8686. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8687. this._cursorOffset--;
  8688. }
  8689. this._blinkIsEven = false;
  8690. this._clickedCoordinate = null;
  8691. }
  8692. // Render cursor
  8693. if (!this._blinkIsEven) {
  8694. var cursorOffsetText = text.substr(text.length - this._cursorOffset);
  8695. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8696. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8697. if (cursorLeft < clipTextLeft) {
  8698. this._scrollLeft += (clipTextLeft - cursorLeft);
  8699. cursorLeft = clipTextLeft;
  8700. this._markAsDirty();
  8701. }
  8702. else if (cursorLeft > clipTextLeft + availableWidth) {
  8703. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8704. cursorLeft = clipTextLeft + availableWidth;
  8705. this._markAsDirty();
  8706. }
  8707. if (!this._isTextHighlightOn) {
  8708. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8709. }
  8710. }
  8711. clearTimeout(this._blinkTimeout);
  8712. this._blinkTimeout = setTimeout(function () {
  8713. _this._blinkIsEven = !_this._blinkIsEven;
  8714. _this._markAsDirty();
  8715. }, 500);
  8716. //show the highlighted text
  8717. if (this._isTextHighlightOn) {
  8718. clearTimeout(this._blinkTimeout);
  8719. var highlightCursorOffsetWidth = context.measureText(text.substring(this._startHighlightIndex)).width;
  8720. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8721. this._highlightedText = text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8722. var width = context.measureText(text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8723. if (highlightCursorLeft < clipTextLeft) {
  8724. width = width - (clipTextLeft - highlightCursorLeft);
  8725. if (!width) {
  8726. // when using left arrow on text.length > availableWidth;
  8727. // assigns the width of the first letter after clipTextLeft
  8728. width = context.measureText(text.charAt(text.length - this._cursorOffset)).width;
  8729. }
  8730. highlightCursorLeft = clipTextLeft;
  8731. }
  8732. //for transparancy
  8733. context.globalAlpha = this._highligherOpacity;
  8734. context.fillStyle = this._textHighlightColor;
  8735. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8736. context.globalAlpha = 1.0;
  8737. }
  8738. }
  8739. context.restore();
  8740. // Border
  8741. if (this._thickness) {
  8742. if (this._isFocused) {
  8743. if (this.focusedColor) {
  8744. context.strokeStyle = this.focusedColor;
  8745. }
  8746. }
  8747. else {
  8748. if (this.color) {
  8749. context.strokeStyle = this.color;
  8750. }
  8751. }
  8752. context.lineWidth = this._thickness;
  8753. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8754. }
  8755. context.restore();
  8756. };
  8757. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  8758. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  8759. return false;
  8760. }
  8761. this._clickedCoordinate = coordinates.x;
  8762. this._isTextHighlightOn = false;
  8763. this._highlightedText = "";
  8764. this._cursorIndex = -1;
  8765. this._isPointerDown = true;
  8766. this._host._capturingControl[pointerId] = this;
  8767. if (this._host.focusedControl === this) {
  8768. // Move cursor
  8769. clearTimeout(this._blinkTimeout);
  8770. this._markAsDirty();
  8771. return true;
  8772. }
  8773. if (!this._isEnabled) {
  8774. return false;
  8775. }
  8776. this._host.focusedControl = this;
  8777. return true;
  8778. };
  8779. InputText.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  8780. if (this._host.focusedControl === this && this._isPointerDown) {
  8781. this._clickedCoordinate = coordinates.x;
  8782. this._markAsDirty();
  8783. this._updateValueFromCursorIndex(this._cursorOffset);
  8784. }
  8785. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  8786. };
  8787. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8788. this._isPointerDown = false;
  8789. delete this._host._capturingControl[pointerId];
  8790. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8791. };
  8792. InputText.prototype._beforeRenderText = function (textWrapper) {
  8793. return textWrapper;
  8794. };
  8795. InputText.prototype.dispose = function () {
  8796. _super.prototype.dispose.call(this);
  8797. this.onBlurObservable.clear();
  8798. this.onFocusObservable.clear();
  8799. this.onTextChangedObservable.clear();
  8800. this.onTextCopyObservable.clear();
  8801. this.onTextCutObservable.clear();
  8802. this.onTextPasteObservable.clear();
  8803. this.onTextHighlightObservable.clear();
  8804. this.onKeyboardEventProcessedObservable.clear();
  8805. };
  8806. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8807. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8808. ], InputText.prototype, "promptMessage", void 0);
  8809. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8810. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8811. ], InputText.prototype, "disableMobilePrompt", void 0);
  8812. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8813. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8814. ], InputText.prototype, "maxWidth", null);
  8815. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8816. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8817. ], InputText.prototype, "highligherOpacity", null);
  8818. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8819. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8820. ], InputText.prototype, "onFocusSelectAll", null);
  8821. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8822. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8823. ], InputText.prototype, "textHighlightColor", null);
  8824. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8825. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8826. ], InputText.prototype, "margin", null);
  8827. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8828. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8829. ], InputText.prototype, "autoStretchWidth", null);
  8830. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8831. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8832. ], InputText.prototype, "thickness", null);
  8833. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8834. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8835. ], InputText.prototype, "focusedBackground", null);
  8836. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8837. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8838. ], InputText.prototype, "focusedColor", null);
  8839. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8840. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8841. ], InputText.prototype, "background", null);
  8842. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8843. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8844. ], InputText.prototype, "placeholderColor", null);
  8845. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8846. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8847. ], InputText.prototype, "placeholderText", null);
  8848. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8849. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8850. ], InputText.prototype, "deadKey", null);
  8851. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8852. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8853. ], InputText.prototype, "text", null);
  8854. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  8855. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  8856. ], InputText.prototype, "width", null);
  8857. return InputText;
  8858. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8859. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8860. /***/ }),
  8861. /***/ "./2D/controls/line.ts":
  8862. /*!*****************************!*\
  8863. !*** ./2D/controls/line.ts ***!
  8864. \*****************************/
  8865. /*! exports provided: Line */
  8866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8867. "use strict";
  8868. __webpack_require__.r(__webpack_exports__);
  8869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8870. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8871. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  8872. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8873. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8874. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8875. /** Class used to render 2D lines */
  8876. var Line = /** @class */ (function (_super) {
  8877. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8878. /**
  8879. * Creates a new Line
  8880. * @param name defines the control name
  8881. */
  8882. function Line(name) {
  8883. var _this = _super.call(this, name) || this;
  8884. _this.name = name;
  8885. _this._lineWidth = 1;
  8886. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8887. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8888. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8889. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8890. _this._dash = new Array();
  8891. _this._automaticSize = true;
  8892. _this.isHitTestVisible = false;
  8893. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8894. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8895. return _this;
  8896. }
  8897. Object.defineProperty(Line.prototype, "dash", {
  8898. /** Gets or sets the dash pattern */
  8899. get: function () {
  8900. return this._dash;
  8901. },
  8902. set: function (value) {
  8903. if (this._dash === value) {
  8904. return;
  8905. }
  8906. this._dash = value;
  8907. this._markAsDirty();
  8908. },
  8909. enumerable: false,
  8910. configurable: true
  8911. });
  8912. Object.defineProperty(Line.prototype, "connectedControl", {
  8913. /** Gets or sets the control connected with the line end */
  8914. get: function () {
  8915. return this._connectedControl;
  8916. },
  8917. set: function (value) {
  8918. var _this = this;
  8919. if (this._connectedControl === value) {
  8920. return;
  8921. }
  8922. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8923. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8924. this._connectedControlDirtyObserver = null;
  8925. }
  8926. if (value) {
  8927. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8928. }
  8929. this._connectedControl = value;
  8930. this._markAsDirty();
  8931. },
  8932. enumerable: false,
  8933. configurable: true
  8934. });
  8935. Object.defineProperty(Line.prototype, "x1", {
  8936. /** Gets or sets start coordinates on X axis */
  8937. get: function () {
  8938. return this._x1.toString(this._host);
  8939. },
  8940. set: function (value) {
  8941. if (this._x1.toString(this._host) === value) {
  8942. return;
  8943. }
  8944. if (this._x1.fromString(value)) {
  8945. this._markAsDirty();
  8946. }
  8947. },
  8948. enumerable: false,
  8949. configurable: true
  8950. });
  8951. Object.defineProperty(Line.prototype, "y1", {
  8952. /** Gets or sets start coordinates on Y axis */
  8953. get: function () {
  8954. return this._y1.toString(this._host);
  8955. },
  8956. set: function (value) {
  8957. if (this._y1.toString(this._host) === value) {
  8958. return;
  8959. }
  8960. if (this._y1.fromString(value)) {
  8961. this._markAsDirty();
  8962. }
  8963. },
  8964. enumerable: false,
  8965. configurable: true
  8966. });
  8967. Object.defineProperty(Line.prototype, "x2", {
  8968. /** Gets or sets end coordinates on X axis */
  8969. get: function () {
  8970. return this._x2.toString(this._host);
  8971. },
  8972. set: function (value) {
  8973. if (this._x2.toString(this._host) === value) {
  8974. return;
  8975. }
  8976. if (this._x2.fromString(value)) {
  8977. this._markAsDirty();
  8978. }
  8979. },
  8980. enumerable: false,
  8981. configurable: true
  8982. });
  8983. Object.defineProperty(Line.prototype, "y2", {
  8984. /** Gets or sets end coordinates on Y axis */
  8985. get: function () {
  8986. return this._y2.toString(this._host);
  8987. },
  8988. set: function (value) {
  8989. if (this._y2.toString(this._host) === value) {
  8990. return;
  8991. }
  8992. if (this._y2.fromString(value)) {
  8993. this._markAsDirty();
  8994. }
  8995. },
  8996. enumerable: false,
  8997. configurable: true
  8998. });
  8999. Object.defineProperty(Line.prototype, "lineWidth", {
  9000. /** Gets or sets line width */
  9001. get: function () {
  9002. return this._lineWidth;
  9003. },
  9004. set: function (value) {
  9005. if (this._lineWidth === value) {
  9006. return;
  9007. }
  9008. this._lineWidth = value;
  9009. this._markAsDirty();
  9010. },
  9011. enumerable: false,
  9012. configurable: true
  9013. });
  9014. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  9015. /** Gets or sets horizontal alignment */
  9016. set: function (value) {
  9017. return;
  9018. },
  9019. enumerable: false,
  9020. configurable: true
  9021. });
  9022. Object.defineProperty(Line.prototype, "verticalAlignment", {
  9023. /** Gets or sets vertical alignment */
  9024. set: function (value) {
  9025. return;
  9026. },
  9027. enumerable: false,
  9028. configurable: true
  9029. });
  9030. Object.defineProperty(Line.prototype, "_effectiveX2", {
  9031. get: function () {
  9032. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  9033. },
  9034. enumerable: false,
  9035. configurable: true
  9036. });
  9037. Object.defineProperty(Line.prototype, "_effectiveY2", {
  9038. get: function () {
  9039. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  9040. },
  9041. enumerable: false,
  9042. configurable: true
  9043. });
  9044. Line.prototype._getTypeName = function () {
  9045. return "Line";
  9046. };
  9047. Line.prototype._draw = function (context) {
  9048. context.save();
  9049. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9050. context.shadowColor = this.shadowColor;
  9051. context.shadowBlur = this.shadowBlur;
  9052. context.shadowOffsetX = this.shadowOffsetX;
  9053. context.shadowOffsetY = this.shadowOffsetY;
  9054. }
  9055. this._applyStates(context);
  9056. context.strokeStyle = this.color;
  9057. context.lineWidth = this._lineWidth;
  9058. context.setLineDash(this._dash);
  9059. context.beginPath();
  9060. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  9061. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  9062. context.stroke();
  9063. context.restore();
  9064. };
  9065. Line.prototype._measure = function () {
  9066. // Width / Height
  9067. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  9068. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  9069. };
  9070. Line.prototype._computeAlignment = function (parentMeasure, context) {
  9071. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  9072. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  9073. };
  9074. /**
  9075. * Move one end of the line given 3D cartesian coordinates.
  9076. * @param position Targeted world position
  9077. * @param scene Scene
  9078. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  9079. */
  9080. Line.prototype.moveToVector3 = function (position, scene, end) {
  9081. if (end === void 0) { end = false; }
  9082. if (!this._host || this.parent !== this._host._rootContainer) {
  9083. 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");
  9084. return;
  9085. }
  9086. var globalViewport = this._host._getGlobalViewport(scene);
  9087. 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);
  9088. this._moveToProjectedPosition(projectedPosition, end);
  9089. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  9090. this.notRenderable = true;
  9091. return;
  9092. }
  9093. this.notRenderable = false;
  9094. };
  9095. /**
  9096. * Move one end of the line to a position in screen absolute space.
  9097. * @param projectedPosition Position in screen absolute space (X, Y)
  9098. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  9099. */
  9100. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  9101. if (end === void 0) { end = false; }
  9102. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  9103. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  9104. if (end) {
  9105. this.x2 = x;
  9106. this.y2 = y;
  9107. this._x2.ignoreAdaptiveScaling = true;
  9108. this._y2.ignoreAdaptiveScaling = true;
  9109. }
  9110. else {
  9111. this.x1 = x;
  9112. this.y1 = y;
  9113. this._x1.ignoreAdaptiveScaling = true;
  9114. this._y1.ignoreAdaptiveScaling = true;
  9115. }
  9116. };
  9117. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9118. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9119. ], Line.prototype, "dash", null);
  9120. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9121. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9122. ], Line.prototype, "x1", null);
  9123. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9124. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9125. ], Line.prototype, "y1", null);
  9126. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9127. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9128. ], Line.prototype, "x2", null);
  9129. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9130. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9131. ], Line.prototype, "y2", null);
  9132. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9133. Object(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9134. ], Line.prototype, "lineWidth", null);
  9135. return Line;
  9136. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9137. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  9138. /***/ }),
  9139. /***/ "./2D/controls/multiLine.ts":
  9140. /*!**********************************!*\
  9141. !*** ./2D/controls/multiLine.ts ***!
  9142. \**********************************/
  9143. /*! exports provided: MultiLine */
  9144. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9145. "use strict";
  9146. __webpack_require__.r(__webpack_exports__);
  9147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  9148. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9149. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  9150. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  9151. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9152. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  9153. /**
  9154. * Class used to create multi line control
  9155. */
  9156. var MultiLine = /** @class */ (function (_super) {
  9157. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  9158. /**
  9159. * Creates a new MultiLine
  9160. * @param name defines the control name
  9161. */
  9162. function MultiLine(name) {
  9163. var _this = _super.call(this, name) || this;
  9164. _this.name = name;
  9165. _this._lineWidth = 1;
  9166. /** Function called when a point is updated */
  9167. _this.onPointUpdate = function () {
  9168. _this._markAsDirty();
  9169. };
  9170. _this._automaticSize = true;
  9171. _this.isHitTestVisible = false;
  9172. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9173. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  9174. _this._dash = [];
  9175. _this._points = [];
  9176. return _this;
  9177. }
  9178. Object.defineProperty(MultiLine.prototype, "dash", {
  9179. /** Gets or sets dash pattern */
  9180. get: function () {
  9181. return this._dash;
  9182. },
  9183. set: function (value) {
  9184. if (this._dash === value) {
  9185. return;
  9186. }
  9187. this._dash = value;
  9188. this._markAsDirty();
  9189. },
  9190. enumerable: false,
  9191. configurable: true
  9192. });
  9193. /**
  9194. * Gets point stored at specified index
  9195. * @param index defines the index to look for
  9196. * @returns the requested point if found
  9197. */
  9198. MultiLine.prototype.getAt = function (index) {
  9199. if (!this._points[index]) {
  9200. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  9201. }
  9202. return this._points[index];
  9203. };
  9204. /**
  9205. * Adds new points to the point collection
  9206. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  9207. * @returns the list of created MultiLinePoint
  9208. */
  9209. MultiLine.prototype.add = function () {
  9210. var _this = this;
  9211. var items = [];
  9212. for (var _i = 0; _i < arguments.length; _i++) {
  9213. items[_i] = arguments[_i];
  9214. }
  9215. return items.map(function (item) { return _this.push(item); });
  9216. };
  9217. /**
  9218. * Adds a new point to the point collection
  9219. * @param item defines the item (mesh, control or 2d coordiantes) to add
  9220. * @returns the created MultiLinePoint
  9221. */
  9222. MultiLine.prototype.push = function (item) {
  9223. var point = this.getAt(this._points.length);
  9224. if (item == null) {
  9225. return point;
  9226. }
  9227. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  9228. point.mesh = item;
  9229. }
  9230. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  9231. point.control = item;
  9232. }
  9233. else if (item.x != null && item.y != null) {
  9234. point.x = item.x;
  9235. point.y = item.y;
  9236. }
  9237. return point;
  9238. };
  9239. /**
  9240. * Remove a specific value or point from the active point collection
  9241. * @param value defines the value or point to remove
  9242. */
  9243. MultiLine.prototype.remove = function (value) {
  9244. var index;
  9245. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  9246. index = this._points.indexOf(value);
  9247. if (index === -1) {
  9248. return;
  9249. }
  9250. }
  9251. else {
  9252. index = value;
  9253. }
  9254. var point = this._points[index];
  9255. if (!point) {
  9256. return;
  9257. }
  9258. point.dispose();
  9259. this._points.splice(index, 1);
  9260. };
  9261. /**
  9262. * Resets this object to initial state (no point)
  9263. */
  9264. MultiLine.prototype.reset = function () {
  9265. while (this._points.length > 0) {
  9266. this.remove(this._points.length - 1);
  9267. }
  9268. };
  9269. /**
  9270. * Resets all links
  9271. */
  9272. MultiLine.prototype.resetLinks = function () {
  9273. this._points.forEach(function (point) {
  9274. if (point != null) {
  9275. point.resetLinks();
  9276. }
  9277. });
  9278. };
  9279. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  9280. /** Gets or sets line width */
  9281. get: function () {
  9282. return this._lineWidth;
  9283. },
  9284. set: function (value) {
  9285. if (this._lineWidth === value) {
  9286. return;
  9287. }
  9288. this._lineWidth = value;
  9289. this._markAsDirty();
  9290. },
  9291. enumerable: false,
  9292. configurable: true
  9293. });
  9294. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  9295. set: function (value) {
  9296. return;
  9297. },
  9298. enumerable: false,
  9299. configurable: true
  9300. });
  9301. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  9302. set: function (value) {
  9303. return;
  9304. },
  9305. enumerable: false,
  9306. configurable: true
  9307. });
  9308. MultiLine.prototype._getTypeName = function () {
  9309. return "MultiLine";
  9310. };
  9311. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  9312. context.save();
  9313. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9314. context.shadowColor = this.shadowColor;
  9315. context.shadowBlur = this.shadowBlur;
  9316. context.shadowOffsetX = this.shadowOffsetX;
  9317. context.shadowOffsetY = this.shadowOffsetY;
  9318. }
  9319. this._applyStates(context);
  9320. context.strokeStyle = this.color;
  9321. context.lineWidth = this._lineWidth;
  9322. context.setLineDash(this._dash);
  9323. context.beginPath();
  9324. var first = true; //first index is not necessarily 0
  9325. var previousPoint;
  9326. this._points.forEach(function (point) {
  9327. if (!point) {
  9328. return;
  9329. }
  9330. if (first) {
  9331. context.moveTo(point._point.x, point._point.y);
  9332. first = false;
  9333. }
  9334. else {
  9335. if (point._point.z < 1 && previousPoint.z < 1) {
  9336. context.lineTo(point._point.x, point._point.y);
  9337. }
  9338. else {
  9339. context.moveTo(point._point.x, point._point.y);
  9340. }
  9341. }
  9342. previousPoint = point._point;
  9343. });
  9344. context.stroke();
  9345. context.restore();
  9346. };
  9347. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  9348. var _this = this;
  9349. this._minX = null;
  9350. this._minY = null;
  9351. this._maxX = null;
  9352. this._maxY = null;
  9353. this._points.forEach(function (point, index) {
  9354. if (!point) {
  9355. return;
  9356. }
  9357. point.translate();
  9358. if (_this._minX == null || point._point.x < _this._minX) {
  9359. _this._minX = point._point.x;
  9360. }
  9361. if (_this._minY == null || point._point.y < _this._minY) {
  9362. _this._minY = point._point.y;
  9363. }
  9364. if (_this._maxX == null || point._point.x > _this._maxX) {
  9365. _this._maxX = point._point.x;
  9366. }
  9367. if (_this._maxY == null || point._point.y > _this._maxY) {
  9368. _this._maxY = point._point.y;
  9369. }
  9370. });
  9371. if (this._minX == null) {
  9372. this._minX = 0;
  9373. }
  9374. if (this._minY == null) {
  9375. this._minY = 0;
  9376. }
  9377. if (this._maxX == null) {
  9378. this._maxX = 0;
  9379. }
  9380. if (this._maxY == null) {
  9381. this._maxY = 0;
  9382. }
  9383. };
  9384. MultiLine.prototype._measure = function () {
  9385. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  9386. return;
  9387. }
  9388. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  9389. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  9390. };
  9391. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  9392. if (this._minX == null || this._minY == null) {
  9393. return;
  9394. }
  9395. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  9396. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  9397. };
  9398. MultiLine.prototype.dispose = function () {
  9399. this.reset();
  9400. _super.prototype.dispose.call(this);
  9401. };
  9402. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9403. Object(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9404. ], MultiLine.prototype, "dash", null);
  9405. return MultiLine;
  9406. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9407. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  9408. /***/ }),
  9409. /***/ "./2D/controls/radioButton.ts":
  9410. /*!************************************!*\
  9411. !*** ./2D/controls/radioButton.ts ***!
  9412. \************************************/
  9413. /*! exports provided: RadioButton */
  9414. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9415. "use strict";
  9416. __webpack_require__.r(__webpack_exports__);
  9417. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  9418. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9419. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  9420. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  9421. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9422. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9423. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9424. /**
  9425. * Class used to create radio button controls
  9426. */
  9427. var RadioButton = /** @class */ (function (_super) {
  9428. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  9429. /**
  9430. * Creates a new RadioButton
  9431. * @param name defines the control name
  9432. */
  9433. function RadioButton(name) {
  9434. var _this = _super.call(this, name) || this;
  9435. _this.name = name;
  9436. _this._isChecked = false;
  9437. _this._background = "black";
  9438. _this._checkSizeRatio = 0.8;
  9439. _this._thickness = 1;
  9440. /** Gets or sets group name */
  9441. _this.group = "";
  9442. /** Observable raised when isChecked is changed */
  9443. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  9444. _this.isPointerBlocker = true;
  9445. return _this;
  9446. }
  9447. Object.defineProperty(RadioButton.prototype, "thickness", {
  9448. /** Gets or sets border thickness */
  9449. get: function () {
  9450. return this._thickness;
  9451. },
  9452. set: function (value) {
  9453. if (this._thickness === value) {
  9454. return;
  9455. }
  9456. this._thickness = value;
  9457. this._markAsDirty();
  9458. },
  9459. enumerable: false,
  9460. configurable: true
  9461. });
  9462. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  9463. /** Gets or sets a value indicating the ratio between overall size and check size */
  9464. get: function () {
  9465. return this._checkSizeRatio;
  9466. },
  9467. set: function (value) {
  9468. value = Math.max(Math.min(1, value), 0);
  9469. if (this._checkSizeRatio === value) {
  9470. return;
  9471. }
  9472. this._checkSizeRatio = value;
  9473. this._markAsDirty();
  9474. },
  9475. enumerable: false,
  9476. configurable: true
  9477. });
  9478. Object.defineProperty(RadioButton.prototype, "background", {
  9479. /** Gets or sets background color */
  9480. get: function () {
  9481. return this._background;
  9482. },
  9483. set: function (value) {
  9484. if (this._background === value) {
  9485. return;
  9486. }
  9487. this._background = value;
  9488. this._markAsDirty();
  9489. },
  9490. enumerable: false,
  9491. configurable: true
  9492. });
  9493. Object.defineProperty(RadioButton.prototype, "isChecked", {
  9494. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  9495. get: function () {
  9496. return this._isChecked;
  9497. },
  9498. set: function (value) {
  9499. var _this = this;
  9500. if (this._isChecked === value) {
  9501. return;
  9502. }
  9503. this._isChecked = value;
  9504. this._markAsDirty();
  9505. this.onIsCheckedChangedObservable.notifyObservers(value);
  9506. if (this._isChecked && this._host) {
  9507. // Update all controls from same group
  9508. this._host.executeOnAllControls(function (control) {
  9509. if (control === _this) {
  9510. return;
  9511. }
  9512. if (control.group === undefined) {
  9513. return;
  9514. }
  9515. var childRadio = control;
  9516. if (childRadio.group === _this.group) {
  9517. childRadio.isChecked = false;
  9518. }
  9519. });
  9520. }
  9521. },
  9522. enumerable: false,
  9523. configurable: true
  9524. });
  9525. RadioButton.prototype._getTypeName = function () {
  9526. return "RadioButton";
  9527. };
  9528. RadioButton.prototype._draw = function (context) {
  9529. context.save();
  9530. this._applyStates(context);
  9531. var actualWidth = this._currentMeasure.width - this._thickness;
  9532. var actualHeight = this._currentMeasure.height - this._thickness;
  9533. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9534. context.shadowColor = this.shadowColor;
  9535. context.shadowBlur = this.shadowBlur;
  9536. context.shadowOffsetX = this.shadowOffsetX;
  9537. context.shadowOffsetY = this.shadowOffsetY;
  9538. }
  9539. // Outer
  9540. _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);
  9541. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  9542. context.fill();
  9543. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9544. context.shadowBlur = 0;
  9545. context.shadowOffsetX = 0;
  9546. context.shadowOffsetY = 0;
  9547. }
  9548. context.strokeStyle = this.color;
  9549. context.lineWidth = this._thickness;
  9550. context.stroke();
  9551. // Inner
  9552. if (this._isChecked) {
  9553. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  9554. var offsetWidth = actualWidth * this._checkSizeRatio;
  9555. var offseHeight = actualHeight * this._checkSizeRatio;
  9556. _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);
  9557. context.fill();
  9558. }
  9559. context.restore();
  9560. };
  9561. // Events
  9562. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  9563. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  9564. return false;
  9565. }
  9566. if (!this.isChecked) {
  9567. this.isChecked = true;
  9568. }
  9569. return true;
  9570. };
  9571. /**
  9572. * Utility function to easily create a radio button with a header
  9573. * @param title defines the label to use for the header
  9574. * @param group defines the group to use for the radio button
  9575. * @param isChecked defines the initial state of the radio button
  9576. * @param onValueChanged defines the callback to call when value changes
  9577. * @returns a StackPanel containing the radio button and a textBlock
  9578. */
  9579. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  9580. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  9581. panel.isVertical = false;
  9582. panel.height = "30px";
  9583. var radio = new RadioButton();
  9584. radio.width = "20px";
  9585. radio.height = "20px";
  9586. radio.isChecked = isChecked;
  9587. radio.color = "green";
  9588. radio.group = group;
  9589. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  9590. panel.addControl(radio);
  9591. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  9592. header.text = title;
  9593. header.width = "180px";
  9594. header.paddingLeft = "5px";
  9595. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9596. header.color = "white";
  9597. panel.addControl(header);
  9598. return panel;
  9599. };
  9600. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9601. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9602. ], RadioButton.prototype, "thickness", null);
  9603. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9604. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9605. ], RadioButton.prototype, "group", void 0);
  9606. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9607. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9608. ], RadioButton.prototype, "checkSizeRatio", null);
  9609. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9610. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9611. ], RadioButton.prototype, "background", null);
  9612. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9613. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  9614. ], RadioButton.prototype, "isChecked", null);
  9615. return RadioButton;
  9616. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  9617. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  9618. /***/ }),
  9619. /***/ "./2D/controls/rectangle.ts":
  9620. /*!**********************************!*\
  9621. !*** ./2D/controls/rectangle.ts ***!
  9622. \**********************************/
  9623. /*! exports provided: Rectangle */
  9624. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9625. "use strict";
  9626. __webpack_require__.r(__webpack_exports__);
  9627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  9628. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9629. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9630. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  9631. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  9632. /** Class used to create rectangle container */
  9633. var Rectangle = /** @class */ (function (_super) {
  9634. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  9635. /**
  9636. * Creates a new Rectangle
  9637. * @param name defines the control name
  9638. */
  9639. function Rectangle(name) {
  9640. var _this = _super.call(this, name) || this;
  9641. _this.name = name;
  9642. _this._thickness = 1;
  9643. _this._cornerRadius = 0;
  9644. return _this;
  9645. }
  9646. Object.defineProperty(Rectangle.prototype, "thickness", {
  9647. /** Gets or sets border thickness */
  9648. get: function () {
  9649. return this._thickness;
  9650. },
  9651. set: function (value) {
  9652. if (this._thickness === value) {
  9653. return;
  9654. }
  9655. this._thickness = value;
  9656. this._markAsDirty();
  9657. },
  9658. enumerable: false,
  9659. configurable: true
  9660. });
  9661. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  9662. /** Gets or sets the corner radius angle */
  9663. get: function () {
  9664. return this._cornerRadius;
  9665. },
  9666. set: function (value) {
  9667. if (value < 0) {
  9668. value = 0;
  9669. }
  9670. if (this._cornerRadius === value) {
  9671. return;
  9672. }
  9673. this._cornerRadius = value;
  9674. this._markAsDirty();
  9675. },
  9676. enumerable: false,
  9677. configurable: true
  9678. });
  9679. Rectangle.prototype._getTypeName = function () {
  9680. return "Rectangle";
  9681. };
  9682. Rectangle.prototype._localDraw = function (context) {
  9683. context.save();
  9684. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9685. context.shadowColor = this.shadowColor;
  9686. context.shadowBlur = this.shadowBlur;
  9687. context.shadowOffsetX = this.shadowOffsetX;
  9688. context.shadowOffsetY = this.shadowOffsetY;
  9689. }
  9690. if (this._background) {
  9691. context.fillStyle = this._background;
  9692. if (this._cornerRadius) {
  9693. this._drawRoundedRect(context, this._thickness / 2);
  9694. context.fill();
  9695. }
  9696. else {
  9697. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  9698. }
  9699. }
  9700. if (this._thickness) {
  9701. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9702. context.shadowBlur = 0;
  9703. context.shadowOffsetX = 0;
  9704. context.shadowOffsetY = 0;
  9705. }
  9706. if (this.color) {
  9707. context.strokeStyle = this.color;
  9708. }
  9709. context.lineWidth = this._thickness;
  9710. if (this._cornerRadius) {
  9711. this._drawRoundedRect(context, this._thickness / 2);
  9712. context.stroke();
  9713. }
  9714. else {
  9715. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  9716. }
  9717. }
  9718. context.restore();
  9719. };
  9720. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  9721. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9722. this._measureForChildren.width -= 2 * this._thickness;
  9723. this._measureForChildren.height -= 2 * this._thickness;
  9724. this._measureForChildren.left += this._thickness;
  9725. this._measureForChildren.top += this._thickness;
  9726. };
  9727. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  9728. if (offset === void 0) { offset = 0; }
  9729. var x = this._currentMeasure.left + offset;
  9730. var y = this._currentMeasure.top + offset;
  9731. var width = this._currentMeasure.width - offset * 2;
  9732. var height = this._currentMeasure.height - offset * 2;
  9733. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  9734. context.beginPath();
  9735. context.moveTo(x + radius, y);
  9736. context.lineTo(x + width - radius, y);
  9737. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  9738. context.lineTo(x + width, y + height - radius);
  9739. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  9740. context.lineTo(x + radius, y + height);
  9741. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  9742. context.lineTo(x, y + radius);
  9743. context.quadraticCurveTo(x, y, x + radius, y);
  9744. context.closePath();
  9745. };
  9746. Rectangle.prototype._clipForChildren = function (context) {
  9747. if (this._cornerRadius) {
  9748. this._drawRoundedRect(context, this._thickness);
  9749. context.clip();
  9750. }
  9751. };
  9752. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9753. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  9754. ], Rectangle.prototype, "thickness", null);
  9755. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  9756. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  9757. ], Rectangle.prototype, "cornerRadius", null);
  9758. return Rectangle;
  9759. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9760. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  9761. /***/ }),
  9762. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  9763. /*!***************************************************!*\
  9764. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  9765. \***************************************************/
  9766. /*! exports provided: ScrollViewer */
  9767. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9768. "use strict";
  9769. __webpack_require__.r(__webpack_exports__);
  9770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  9771. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9772. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  9773. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  9774. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9775. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  9776. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  9777. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  9778. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  9779. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  9780. /**
  9781. * Class used to hold a viewer window and sliders in a grid
  9782. */
  9783. var ScrollViewer = /** @class */ (function (_super) {
  9784. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  9785. /**
  9786. * Creates a new ScrollViewer
  9787. * @param name of ScrollViewer
  9788. */
  9789. function ScrollViewer(name, isImageBased) {
  9790. var _this = _super.call(this, name) || this;
  9791. _this._barSize = 20;
  9792. _this._pointerIsOver = false;
  9793. _this._wheelPrecision = 0.05;
  9794. _this._thumbLength = 0.5;
  9795. _this._thumbHeight = 1;
  9796. _this._barImageHeight = 1;
  9797. _this._horizontalBarImageHeight = 1;
  9798. _this._verticalBarImageHeight = 1;
  9799. _this._oldWindowContentsWidth = 0;
  9800. _this._oldWindowContentsHeight = 0;
  9801. _this._forceHorizontalBar = false;
  9802. _this._forceVerticalBar = false;
  9803. _this._useImageBar = isImageBased ? isImageBased : false;
  9804. _this.onDirtyObservable.add(function () {
  9805. _this._horizontalBarSpace.color = _this.color;
  9806. _this._verticalBarSpace.color = _this.color;
  9807. _this._dragSpace.color = _this.color;
  9808. });
  9809. _this.onPointerEnterObservable.add(function () {
  9810. _this._pointerIsOver = true;
  9811. });
  9812. _this.onPointerOutObservable.add(function () {
  9813. _this._pointerIsOver = false;
  9814. });
  9815. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9816. if (_this._useImageBar) {
  9817. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9818. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9819. }
  9820. else {
  9821. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9822. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9823. }
  9824. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9825. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9826. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9827. _this._grid.addColumnDefinition(1);
  9828. _this._grid.addColumnDefinition(0, true);
  9829. _this._grid.addRowDefinition(1);
  9830. _this._grid.addRowDefinition(0, true);
  9831. _super.prototype.addControl.call(_this, _this._grid);
  9832. _this._grid.addControl(_this._window, 0, 0);
  9833. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9834. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9835. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9836. _this._verticalBarSpace.thickness = 1;
  9837. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9838. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9839. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9840. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9841. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9842. _this._horizontalBarSpace.thickness = 1;
  9843. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9844. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9845. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9846. _this._dragSpace.thickness = 1;
  9847. _this._grid.addControl(_this._dragSpace, 1, 1);
  9848. // Colors
  9849. if (!_this._useImageBar) {
  9850. _this.barColor = "grey";
  9851. _this.barBackground = "transparent";
  9852. }
  9853. return _this;
  9854. }
  9855. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9856. /**
  9857. * Gets the horizontal scrollbar
  9858. */
  9859. get: function () {
  9860. return this._horizontalBar;
  9861. },
  9862. enumerable: false,
  9863. configurable: true
  9864. });
  9865. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9866. /**
  9867. * Gets the vertical scrollbar
  9868. */
  9869. get: function () {
  9870. return this._verticalBar;
  9871. },
  9872. enumerable: false,
  9873. configurable: true
  9874. });
  9875. /**
  9876. * Adds a new control to the current container
  9877. * @param control defines the control to add
  9878. * @returns the current container
  9879. */
  9880. ScrollViewer.prototype.addControl = function (control) {
  9881. if (!control) {
  9882. return this;
  9883. }
  9884. this._window.addControl(control);
  9885. return this;
  9886. };
  9887. /**
  9888. * Removes a control from the current container
  9889. * @param control defines the control to remove
  9890. * @returns the current container
  9891. */
  9892. ScrollViewer.prototype.removeControl = function (control) {
  9893. this._window.removeControl(control);
  9894. return this;
  9895. };
  9896. Object.defineProperty(ScrollViewer.prototype, "children", {
  9897. /** Gets the list of children */
  9898. get: function () {
  9899. return this._window.children;
  9900. },
  9901. enumerable: false,
  9902. configurable: true
  9903. });
  9904. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9905. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9906. var child = _a[_i];
  9907. child._markMatrixAsDirty();
  9908. }
  9909. };
  9910. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9911. /**
  9912. * Freezes or unfreezes the controls in the window.
  9913. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9914. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9915. */
  9916. get: function () {
  9917. return this._window.freezeControls;
  9918. },
  9919. set: function (value) {
  9920. this._window.freezeControls = value;
  9921. },
  9922. enumerable: false,
  9923. configurable: true
  9924. });
  9925. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9926. /** Gets the bucket width */
  9927. get: function () {
  9928. return this._window.bucketWidth;
  9929. },
  9930. enumerable: false,
  9931. configurable: true
  9932. });
  9933. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9934. /** Gets the bucket height */
  9935. get: function () {
  9936. return this._window.bucketHeight;
  9937. },
  9938. enumerable: false,
  9939. configurable: true
  9940. });
  9941. /**
  9942. * Sets the bucket sizes.
  9943. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9944. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9945. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9946. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9947. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9948. * used), that's why it is not enabled by default.
  9949. * @param width width of the bucket
  9950. * @param height height of the bucket
  9951. */
  9952. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9953. this._window.setBucketSizes(width, height);
  9954. };
  9955. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9956. /**
  9957. * Forces the horizontal scroll bar to be displayed
  9958. */
  9959. get: function () {
  9960. return this._forceHorizontalBar;
  9961. },
  9962. set: function (value) {
  9963. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9964. this._horizontalBar.isVisible = value;
  9965. this._forceHorizontalBar = value;
  9966. },
  9967. enumerable: false,
  9968. configurable: true
  9969. });
  9970. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9971. /**
  9972. * Forces the vertical scroll bar to be displayed
  9973. */
  9974. get: function () {
  9975. return this._forceVerticalBar;
  9976. },
  9977. set: function (value) {
  9978. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9979. this._verticalBar.isVisible = value;
  9980. this._forceVerticalBar = value;
  9981. },
  9982. enumerable: false,
  9983. configurable: true
  9984. });
  9985. /** Reset the scroll viewer window to initial size */
  9986. ScrollViewer.prototype.resetWindow = function () {
  9987. this._window.width = "100%";
  9988. this._window.height = "100%";
  9989. };
  9990. ScrollViewer.prototype._getTypeName = function () {
  9991. return "ScrollViewer";
  9992. };
  9993. ScrollViewer.prototype._buildClientSizes = function () {
  9994. var ratio = this.host.idealRatio;
  9995. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9996. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9997. this._clientWidth = this._window.parentClientWidth;
  9998. this._clientHeight = this._window.parentClientHeight;
  9999. };
  10000. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  10001. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10002. this._buildClientSizes();
  10003. };
  10004. ScrollViewer.prototype._postMeasure = function () {
  10005. _super.prototype._postMeasure.call(this);
  10006. this._updateScroller();
  10007. this._setWindowPosition(false);
  10008. };
  10009. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  10010. /**
  10011. * Gets or sets the mouse wheel precision
  10012. * from 0 to 1 with a default value of 0.05
  10013. * */
  10014. get: function () {
  10015. return this._wheelPrecision;
  10016. },
  10017. set: function (value) {
  10018. if (this._wheelPrecision === value) {
  10019. return;
  10020. }
  10021. if (value < 0) {
  10022. value = 0;
  10023. }
  10024. if (value > 1) {
  10025. value = 1;
  10026. }
  10027. this._wheelPrecision = value;
  10028. },
  10029. enumerable: false,
  10030. configurable: true
  10031. });
  10032. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  10033. /** Gets or sets the scroll bar container background color */
  10034. get: function () {
  10035. return this._horizontalBarSpace.background;
  10036. },
  10037. set: function (color) {
  10038. if (this._horizontalBarSpace.background === color) {
  10039. return;
  10040. }
  10041. this._horizontalBarSpace.background = color;
  10042. this._verticalBarSpace.background = color;
  10043. },
  10044. enumerable: false,
  10045. configurable: true
  10046. });
  10047. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  10048. /** Gets or sets the bar color */
  10049. get: function () {
  10050. return this._barColor;
  10051. },
  10052. set: function (color) {
  10053. if (this._barColor === color) {
  10054. return;
  10055. }
  10056. this._barColor = color;
  10057. this._horizontalBar.color = color;
  10058. this._verticalBar.color = color;
  10059. },
  10060. enumerable: false,
  10061. configurable: true
  10062. });
  10063. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  10064. /** Gets or sets the bar image */
  10065. get: function () {
  10066. return this._barImage;
  10067. },
  10068. set: function (value) {
  10069. if (this._barImage === value) {
  10070. return;
  10071. }
  10072. this._barImage = value;
  10073. var hb = this._horizontalBar;
  10074. var vb = this._verticalBar;
  10075. hb.thumbImage = value;
  10076. vb.thumbImage = value;
  10077. },
  10078. enumerable: false,
  10079. configurable: true
  10080. });
  10081. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  10082. /** Gets or sets the horizontal bar image */
  10083. get: function () {
  10084. return this._horizontalBarImage;
  10085. },
  10086. set: function (value) {
  10087. if (this._horizontalBarImage === value) {
  10088. return;
  10089. }
  10090. this._horizontalBarImage = value;
  10091. var hb = this._horizontalBar;
  10092. hb.thumbImage = value;
  10093. },
  10094. enumerable: false,
  10095. configurable: true
  10096. });
  10097. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  10098. /** Gets or sets the vertical bar image */
  10099. get: function () {
  10100. return this._verticalBarImage;
  10101. },
  10102. set: function (value) {
  10103. if (this._verticalBarImage === value) {
  10104. return;
  10105. }
  10106. this._verticalBarImage = value;
  10107. var vb = this._verticalBar;
  10108. vb.thumbImage = value;
  10109. },
  10110. enumerable: false,
  10111. configurable: true
  10112. });
  10113. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  10114. /** Gets or sets the size of the bar */
  10115. get: function () {
  10116. return this._barSize;
  10117. },
  10118. set: function (value) {
  10119. if (this._barSize === value) {
  10120. return;
  10121. }
  10122. this._barSize = value;
  10123. this._markAsDirty();
  10124. if (this._horizontalBar.isVisible) {
  10125. this._grid.setRowDefinition(1, this._barSize, true);
  10126. }
  10127. if (this._verticalBar.isVisible) {
  10128. this._grid.setColumnDefinition(1, this._barSize, true);
  10129. }
  10130. },
  10131. enumerable: false,
  10132. configurable: true
  10133. });
  10134. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  10135. /** Gets or sets the length of the thumb */
  10136. get: function () {
  10137. return this._thumbLength;
  10138. },
  10139. set: function (value) {
  10140. if (this._thumbLength === value) {
  10141. return;
  10142. }
  10143. if (value <= 0) {
  10144. value = 0.1;
  10145. }
  10146. if (value > 1) {
  10147. value = 1;
  10148. }
  10149. this._thumbLength = value;
  10150. var hb = this._horizontalBar;
  10151. var vb = this._verticalBar;
  10152. hb.thumbLength = value;
  10153. vb.thumbLength = value;
  10154. this._markAsDirty();
  10155. },
  10156. enumerable: false,
  10157. configurable: true
  10158. });
  10159. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  10160. /** Gets or sets the height of the thumb */
  10161. get: function () {
  10162. return this._thumbHeight;
  10163. },
  10164. set: function (value) {
  10165. if (this._thumbHeight === value) {
  10166. return;
  10167. }
  10168. if (value <= 0) {
  10169. value = 0.1;
  10170. }
  10171. if (value > 1) {
  10172. value = 1;
  10173. }
  10174. this._thumbHeight = value;
  10175. var hb = this._horizontalBar;
  10176. var vb = this._verticalBar;
  10177. hb.thumbHeight = value;
  10178. vb.thumbHeight = value;
  10179. this._markAsDirty();
  10180. },
  10181. enumerable: false,
  10182. configurable: true
  10183. });
  10184. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  10185. /** Gets or sets the height of the bar image */
  10186. get: function () {
  10187. return this._barImageHeight;
  10188. },
  10189. set: function (value) {
  10190. if (this._barImageHeight === value) {
  10191. return;
  10192. }
  10193. if (value <= 0) {
  10194. value = 0.1;
  10195. }
  10196. if (value > 1) {
  10197. value = 1;
  10198. }
  10199. this._barImageHeight = value;
  10200. var hb = this._horizontalBar;
  10201. var vb = this._verticalBar;
  10202. hb.barImageHeight = value;
  10203. vb.barImageHeight = value;
  10204. this._markAsDirty();
  10205. },
  10206. enumerable: false,
  10207. configurable: true
  10208. });
  10209. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  10210. /** Gets or sets the height of the horizontal bar image */
  10211. get: function () {
  10212. return this._horizontalBarImageHeight;
  10213. },
  10214. set: function (value) {
  10215. if (this._horizontalBarImageHeight === value) {
  10216. return;
  10217. }
  10218. if (value <= 0) {
  10219. value = 0.1;
  10220. }
  10221. if (value > 1) {
  10222. value = 1;
  10223. }
  10224. this._horizontalBarImageHeight = value;
  10225. var hb = this._horizontalBar;
  10226. hb.barImageHeight = value;
  10227. this._markAsDirty();
  10228. },
  10229. enumerable: false,
  10230. configurable: true
  10231. });
  10232. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  10233. /** Gets or sets the height of the vertical bar image */
  10234. get: function () {
  10235. return this._verticalBarImageHeight;
  10236. },
  10237. set: function (value) {
  10238. if (this._verticalBarImageHeight === value) {
  10239. return;
  10240. }
  10241. if (value <= 0) {
  10242. value = 0.1;
  10243. }
  10244. if (value > 1) {
  10245. value = 1;
  10246. }
  10247. this._verticalBarImageHeight = value;
  10248. var vb = this._verticalBar;
  10249. vb.barImageHeight = value;
  10250. this._markAsDirty();
  10251. },
  10252. enumerable: false,
  10253. configurable: true
  10254. });
  10255. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  10256. /** Gets or sets the bar background */
  10257. get: function () {
  10258. return this._barBackground;
  10259. },
  10260. set: function (color) {
  10261. if (this._barBackground === color) {
  10262. return;
  10263. }
  10264. this._barBackground = color;
  10265. var hb = this._horizontalBar;
  10266. var vb = this._verticalBar;
  10267. hb.background = color;
  10268. vb.background = color;
  10269. this._dragSpace.background = color;
  10270. },
  10271. enumerable: false,
  10272. configurable: true
  10273. });
  10274. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  10275. /** Gets or sets the bar background image */
  10276. get: function () {
  10277. return this._barBackgroundImage;
  10278. },
  10279. set: function (value) {
  10280. if (this._barBackgroundImage === value) {
  10281. }
  10282. this._barBackgroundImage = value;
  10283. var hb = this._horizontalBar;
  10284. var vb = this._verticalBar;
  10285. hb.backgroundImage = value;
  10286. vb.backgroundImage = value;
  10287. },
  10288. enumerable: false,
  10289. configurable: true
  10290. });
  10291. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  10292. /** Gets or sets the horizontal bar background image */
  10293. get: function () {
  10294. return this._horizontalBarBackgroundImage;
  10295. },
  10296. set: function (value) {
  10297. if (this._horizontalBarBackgroundImage === value) {
  10298. }
  10299. this._horizontalBarBackgroundImage = value;
  10300. var hb = this._horizontalBar;
  10301. hb.backgroundImage = value;
  10302. },
  10303. enumerable: false,
  10304. configurable: true
  10305. });
  10306. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  10307. /** Gets or sets the vertical bar background image */
  10308. get: function () {
  10309. return this._verticalBarBackgroundImage;
  10310. },
  10311. set: function (value) {
  10312. if (this._verticalBarBackgroundImage === value) {
  10313. }
  10314. this._verticalBarBackgroundImage = value;
  10315. var vb = this._verticalBar;
  10316. vb.backgroundImage = value;
  10317. },
  10318. enumerable: false,
  10319. configurable: true
  10320. });
  10321. ScrollViewer.prototype._setWindowPosition = function (force) {
  10322. if (force === void 0) { force = true; }
  10323. var ratio = this.host.idealRatio;
  10324. var windowContentsWidth = this._window._currentMeasure.width;
  10325. var windowContentsHeight = this._window._currentMeasure.height;
  10326. if (!force && this._oldWindowContentsWidth === windowContentsWidth && this._oldWindowContentsHeight === windowContentsHeight) {
  10327. return;
  10328. }
  10329. this._oldWindowContentsWidth = windowContentsWidth;
  10330. this._oldWindowContentsHeight = windowContentsHeight;
  10331. var _endLeft = this._clientWidth - windowContentsWidth;
  10332. var _endTop = this._clientHeight - windowContentsHeight;
  10333. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  10334. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  10335. if (newLeft !== this._window.left) {
  10336. this._window.left = newLeft;
  10337. if (!this.freezeControls) {
  10338. this._rebuildLayout = true;
  10339. }
  10340. }
  10341. if (newTop !== this._window.top) {
  10342. this._window.top = newTop;
  10343. if (!this.freezeControls) {
  10344. this._rebuildLayout = true;
  10345. }
  10346. }
  10347. };
  10348. /** @hidden */
  10349. ScrollViewer.prototype._updateScroller = function () {
  10350. var windowContentsWidth = this._window._currentMeasure.width;
  10351. var windowContentsHeight = this._window._currentMeasure.height;
  10352. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  10353. this._grid.setRowDefinition(1, 0, true);
  10354. this._horizontalBar.isVisible = false;
  10355. this._horizontalBar.value = 0;
  10356. this._rebuildLayout = true;
  10357. }
  10358. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  10359. this._grid.setRowDefinition(1, this._barSize, true);
  10360. this._horizontalBar.isVisible = true;
  10361. this._rebuildLayout = true;
  10362. }
  10363. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  10364. this._grid.setColumnDefinition(1, 0, true);
  10365. this._verticalBar.isVisible = false;
  10366. this._verticalBar.value = 0;
  10367. this._rebuildLayout = true;
  10368. }
  10369. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  10370. this._grid.setColumnDefinition(1, this._barSize, true);
  10371. this._verticalBar.isVisible = true;
  10372. this._rebuildLayout = true;
  10373. }
  10374. this._buildClientSizes();
  10375. var ratio = this.host.idealRatio;
  10376. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  10377. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  10378. };
  10379. ScrollViewer.prototype._link = function (host) {
  10380. _super.prototype._link.call(this, host);
  10381. this._attachWheel();
  10382. };
  10383. /** @hidden */
  10384. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  10385. var _this = this;
  10386. barControl.paddingLeft = 0;
  10387. barControl.width = "100%";
  10388. barControl.height = "100%";
  10389. barControl.barOffset = 0;
  10390. barControl.value = 0;
  10391. barControl.maximum = 1;
  10392. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  10393. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10394. barControl.isVertical = isVertical;
  10395. barControl.rotation = rotation;
  10396. barControl.isVisible = false;
  10397. barContainer.addControl(barControl);
  10398. barControl.onValueChangedObservable.add(function (value) {
  10399. _this._setWindowPosition();
  10400. });
  10401. };
  10402. /** @hidden */
  10403. ScrollViewer.prototype._attachWheel = function () {
  10404. var _this = this;
  10405. if (!this._host || this._onWheelObserver) {
  10406. return;
  10407. }
  10408. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  10409. if (!_this._pointerIsOver) {
  10410. return;
  10411. }
  10412. if (_this._verticalBar.isVisible == true) {
  10413. if (pi.y < 0 && _this._verticalBar.value > 0) {
  10414. _this._verticalBar.value -= _this._wheelPrecision;
  10415. }
  10416. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  10417. _this._verticalBar.value += _this._wheelPrecision;
  10418. }
  10419. }
  10420. if (_this._horizontalBar.isVisible == true) {
  10421. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  10422. _this._horizontalBar.value += _this._wheelPrecision;
  10423. }
  10424. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  10425. _this._horizontalBar.value -= _this._wheelPrecision;
  10426. }
  10427. }
  10428. });
  10429. };
  10430. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  10431. if (!this.isHighlighted) {
  10432. return;
  10433. }
  10434. _super.prototype._renderHighlightSpecific.call(this, context);
  10435. this._grid._renderHighlightSpecific(context);
  10436. context.restore();
  10437. };
  10438. /** Releases associated resources */
  10439. ScrollViewer.prototype.dispose = function () {
  10440. this.onWheelObservable.remove(this._onWheelObserver);
  10441. this._onWheelObserver = null;
  10442. _super.prototype.dispose.call(this);
  10443. };
  10444. return ScrollViewer;
  10445. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10446. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  10447. /***/ }),
  10448. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  10449. /*!*********************************************************!*\
  10450. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  10451. \*********************************************************/
  10452. /*! exports provided: _ScrollViewerWindow */
  10453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10454. "use strict";
  10455. __webpack_require__.r(__webpack_exports__);
  10456. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  10457. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10458. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10459. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  10460. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10461. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10462. /**
  10463. * Class used to hold a the container for ScrollViewer
  10464. * @hidden
  10465. */
  10466. var _ScrollViewerWindow = /** @class */ (function (_super) {
  10467. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  10468. /**
  10469. * Creates a new ScrollViewerWindow
  10470. * @param name of ScrollViewerWindow
  10471. */
  10472. function _ScrollViewerWindow(name) {
  10473. var _this = _super.call(this, name) || this;
  10474. _this._freezeControls = false;
  10475. _this._bucketWidth = 0;
  10476. _this._bucketHeight = 0;
  10477. _this._buckets = {};
  10478. return _this;
  10479. }
  10480. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  10481. get: function () {
  10482. return this._freezeControls;
  10483. },
  10484. set: function (value) {
  10485. if (this._freezeControls === value) {
  10486. return;
  10487. }
  10488. if (!value) {
  10489. this._restoreMeasures();
  10490. }
  10491. // trigger a full normal layout calculation to be sure all children have their measures up to date
  10492. this._freezeControls = false;
  10493. var textureSize = this.host.getSize();
  10494. var renderWidth = textureSize.width;
  10495. var renderHeight = textureSize.height;
  10496. var context = this.host.getContext();
  10497. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  10498. this.host._numLayoutCalls = 0;
  10499. this.host._rootContainer._layout(measure, context);
  10500. // in freeze mode, prepare children measures accordingly
  10501. if (value) {
  10502. this._updateMeasures();
  10503. if (this._useBuckets()) {
  10504. this._makeBuckets();
  10505. }
  10506. }
  10507. this._freezeControls = value;
  10508. this.host.markAsDirty(); // redraw with the (new) current settings
  10509. },
  10510. enumerable: false,
  10511. configurable: true
  10512. });
  10513. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  10514. get: function () {
  10515. return this._bucketWidth;
  10516. },
  10517. enumerable: false,
  10518. configurable: true
  10519. });
  10520. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  10521. get: function () {
  10522. return this._bucketHeight;
  10523. },
  10524. enumerable: false,
  10525. configurable: true
  10526. });
  10527. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  10528. this._bucketWidth = width;
  10529. this._bucketHeight = height;
  10530. if (this._useBuckets()) {
  10531. if (this._freezeControls) {
  10532. this._makeBuckets();
  10533. }
  10534. }
  10535. else {
  10536. this._buckets = {};
  10537. }
  10538. };
  10539. _ScrollViewerWindow.prototype._useBuckets = function () {
  10540. return this._bucketWidth > 0 && this._bucketHeight > 0;
  10541. };
  10542. _ScrollViewerWindow.prototype._makeBuckets = function () {
  10543. this._buckets = {};
  10544. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  10545. this._dispatchInBuckets(this._children);
  10546. this._oldLeft = null;
  10547. this._oldTop = null;
  10548. };
  10549. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  10550. for (var i = 0; i < children.length; ++i) {
  10551. var child = children[i];
  10552. 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);
  10553. while (bStartY <= bEndY) {
  10554. for (var x = bStartX; x <= bEndX; ++x) {
  10555. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  10556. if (!lstc) {
  10557. lstc = [];
  10558. this._buckets[bucket] = lstc;
  10559. }
  10560. lstc.push(child);
  10561. }
  10562. bStartY++;
  10563. }
  10564. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10565. this._dispatchInBuckets(child._children);
  10566. }
  10567. }
  10568. };
  10569. // reset left and top measures for the window and all its children
  10570. _ScrollViewerWindow.prototype._updateMeasures = function () {
  10571. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10572. this._measureForChildren.left -= left;
  10573. this._measureForChildren.top -= top;
  10574. this._currentMeasure.left -= left;
  10575. this._currentMeasure.top -= top;
  10576. this._customData.origLeftForChildren = this._measureForChildren.left;
  10577. this._customData.origTopForChildren = this._measureForChildren.top;
  10578. this._customData.origLeft = this._currentMeasure.left;
  10579. this._customData.origTop = this._currentMeasure.top;
  10580. this._updateChildrenMeasures(this._children, left, top);
  10581. };
  10582. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  10583. for (var i = 0; i < children.length; ++i) {
  10584. var child = children[i];
  10585. child._currentMeasure.left -= left;
  10586. child._currentMeasure.top -= top;
  10587. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  10588. child._customData._origTop = child._currentMeasure.top;
  10589. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10590. this._updateChildrenMeasures(child._children, left, top);
  10591. }
  10592. }
  10593. };
  10594. _ScrollViewerWindow.prototype._restoreMeasures = function () {
  10595. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10596. this._measureForChildren.left = this._customData.origLeftForChildren + left;
  10597. this._measureForChildren.top = this._customData.origTopForChildren + top;
  10598. this._currentMeasure.left = this._customData.origLeft + left;
  10599. this._currentMeasure.top = this._customData.origTop + top;
  10600. };
  10601. _ScrollViewerWindow.prototype._getTypeName = function () {
  10602. return "ScrollViewerWindow";
  10603. };
  10604. /** @hidden */
  10605. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  10606. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  10607. this._parentMeasure = parentMeasure;
  10608. this._measureForChildren.left = this._currentMeasure.left;
  10609. this._measureForChildren.top = this._currentMeasure.top;
  10610. this._measureForChildren.width = parentMeasure.width;
  10611. this._measureForChildren.height = parentMeasure.height;
  10612. };
  10613. /** @hidden */
  10614. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  10615. if (this._freezeControls) {
  10616. this.invalidateRect(); // will trigger a redraw of the window
  10617. return false;
  10618. }
  10619. return _super.prototype._layout.call(this, parentMeasure, context);
  10620. };
  10621. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  10622. for (var i = 0; i < children.length; ++i) {
  10623. var child = children[i];
  10624. child._currentMeasure.left = child._customData._origLeft + left;
  10625. child._currentMeasure.top = child._customData._origTop + top;
  10626. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  10627. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  10628. this._scrollChildren(child._children, left, top);
  10629. }
  10630. }
  10631. };
  10632. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  10633. 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);
  10634. while (bStartY <= bEndY) {
  10635. for (var x = bStartX; x <= bEndX; ++x) {
  10636. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  10637. if (lstc) {
  10638. for (var i = 0; i < lstc.length; ++i) {
  10639. var child = lstc[i];
  10640. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  10641. child._currentMeasure.top = child._customData._origTop + scrollTop;
  10642. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  10643. }
  10644. }
  10645. }
  10646. bStartY++;
  10647. }
  10648. };
  10649. /** @hidden */
  10650. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  10651. if (!this._freezeControls) {
  10652. _super.prototype._draw.call(this, context, invalidatedRectangle);
  10653. return;
  10654. }
  10655. this._localDraw(context);
  10656. if (this.clipChildren) {
  10657. this._clipForChildren(context);
  10658. }
  10659. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  10660. if (this._useBuckets()) {
  10661. if (this._oldLeft !== null && this._oldTop !== null) {
  10662. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  10663. this._scrollChildrenWithBuckets(left, top, left, top);
  10664. }
  10665. else {
  10666. this._scrollChildren(this._children, left, top);
  10667. }
  10668. }
  10669. else {
  10670. this._scrollChildren(this._children, left, top);
  10671. }
  10672. this._oldLeft = left;
  10673. this._oldTop = top;
  10674. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10675. var child = _a[_i];
  10676. if (!child._intersectsRect(this._parentMeasure)) {
  10677. continue;
  10678. }
  10679. child._render(context, this._parentMeasure);
  10680. }
  10681. };
  10682. _ScrollViewerWindow.prototype._postMeasure = function () {
  10683. if (this._freezeControls) {
  10684. _super.prototype._postMeasure.call(this);
  10685. return;
  10686. }
  10687. var maxWidth = this.parentClientWidth;
  10688. var maxHeight = this.parentClientHeight;
  10689. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10690. var child = _a[_i];
  10691. if (!child.isVisible || child.notRenderable) {
  10692. continue;
  10693. }
  10694. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  10695. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  10696. }
  10697. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  10698. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  10699. }
  10700. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width + child.paddingRightInPixels);
  10701. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height + child.paddingBottomInPixels);
  10702. }
  10703. if (this._currentMeasure.width !== maxWidth) {
  10704. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10705. this._currentMeasure.width = maxWidth;
  10706. this._rebuildLayout = true;
  10707. this._isDirty = true;
  10708. }
  10709. if (this._currentMeasure.height !== maxHeight) {
  10710. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10711. this._currentMeasure.height = maxHeight;
  10712. this._rebuildLayout = true;
  10713. this._isDirty = true;
  10714. }
  10715. _super.prototype._postMeasure.call(this);
  10716. };
  10717. return _ScrollViewerWindow;
  10718. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10719. /***/ }),
  10720. /***/ "./2D/controls/selector.ts":
  10721. /*!*********************************!*\
  10722. !*** ./2D/controls/selector.ts ***!
  10723. \*********************************/
  10724. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  10725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10726. "use strict";
  10727. __webpack_require__.r(__webpack_exports__);
  10728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  10729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  10730. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  10731. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  10732. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  10733. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10734. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  10735. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10736. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10737. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10738. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  10739. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  10740. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  10741. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10742. /** Class used to create a RadioGroup
  10743. * which contains groups of radio buttons
  10744. */
  10745. var SelectorGroup = /** @class */ (function () {
  10746. /**
  10747. * Creates a new SelectorGroup
  10748. * @param name of group, used as a group heading
  10749. */
  10750. function SelectorGroup(
  10751. /** name of SelectorGroup */
  10752. name) {
  10753. this.name = name;
  10754. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10755. this._selectors = new Array();
  10756. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10757. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10758. this._groupHeader = this._addGroupHeader(name);
  10759. }
  10760. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  10761. /** Gets the groupPanel of the SelectorGroup */
  10762. get: function () {
  10763. return this._groupPanel;
  10764. },
  10765. enumerable: false,
  10766. configurable: true
  10767. });
  10768. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  10769. /** Gets the selectors array */
  10770. get: function () {
  10771. return this._selectors;
  10772. },
  10773. enumerable: false,
  10774. configurable: true
  10775. });
  10776. Object.defineProperty(SelectorGroup.prototype, "header", {
  10777. /** Gets and sets the group header */
  10778. get: function () {
  10779. return this._groupHeader.text;
  10780. },
  10781. set: function (label) {
  10782. if (this._groupHeader.text === "label") {
  10783. return;
  10784. }
  10785. this._groupHeader.text = label;
  10786. },
  10787. enumerable: false,
  10788. configurable: true
  10789. });
  10790. /** @hidden */
  10791. SelectorGroup.prototype._addGroupHeader = function (text) {
  10792. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  10793. groupHeading.width = 0.9;
  10794. groupHeading.height = "30px";
  10795. groupHeading.textWrapping = true;
  10796. groupHeading.color = "black";
  10797. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10798. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10799. groupHeading.left = "2px";
  10800. this._groupPanel.addControl(groupHeading);
  10801. return groupHeading;
  10802. };
  10803. /** @hidden*/
  10804. SelectorGroup.prototype._getSelector = function (selectorNb) {
  10805. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10806. return;
  10807. }
  10808. return this._selectors[selectorNb];
  10809. };
  10810. /** Removes the selector at the given position
  10811. * @param selectorNb the position of the selector within the group
  10812. */
  10813. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  10814. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10815. return;
  10816. }
  10817. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10818. this._selectors.splice(selectorNb, 1);
  10819. };
  10820. return SelectorGroup;
  10821. }());
  10822. /** Class used to create a CheckboxGroup
  10823. * which contains groups of checkbox buttons
  10824. */
  10825. var CheckboxGroup = /** @class */ (function (_super) {
  10826. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10827. function CheckboxGroup() {
  10828. return _super !== null && _super.apply(this, arguments) || this;
  10829. }
  10830. /** Adds a checkbox as a control
  10831. * @param text is the label for the selector
  10832. * @param func is the function called when the Selector is checked
  10833. * @param checked is true when Selector is checked
  10834. */
  10835. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10836. if (func === void 0) { func = function (s) { }; }
  10837. if (checked === void 0) { checked = false; }
  10838. var checked = checked || false;
  10839. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10840. button.width = "20px";
  10841. button.height = "20px";
  10842. button.color = "#364249";
  10843. button.background = "#CCCCCC";
  10844. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10845. button.onIsCheckedChangedObservable.add(function (state) {
  10846. func(state);
  10847. });
  10848. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10849. _selector.height = "30px";
  10850. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10851. _selector.left = "4px";
  10852. this.groupPanel.addControl(_selector);
  10853. this.selectors.push(_selector);
  10854. button.isChecked = checked;
  10855. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10856. button.color = this.groupPanel.parent.parent.buttonColor;
  10857. button.background = this.groupPanel.parent.parent.buttonBackground;
  10858. }
  10859. };
  10860. /** @hidden */
  10861. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10862. this.selectors[selectorNb].children[1].text = label;
  10863. };
  10864. /** @hidden */
  10865. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10866. this.selectors[selectorNb].children[1].color = color;
  10867. };
  10868. /** @hidden */
  10869. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10870. this.selectors[selectorNb].children[0].color = color;
  10871. };
  10872. /** @hidden */
  10873. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10874. this.selectors[selectorNb].children[0].background = color;
  10875. };
  10876. return CheckboxGroup;
  10877. }(SelectorGroup));
  10878. /** Class used to create a RadioGroup
  10879. * which contains groups of radio buttons
  10880. */
  10881. var RadioGroup = /** @class */ (function (_super) {
  10882. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10883. function RadioGroup() {
  10884. var _this = _super !== null && _super.apply(this, arguments) || this;
  10885. _this._selectNb = 0;
  10886. return _this;
  10887. }
  10888. /** Adds a radio button as a control
  10889. * @param label is the label for the selector
  10890. * @param func is the function called when the Selector is checked
  10891. * @param checked is true when Selector is checked
  10892. */
  10893. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10894. if (func === void 0) { func = function (n) { }; }
  10895. if (checked === void 0) { checked = false; }
  10896. var nb = this._selectNb++;
  10897. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10898. button.name = label;
  10899. button.width = "20px";
  10900. button.height = "20px";
  10901. button.color = "#364249";
  10902. button.background = "#CCCCCC";
  10903. button.group = this.name;
  10904. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10905. button.onIsCheckedChangedObservable.add(function (state) {
  10906. if (state) {
  10907. func(nb);
  10908. }
  10909. });
  10910. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10911. _selector.height = "30px";
  10912. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10913. _selector.left = "4px";
  10914. this.groupPanel.addControl(_selector);
  10915. this.selectors.push(_selector);
  10916. button.isChecked = checked;
  10917. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10918. button.color = this.groupPanel.parent.parent.buttonColor;
  10919. button.background = this.groupPanel.parent.parent.buttonBackground;
  10920. }
  10921. };
  10922. /** @hidden */
  10923. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10924. this.selectors[selectorNb].children[1].text = label;
  10925. };
  10926. /** @hidden */
  10927. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10928. this.selectors[selectorNb].children[1].color = color;
  10929. };
  10930. /** @hidden */
  10931. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10932. this.selectors[selectorNb].children[0].color = color;
  10933. };
  10934. /** @hidden */
  10935. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10936. this.selectors[selectorNb].children[0].background = color;
  10937. };
  10938. return RadioGroup;
  10939. }(SelectorGroup));
  10940. /** Class used to create a SliderGroup
  10941. * which contains groups of slider buttons
  10942. */
  10943. var SliderGroup = /** @class */ (function (_super) {
  10944. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10945. function SliderGroup() {
  10946. return _super !== null && _super.apply(this, arguments) || this;
  10947. }
  10948. /**
  10949. * Adds a slider to the SelectorGroup
  10950. * @param label is the label for the SliderBar
  10951. * @param func is the function called when the Slider moves
  10952. * @param unit is a string describing the units used, eg degrees or metres
  10953. * @param min is the minimum value for the Slider
  10954. * @param max is the maximum value for the Slider
  10955. * @param value is the start value for the Slider between min and max
  10956. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10957. */
  10958. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10959. if (func === void 0) { func = function (v) { }; }
  10960. if (unit === void 0) { unit = "Units"; }
  10961. if (min === void 0) { min = 0; }
  10962. if (max === void 0) { max = 0; }
  10963. if (value === void 0) { value = 0; }
  10964. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10965. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10966. button.name = unit;
  10967. button.value = value;
  10968. button.minimum = min;
  10969. button.maximum = max;
  10970. button.width = 0.9;
  10971. button.height = "20px";
  10972. button.color = "#364249";
  10973. button.background = "#CCCCCC";
  10974. button.borderColor = "black";
  10975. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10976. button.left = "4px";
  10977. button.paddingBottom = "4px";
  10978. button.onValueChangedObservable.add(function (value) {
  10979. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10980. func(value);
  10981. });
  10982. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10983. _selector.height = "60px";
  10984. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10985. _selector.left = "4px";
  10986. _selector.children[0].name = label;
  10987. this.groupPanel.addControl(_selector);
  10988. this.selectors.push(_selector);
  10989. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10990. button.color = this.groupPanel.parent.parent.buttonColor;
  10991. button.background = this.groupPanel.parent.parent.buttonBackground;
  10992. }
  10993. };
  10994. /** @hidden */
  10995. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10996. this.selectors[selectorNb].children[0].name = label;
  10997. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10998. };
  10999. /** @hidden */
  11000. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  11001. this.selectors[selectorNb].children[0].color = color;
  11002. };
  11003. /** @hidden */
  11004. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  11005. this.selectors[selectorNb].children[1].color = color;
  11006. };
  11007. /** @hidden */
  11008. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  11009. this.selectors[selectorNb].children[1].background = color;
  11010. };
  11011. return SliderGroup;
  11012. }(SelectorGroup));
  11013. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  11014. * @see https://doc.babylonjs.com/how_to/selector
  11015. */
  11016. var SelectionPanel = /** @class */ (function (_super) {
  11017. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  11018. /**
  11019. * Creates a new SelectionPanel
  11020. * @param name of SelectionPanel
  11021. * @param groups is an array of SelectionGroups
  11022. */
  11023. function SelectionPanel(
  11024. /** name of SelectionPanel */
  11025. name,
  11026. /** an array of SelectionGroups */
  11027. groups) {
  11028. if (groups === void 0) { groups = []; }
  11029. var _this = _super.call(this, name) || this;
  11030. _this.name = name;
  11031. _this.groups = groups;
  11032. _this._buttonColor = "#364249";
  11033. _this._buttonBackground = "#CCCCCC";
  11034. _this._headerColor = "black";
  11035. _this._barColor = "white";
  11036. _this._barHeight = "2px";
  11037. _this._spacerHeight = "20px";
  11038. _this._bars = new Array();
  11039. _this._groups = groups;
  11040. _this.thickness = 2;
  11041. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11042. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11043. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11044. _this._panel.top = 5;
  11045. _this._panel.left = 5;
  11046. _this._panel.width = 0.95;
  11047. if (groups.length > 0) {
  11048. for (var i = 0; i < groups.length - 1; i++) {
  11049. _this._panel.addControl(groups[i].groupPanel);
  11050. _this._addSpacer();
  11051. }
  11052. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  11053. }
  11054. _this.addControl(_this._panel);
  11055. return _this;
  11056. }
  11057. SelectionPanel.prototype._getTypeName = function () {
  11058. return "SelectionPanel";
  11059. };
  11060. Object.defineProperty(SelectionPanel.prototype, "panel", {
  11061. /** Gets the (stack) panel of the SelectionPanel */
  11062. get: function () {
  11063. return this._panel;
  11064. },
  11065. enumerable: false,
  11066. configurable: true
  11067. });
  11068. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  11069. /** Gets or sets the headerColor */
  11070. get: function () {
  11071. return this._headerColor;
  11072. },
  11073. set: function (color) {
  11074. if (this._headerColor === color) {
  11075. return;
  11076. }
  11077. this._headerColor = color;
  11078. this._setHeaderColor();
  11079. },
  11080. enumerable: false,
  11081. configurable: true
  11082. });
  11083. SelectionPanel.prototype._setHeaderColor = function () {
  11084. for (var i = 0; i < this._groups.length; i++) {
  11085. this._groups[i].groupPanel.children[0].color = this._headerColor;
  11086. }
  11087. };
  11088. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  11089. /** Gets or sets the button color */
  11090. get: function () {
  11091. return this._buttonColor;
  11092. },
  11093. set: function (color) {
  11094. if (this._buttonColor === color) {
  11095. return;
  11096. }
  11097. this._buttonColor = color;
  11098. this._setbuttonColor();
  11099. },
  11100. enumerable: false,
  11101. configurable: true
  11102. });
  11103. SelectionPanel.prototype._setbuttonColor = function () {
  11104. for (var i = 0; i < this._groups.length; i++) {
  11105. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  11106. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  11107. }
  11108. }
  11109. };
  11110. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  11111. /** Gets or sets the label color */
  11112. get: function () {
  11113. return this._labelColor;
  11114. },
  11115. set: function (color) {
  11116. if (this._labelColor === color) {
  11117. return;
  11118. }
  11119. this._labelColor = color;
  11120. this._setLabelColor();
  11121. },
  11122. enumerable: false,
  11123. configurable: true
  11124. });
  11125. SelectionPanel.prototype._setLabelColor = function () {
  11126. for (var i = 0; i < this._groups.length; i++) {
  11127. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  11128. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  11129. }
  11130. }
  11131. };
  11132. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  11133. /** Gets or sets the button background */
  11134. get: function () {
  11135. return this._buttonBackground;
  11136. },
  11137. set: function (color) {
  11138. if (this._buttonBackground === color) {
  11139. return;
  11140. }
  11141. this._buttonBackground = color;
  11142. this._setButtonBackground();
  11143. },
  11144. enumerable: false,
  11145. configurable: true
  11146. });
  11147. SelectionPanel.prototype._setButtonBackground = function () {
  11148. for (var i = 0; i < this._groups.length; i++) {
  11149. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  11150. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  11151. }
  11152. }
  11153. };
  11154. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  11155. /** Gets or sets the color of separator bar */
  11156. get: function () {
  11157. return this._barColor;
  11158. },
  11159. set: function (color) {
  11160. if (this._barColor === color) {
  11161. return;
  11162. }
  11163. this._barColor = color;
  11164. this._setBarColor();
  11165. },
  11166. enumerable: false,
  11167. configurable: true
  11168. });
  11169. SelectionPanel.prototype._setBarColor = function () {
  11170. for (var i = 0; i < this._bars.length; i++) {
  11171. this._bars[i].children[0].background = this._barColor;
  11172. }
  11173. };
  11174. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  11175. /** Gets or sets the height of separator bar */
  11176. get: function () {
  11177. return this._barHeight;
  11178. },
  11179. set: function (value) {
  11180. if (this._barHeight === value) {
  11181. return;
  11182. }
  11183. this._barHeight = value;
  11184. this._setBarHeight();
  11185. },
  11186. enumerable: false,
  11187. configurable: true
  11188. });
  11189. SelectionPanel.prototype._setBarHeight = function () {
  11190. for (var i = 0; i < this._bars.length; i++) {
  11191. this._bars[i].children[0].height = this._barHeight;
  11192. }
  11193. };
  11194. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  11195. /** Gets or sets the height of spacers*/
  11196. get: function () {
  11197. return this._spacerHeight;
  11198. },
  11199. set: function (value) {
  11200. if (this._spacerHeight === value) {
  11201. return;
  11202. }
  11203. this._spacerHeight = value;
  11204. this._setSpacerHeight();
  11205. },
  11206. enumerable: false,
  11207. configurable: true
  11208. });
  11209. SelectionPanel.prototype._setSpacerHeight = function () {
  11210. for (var i = 0; i < this._bars.length; i++) {
  11211. this._bars[i].height = this._spacerHeight;
  11212. }
  11213. };
  11214. /** Adds a bar between groups */
  11215. SelectionPanel.prototype._addSpacer = function () {
  11216. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  11217. separator.width = 1;
  11218. separator.height = this._spacerHeight;
  11219. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11220. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  11221. bar.width = 1;
  11222. bar.height = this._barHeight;
  11223. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11224. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11225. bar.background = this._barColor;
  11226. bar.color = "transparent";
  11227. separator.addControl(bar);
  11228. this._panel.addControl(separator);
  11229. this._bars.push(separator);
  11230. };
  11231. /** Add a group to the selection panel
  11232. * @param group is the selector group to add
  11233. */
  11234. SelectionPanel.prototype.addGroup = function (group) {
  11235. if (this._groups.length > 0) {
  11236. this._addSpacer();
  11237. }
  11238. this._panel.addControl(group.groupPanel);
  11239. this._groups.push(group);
  11240. group.groupPanel.children[0].color = this._headerColor;
  11241. for (var j = 0; j < group.selectors.length; j++) {
  11242. group._setSelectorButtonColor(j, this._buttonColor);
  11243. group._setSelectorButtonBackground(j, this._buttonBackground);
  11244. }
  11245. };
  11246. /** Remove the group from the given position
  11247. * @param groupNb is the position of the group in the list
  11248. */
  11249. SelectionPanel.prototype.removeGroup = function (groupNb) {
  11250. if (groupNb < 0 || groupNb >= this._groups.length) {
  11251. return;
  11252. }
  11253. var group = this._groups[groupNb];
  11254. this._panel.removeControl(group.groupPanel);
  11255. this._groups.splice(groupNb, 1);
  11256. if (groupNb < this._bars.length) {
  11257. this._panel.removeControl(this._bars[groupNb]);
  11258. this._bars.splice(groupNb, 1);
  11259. }
  11260. };
  11261. /** Change a group header label
  11262. * @param label is the new group header label
  11263. * @param groupNb is the number of the group to relabel
  11264. * */
  11265. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  11266. if (groupNb < 0 || groupNb >= this._groups.length) {
  11267. return;
  11268. }
  11269. var group = this._groups[groupNb];
  11270. group.groupPanel.children[0].text = label;
  11271. };
  11272. /** Change selector label to the one given
  11273. * @param label is the new selector label
  11274. * @param groupNb is the number of the groupcontaining the selector
  11275. * @param selectorNb is the number of the selector within a group to relabel
  11276. * */
  11277. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  11278. if (groupNb < 0 || groupNb >= this._groups.length) {
  11279. return;
  11280. }
  11281. var group = this._groups[groupNb];
  11282. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  11283. return;
  11284. }
  11285. group._setSelectorLabel(selectorNb, label);
  11286. };
  11287. /** For a given group position remove the selector at the given position
  11288. * @param groupNb is the number of the group to remove the selector from
  11289. * @param selectorNb is the number of the selector within the group
  11290. */
  11291. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  11292. if (groupNb < 0 || groupNb >= this._groups.length) {
  11293. return;
  11294. }
  11295. var group = this._groups[groupNb];
  11296. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  11297. return;
  11298. }
  11299. group.removeSelector(selectorNb);
  11300. };
  11301. /** For a given group position of correct type add a checkbox button
  11302. * @param groupNb is the number of the group to remove the selector from
  11303. * @param label is the label for the selector
  11304. * @param func is the function called when the Selector is checked
  11305. * @param checked is true when Selector is checked
  11306. */
  11307. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  11308. if (func === void 0) { func = function () { }; }
  11309. if (checked === void 0) { checked = false; }
  11310. if (groupNb < 0 || groupNb >= this._groups.length) {
  11311. return;
  11312. }
  11313. var group = this._groups[groupNb];
  11314. group.addCheckbox(label, func, checked);
  11315. };
  11316. /** For a given group position of correct type add a radio button
  11317. * @param groupNb is the number of the group to remove the selector from
  11318. * @param label is the label for the selector
  11319. * @param func is the function called when the Selector is checked
  11320. * @param checked is true when Selector is checked
  11321. */
  11322. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  11323. if (func === void 0) { func = function () { }; }
  11324. if (checked === void 0) { checked = false; }
  11325. if (groupNb < 0 || groupNb >= this._groups.length) {
  11326. return;
  11327. }
  11328. var group = this._groups[groupNb];
  11329. group.addRadio(label, func, checked);
  11330. };
  11331. /**
  11332. * For a given slider group add a slider
  11333. * @param groupNb is the number of the group to add the slider to
  11334. * @param label is the label for the Slider
  11335. * @param func is the function called when the Slider moves
  11336. * @param unit is a string describing the units used, eg degrees or metres
  11337. * @param min is the minimum value for the Slider
  11338. * @param max is the maximum value for the Slider
  11339. * @param value is the start value for the Slider between min and max
  11340. * @param onVal is the function used to format the value displayed, eg radians to degrees
  11341. */
  11342. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  11343. if (func === void 0) { func = function () { }; }
  11344. if (unit === void 0) { unit = "Units"; }
  11345. if (min === void 0) { min = 0; }
  11346. if (max === void 0) { max = 0; }
  11347. if (value === void 0) { value = 0; }
  11348. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  11349. if (groupNb < 0 || groupNb >= this._groups.length) {
  11350. return;
  11351. }
  11352. var group = this._groups[groupNb];
  11353. group.addSlider(label, func, unit, min, max, value, onVal);
  11354. };
  11355. return SelectionPanel;
  11356. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  11357. /***/ }),
  11358. /***/ "./2D/controls/sliders/baseSlider.ts":
  11359. /*!*******************************************!*\
  11360. !*** ./2D/controls/sliders/baseSlider.ts ***!
  11361. \*******************************************/
  11362. /*! exports provided: BaseSlider */
  11363. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11364. "use strict";
  11365. __webpack_require__.r(__webpack_exports__);
  11366. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  11367. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11368. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  11369. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11370. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  11371. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  11372. /**
  11373. * Class used to create slider controls
  11374. */
  11375. var BaseSlider = /** @class */ (function (_super) {
  11376. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  11377. /**
  11378. * Creates a new BaseSlider
  11379. * @param name defines the control name
  11380. */
  11381. function BaseSlider(name) {
  11382. var _this = _super.call(this, name) || this;
  11383. _this.name = name;
  11384. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11385. _this._minimum = 0;
  11386. _this._maximum = 100;
  11387. _this._value = 50;
  11388. _this._isVertical = false;
  11389. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  11390. _this._isThumbClamped = false;
  11391. _this._displayThumb = true;
  11392. _this._step = 0;
  11393. _this._lastPointerDownID = -1;
  11394. // Shared rendering info
  11395. _this._effectiveBarOffset = 0;
  11396. /** Observable raised when the sldier value changes */
  11397. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11398. // Events
  11399. _this._pointerIsDown = false;
  11400. _this.isPointerBlocker = true;
  11401. return _this;
  11402. }
  11403. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  11404. /** Gets or sets a boolean indicating if the thumb must be rendered */
  11405. get: function () {
  11406. return this._displayThumb;
  11407. },
  11408. set: function (value) {
  11409. if (this._displayThumb === value) {
  11410. return;
  11411. }
  11412. this._displayThumb = value;
  11413. this._markAsDirty();
  11414. },
  11415. enumerable: false,
  11416. configurable: true
  11417. });
  11418. Object.defineProperty(BaseSlider.prototype, "step", {
  11419. /** Gets or sets a step to apply to values (0 by default) */
  11420. get: function () {
  11421. return this._step;
  11422. },
  11423. set: function (value) {
  11424. if (this._step === value) {
  11425. return;
  11426. }
  11427. this._step = value;
  11428. this._markAsDirty();
  11429. },
  11430. enumerable: false,
  11431. configurable: true
  11432. });
  11433. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  11434. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  11435. get: function () {
  11436. return this._barOffset.toString(this._host);
  11437. },
  11438. set: function (value) {
  11439. if (this._barOffset.toString(this._host) === value) {
  11440. return;
  11441. }
  11442. if (this._barOffset.fromString(value)) {
  11443. this._markAsDirty();
  11444. }
  11445. },
  11446. enumerable: false,
  11447. configurable: true
  11448. });
  11449. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  11450. /** Gets main bar offset in pixels*/
  11451. get: function () {
  11452. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  11453. },
  11454. enumerable: false,
  11455. configurable: true
  11456. });
  11457. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  11458. /** Gets or sets thumb width */
  11459. get: function () {
  11460. return this._thumbWidth.toString(this._host);
  11461. },
  11462. set: function (value) {
  11463. if (this._thumbWidth.toString(this._host) === value) {
  11464. return;
  11465. }
  11466. if (this._thumbWidth.fromString(value)) {
  11467. this._markAsDirty();
  11468. }
  11469. },
  11470. enumerable: false,
  11471. configurable: true
  11472. });
  11473. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  11474. /** Gets thumb width in pixels */
  11475. get: function () {
  11476. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  11477. },
  11478. enumerable: false,
  11479. configurable: true
  11480. });
  11481. Object.defineProperty(BaseSlider.prototype, "minimum", {
  11482. /** Gets or sets minimum value */
  11483. get: function () {
  11484. return this._minimum;
  11485. },
  11486. set: function (value) {
  11487. if (this._minimum === value) {
  11488. return;
  11489. }
  11490. this._minimum = value;
  11491. this._markAsDirty();
  11492. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  11493. },
  11494. enumerable: false,
  11495. configurable: true
  11496. });
  11497. Object.defineProperty(BaseSlider.prototype, "maximum", {
  11498. /** Gets or sets maximum value */
  11499. get: function () {
  11500. return this._maximum;
  11501. },
  11502. set: function (value) {
  11503. if (this._maximum === value) {
  11504. return;
  11505. }
  11506. this._maximum = value;
  11507. this._markAsDirty();
  11508. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  11509. },
  11510. enumerable: false,
  11511. configurable: true
  11512. });
  11513. Object.defineProperty(BaseSlider.prototype, "value", {
  11514. /** Gets or sets current value */
  11515. get: function () {
  11516. return this._value;
  11517. },
  11518. set: function (value) {
  11519. value = Math.max(Math.min(value, this._maximum), this._minimum);
  11520. if (this._value === value) {
  11521. return;
  11522. }
  11523. this._value = value;
  11524. this._markAsDirty();
  11525. this.onValueChangedObservable.notifyObservers(this._value);
  11526. },
  11527. enumerable: false,
  11528. configurable: true
  11529. });
  11530. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  11531. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  11532. get: function () {
  11533. return this._isVertical;
  11534. },
  11535. set: function (value) {
  11536. if (this._isVertical === value) {
  11537. return;
  11538. }
  11539. this._isVertical = value;
  11540. this._markAsDirty();
  11541. },
  11542. enumerable: false,
  11543. configurable: true
  11544. });
  11545. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  11546. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  11547. get: function () {
  11548. return this._isThumbClamped;
  11549. },
  11550. set: function (value) {
  11551. if (this._isThumbClamped === value) {
  11552. return;
  11553. }
  11554. this._isThumbClamped = value;
  11555. this._markAsDirty();
  11556. },
  11557. enumerable: false,
  11558. configurable: true
  11559. });
  11560. BaseSlider.prototype._getTypeName = function () {
  11561. return "BaseSlider";
  11562. };
  11563. BaseSlider.prototype._getThumbPosition = function () {
  11564. if (this.isVertical) {
  11565. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  11566. }
  11567. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  11568. };
  11569. BaseSlider.prototype._getThumbThickness = function (type) {
  11570. var thumbThickness = 0;
  11571. switch (type) {
  11572. case "circle":
  11573. if (this._thumbWidth.isPixel) {
  11574. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  11575. }
  11576. else {
  11577. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11578. }
  11579. break;
  11580. case "rectangle":
  11581. if (this._thumbWidth.isPixel) {
  11582. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  11583. }
  11584. else {
  11585. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11586. }
  11587. }
  11588. return thumbThickness;
  11589. };
  11590. BaseSlider.prototype._prepareRenderingData = function (type) {
  11591. // Main bar
  11592. this._effectiveBarOffset = 0;
  11593. this._renderLeft = this._currentMeasure.left;
  11594. this._renderTop = this._currentMeasure.top;
  11595. this._renderWidth = this._currentMeasure.width;
  11596. this._renderHeight = this._currentMeasure.height;
  11597. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  11598. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  11599. this._effectiveThumbThickness = this._getThumbThickness(type);
  11600. if (this.displayThumb) {
  11601. this._backgroundBoxLength -= this._effectiveThumbThickness;
  11602. }
  11603. //throw error when height is less than width for vertical slider
  11604. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  11605. console.error("Height should be greater than width");
  11606. return;
  11607. }
  11608. if (this._barOffset.isPixel) {
  11609. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  11610. }
  11611. else {
  11612. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  11613. }
  11614. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  11615. if (this.isVertical) {
  11616. this._renderLeft += this._effectiveBarOffset;
  11617. if (!this.isThumbClamped && this.displayThumb) {
  11618. this._renderTop += (this._effectiveThumbThickness / 2);
  11619. }
  11620. this._renderHeight = this._backgroundBoxLength;
  11621. this._renderWidth = this._backgroundBoxThickness;
  11622. }
  11623. else {
  11624. this._renderTop += this._effectiveBarOffset;
  11625. if (!this.isThumbClamped && this.displayThumb) {
  11626. this._renderLeft += (this._effectiveThumbThickness / 2);
  11627. }
  11628. this._renderHeight = this._backgroundBoxThickness;
  11629. this._renderWidth = this._backgroundBoxLength;
  11630. }
  11631. };
  11632. /** @hidden */
  11633. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  11634. if (this.rotation != 0) {
  11635. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11636. x = this._transformedPosition.x;
  11637. y = this._transformedPosition.y;
  11638. }
  11639. var value;
  11640. if (this._isVertical) {
  11641. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  11642. }
  11643. else {
  11644. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  11645. }
  11646. var mult = (1 / this._step) | 0;
  11647. this.value = this._step ? ((value * mult) | 0) / mult : value;
  11648. };
  11649. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  11650. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  11651. return false;
  11652. }
  11653. this._pointerIsDown = true;
  11654. this._updateValueFromPointer(coordinates.x, coordinates.y);
  11655. this._host._capturingControl[pointerId] = this;
  11656. this._lastPointerDownID = pointerId;
  11657. return true;
  11658. };
  11659. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  11660. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  11661. if (pointerId != this._lastPointerDownID) {
  11662. return;
  11663. }
  11664. if (this._pointerIsDown) {
  11665. this._updateValueFromPointer(coordinates.x, coordinates.y);
  11666. }
  11667. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  11668. };
  11669. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  11670. this._pointerIsDown = false;
  11671. delete this._host._capturingControl[pointerId];
  11672. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  11673. };
  11674. BaseSlider.prototype._onCanvasBlur = function () {
  11675. this._forcePointerUp();
  11676. _super.prototype._onCanvasBlur.call(this);
  11677. };
  11678. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11679. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11680. ], BaseSlider.prototype, "displayThumb", null);
  11681. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11682. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11683. ], BaseSlider.prototype, "step", null);
  11684. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11685. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11686. ], BaseSlider.prototype, "barOffset", null);
  11687. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11688. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11689. ], BaseSlider.prototype, "thumbWidth", null);
  11690. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11691. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11692. ], BaseSlider.prototype, "minimum", null);
  11693. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11694. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11695. ], BaseSlider.prototype, "maximum", null);
  11696. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11697. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11698. ], BaseSlider.prototype, "value", null);
  11699. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11700. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11701. ], BaseSlider.prototype, "isVertical", null);
  11702. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11703. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  11704. ], BaseSlider.prototype, "isThumbClamped", null);
  11705. return BaseSlider;
  11706. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  11707. /***/ }),
  11708. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  11709. /*!*************************************************!*\
  11710. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  11711. \*************************************************/
  11712. /*! exports provided: ImageBasedSlider */
  11713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11714. "use strict";
  11715. __webpack_require__.r(__webpack_exports__);
  11716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  11717. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11718. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11719. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11720. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  11721. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  11722. /**
  11723. * Class used to create slider controls based on images
  11724. */
  11725. var ImageBasedSlider = /** @class */ (function (_super) {
  11726. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  11727. /**
  11728. * Creates a new ImageBasedSlider
  11729. * @param name defines the control name
  11730. */
  11731. function ImageBasedSlider(name) {
  11732. var _this = _super.call(this, name) || this;
  11733. _this.name = name;
  11734. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11735. return _this;
  11736. }
  11737. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  11738. get: function () {
  11739. return this._displayThumb && this.thumbImage != null;
  11740. },
  11741. set: function (value) {
  11742. if (this._displayThumb === value) {
  11743. return;
  11744. }
  11745. this._displayThumb = value;
  11746. this._markAsDirty();
  11747. },
  11748. enumerable: false,
  11749. configurable: true
  11750. });
  11751. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  11752. /**
  11753. * Gets or sets the image used to render the background
  11754. */
  11755. get: function () {
  11756. return this._backgroundImage;
  11757. },
  11758. set: function (value) {
  11759. var _this = this;
  11760. if (this._backgroundImage === value) {
  11761. return;
  11762. }
  11763. this._backgroundImage = value;
  11764. if (value && !value.isLoaded) {
  11765. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11766. }
  11767. this._markAsDirty();
  11768. },
  11769. enumerable: false,
  11770. configurable: true
  11771. });
  11772. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  11773. /**
  11774. * Gets or sets the image used to render the value bar
  11775. */
  11776. get: function () {
  11777. return this._valueBarImage;
  11778. },
  11779. set: function (value) {
  11780. var _this = this;
  11781. if (this._valueBarImage === value) {
  11782. return;
  11783. }
  11784. this._valueBarImage = value;
  11785. if (value && !value.isLoaded) {
  11786. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11787. }
  11788. this._markAsDirty();
  11789. },
  11790. enumerable: false,
  11791. configurable: true
  11792. });
  11793. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  11794. /**
  11795. * Gets or sets the image used to render the thumb
  11796. */
  11797. get: function () {
  11798. return this._thumbImage;
  11799. },
  11800. set: function (value) {
  11801. var _this = this;
  11802. if (this._thumbImage === value) {
  11803. return;
  11804. }
  11805. this._thumbImage = value;
  11806. if (value && !value.isLoaded) {
  11807. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11808. }
  11809. this._markAsDirty();
  11810. },
  11811. enumerable: false,
  11812. configurable: true
  11813. });
  11814. ImageBasedSlider.prototype._getTypeName = function () {
  11815. return "ImageBasedSlider";
  11816. };
  11817. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  11818. context.save();
  11819. this._applyStates(context);
  11820. this._prepareRenderingData("rectangle");
  11821. var thumbPosition = this._getThumbPosition();
  11822. var left = this._renderLeft;
  11823. var top = this._renderTop;
  11824. var width = this._renderWidth;
  11825. var height = this._renderHeight;
  11826. // Background
  11827. if (this._backgroundImage) {
  11828. this._tempMeasure.copyFromFloats(left, top, width, height);
  11829. if (this.isThumbClamped && this.displayThumb) {
  11830. if (this.isVertical) {
  11831. this._tempMeasure.height += this._effectiveThumbThickness;
  11832. }
  11833. else {
  11834. this._tempMeasure.width += this._effectiveThumbThickness;
  11835. }
  11836. }
  11837. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11838. this._backgroundImage._draw(context);
  11839. }
  11840. // Bar
  11841. if (this._valueBarImage) {
  11842. if (this.isVertical) {
  11843. if (this.isThumbClamped && this.displayThumb) {
  11844. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11845. }
  11846. else {
  11847. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  11848. }
  11849. }
  11850. else {
  11851. if (this.isThumbClamped && this.displayThumb) {
  11852. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  11853. }
  11854. else {
  11855. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11856. }
  11857. }
  11858. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11859. this._valueBarImage._draw(context);
  11860. }
  11861. // Thumb
  11862. if (this.displayThumb) {
  11863. if (this.isVertical) {
  11864. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11865. }
  11866. else {
  11867. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11868. }
  11869. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11870. this._thumbImage._draw(context);
  11871. }
  11872. context.restore();
  11873. };
  11874. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  11875. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  11876. ], ImageBasedSlider.prototype, "displayThumb", null);
  11877. return ImageBasedSlider;
  11878. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11879. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11880. /***/ }),
  11881. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11882. /*!***********************************************!*\
  11883. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11884. \***********************************************/
  11885. /*! exports provided: ImageScrollBar */
  11886. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11887. "use strict";
  11888. __webpack_require__.r(__webpack_exports__);
  11889. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11890. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11891. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11892. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11893. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  11894. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__);
  11895. /**
  11896. * Class used to create slider controls
  11897. */
  11898. var ImageScrollBar = /** @class */ (function (_super) {
  11899. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11900. /**
  11901. * Creates a new ImageScrollBar
  11902. * @param name defines the control name
  11903. */
  11904. function ImageScrollBar(name) {
  11905. var _this = _super.call(this, name) || this;
  11906. _this.name = name;
  11907. _this._thumbLength = 0.5;
  11908. _this._thumbHeight = 1;
  11909. _this._barImageHeight = 1;
  11910. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11911. /** Number of 90° rotation to apply on the images when in vertical mode */
  11912. _this.num90RotationInVerticalMode = 1;
  11913. return _this;
  11914. }
  11915. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11916. /**
  11917. * Gets or sets the image used to render the background for horizontal bar
  11918. */
  11919. get: function () {
  11920. return this._backgroundBaseImage;
  11921. },
  11922. set: function (value) {
  11923. var _this = this;
  11924. if (this._backgroundBaseImage === value) {
  11925. return;
  11926. }
  11927. this._backgroundBaseImage = value;
  11928. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11929. if (!value.isLoaded) {
  11930. value.onImageLoadedObservable.addOnce(function () {
  11931. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11932. _this._backgroundImage = rotatedValue;
  11933. if (!rotatedValue.isLoaded) {
  11934. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11935. _this._markAsDirty();
  11936. });
  11937. }
  11938. _this._markAsDirty();
  11939. });
  11940. }
  11941. else {
  11942. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11943. this._markAsDirty();
  11944. }
  11945. }
  11946. else {
  11947. this._backgroundImage = value;
  11948. if (value && !value.isLoaded) {
  11949. value.onImageLoadedObservable.addOnce(function () {
  11950. _this._markAsDirty();
  11951. });
  11952. }
  11953. this._markAsDirty();
  11954. }
  11955. },
  11956. enumerable: false,
  11957. configurable: true
  11958. });
  11959. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11960. /**
  11961. * Gets or sets the image used to render the thumb
  11962. */
  11963. get: function () {
  11964. return this._thumbBaseImage;
  11965. },
  11966. set: function (value) {
  11967. var _this = this;
  11968. if (this._thumbBaseImage === value) {
  11969. return;
  11970. }
  11971. this._thumbBaseImage = value;
  11972. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11973. if (!value.isLoaded) {
  11974. value.onImageLoadedObservable.addOnce(function () {
  11975. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11976. _this._thumbImage = rotatedValue;
  11977. if (!rotatedValue.isLoaded) {
  11978. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11979. _this._markAsDirty();
  11980. });
  11981. }
  11982. _this._markAsDirty();
  11983. });
  11984. }
  11985. else {
  11986. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11987. this._markAsDirty();
  11988. }
  11989. }
  11990. else {
  11991. this._thumbImage = value;
  11992. if (value && !value.isLoaded) {
  11993. value.onImageLoadedObservable.addOnce(function () {
  11994. _this._markAsDirty();
  11995. });
  11996. }
  11997. this._markAsDirty();
  11998. }
  11999. },
  12000. enumerable: false,
  12001. configurable: true
  12002. });
  12003. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  12004. /**
  12005. * Gets or sets the length of the thumb
  12006. */
  12007. get: function () {
  12008. return this._thumbLength;
  12009. },
  12010. set: function (value) {
  12011. if (this._thumbLength === value) {
  12012. return;
  12013. }
  12014. this._thumbLength = value;
  12015. this._markAsDirty();
  12016. },
  12017. enumerable: false,
  12018. configurable: true
  12019. });
  12020. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  12021. /**
  12022. * Gets or sets the height of the thumb
  12023. */
  12024. get: function () {
  12025. return this._thumbHeight;
  12026. },
  12027. set: function (value) {
  12028. if (this._thumbLength === value) {
  12029. return;
  12030. }
  12031. this._thumbHeight = value;
  12032. this._markAsDirty();
  12033. },
  12034. enumerable: false,
  12035. configurable: true
  12036. });
  12037. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  12038. /**
  12039. * Gets or sets the height of the bar image
  12040. */
  12041. get: function () {
  12042. return this._barImageHeight;
  12043. },
  12044. set: function (value) {
  12045. if (this._barImageHeight === value) {
  12046. return;
  12047. }
  12048. this._barImageHeight = value;
  12049. this._markAsDirty();
  12050. },
  12051. enumerable: false,
  12052. configurable: true
  12053. });
  12054. ImageScrollBar.prototype._getTypeName = function () {
  12055. return "ImageScrollBar";
  12056. };
  12057. ImageScrollBar.prototype._getThumbThickness = function () {
  12058. var thumbThickness = 0;
  12059. if (this._thumbWidth.isPixel) {
  12060. thumbThickness = this._thumbWidth.getValue(this._host);
  12061. }
  12062. else {
  12063. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  12064. }
  12065. return thumbThickness;
  12066. };
  12067. ImageScrollBar.prototype._draw = function (context) {
  12068. context.save();
  12069. this._applyStates(context);
  12070. this._prepareRenderingData("rectangle");
  12071. var thumbPosition = this._getThumbPosition();
  12072. var left = this._renderLeft;
  12073. var top = this._renderTop;
  12074. var width = this._renderWidth;
  12075. var height = this._renderHeight;
  12076. // Background
  12077. if (this._backgroundImage) {
  12078. this._tempMeasure.copyFromFloats(left, top, width, height);
  12079. if (this.isVertical) {
  12080. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  12081. this._tempMeasure.height += this._effectiveThumbThickness;
  12082. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  12083. }
  12084. else {
  12085. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  12086. this._tempMeasure.width += this._effectiveThumbThickness;
  12087. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  12088. }
  12089. this._backgroundImage._draw(context);
  12090. }
  12091. // Thumb
  12092. if (this.isVertical) {
  12093. 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);
  12094. }
  12095. else {
  12096. 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);
  12097. }
  12098. if (this._thumbImage) {
  12099. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  12100. this._thumbImage._draw(context);
  12101. }
  12102. context.restore();
  12103. };
  12104. /** @hidden */
  12105. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  12106. if (this.rotation != 0) {
  12107. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  12108. x = this._transformedPosition.x;
  12109. y = this._transformedPosition.y;
  12110. }
  12111. if (this._first) {
  12112. this._first = false;
  12113. this._originX = x;
  12114. this._originY = y;
  12115. // Check if move is required
  12116. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  12117. if (this.isVertical) {
  12118. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  12119. }
  12120. else {
  12121. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  12122. }
  12123. }
  12124. }
  12125. // Delta mode
  12126. var delta = 0;
  12127. if (this.isVertical) {
  12128. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  12129. }
  12130. else {
  12131. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  12132. }
  12133. this.value += delta * (this.maximum - this.minimum);
  12134. this._originX = x;
  12135. this._originY = y;
  12136. };
  12137. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  12138. this._first = true;
  12139. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  12140. };
  12141. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12142. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  12143. ], ImageScrollBar.prototype, "num90RotationInVerticalMode", void 0);
  12144. return ImageScrollBar;
  12145. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  12146. /***/ }),
  12147. /***/ "./2D/controls/sliders/scrollBar.ts":
  12148. /*!******************************************!*\
  12149. !*** ./2D/controls/sliders/scrollBar.ts ***!
  12150. \******************************************/
  12151. /*! exports provided: ScrollBar */
  12152. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12153. "use strict";
  12154. __webpack_require__.r(__webpack_exports__);
  12155. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  12156. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12157. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  12158. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  12159. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  12160. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__);
  12161. /**
  12162. * Class used to create slider controls
  12163. */
  12164. var ScrollBar = /** @class */ (function (_super) {
  12165. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  12166. /**
  12167. * Creates a new Slider
  12168. * @param name defines the control name
  12169. */
  12170. function ScrollBar(name) {
  12171. var _this = _super.call(this, name) || this;
  12172. _this.name = name;
  12173. _this._background = "black";
  12174. _this._borderColor = "white";
  12175. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  12176. return _this;
  12177. }
  12178. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  12179. /** Gets or sets border color */
  12180. get: function () {
  12181. return this._borderColor;
  12182. },
  12183. set: function (value) {
  12184. if (this._borderColor === value) {
  12185. return;
  12186. }
  12187. this._borderColor = value;
  12188. this._markAsDirty();
  12189. },
  12190. enumerable: false,
  12191. configurable: true
  12192. });
  12193. Object.defineProperty(ScrollBar.prototype, "background", {
  12194. /** Gets or sets background color */
  12195. get: function () {
  12196. return this._background;
  12197. },
  12198. set: function (value) {
  12199. if (this._background === value) {
  12200. return;
  12201. }
  12202. this._background = value;
  12203. this._markAsDirty();
  12204. },
  12205. enumerable: false,
  12206. configurable: true
  12207. });
  12208. ScrollBar.prototype._getTypeName = function () {
  12209. return "Scrollbar";
  12210. };
  12211. ScrollBar.prototype._getThumbThickness = function () {
  12212. var thumbThickness = 0;
  12213. if (this._thumbWidth.isPixel) {
  12214. thumbThickness = this._thumbWidth.getValue(this._host);
  12215. }
  12216. else {
  12217. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  12218. }
  12219. return thumbThickness;
  12220. };
  12221. ScrollBar.prototype._draw = function (context) {
  12222. context.save();
  12223. this._applyStates(context);
  12224. this._prepareRenderingData("rectangle");
  12225. var left = this._renderLeft;
  12226. var thumbPosition = this._getThumbPosition();
  12227. context.fillStyle = this._background;
  12228. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  12229. // Value bar
  12230. context.fillStyle = this.color;
  12231. // Thumb
  12232. if (this.isVertical) {
  12233. this._tempMeasure.left = left - this._effectiveBarOffset;
  12234. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  12235. this._tempMeasure.width = this._currentMeasure.width;
  12236. this._tempMeasure.height = this._effectiveThumbThickness;
  12237. }
  12238. else {
  12239. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  12240. this._tempMeasure.top = this._currentMeasure.top;
  12241. this._tempMeasure.width = this._effectiveThumbThickness;
  12242. this._tempMeasure.height = this._currentMeasure.height;
  12243. }
  12244. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  12245. context.restore();
  12246. };
  12247. /** @hidden */
  12248. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  12249. if (this.rotation != 0) {
  12250. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  12251. x = this._transformedPosition.x;
  12252. y = this._transformedPosition.y;
  12253. }
  12254. if (this._first) {
  12255. this._first = false;
  12256. this._originX = x;
  12257. this._originY = y;
  12258. // Check if move is required
  12259. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  12260. if (this.isVertical) {
  12261. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  12262. }
  12263. else {
  12264. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  12265. }
  12266. }
  12267. }
  12268. // Delta mode
  12269. var delta = 0;
  12270. if (this.isVertical) {
  12271. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  12272. }
  12273. else {
  12274. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  12275. }
  12276. this.value += delta * (this.maximum - this.minimum);
  12277. this._originX = x;
  12278. this._originY = y;
  12279. };
  12280. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  12281. this._first = true;
  12282. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  12283. };
  12284. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12285. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  12286. ], ScrollBar.prototype, "borderColor", null);
  12287. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12288. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"])()
  12289. ], ScrollBar.prototype, "background", null);
  12290. return ScrollBar;
  12291. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  12292. /***/ }),
  12293. /***/ "./2D/controls/sliders/slider.ts":
  12294. /*!***************************************!*\
  12295. !*** ./2D/controls/sliders/slider.ts ***!
  12296. \***************************************/
  12297. /*! exports provided: Slider */
  12298. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12299. "use strict";
  12300. __webpack_require__.r(__webpack_exports__);
  12301. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  12302. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12303. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  12304. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  12305. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  12306. /**
  12307. * Class used to create slider controls
  12308. */
  12309. var Slider = /** @class */ (function (_super) {
  12310. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  12311. /**
  12312. * Creates a new Slider
  12313. * @param name defines the control name
  12314. */
  12315. function Slider(name) {
  12316. var _this = _super.call(this, name) || this;
  12317. _this.name = name;
  12318. _this._background = "black";
  12319. _this._borderColor = "white";
  12320. _this._thumbColor = "";
  12321. _this._isThumbCircle = false;
  12322. _this._displayValueBar = true;
  12323. return _this;
  12324. }
  12325. Object.defineProperty(Slider.prototype, "displayValueBar", {
  12326. /** Gets or sets a boolean indicating if the value bar must be rendered */
  12327. get: function () {
  12328. return this._displayValueBar;
  12329. },
  12330. set: function (value) {
  12331. if (this._displayValueBar === value) {
  12332. return;
  12333. }
  12334. this._displayValueBar = value;
  12335. this._markAsDirty();
  12336. },
  12337. enumerable: false,
  12338. configurable: true
  12339. });
  12340. Object.defineProperty(Slider.prototype, "borderColor", {
  12341. /** Gets or sets border color */
  12342. get: function () {
  12343. return this._borderColor;
  12344. },
  12345. set: function (value) {
  12346. if (this._borderColor === value) {
  12347. return;
  12348. }
  12349. this._borderColor = value;
  12350. this._markAsDirty();
  12351. },
  12352. enumerable: false,
  12353. configurable: true
  12354. });
  12355. Object.defineProperty(Slider.prototype, "background", {
  12356. /** Gets or sets background color */
  12357. get: function () {
  12358. return this._background;
  12359. },
  12360. set: function (value) {
  12361. if (this._background === value) {
  12362. return;
  12363. }
  12364. this._background = value;
  12365. this._markAsDirty();
  12366. },
  12367. enumerable: false,
  12368. configurable: true
  12369. });
  12370. Object.defineProperty(Slider.prototype, "thumbColor", {
  12371. /** Gets or sets thumb's color */
  12372. get: function () {
  12373. return this._thumbColor;
  12374. },
  12375. set: function (value) {
  12376. if (this._thumbColor === value) {
  12377. return;
  12378. }
  12379. this._thumbColor = value;
  12380. this._markAsDirty();
  12381. },
  12382. enumerable: false,
  12383. configurable: true
  12384. });
  12385. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  12386. /** Gets or sets a boolean indicating if the thumb should be round or square */
  12387. get: function () {
  12388. return this._isThumbCircle;
  12389. },
  12390. set: function (value) {
  12391. if (this._isThumbCircle === value) {
  12392. return;
  12393. }
  12394. this._isThumbCircle = value;
  12395. this._markAsDirty();
  12396. },
  12397. enumerable: false,
  12398. configurable: true
  12399. });
  12400. Slider.prototype._getTypeName = function () {
  12401. return "Slider";
  12402. };
  12403. Slider.prototype._draw = function (context, invalidatedRectangle) {
  12404. context.save();
  12405. this._applyStates(context);
  12406. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  12407. var left = this._renderLeft;
  12408. var top = this._renderTop;
  12409. var width = this._renderWidth;
  12410. var height = this._renderHeight;
  12411. var radius = 0;
  12412. if (this.isThumbClamped && this.isThumbCircle) {
  12413. if (this.isVertical) {
  12414. top += (this._effectiveThumbThickness / 2);
  12415. }
  12416. else {
  12417. left += (this._effectiveThumbThickness / 2);
  12418. }
  12419. radius = this._backgroundBoxThickness / 2;
  12420. }
  12421. else {
  12422. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  12423. }
  12424. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12425. context.shadowColor = this.shadowColor;
  12426. context.shadowBlur = this.shadowBlur;
  12427. context.shadowOffsetX = this.shadowOffsetX;
  12428. context.shadowOffsetY = this.shadowOffsetY;
  12429. }
  12430. var thumbPosition = this._getThumbPosition();
  12431. context.fillStyle = this._background;
  12432. if (this.isVertical) {
  12433. if (this.isThumbClamped) {
  12434. if (this.isThumbCircle) {
  12435. context.beginPath();
  12436. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  12437. context.fill();
  12438. context.fillRect(left, top, width, height);
  12439. }
  12440. else {
  12441. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  12442. }
  12443. }
  12444. else {
  12445. context.fillRect(left, top, width, height);
  12446. }
  12447. }
  12448. else {
  12449. if (this.isThumbClamped) {
  12450. if (this.isThumbCircle) {
  12451. context.beginPath();
  12452. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  12453. context.fill();
  12454. context.fillRect(left, top, width, height);
  12455. }
  12456. else {
  12457. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  12458. }
  12459. }
  12460. else {
  12461. context.fillRect(left, top, width, height);
  12462. }
  12463. }
  12464. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12465. context.shadowBlur = 0;
  12466. context.shadowOffsetX = 0;
  12467. context.shadowOffsetY = 0;
  12468. }
  12469. // Value bar
  12470. context.fillStyle = this.color;
  12471. if (this._displayValueBar) {
  12472. if (this.isVertical) {
  12473. if (this.isThumbClamped) {
  12474. if (this.isThumbCircle) {
  12475. context.beginPath();
  12476. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  12477. context.fill();
  12478. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  12479. }
  12480. else {
  12481. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  12482. }
  12483. }
  12484. else {
  12485. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  12486. }
  12487. }
  12488. else {
  12489. if (this.isThumbClamped) {
  12490. if (this.isThumbCircle) {
  12491. context.beginPath();
  12492. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  12493. context.fill();
  12494. context.fillRect(left, top, thumbPosition, height);
  12495. }
  12496. else {
  12497. context.fillRect(left, top, thumbPosition, height);
  12498. }
  12499. }
  12500. else {
  12501. context.fillRect(left, top, thumbPosition, height);
  12502. }
  12503. }
  12504. }
  12505. // Thumb
  12506. context.fillStyle = this._thumbColor || this.color;
  12507. if (this.displayThumb) {
  12508. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12509. context.shadowColor = this.shadowColor;
  12510. context.shadowBlur = this.shadowBlur;
  12511. context.shadowOffsetX = this.shadowOffsetX;
  12512. context.shadowOffsetY = this.shadowOffsetY;
  12513. }
  12514. if (this._isThumbCircle) {
  12515. context.beginPath();
  12516. if (this.isVertical) {
  12517. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  12518. }
  12519. else {
  12520. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  12521. }
  12522. context.fill();
  12523. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12524. context.shadowBlur = 0;
  12525. context.shadowOffsetX = 0;
  12526. context.shadowOffsetY = 0;
  12527. }
  12528. context.strokeStyle = this._borderColor;
  12529. context.stroke();
  12530. }
  12531. else {
  12532. if (this.isVertical) {
  12533. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  12534. }
  12535. else {
  12536. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  12537. }
  12538. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12539. context.shadowBlur = 0;
  12540. context.shadowOffsetX = 0;
  12541. context.shadowOffsetY = 0;
  12542. }
  12543. context.strokeStyle = this._borderColor;
  12544. if (this.isVertical) {
  12545. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  12546. }
  12547. else {
  12548. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  12549. }
  12550. }
  12551. }
  12552. context.restore();
  12553. };
  12554. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12555. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12556. ], Slider.prototype, "displayValueBar", null);
  12557. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12558. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12559. ], Slider.prototype, "borderColor", null);
  12560. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12561. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12562. ], Slider.prototype, "background", null);
  12563. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12564. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12565. ], Slider.prototype, "thumbColor", null);
  12566. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12567. Object(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  12568. ], Slider.prototype, "isThumbCircle", null);
  12569. return Slider;
  12570. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  12571. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  12572. /***/ }),
  12573. /***/ "./2D/controls/stackPanel.ts":
  12574. /*!***********************************!*\
  12575. !*** ./2D/controls/stackPanel.ts ***!
  12576. \***********************************/
  12577. /*! exports provided: StackPanel */
  12578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12579. "use strict";
  12580. __webpack_require__.r(__webpack_exports__);
  12581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  12582. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12583. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  12584. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  12585. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  12586. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12587. /**
  12588. * Class used to create a 2D stack panel container
  12589. */
  12590. var StackPanel = /** @class */ (function (_super) {
  12591. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  12592. /**
  12593. * Creates a new StackPanel
  12594. * @param name defines control name
  12595. */
  12596. function StackPanel(name) {
  12597. var _this = _super.call(this, name) || this;
  12598. _this.name = name;
  12599. _this._isVertical = true;
  12600. _this._manualWidth = false;
  12601. _this._manualHeight = false;
  12602. _this._doNotTrackManualChanges = false;
  12603. /**
  12604. * Gets or sets a boolean indicating that layou warnings should be ignored
  12605. */
  12606. _this.ignoreLayoutWarnings = false;
  12607. return _this;
  12608. }
  12609. Object.defineProperty(StackPanel.prototype, "isVertical", {
  12610. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  12611. get: function () {
  12612. return this._isVertical;
  12613. },
  12614. set: function (value) {
  12615. if (this._isVertical === value) {
  12616. return;
  12617. }
  12618. this._isVertical = value;
  12619. this._markAsDirty();
  12620. },
  12621. enumerable: false,
  12622. configurable: true
  12623. });
  12624. Object.defineProperty(StackPanel.prototype, "width", {
  12625. get: function () {
  12626. return this._width.toString(this._host);
  12627. },
  12628. /**
  12629. * Gets or sets panel width.
  12630. * This value should not be set when in horizontal mode as it will be computed automatically
  12631. */
  12632. set: function (value) {
  12633. if (!this._doNotTrackManualChanges) {
  12634. this._manualWidth = true;
  12635. }
  12636. if (this._width.toString(this._host) === value) {
  12637. return;
  12638. }
  12639. if (this._width.fromString(value)) {
  12640. this._markAsDirty();
  12641. }
  12642. },
  12643. enumerable: false,
  12644. configurable: true
  12645. });
  12646. Object.defineProperty(StackPanel.prototype, "height", {
  12647. get: function () {
  12648. return this._height.toString(this._host);
  12649. },
  12650. /**
  12651. * Gets or sets panel height.
  12652. * This value should not be set when in vertical mode as it will be computed automatically
  12653. */
  12654. set: function (value) {
  12655. if (!this._doNotTrackManualChanges) {
  12656. this._manualHeight = true;
  12657. }
  12658. if (this._height.toString(this._host) === value) {
  12659. return;
  12660. }
  12661. if (this._height.fromString(value)) {
  12662. this._markAsDirty();
  12663. }
  12664. },
  12665. enumerable: false,
  12666. configurable: true
  12667. });
  12668. StackPanel.prototype._getTypeName = function () {
  12669. return "StackPanel";
  12670. };
  12671. /** @hidden */
  12672. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  12673. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12674. var child = _a[_i];
  12675. if (this._isVertical) {
  12676. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  12677. }
  12678. else {
  12679. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12680. }
  12681. }
  12682. _super.prototype._preMeasure.call(this, parentMeasure, context);
  12683. };
  12684. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  12685. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  12686. this._measureForChildren.copyFrom(parentMeasure);
  12687. this._measureForChildren.left = this._currentMeasure.left;
  12688. this._measureForChildren.top = this._currentMeasure.top;
  12689. if (!this.isVertical || this._manualWidth) {
  12690. this._measureForChildren.width = this._currentMeasure.width;
  12691. }
  12692. if (this.isVertical || this._manualHeight) {
  12693. this._measureForChildren.height = this._currentMeasure.height;
  12694. }
  12695. };
  12696. StackPanel.prototype._postMeasure = function () {
  12697. var stackWidth = 0;
  12698. var stackHeight = 0;
  12699. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  12700. var child = _a[_i];
  12701. if (!child.isVisible || child.notRenderable) {
  12702. continue;
  12703. }
  12704. if (this._isVertical) {
  12705. if (child.top !== stackHeight + "px") {
  12706. child.top = stackHeight + "px";
  12707. this._rebuildLayout = true;
  12708. child._top.ignoreAdaptiveScaling = true;
  12709. }
  12710. if (child._height.isPercentage && !child._automaticSize) {
  12711. if (!this.ignoreLayoutWarnings) {
  12712. 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");
  12713. }
  12714. }
  12715. else {
  12716. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  12717. }
  12718. }
  12719. else {
  12720. if (child.left !== stackWidth + "px") {
  12721. child.left = stackWidth + "px";
  12722. this._rebuildLayout = true;
  12723. child._left.ignoreAdaptiveScaling = true;
  12724. }
  12725. if (child._width.isPercentage && !child._automaticSize) {
  12726. if (!this.ignoreLayoutWarnings) {
  12727. 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");
  12728. }
  12729. }
  12730. else {
  12731. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  12732. }
  12733. }
  12734. }
  12735. stackWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  12736. stackHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  12737. this._doNotTrackManualChanges = true;
  12738. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  12739. // User can now define their own height and width for stack panel.
  12740. var panelWidthChanged = false;
  12741. var panelHeightChanged = false;
  12742. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  12743. var previousHeight = this.height;
  12744. this.height = stackHeight + "px";
  12745. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  12746. }
  12747. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  12748. var previousWidth = this.width;
  12749. this.width = stackWidth + "px";
  12750. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  12751. }
  12752. if (panelHeightChanged) {
  12753. this._height.ignoreAdaptiveScaling = true;
  12754. }
  12755. if (panelWidthChanged) {
  12756. this._width.ignoreAdaptiveScaling = true;
  12757. }
  12758. this._doNotTrackManualChanges = false;
  12759. if (panelWidthChanged || panelHeightChanged) {
  12760. this._rebuildLayout = true;
  12761. }
  12762. _super.prototype._postMeasure.call(this);
  12763. };
  12764. /**
  12765. * Serializes the current control
  12766. * @param serializationObject defined the JSON serialized object
  12767. */
  12768. StackPanel.prototype.serialize = function (serializationObject) {
  12769. _super.prototype.serialize.call(this, serializationObject);
  12770. serializationObject.manualWidth = this._manualWidth;
  12771. serializationObject.manualHeight = this._manualHeight;
  12772. };
  12773. /** @hidden */
  12774. StackPanel.prototype._parseFromContent = function (serializedObject, host) {
  12775. this._manualWidth = serializedObject.manualWidth;
  12776. this._manualHeight = serializedObject.manualHeight;
  12777. _super.prototype._parseFromContent.call(this, serializedObject, host);
  12778. };
  12779. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12780. Object(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12781. ], StackPanel.prototype, "ignoreLayoutWarnings", void 0);
  12782. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12783. Object(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12784. ], StackPanel.prototype, "isVertical", null);
  12785. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12786. Object(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12787. ], StackPanel.prototype, "width", null);
  12788. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  12789. Object(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12790. ], StackPanel.prototype, "height", null);
  12791. return StackPanel;
  12792. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  12793. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  12794. /***/ }),
  12795. /***/ "./2D/controls/statics.ts":
  12796. /*!********************************!*\
  12797. !*** ./2D/controls/statics.ts ***!
  12798. \********************************/
  12799. /*! exports provided: name */
  12800. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12801. "use strict";
  12802. __webpack_require__.r(__webpack_exports__);
  12803. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  12804. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12805. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12806. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  12807. /**
  12808. * Forcing an export so that this code will execute
  12809. * @hidden
  12810. */
  12811. var name = "Statics";
  12812. /**
  12813. * Creates a stack panel that can be used to render headers
  12814. * @param control defines the control to associate with the header
  12815. * @param text defines the text of the header
  12816. * @param size defines the size of the header
  12817. * @param options defines options used to configure the header
  12818. * @returns a new StackPanel
  12819. */
  12820. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  12821. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  12822. var isHorizontal = options ? options.isHorizontal : true;
  12823. var controlFirst = options ? options.controlFirst : true;
  12824. panel.isVertical = !isHorizontal;
  12825. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  12826. header.text = text;
  12827. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12828. if (isHorizontal) {
  12829. header.width = size;
  12830. }
  12831. else {
  12832. header.height = size;
  12833. }
  12834. if (controlFirst) {
  12835. panel.addControl(control);
  12836. panel.addControl(header);
  12837. header.paddingLeft = "5px";
  12838. }
  12839. else {
  12840. panel.addControl(header);
  12841. panel.addControl(control);
  12842. header.paddingRight = "5px";
  12843. }
  12844. header.shadowBlur = control.shadowBlur;
  12845. header.shadowColor = control.shadowColor;
  12846. header.shadowOffsetX = control.shadowOffsetX;
  12847. header.shadowOffsetY = control.shadowOffsetY;
  12848. return panel;
  12849. };
  12850. /***/ }),
  12851. /***/ "./2D/controls/textBlock.ts":
  12852. /*!**********************************!*\
  12853. !*** ./2D/controls/textBlock.ts ***!
  12854. \**********************************/
  12855. /*! exports provided: TextWrapping, TextBlock */
  12856. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12857. "use strict";
  12858. __webpack_require__.r(__webpack_exports__);
  12859. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  12860. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  12861. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12862. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12863. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12864. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  12865. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12866. /**
  12867. * Enum that determines the text-wrapping mode to use.
  12868. */
  12869. var TextWrapping;
  12870. (function (TextWrapping) {
  12871. /**
  12872. * Clip the text when it's larger than Control.width; this is the default mode.
  12873. */
  12874. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  12875. /**
  12876. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  12877. */
  12878. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  12879. /**
  12880. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  12881. */
  12882. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  12883. })(TextWrapping || (TextWrapping = {}));
  12884. /**
  12885. * Class used to create text block control
  12886. */
  12887. var TextBlock = /** @class */ (function (_super) {
  12888. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  12889. /**
  12890. * Creates a new TextBlock object
  12891. * @param name defines the name of the control
  12892. * @param text defines the text to display (emptry string by default)
  12893. */
  12894. function TextBlock(
  12895. /**
  12896. * Defines the name of the control
  12897. */
  12898. name, text) {
  12899. if (text === void 0) { text = ""; }
  12900. var _this = _super.call(this, name) || this;
  12901. _this.name = name;
  12902. _this._text = "";
  12903. _this._textWrapping = TextWrapping.Clip;
  12904. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  12905. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  12906. _this._resizeToFit = false;
  12907. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  12908. _this._outlineWidth = 0;
  12909. _this._outlineColor = "white";
  12910. _this._underline = false;
  12911. _this._lineThrough = false;
  12912. /**
  12913. * An event triggered after the text is changed
  12914. */
  12915. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12916. /**
  12917. * An event triggered after the text was broken up into lines
  12918. */
  12919. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12920. _this.text = text;
  12921. return _this;
  12922. }
  12923. Object.defineProperty(TextBlock.prototype, "lines", {
  12924. /**
  12925. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  12926. */
  12927. get: function () {
  12928. return this._lines;
  12929. },
  12930. enumerable: false,
  12931. configurable: true
  12932. });
  12933. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12934. /**
  12935. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12936. */
  12937. get: function () {
  12938. return this._resizeToFit;
  12939. },
  12940. /**
  12941. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12942. */
  12943. set: function (value) {
  12944. if (this._resizeToFit === value) {
  12945. return;
  12946. }
  12947. this._resizeToFit = value;
  12948. if (this._resizeToFit) {
  12949. this._width.ignoreAdaptiveScaling = true;
  12950. this._height.ignoreAdaptiveScaling = true;
  12951. }
  12952. this._markAsDirty();
  12953. },
  12954. enumerable: false,
  12955. configurable: true
  12956. });
  12957. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12958. /**
  12959. * Gets or sets a boolean indicating if text must be wrapped
  12960. */
  12961. get: function () {
  12962. return this._textWrapping;
  12963. },
  12964. /**
  12965. * Gets or sets a boolean indicating if text must be wrapped
  12966. */
  12967. set: function (value) {
  12968. if (this._textWrapping === value) {
  12969. return;
  12970. }
  12971. this._textWrapping = +value;
  12972. this._markAsDirty();
  12973. },
  12974. enumerable: false,
  12975. configurable: true
  12976. });
  12977. Object.defineProperty(TextBlock.prototype, "text", {
  12978. /**
  12979. * Gets or sets text to display
  12980. */
  12981. get: function () {
  12982. return this._text;
  12983. },
  12984. /**
  12985. * Gets or sets text to display
  12986. */
  12987. set: function (value) {
  12988. if (this._text === value) {
  12989. return;
  12990. }
  12991. this._text = value;
  12992. this._markAsDirty();
  12993. this.onTextChangedObservable.notifyObservers(this);
  12994. },
  12995. enumerable: false,
  12996. configurable: true
  12997. });
  12998. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12999. /**
  13000. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  13001. */
  13002. get: function () {
  13003. return this._textHorizontalAlignment;
  13004. },
  13005. /**
  13006. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  13007. */
  13008. set: function (value) {
  13009. if (this._textHorizontalAlignment === value) {
  13010. return;
  13011. }
  13012. this._textHorizontalAlignment = value;
  13013. this._markAsDirty();
  13014. },
  13015. enumerable: false,
  13016. configurable: true
  13017. });
  13018. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  13019. /**
  13020. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  13021. */
  13022. get: function () {
  13023. return this._textVerticalAlignment;
  13024. },
  13025. /**
  13026. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  13027. */
  13028. set: function (value) {
  13029. if (this._textVerticalAlignment === value) {
  13030. return;
  13031. }
  13032. this._textVerticalAlignment = value;
  13033. this._markAsDirty();
  13034. },
  13035. enumerable: false,
  13036. configurable: true
  13037. });
  13038. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  13039. /**
  13040. * Gets or sets line spacing value
  13041. */
  13042. get: function () {
  13043. return this._lineSpacing.toString(this._host);
  13044. },
  13045. /**
  13046. * Gets or sets line spacing value
  13047. */
  13048. set: function (value) {
  13049. if (this._lineSpacing.fromString(value)) {
  13050. this._markAsDirty();
  13051. }
  13052. },
  13053. enumerable: false,
  13054. configurable: true
  13055. });
  13056. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  13057. /**
  13058. * Gets or sets outlineWidth of the text to display
  13059. */
  13060. get: function () {
  13061. return this._outlineWidth;
  13062. },
  13063. /**
  13064. * Gets or sets outlineWidth of the text to display
  13065. */
  13066. set: function (value) {
  13067. if (this._outlineWidth === value) {
  13068. return;
  13069. }
  13070. this._outlineWidth = value;
  13071. this._markAsDirty();
  13072. },
  13073. enumerable: false,
  13074. configurable: true
  13075. });
  13076. Object.defineProperty(TextBlock.prototype, "underline", {
  13077. /**
  13078. * Gets or sets a boolean indicating that text must have underline
  13079. */
  13080. get: function () {
  13081. return this._underline;
  13082. },
  13083. /**
  13084. * Gets or sets a boolean indicating that text must have underline
  13085. */
  13086. set: function (value) {
  13087. if (this._underline === value) {
  13088. return;
  13089. }
  13090. this._underline = value;
  13091. this._markAsDirty();
  13092. },
  13093. enumerable: false,
  13094. configurable: true
  13095. });
  13096. Object.defineProperty(TextBlock.prototype, "lineThrough", {
  13097. /**
  13098. * Gets or sets an boolean indicating that text must be crossed out
  13099. */
  13100. get: function () {
  13101. return this._lineThrough;
  13102. },
  13103. /**
  13104. * Gets or sets an boolean indicating that text must be crossed out
  13105. */
  13106. set: function (value) {
  13107. if (this._lineThrough === value) {
  13108. return;
  13109. }
  13110. this._lineThrough = value;
  13111. this._markAsDirty();
  13112. },
  13113. enumerable: false,
  13114. configurable: true
  13115. });
  13116. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  13117. /**
  13118. * Gets or sets outlineColor of the text to display
  13119. */
  13120. get: function () {
  13121. return this._outlineColor;
  13122. },
  13123. /**
  13124. * Gets or sets outlineColor of the text to display
  13125. */
  13126. set: function (value) {
  13127. if (this._outlineColor === value) {
  13128. return;
  13129. }
  13130. this._outlineColor = value;
  13131. this._markAsDirty();
  13132. },
  13133. enumerable: false,
  13134. configurable: true
  13135. });
  13136. TextBlock.prototype._getTypeName = function () {
  13137. return "TextBlock";
  13138. };
  13139. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  13140. if (!this._fontOffset) {
  13141. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  13142. }
  13143. _super.prototype._processMeasures.call(this, parentMeasure, context);
  13144. // Prepare lines
  13145. this._lines = this._breakLines(this._currentMeasure.width, context);
  13146. this.onLinesReadyObservable.notifyObservers(this);
  13147. var maxLineWidth = 0;
  13148. for (var i = 0; i < this._lines.length; i++) {
  13149. var line = this._lines[i];
  13150. if (line.width > maxLineWidth) {
  13151. maxLineWidth = line.width;
  13152. }
  13153. }
  13154. if (this._resizeToFit) {
  13155. if (this._textWrapping === TextWrapping.Clip) {
  13156. var newWidth = (this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth) | 0;
  13157. if (newWidth !== this._width.internalValue) {
  13158. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  13159. this._rebuildLayout = true;
  13160. }
  13161. }
  13162. var newHeight = (this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;
  13163. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  13164. var lineSpacing = 0;
  13165. if (this._lineSpacing.isPixel) {
  13166. lineSpacing = this._lineSpacing.getValue(this._host);
  13167. }
  13168. else {
  13169. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  13170. }
  13171. newHeight += (this._lines.length - 1) * lineSpacing;
  13172. }
  13173. if (newHeight !== this._height.internalValue) {
  13174. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  13175. this._rebuildLayout = true;
  13176. }
  13177. }
  13178. };
  13179. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  13180. var width = this._currentMeasure.width;
  13181. var x = 0;
  13182. switch (this._textHorizontalAlignment) {
  13183. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  13184. x = 0;
  13185. break;
  13186. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  13187. x = width - textWidth;
  13188. break;
  13189. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  13190. x = (width - textWidth) / 2;
  13191. break;
  13192. }
  13193. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  13194. context.shadowColor = this.shadowColor;
  13195. context.shadowBlur = this.shadowBlur;
  13196. context.shadowOffsetX = this.shadowOffsetX;
  13197. context.shadowOffsetY = this.shadowOffsetY;
  13198. }
  13199. if (this.outlineWidth) {
  13200. context.strokeText(text, this._currentMeasure.left + x, y);
  13201. }
  13202. context.fillText(text, this._currentMeasure.left + x, y);
  13203. if (this._underline) {
  13204. context.beginPath();
  13205. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  13206. context.moveTo(this._currentMeasure.left + x, y + 3);
  13207. context.lineTo(this._currentMeasure.left + x + textWidth, y + 3);
  13208. context.stroke();
  13209. context.closePath();
  13210. }
  13211. if (this._lineThrough) {
  13212. context.beginPath();
  13213. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  13214. context.moveTo(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3);
  13215. context.lineTo(this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3);
  13216. context.stroke();
  13217. context.closePath();
  13218. }
  13219. };
  13220. /** @hidden */
  13221. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  13222. context.save();
  13223. this._applyStates(context);
  13224. // Render lines
  13225. this._renderLines(context);
  13226. context.restore();
  13227. };
  13228. TextBlock.prototype._applyStates = function (context) {
  13229. _super.prototype._applyStates.call(this, context);
  13230. if (this.outlineWidth) {
  13231. context.lineWidth = this.outlineWidth;
  13232. context.strokeStyle = this.outlineColor;
  13233. context.lineJoin = 'miter';
  13234. context.miterLimit = 2;
  13235. }
  13236. };
  13237. TextBlock.prototype._breakLines = function (refWidth, context) {
  13238. var lines = [];
  13239. var _lines = this.text.split("\n");
  13240. if (this._textWrapping === TextWrapping.Ellipsis) {
  13241. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  13242. var _line = _lines_1[_i];
  13243. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  13244. }
  13245. }
  13246. else if (this._textWrapping === TextWrapping.WordWrap) {
  13247. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  13248. var _line = _lines_2[_a];
  13249. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  13250. }
  13251. }
  13252. else {
  13253. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  13254. var _line = _lines_3[_b];
  13255. lines.push(this._parseLine(_line, context));
  13256. }
  13257. }
  13258. return lines;
  13259. };
  13260. TextBlock.prototype._parseLine = function (line, context) {
  13261. if (line === void 0) { line = ""; }
  13262. return { text: line, width: context.measureText(line).width };
  13263. };
  13264. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  13265. if (line === void 0) { line = ""; }
  13266. var lineWidth = context.measureText(line).width;
  13267. if (lineWidth > width) {
  13268. line += "…";
  13269. }
  13270. // unicode support. split('') does not work with unicode!
  13271. // make sure Array.from is available
  13272. var characters = Array.from && Array.from(line);
  13273. if (!characters) {
  13274. // no array.from, use the old method
  13275. while (line.length > 2 && lineWidth > width) {
  13276. line = line.slice(0, -2) + "…";
  13277. lineWidth = context.measureText(line).width;
  13278. }
  13279. }
  13280. else {
  13281. while (characters.length && lineWidth > width) {
  13282. characters.pop();
  13283. line = characters.join("") + "...";
  13284. lineWidth = context.measureText(line).width;
  13285. }
  13286. }
  13287. return { text: line, width: lineWidth };
  13288. };
  13289. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  13290. if (line === void 0) { line = ""; }
  13291. var lines = [];
  13292. var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(" ");
  13293. var lineWidth = 0;
  13294. for (var n = 0; n < words.length; n++) {
  13295. var testLine = n > 0 ? line + " " + words[n] : words[0];
  13296. var metrics = context.measureText(testLine);
  13297. var testWidth = metrics.width;
  13298. if (testWidth > width && n > 0) {
  13299. lines.push({ text: line, width: lineWidth });
  13300. line = words[n];
  13301. lineWidth = context.measureText(line).width;
  13302. }
  13303. else {
  13304. lineWidth = testWidth;
  13305. line = testLine;
  13306. }
  13307. }
  13308. lines.push({ text: line, width: lineWidth });
  13309. return lines;
  13310. };
  13311. TextBlock.prototype._renderLines = function (context) {
  13312. var height = this._currentMeasure.height;
  13313. var rootY = 0;
  13314. switch (this._textVerticalAlignment) {
  13315. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  13316. rootY = this._fontOffset.ascent;
  13317. break;
  13318. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  13319. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  13320. break;
  13321. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  13322. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  13323. break;
  13324. }
  13325. rootY += this._currentMeasure.top;
  13326. for (var i = 0; i < this._lines.length; i++) {
  13327. var line = this._lines[i];
  13328. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  13329. if (this._lineSpacing.isPixel) {
  13330. rootY += this._lineSpacing.getValue(this._host);
  13331. }
  13332. else {
  13333. rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  13334. }
  13335. }
  13336. this._drawText(line.text, line.width, rootY, context);
  13337. rootY += this._fontOffset.height;
  13338. }
  13339. };
  13340. /**
  13341. * Given a width constraint applied on the text block, find the expected height
  13342. * @returns expected height
  13343. */
  13344. TextBlock.prototype.computeExpectedHeight = function () {
  13345. if (this.text && this.widthInPixels) {
  13346. var context_1 = document.createElement("canvas").getContext("2d");
  13347. if (context_1) {
  13348. this._applyStates(context_1);
  13349. if (!this._fontOffset) {
  13350. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  13351. }
  13352. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  13353. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  13354. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  13355. var lineSpacing = 0;
  13356. if (this._lineSpacing.isPixel) {
  13357. lineSpacing = this._lineSpacing.getValue(this._host);
  13358. }
  13359. else {
  13360. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  13361. }
  13362. newHeight += (lines.length - 1) * lineSpacing;
  13363. }
  13364. return newHeight;
  13365. }
  13366. }
  13367. return 0;
  13368. };
  13369. TextBlock.prototype.dispose = function () {
  13370. _super.prototype.dispose.call(this);
  13371. this.onTextChangedObservable.clear();
  13372. };
  13373. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13374. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13375. ], TextBlock.prototype, "resizeToFit", null);
  13376. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13377. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13378. ], TextBlock.prototype, "textWrapping", null);
  13379. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13380. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13381. ], TextBlock.prototype, "text", null);
  13382. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13383. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13384. ], TextBlock.prototype, "textHorizontalAlignment", null);
  13385. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13386. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13387. ], TextBlock.prototype, "textVerticalAlignment", null);
  13388. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13389. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13390. ], TextBlock.prototype, "lineSpacing", null);
  13391. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13392. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13393. ], TextBlock.prototype, "outlineWidth", null);
  13394. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13395. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13396. ], TextBlock.prototype, "underline", null);
  13397. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13398. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13399. ], TextBlock.prototype, "lineThrough", null);
  13400. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  13401. Object(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13402. ], TextBlock.prototype, "outlineColor", null);
  13403. return TextBlock;
  13404. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  13405. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  13406. /***/ }),
  13407. /***/ "./2D/controls/textWrapper.ts":
  13408. /*!************************************!*\
  13409. !*** ./2D/controls/textWrapper.ts ***!
  13410. \************************************/
  13411. /*! exports provided: TextWrapper */
  13412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13413. "use strict";
  13414. __webpack_require__.r(__webpack_exports__);
  13415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return TextWrapper; });
  13416. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13417. /** @hidden */
  13418. var TextWrapper = /** @class */ (function () {
  13419. function TextWrapper() {
  13420. }
  13421. Object.defineProperty(TextWrapper.prototype, "text", {
  13422. get: function () {
  13423. return this._characters ? this._characters.join("") : this._text;
  13424. },
  13425. set: function (txt) {
  13426. this._text = txt;
  13427. this._characters = Array.from && Array.from(txt);
  13428. },
  13429. enumerable: false,
  13430. configurable: true
  13431. });
  13432. Object.defineProperty(TextWrapper.prototype, "length", {
  13433. get: function () {
  13434. return this._characters ? this._characters.length : this._text.length;
  13435. },
  13436. enumerable: false,
  13437. configurable: true
  13438. });
  13439. TextWrapper.prototype.removePart = function (idxStart, idxEnd, insertTxt) {
  13440. var _a;
  13441. this._text = this._text.slice(0, idxStart) + (insertTxt ? insertTxt : "") + this._text.slice(idxEnd);
  13442. if (this._characters) {
  13443. var newCharacters = insertTxt ? Array.from(insertTxt) : [];
  13444. (_a = this._characters).splice.apply(_a, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spreadArrays"])([idxStart, idxEnd - idxStart], newCharacters));
  13445. }
  13446. };
  13447. TextWrapper.prototype.charAt = function (idx) {
  13448. return this._characters ? this._characters[idx] : this._text.charAt(idx);
  13449. };
  13450. TextWrapper.prototype.substr = function (from, length) {
  13451. if (this._characters) {
  13452. if (isNaN(from)) {
  13453. from = 0;
  13454. }
  13455. else if (from >= 0) {
  13456. from = Math.min(from, this._characters.length);
  13457. }
  13458. else {
  13459. from = this._characters.length + Math.max(from, -this._characters.length);
  13460. }
  13461. if (length === undefined) {
  13462. length = this._characters.length - from;
  13463. }
  13464. else if (isNaN(length)) {
  13465. length = 0;
  13466. }
  13467. else if (length < 0) {
  13468. length = 0;
  13469. }
  13470. var temp = [];
  13471. while (--length >= 0) {
  13472. temp[length] = this._characters[from + length];
  13473. }
  13474. return temp.join("");
  13475. }
  13476. return this._text.substr(from, length);
  13477. };
  13478. TextWrapper.prototype.substring = function (from, to) {
  13479. if (this._characters) {
  13480. if (isNaN(from)) {
  13481. from = 0;
  13482. }
  13483. else if (from > this._characters.length) {
  13484. from = this._characters.length;
  13485. }
  13486. else if (from < 0) {
  13487. from = 0;
  13488. }
  13489. if (to === undefined) {
  13490. to = this._characters.length;
  13491. }
  13492. else if (isNaN(to)) {
  13493. to = 0;
  13494. }
  13495. else if (to > this._characters.length) {
  13496. to = this._characters.length;
  13497. }
  13498. else if (to < 0) {
  13499. to = 0;
  13500. }
  13501. var temp = [];
  13502. var idx = 0;
  13503. while (from < to) {
  13504. temp[idx++] = this._characters[from++];
  13505. }
  13506. return temp.join("");
  13507. }
  13508. return this._text.substring(from, to);
  13509. };
  13510. TextWrapper.prototype.isWord = function (index) {
  13511. var rWord = /\w/g;
  13512. return this._characters ? this._characters[index].search(rWord) !== -1 : this._text.search(rWord) !== -1;
  13513. };
  13514. return TextWrapper;
  13515. }());
  13516. /***/ }),
  13517. /***/ "./2D/controls/toggleButton.ts":
  13518. /*!*************************************!*\
  13519. !*** ./2D/controls/toggleButton.ts ***!
  13520. \*************************************/
  13521. /*! exports provided: ToggleButton */
  13522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13523. "use strict";
  13524. __webpack_require__.r(__webpack_exports__);
  13525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return ToggleButton; });
  13526. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13527. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  13528. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  13529. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  13530. /**
  13531. * Class used to create toggle buttons
  13532. */
  13533. var ToggleButton = /** @class */ (function (_super) {
  13534. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ToggleButton, _super);
  13535. /**
  13536. * Creates a new ToggleButton
  13537. * @param name defines the control name
  13538. * @param group defines the toggle group this toggle belongs to
  13539. */
  13540. function ToggleButton(name, group) {
  13541. var _this = _super.call(this, name) || this;
  13542. _this.name = name;
  13543. /** Observable raised when isActive is changed */
  13544. _this.onIsActiveChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  13545. /**
  13546. * Gets or sets a boolean indicating that the toggle button will let internal controls handle picking instead of doing it directly using its bounding info
  13547. */
  13548. _this.delegatePickingToChildren = false;
  13549. _this._isActive = false;
  13550. _this.group = group !== null && group !== void 0 ? group : "";
  13551. _this.thickness = 0;
  13552. _this.isPointerBlocker = true;
  13553. var alphaStore = null;
  13554. _this.toActiveAnimation = function () {
  13555. _this.thickness = 1;
  13556. };
  13557. _this.toInactiveAnimation = function () {
  13558. _this.thickness = 0;
  13559. };
  13560. _this.pointerEnterActiveAnimation = function () {
  13561. alphaStore = _this.alpha;
  13562. _this.alpha -= 0.1;
  13563. };
  13564. _this.pointerOutActiveAnimation = function () {
  13565. if (alphaStore !== null) {
  13566. _this.alpha = alphaStore;
  13567. }
  13568. };
  13569. _this.pointerDownActiveAnimation = function () {
  13570. _this.scaleX -= 0.05;
  13571. _this.scaleY -= 0.05;
  13572. };
  13573. _this.pointerUpActiveAnimation = function () {
  13574. _this.scaleX += 0.05;
  13575. _this.scaleY += 0.05;
  13576. };
  13577. _this.pointerEnterInactiveAnimation = function () {
  13578. alphaStore = _this.alpha;
  13579. _this.alpha -= 0.1;
  13580. };
  13581. _this.pointerOutInactiveAnimation = function () {
  13582. if (alphaStore !== null) {
  13583. _this.alpha = alphaStore;
  13584. }
  13585. };
  13586. _this.pointerDownInactiveAnimation = function () {
  13587. _this.scaleX -= 0.05;
  13588. _this.scaleY -= 0.05;
  13589. };
  13590. _this.pointerUpInactiveAnimation = function () {
  13591. _this.scaleX += 0.05;
  13592. _this.scaleY += 0.05;
  13593. };
  13594. return _this;
  13595. }
  13596. Object.defineProperty(ToggleButton.prototype, "image", {
  13597. /**
  13598. * Returns the ToggleButton's image control if it exists
  13599. */
  13600. get: function () {
  13601. return this._image;
  13602. },
  13603. enumerable: false,
  13604. configurable: true
  13605. });
  13606. Object.defineProperty(ToggleButton.prototype, "textBlock", {
  13607. /**
  13608. * Returns the ToggleButton's child TextBlock control if it exists
  13609. */
  13610. get: function () {
  13611. return this._textBlock;
  13612. },
  13613. enumerable: false,
  13614. configurable: true
  13615. });
  13616. Object.defineProperty(ToggleButton.prototype, "group", {
  13617. /** Gets or sets group name this toggle button belongs to */
  13618. get: function () {
  13619. return this._group;
  13620. },
  13621. set: function (value) {
  13622. if (this._group === value) {
  13623. return;
  13624. }
  13625. this._group = value;
  13626. },
  13627. enumerable: false,
  13628. configurable: true
  13629. });
  13630. Object.defineProperty(ToggleButton.prototype, "isActive", {
  13631. /** Gets or sets a boolean indicating if the toogle button is active or not */
  13632. get: function () {
  13633. return this._isActive;
  13634. },
  13635. set: function (value) {
  13636. var _this = this;
  13637. var _a, _b;
  13638. // Function modeled after radioButton.ts
  13639. if (this._isActive === value) {
  13640. return;
  13641. }
  13642. this._isActive = value;
  13643. // Update the visual state based on the new value
  13644. if (this._isActive) {
  13645. (_a = this.toActiveAnimation) === null || _a === void 0 ? void 0 : _a.call(this);
  13646. }
  13647. else {
  13648. (_b = this.toInactiveAnimation) === null || _b === void 0 ? void 0 : _b.call(this);
  13649. }
  13650. this._markAsDirty();
  13651. this.onIsActiveChangedObservable.notifyObservers(value);
  13652. if (this._isActive && this._host && this._group) {
  13653. // A toggle button in a group can only have 1 active element at a given time.
  13654. // If this toggle button has a group, set other toggle buttons in the group to inactive.
  13655. this._host.executeOnAllControls(function (control) {
  13656. // Check for control type ToggleButton
  13657. if (control.typeName === "ToggleButton") {
  13658. // Don't do anything to this toggle button
  13659. if (control === _this) {
  13660. return;
  13661. }
  13662. var childToggle = control;
  13663. // If toggle button is in same group, set isActive to false
  13664. if (childToggle.group === _this.group) {
  13665. childToggle.isActive = false;
  13666. }
  13667. }
  13668. });
  13669. }
  13670. },
  13671. enumerable: false,
  13672. configurable: true
  13673. });
  13674. ToggleButton.prototype._getTypeName = function () {
  13675. return "ToggleButton";
  13676. };
  13677. // While being a container, the toggle button behaves like a control.
  13678. /** @hidden */
  13679. ToggleButton.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  13680. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  13681. return false;
  13682. }
  13683. if (!_super.prototype.contains.call(this, x, y)) {
  13684. return false;
  13685. }
  13686. if (this.delegatePickingToChildren) {
  13687. var contains = false;
  13688. for (var index = this._children.length - 1; index >= 0; index--) {
  13689. var child = this._children[index];
  13690. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  13691. contains = true;
  13692. break;
  13693. }
  13694. }
  13695. if (!contains) {
  13696. return false;
  13697. }
  13698. }
  13699. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  13700. return true;
  13701. };
  13702. /** @hidden */
  13703. ToggleButton.prototype._onPointerEnter = function (target, pi) {
  13704. if (!_super.prototype._onPointerEnter.call(this, target, pi)) {
  13705. return false;
  13706. }
  13707. if (this._isActive) {
  13708. if (this.pointerEnterActiveAnimation) {
  13709. this.pointerEnterActiveAnimation();
  13710. }
  13711. }
  13712. else {
  13713. if (this.pointerEnterInactiveAnimation) {
  13714. this.pointerEnterInactiveAnimation();
  13715. }
  13716. }
  13717. return true;
  13718. };
  13719. /** @hidden */
  13720. ToggleButton.prototype._onPointerOut = function (target, pi, force) {
  13721. if (force === void 0) { force = false; }
  13722. if (this._isActive) {
  13723. if (this.pointerOutActiveAnimation) {
  13724. this.pointerOutActiveAnimation();
  13725. }
  13726. }
  13727. else {
  13728. if (this.pointerOutInactiveAnimation) {
  13729. this.pointerOutInactiveAnimation();
  13730. }
  13731. }
  13732. _super.prototype._onPointerOut.call(this, target, pi, force);
  13733. };
  13734. /** @hidden */
  13735. ToggleButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  13736. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  13737. return false;
  13738. }
  13739. if (this._isActive) {
  13740. if (this.pointerDownActiveAnimation) {
  13741. this.pointerDownActiveAnimation();
  13742. }
  13743. }
  13744. else {
  13745. if (this.pointerDownInactiveAnimation) {
  13746. this.pointerDownInactiveAnimation();
  13747. }
  13748. }
  13749. return true;
  13750. };
  13751. /** @hidden */
  13752. ToggleButton.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  13753. if (this._isActive) {
  13754. if (this.pointerUpActiveAnimation) {
  13755. this.pointerUpActiveAnimation();
  13756. }
  13757. }
  13758. else {
  13759. if (this.pointerUpInactiveAnimation) {
  13760. this.pointerUpInactiveAnimation();
  13761. }
  13762. }
  13763. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  13764. };
  13765. return ToggleButton;
  13766. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  13767. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ToggleButton"] = ToggleButton;
  13768. /***/ }),
  13769. /***/ "./2D/controls/virtualKeyboard.ts":
  13770. /*!****************************************!*\
  13771. !*** ./2D/controls/virtualKeyboard.ts ***!
  13772. \****************************************/
  13773. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  13774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13775. "use strict";
  13776. __webpack_require__.r(__webpack_exports__);
  13777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  13778. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  13779. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13780. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  13781. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  13782. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  13783. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  13784. /**
  13785. * Class used to store key control properties
  13786. */
  13787. var KeyPropertySet = /** @class */ (function () {
  13788. function KeyPropertySet() {
  13789. }
  13790. return KeyPropertySet;
  13791. }());
  13792. /**
  13793. * Class used to create virtual keyboard
  13794. */
  13795. var VirtualKeyboard = /** @class */ (function (_super) {
  13796. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  13797. function VirtualKeyboard() {
  13798. var _this = _super !== null && _super.apply(this, arguments) || this;
  13799. /** Observable raised when a key is pressed */
  13800. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  13801. /** Gets or sets default key button width */
  13802. _this.defaultButtonWidth = "40px";
  13803. /** Gets or sets default key button height */
  13804. _this.defaultButtonHeight = "40px";
  13805. /** Gets or sets default key button left padding */
  13806. _this.defaultButtonPaddingLeft = "2px";
  13807. /** Gets or sets default key button right padding */
  13808. _this.defaultButtonPaddingRight = "2px";
  13809. /** Gets or sets default key button top padding */
  13810. _this.defaultButtonPaddingTop = "2px";
  13811. /** Gets or sets default key button bottom padding */
  13812. _this.defaultButtonPaddingBottom = "2px";
  13813. /** Gets or sets default key button foreground color */
  13814. _this.defaultButtonColor = "#DDD";
  13815. /** Gets or sets default key button background color */
  13816. _this.defaultButtonBackground = "#070707";
  13817. /** Gets or sets shift button foreground color */
  13818. _this.shiftButtonColor = "#7799FF";
  13819. /** Gets or sets shift button thickness*/
  13820. _this.selectedShiftThickness = 1;
  13821. /** Gets shift key state */
  13822. _this.shiftState = 0;
  13823. _this._currentlyConnectedInputText = null;
  13824. _this._connectedInputTexts = [];
  13825. _this._onKeyPressObserver = null;
  13826. return _this;
  13827. }
  13828. VirtualKeyboard.prototype._getTypeName = function () {
  13829. return "VirtualKeyboard";
  13830. };
  13831. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  13832. var _this = this;
  13833. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  13834. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  13835. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  13836. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  13837. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  13838. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  13839. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  13840. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  13841. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  13842. button.thickness = 0;
  13843. button.isFocusInvisible = true;
  13844. button.shadowColor = this.shadowColor;
  13845. button.shadowBlur = this.shadowBlur;
  13846. button.shadowOffsetX = this.shadowOffsetX;
  13847. button.shadowOffsetY = this.shadowOffsetY;
  13848. button.onPointerUpObservable.add(function () {
  13849. _this.onKeyPressObservable.notifyObservers(key);
  13850. });
  13851. return button;
  13852. };
  13853. /**
  13854. * Adds a new row of keys
  13855. * @param keys defines the list of keys to add
  13856. * @param propertySets defines the associated property sets
  13857. */
  13858. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  13859. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  13860. panel.isVertical = false;
  13861. panel.isFocusInvisible = true;
  13862. var maxKey = null;
  13863. for (var i = 0; i < keys.length; i++) {
  13864. var properties = null;
  13865. if (propertySets && propertySets.length === keys.length) {
  13866. properties = propertySets[i];
  13867. }
  13868. var key = this._createKey(keys[i], properties);
  13869. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  13870. maxKey = key;
  13871. }
  13872. panel.addControl(key);
  13873. }
  13874. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  13875. this.addControl(panel);
  13876. };
  13877. /**
  13878. * Set the shift key to a specific state
  13879. * @param shiftState defines the new shift state
  13880. */
  13881. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  13882. if (!this.children) {
  13883. return;
  13884. }
  13885. for (var i = 0; i < this.children.length; i++) {
  13886. var row = this.children[i];
  13887. if (!row || !row.children) {
  13888. continue;
  13889. }
  13890. var rowContainer = row;
  13891. for (var j = 0; j < rowContainer.children.length; j++) {
  13892. var button = rowContainer.children[j];
  13893. if (!button || !button.children[0]) {
  13894. continue;
  13895. }
  13896. var button_tblock = button.children[0];
  13897. if (button_tblock.text === "\u21E7") {
  13898. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  13899. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  13900. }
  13901. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  13902. }
  13903. }
  13904. };
  13905. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  13906. /** Gets the input text control currently attached to the keyboard */
  13907. get: function () {
  13908. return this._currentlyConnectedInputText;
  13909. },
  13910. enumerable: false,
  13911. configurable: true
  13912. });
  13913. /**
  13914. * Connects the keyboard with an input text control
  13915. *
  13916. * @param input defines the target control
  13917. */
  13918. VirtualKeyboard.prototype.connect = function (input) {
  13919. var _this = this;
  13920. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  13921. if (inputTextAlreadyConnected) {
  13922. return;
  13923. }
  13924. if (this._onKeyPressObserver === null) {
  13925. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  13926. if (!_this._currentlyConnectedInputText) {
  13927. return;
  13928. }
  13929. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  13930. switch (key) {
  13931. case "\u21E7":
  13932. _this.shiftState++;
  13933. if (_this.shiftState > 2) {
  13934. _this.shiftState = 0;
  13935. }
  13936. _this.applyShiftState(_this.shiftState);
  13937. return;
  13938. case "\u2190":
  13939. _this._currentlyConnectedInputText.processKey(8);
  13940. return;
  13941. case "\u21B5":
  13942. _this._currentlyConnectedInputText.processKey(13);
  13943. return;
  13944. }
  13945. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  13946. if (_this.shiftState === 1) {
  13947. _this.shiftState = 0;
  13948. _this.applyShiftState(_this.shiftState);
  13949. }
  13950. });
  13951. }
  13952. this.isVisible = false;
  13953. this._currentlyConnectedInputText = input;
  13954. input._connectedVirtualKeyboard = this;
  13955. // Events hooking
  13956. var onFocusObserver = input.onFocusObservable.add(function () {
  13957. _this._currentlyConnectedInputText = input;
  13958. input._connectedVirtualKeyboard = _this;
  13959. _this.isVisible = true;
  13960. });
  13961. var onBlurObserver = input.onBlurObservable.add(function () {
  13962. input._connectedVirtualKeyboard = null;
  13963. _this._currentlyConnectedInputText = null;
  13964. _this.isVisible = false;
  13965. });
  13966. this._connectedInputTexts.push({
  13967. input: input,
  13968. onBlurObserver: onBlurObserver,
  13969. onFocusObserver: onFocusObserver
  13970. });
  13971. };
  13972. /**
  13973. * Disconnects the keyboard from connected InputText controls
  13974. *
  13975. * @param input optionally defines a target control, otherwise all are disconnected
  13976. */
  13977. VirtualKeyboard.prototype.disconnect = function (input) {
  13978. var _this = this;
  13979. if (input) {
  13980. // .find not available on IE
  13981. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  13982. if (filtered.length === 1) {
  13983. this._removeConnectedInputObservables(filtered[0]);
  13984. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  13985. if (this._currentlyConnectedInputText === input) {
  13986. this._currentlyConnectedInputText = null;
  13987. }
  13988. }
  13989. }
  13990. else {
  13991. this._connectedInputTexts.forEach(function (connectedInputText) {
  13992. _this._removeConnectedInputObservables(connectedInputText);
  13993. });
  13994. this._connectedInputTexts = [];
  13995. }
  13996. if (this._connectedInputTexts.length === 0) {
  13997. this._currentlyConnectedInputText = null;
  13998. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  13999. this._onKeyPressObserver = null;
  14000. }
  14001. };
  14002. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  14003. connectedInputText.input._connectedVirtualKeyboard = null;
  14004. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  14005. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  14006. };
  14007. /**
  14008. * Release all resources
  14009. */
  14010. VirtualKeyboard.prototype.dispose = function () {
  14011. _super.prototype.dispose.call(this);
  14012. this.disconnect();
  14013. };
  14014. // Statics
  14015. /**
  14016. * Creates a new keyboard using a default layout
  14017. *
  14018. * @param name defines control name
  14019. * @returns a new VirtualKeyboard
  14020. */
  14021. VirtualKeyboard.CreateDefaultLayout = function (name) {
  14022. var returnValue = new VirtualKeyboard(name);
  14023. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  14024. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  14025. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  14026. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  14027. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  14028. return returnValue;
  14029. };
  14030. return VirtualKeyboard;
  14031. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  14032. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  14033. /***/ }),
  14034. /***/ "./2D/index.ts":
  14035. /*!*********************!*\
  14036. !*** ./2D/index.ts ***!
  14037. \*********************/
  14038. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, FocusableButton, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, ToggleButton, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader */
  14039. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14040. "use strict";
  14041. __webpack_require__.r(__webpack_exports__);
  14042. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  14043. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  14044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  14045. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  14046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  14047. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  14048. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  14049. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["FocusableButton"]; });
  14050. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  14051. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  14052. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  14053. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  14054. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  14055. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  14056. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  14057. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  14058. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  14059. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  14060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  14061. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  14062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  14063. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  14064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  14065. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  14066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  14067. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ToggleButton"]; });
  14068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  14069. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  14070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  14071. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  14072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  14073. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  14074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  14075. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  14076. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  14077. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  14078. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14079. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  14080. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  14081. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  14082. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  14083. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  14084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  14085. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  14086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  14087. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  14088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  14089. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  14090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  14091. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  14092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  14093. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  14094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  14095. /***/ }),
  14096. /***/ "./2D/math2D.ts":
  14097. /*!**********************!*\
  14098. !*** ./2D/math2D.ts ***!
  14099. \**********************/
  14100. /*! exports provided: Vector2WithInfo, Matrix2D */
  14101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14102. "use strict";
  14103. __webpack_require__.r(__webpack_exports__);
  14104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  14105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  14106. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14107. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  14108. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  14109. /**
  14110. * Class used to transport Vector2 information for pointer events
  14111. */
  14112. var Vector2WithInfo = /** @class */ (function (_super) {
  14113. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  14114. /**
  14115. * Creates a new Vector2WithInfo
  14116. * @param source defines the vector2 data to transport
  14117. * @param buttonIndex defines the current mouse button index
  14118. */
  14119. function Vector2WithInfo(source,
  14120. /** defines the current mouse button index */
  14121. buttonIndex) {
  14122. if (buttonIndex === void 0) { buttonIndex = 0; }
  14123. var _this = _super.call(this, source.x, source.y) || this;
  14124. _this.buttonIndex = buttonIndex;
  14125. return _this;
  14126. }
  14127. return Vector2WithInfo;
  14128. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  14129. /** Class used to provide 2D matrix features */
  14130. var Matrix2D = /** @class */ (function () {
  14131. /**
  14132. * Creates a new matrix
  14133. * @param m00 defines value for (0, 0)
  14134. * @param m01 defines value for (0, 1)
  14135. * @param m10 defines value for (1, 0)
  14136. * @param m11 defines value for (1, 1)
  14137. * @param m20 defines value for (2, 0)
  14138. * @param m21 defines value for (2, 1)
  14139. */
  14140. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  14141. /** Gets the internal array of 6 floats used to store matrix data */
  14142. this.m = new Float32Array(6);
  14143. this.fromValues(m00, m01, m10, m11, m20, m21);
  14144. }
  14145. /**
  14146. * Fills the matrix from direct values
  14147. * @param m00 defines value for (0, 0)
  14148. * @param m01 defines value for (0, 1)
  14149. * @param m10 defines value for (1, 0)
  14150. * @param m11 defines value for (1, 1)
  14151. * @param m20 defines value for (2, 0)
  14152. * @param m21 defines value for (2, 1)
  14153. * @returns the current modified matrix
  14154. */
  14155. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  14156. this.m[0] = m00;
  14157. this.m[1] = m01;
  14158. this.m[2] = m10;
  14159. this.m[3] = m11;
  14160. this.m[4] = m20;
  14161. this.m[5] = m21;
  14162. return this;
  14163. };
  14164. /**
  14165. * Gets matrix determinant
  14166. * @returns the determinant
  14167. */
  14168. Matrix2D.prototype.determinant = function () {
  14169. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  14170. };
  14171. /**
  14172. * Inverses the matrix and stores it in a target matrix
  14173. * @param result defines the target matrix
  14174. * @returns the current matrix
  14175. */
  14176. Matrix2D.prototype.invertToRef = function (result) {
  14177. var l0 = this.m[0];
  14178. var l1 = this.m[1];
  14179. var l2 = this.m[2];
  14180. var l3 = this.m[3];
  14181. var l4 = this.m[4];
  14182. var l5 = this.m[5];
  14183. var det = this.determinant();
  14184. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  14185. result.m[0] = 0;
  14186. result.m[1] = 0;
  14187. result.m[2] = 0;
  14188. result.m[3] = 0;
  14189. result.m[4] = 0;
  14190. result.m[5] = 0;
  14191. return this;
  14192. }
  14193. var detDiv = 1 / det;
  14194. var det4 = l2 * l5 - l3 * l4;
  14195. var det5 = l1 * l4 - l0 * l5;
  14196. result.m[0] = l3 * detDiv;
  14197. result.m[1] = -l1 * detDiv;
  14198. result.m[2] = -l2 * detDiv;
  14199. result.m[3] = l0 * detDiv;
  14200. result.m[4] = det4 * detDiv;
  14201. result.m[5] = det5 * detDiv;
  14202. return this;
  14203. };
  14204. /**
  14205. * Multiplies the current matrix with another one
  14206. * @param other defines the second operand
  14207. * @param result defines the target matrix
  14208. * @returns the current matrix
  14209. */
  14210. Matrix2D.prototype.multiplyToRef = function (other, result) {
  14211. var l0 = this.m[0];
  14212. var l1 = this.m[1];
  14213. var l2 = this.m[2];
  14214. var l3 = this.m[3];
  14215. var l4 = this.m[4];
  14216. var l5 = this.m[5];
  14217. var r0 = other.m[0];
  14218. var r1 = other.m[1];
  14219. var r2 = other.m[2];
  14220. var r3 = other.m[3];
  14221. var r4 = other.m[4];
  14222. var r5 = other.m[5];
  14223. result.m[0] = l0 * r0 + l1 * r2;
  14224. result.m[1] = l0 * r1 + l1 * r3;
  14225. result.m[2] = l2 * r0 + l3 * r2;
  14226. result.m[3] = l2 * r1 + l3 * r3;
  14227. result.m[4] = l4 * r0 + l5 * r2 + r4;
  14228. result.m[5] = l4 * r1 + l5 * r3 + r5;
  14229. return this;
  14230. };
  14231. /**
  14232. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  14233. * @param x defines the x coordinate to transform
  14234. * @param y defines the x coordinate to transform
  14235. * @param result defines the target vector2
  14236. * @returns the current matrix
  14237. */
  14238. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  14239. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  14240. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  14241. return this;
  14242. };
  14243. // Statics
  14244. /**
  14245. * Creates an identity matrix
  14246. * @returns a new matrix
  14247. */
  14248. Matrix2D.Identity = function () {
  14249. return new Matrix2D(1, 0, 0, 1, 0, 0);
  14250. };
  14251. /**
  14252. * Creates a translation matrix and stores it in a target matrix
  14253. * @param x defines the x coordinate of the translation
  14254. * @param y defines the y coordinate of the translation
  14255. * @param result defines the target matrix
  14256. */
  14257. Matrix2D.TranslationToRef = function (x, y, result) {
  14258. result.fromValues(1, 0, 0, 1, x, y);
  14259. };
  14260. /**
  14261. * Creates a scaling matrix and stores it in a target matrix
  14262. * @param x defines the x coordinate of the scaling
  14263. * @param y defines the y coordinate of the scaling
  14264. * @param result defines the target matrix
  14265. */
  14266. Matrix2D.ScalingToRef = function (x, y, result) {
  14267. result.fromValues(x, 0, 0, y, 0, 0);
  14268. };
  14269. /**
  14270. * Creates a rotation matrix and stores it in a target matrix
  14271. * @param angle defines the rotation angle
  14272. * @param result defines the target matrix
  14273. */
  14274. Matrix2D.RotationToRef = function (angle, result) {
  14275. var s = Math.sin(angle);
  14276. var c = Math.cos(angle);
  14277. result.fromValues(c, s, -s, c, 0, 0);
  14278. };
  14279. /**
  14280. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  14281. * @param tx defines the x coordinate of the translation
  14282. * @param ty defines the y coordinate of the translation
  14283. * @param angle defines the rotation angle
  14284. * @param scaleX defines the x coordinate of the scaling
  14285. * @param scaleY defines the y coordinate of the scaling
  14286. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  14287. * @param result defines the target matrix
  14288. */
  14289. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  14290. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  14291. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  14292. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  14293. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  14294. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  14295. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  14296. if (parentMatrix) {
  14297. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  14298. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  14299. }
  14300. else {
  14301. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  14302. }
  14303. };
  14304. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  14305. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  14306. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  14307. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  14308. Matrix2D._TempCompose0 = Matrix2D.Identity();
  14309. Matrix2D._TempCompose1 = Matrix2D.Identity();
  14310. Matrix2D._TempCompose2 = Matrix2D.Identity();
  14311. return Matrix2D;
  14312. }());
  14313. /***/ }),
  14314. /***/ "./2D/measure.ts":
  14315. /*!***********************!*\
  14316. !*** ./2D/measure.ts ***!
  14317. \***********************/
  14318. /*! exports provided: Measure */
  14319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14320. "use strict";
  14321. __webpack_require__.r(__webpack_exports__);
  14322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  14323. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  14324. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  14325. var tmpRect = [
  14326. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14327. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14328. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14329. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14330. ];
  14331. var tmpRect2 = [
  14332. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14333. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14334. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14335. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  14336. ];
  14337. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  14338. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  14339. /**
  14340. * Class used to store 2D control sizes
  14341. */
  14342. var Measure = /** @class */ (function () {
  14343. /**
  14344. * Creates a new measure
  14345. * @param left defines left coordinate
  14346. * @param top defines top coordinate
  14347. * @param width defines width dimension
  14348. * @param height defines height dimension
  14349. */
  14350. function Measure(
  14351. /** defines left coordinate */
  14352. left,
  14353. /** defines top coordinate */
  14354. top,
  14355. /** defines width dimension */
  14356. width,
  14357. /** defines height dimension */
  14358. height) {
  14359. this.left = left;
  14360. this.top = top;
  14361. this.width = width;
  14362. this.height = height;
  14363. }
  14364. /**
  14365. * Copy from another measure
  14366. * @param other defines the other measure to copy from
  14367. */
  14368. Measure.prototype.copyFrom = function (other) {
  14369. this.left = other.left;
  14370. this.top = other.top;
  14371. this.width = other.width;
  14372. this.height = other.height;
  14373. };
  14374. /**
  14375. * Copy from a group of 4 floats
  14376. * @param left defines left coordinate
  14377. * @param top defines top coordinate
  14378. * @param width defines width dimension
  14379. * @param height defines height dimension
  14380. */
  14381. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  14382. this.left = left;
  14383. this.top = top;
  14384. this.width = width;
  14385. this.height = height;
  14386. };
  14387. /**
  14388. * Computes the axis aligned bounding box measure for two given measures
  14389. * @param a Input measure
  14390. * @param b Input measure
  14391. * @param result the resulting bounding measure
  14392. */
  14393. Measure.CombineToRef = function (a, b, result) {
  14394. var left = Math.min(a.left, b.left);
  14395. var top = Math.min(a.top, b.top);
  14396. var right = Math.max(a.left + a.width, b.left + b.width);
  14397. var bottom = Math.max(a.top + a.height, b.top + b.height);
  14398. result.left = left;
  14399. result.top = top;
  14400. result.width = right - left;
  14401. result.height = bottom - top;
  14402. };
  14403. /**
  14404. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  14405. * @param transform the matrix to transform the measure before computing the AABB
  14406. * @param addX number to add to left
  14407. * @param addY number to add to top
  14408. * @param addWidth number to add to width
  14409. * @param addHeight number to add to height
  14410. * @param result the resulting AABB
  14411. */
  14412. Measure.prototype.addAndTransformToRef = function (transform, addX, addY, addWidth, addHeight, result) {
  14413. var left = this.left + addX;
  14414. var top = this.top + addY;
  14415. var width = this.width + addWidth;
  14416. var height = this.height + addHeight;
  14417. tmpRect[0].copyFromFloats(left, top);
  14418. tmpRect[1].copyFromFloats(left + width, top);
  14419. tmpRect[2].copyFromFloats(left + width, top + height);
  14420. tmpRect[3].copyFromFloats(left, top + height);
  14421. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  14422. tmpV2.copyFromFloats(0, 0);
  14423. for (var i = 0; i < 4; i++) {
  14424. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  14425. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  14426. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  14427. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  14428. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  14429. }
  14430. result.left = tmpV1.x;
  14431. result.top = tmpV1.y;
  14432. result.width = tmpV2.x - tmpV1.x;
  14433. result.height = tmpV2.y - tmpV1.y;
  14434. };
  14435. /**
  14436. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  14437. * @param transform the matrix to transform the measure before computing the AABB
  14438. * @param result the resulting AABB
  14439. */
  14440. Measure.prototype.transformToRef = function (transform, result) {
  14441. this.addAndTransformToRef(transform, 0, 0, 0, 0, result);
  14442. };
  14443. /**
  14444. * Check equality between this measure and another one
  14445. * @param other defines the other measures
  14446. * @returns true if both measures are equals
  14447. */
  14448. Measure.prototype.isEqualsTo = function (other) {
  14449. if (this.left !== other.left) {
  14450. return false;
  14451. }
  14452. if (this.top !== other.top) {
  14453. return false;
  14454. }
  14455. if (this.width !== other.width) {
  14456. return false;
  14457. }
  14458. if (this.height !== other.height) {
  14459. return false;
  14460. }
  14461. return true;
  14462. };
  14463. /**
  14464. * Creates an empty measure
  14465. * @returns a new measure
  14466. */
  14467. Measure.Empty = function () {
  14468. return new Measure(0, 0, 0, 0);
  14469. };
  14470. return Measure;
  14471. }());
  14472. /***/ }),
  14473. /***/ "./2D/multiLinePoint.ts":
  14474. /*!******************************!*\
  14475. !*** ./2D/multiLinePoint.ts ***!
  14476. \******************************/
  14477. /*! exports provided: MultiLinePoint */
  14478. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14479. "use strict";
  14480. __webpack_require__.r(__webpack_exports__);
  14481. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  14482. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  14483. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  14484. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  14485. /**
  14486. * Class used to store a point for a MultiLine object.
  14487. * The point can be pure 2D coordinates, a mesh or a control
  14488. */
  14489. var MultiLinePoint = /** @class */ (function () {
  14490. /**
  14491. * Creates a new MultiLinePoint
  14492. * @param multiLine defines the source MultiLine object
  14493. */
  14494. function MultiLinePoint(multiLine) {
  14495. this._multiLine = multiLine;
  14496. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  14497. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  14498. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  14499. }
  14500. Object.defineProperty(MultiLinePoint.prototype, "x", {
  14501. /** Gets or sets x coordinate */
  14502. get: function () {
  14503. return this._x.toString(this._multiLine._host);
  14504. },
  14505. set: function (value) {
  14506. if (this._x.toString(this._multiLine._host) === value) {
  14507. return;
  14508. }
  14509. if (this._x.fromString(value)) {
  14510. this._multiLine._markAsDirty();
  14511. }
  14512. },
  14513. enumerable: false,
  14514. configurable: true
  14515. });
  14516. Object.defineProperty(MultiLinePoint.prototype, "y", {
  14517. /** Gets or sets y coordinate */
  14518. get: function () {
  14519. return this._y.toString(this._multiLine._host);
  14520. },
  14521. set: function (value) {
  14522. if (this._y.toString(this._multiLine._host) === value) {
  14523. return;
  14524. }
  14525. if (this._y.fromString(value)) {
  14526. this._multiLine._markAsDirty();
  14527. }
  14528. },
  14529. enumerable: false,
  14530. configurable: true
  14531. });
  14532. Object.defineProperty(MultiLinePoint.prototype, "control", {
  14533. /** Gets or sets the control associated with this point */
  14534. get: function () {
  14535. return this._control;
  14536. },
  14537. set: function (value) {
  14538. if (this._control === value) {
  14539. return;
  14540. }
  14541. if (this._control && this._controlObserver) {
  14542. this._control.onDirtyObservable.remove(this._controlObserver);
  14543. this._controlObserver = null;
  14544. }
  14545. this._control = value;
  14546. if (this._control) {
  14547. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  14548. }
  14549. this._multiLine._markAsDirty();
  14550. },
  14551. enumerable: false,
  14552. configurable: true
  14553. });
  14554. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  14555. /** Gets or sets the mesh associated with this point */
  14556. get: function () {
  14557. return this._mesh;
  14558. },
  14559. set: function (value) {
  14560. if (this._mesh === value) {
  14561. return;
  14562. }
  14563. if (this._mesh && this._meshObserver) {
  14564. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  14565. }
  14566. this._mesh = value;
  14567. if (this._mesh) {
  14568. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  14569. }
  14570. this._multiLine._markAsDirty();
  14571. },
  14572. enumerable: false,
  14573. configurable: true
  14574. });
  14575. /** Resets links */
  14576. MultiLinePoint.prototype.resetLinks = function () {
  14577. this.control = null;
  14578. this.mesh = null;
  14579. };
  14580. /**
  14581. * Gets a translation vector with Z component
  14582. * @returns the translation vector
  14583. */
  14584. MultiLinePoint.prototype.translate = function () {
  14585. this._point = this._translatePoint();
  14586. return this._point;
  14587. };
  14588. MultiLinePoint.prototype._translatePoint = function () {
  14589. if (this._mesh != null) {
  14590. return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  14591. }
  14592. else if (this._control != null) {
  14593. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](this._control.centerX, this._control.centerY, 1. - babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]);
  14594. }
  14595. else {
  14596. var host = this._multiLine._host;
  14597. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  14598. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  14599. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](xValue, yValue, 1. - babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]);
  14600. }
  14601. };
  14602. /** Release associated resources */
  14603. MultiLinePoint.prototype.dispose = function () {
  14604. this.resetLinks();
  14605. };
  14606. return MultiLinePoint;
  14607. }());
  14608. /***/ }),
  14609. /***/ "./2D/style.ts":
  14610. /*!*********************!*\
  14611. !*** ./2D/style.ts ***!
  14612. \*********************/
  14613. /*! exports provided: Style */
  14614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14615. "use strict";
  14616. __webpack_require__.r(__webpack_exports__);
  14617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  14618. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  14619. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14620. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  14621. /**
  14622. * Define a style used by control to automatically setup properties based on a template.
  14623. * Only support font related properties so far
  14624. */
  14625. var Style = /** @class */ (function () {
  14626. /**
  14627. * Creates a new style object
  14628. * @param host defines the AdvancedDynamicTexture which hosts this style
  14629. */
  14630. function Style(host) {
  14631. this._fontFamily = "Arial";
  14632. this._fontStyle = "";
  14633. this._fontWeight = "";
  14634. /** @hidden */
  14635. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  14636. /**
  14637. * Observable raised when the style values are changed
  14638. */
  14639. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14640. this._host = host;
  14641. }
  14642. Object.defineProperty(Style.prototype, "fontSize", {
  14643. /**
  14644. * Gets or sets the font size
  14645. */
  14646. get: function () {
  14647. return this._fontSize.toString(this._host);
  14648. },
  14649. set: function (value) {
  14650. if (this._fontSize.toString(this._host) === value) {
  14651. return;
  14652. }
  14653. if (this._fontSize.fromString(value)) {
  14654. this.onChangedObservable.notifyObservers(this);
  14655. }
  14656. },
  14657. enumerable: false,
  14658. configurable: true
  14659. });
  14660. Object.defineProperty(Style.prototype, "fontFamily", {
  14661. /**
  14662. * Gets or sets the font family
  14663. */
  14664. get: function () {
  14665. return this._fontFamily;
  14666. },
  14667. set: function (value) {
  14668. if (this._fontFamily === value) {
  14669. return;
  14670. }
  14671. this._fontFamily = value;
  14672. this.onChangedObservable.notifyObservers(this);
  14673. },
  14674. enumerable: false,
  14675. configurable: true
  14676. });
  14677. Object.defineProperty(Style.prototype, "fontStyle", {
  14678. /**
  14679. * Gets or sets the font style
  14680. */
  14681. get: function () {
  14682. return this._fontStyle;
  14683. },
  14684. set: function (value) {
  14685. if (this._fontStyle === value) {
  14686. return;
  14687. }
  14688. this._fontStyle = value;
  14689. this.onChangedObservable.notifyObservers(this);
  14690. },
  14691. enumerable: false,
  14692. configurable: true
  14693. });
  14694. Object.defineProperty(Style.prototype, "fontWeight", {
  14695. /** Gets or sets font weight */
  14696. get: function () {
  14697. return this._fontWeight;
  14698. },
  14699. set: function (value) {
  14700. if (this._fontWeight === value) {
  14701. return;
  14702. }
  14703. this._fontWeight = value;
  14704. this.onChangedObservable.notifyObservers(this);
  14705. },
  14706. enumerable: false,
  14707. configurable: true
  14708. });
  14709. /** Dispose all associated resources */
  14710. Style.prototype.dispose = function () {
  14711. this.onChangedObservable.clear();
  14712. };
  14713. return Style;
  14714. }());
  14715. /***/ }),
  14716. /***/ "./2D/valueAndUnit.ts":
  14717. /*!****************************!*\
  14718. !*** ./2D/valueAndUnit.ts ***!
  14719. \****************************/
  14720. /*! exports provided: ValueAndUnit */
  14721. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14722. "use strict";
  14723. __webpack_require__.r(__webpack_exports__);
  14724. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  14725. /**
  14726. * Class used to specific a value and its associated unit
  14727. */
  14728. var ValueAndUnit = /** @class */ (function () {
  14729. /**
  14730. * Creates a new ValueAndUnit
  14731. * @param value defines the value to store
  14732. * @param unit defines the unit to store
  14733. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  14734. */
  14735. function ValueAndUnit(value,
  14736. /** defines the unit to store */
  14737. unit,
  14738. /** defines a boolean indicating if the value can be negative */
  14739. negativeValueAllowed) {
  14740. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  14741. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  14742. this.unit = unit;
  14743. this.negativeValueAllowed = negativeValueAllowed;
  14744. this._value = 1;
  14745. /**
  14746. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  14747. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  14748. */
  14749. this.ignoreAdaptiveScaling = false;
  14750. this._value = value;
  14751. this._originalUnit = unit;
  14752. }
  14753. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  14754. /** Gets a boolean indicating if the value is a percentage */
  14755. get: function () {
  14756. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  14757. },
  14758. enumerable: false,
  14759. configurable: true
  14760. });
  14761. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  14762. /** Gets a boolean indicating if the value is store as pixel */
  14763. get: function () {
  14764. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  14765. },
  14766. enumerable: false,
  14767. configurable: true
  14768. });
  14769. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  14770. /** Gets direct internal value */
  14771. get: function () {
  14772. return this._value;
  14773. },
  14774. enumerable: false,
  14775. configurable: true
  14776. });
  14777. /**
  14778. * Gets value as pixel
  14779. * @param host defines the root host
  14780. * @param refValue defines the reference value for percentages
  14781. * @returns the value as pixel
  14782. */
  14783. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  14784. if (this.isPixel) {
  14785. return this.getValue(host);
  14786. }
  14787. return this.getValue(host) * refValue;
  14788. };
  14789. /**
  14790. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  14791. * @param value defines the value to store
  14792. * @param unit defines the unit to store
  14793. * @returns the current ValueAndUnit
  14794. */
  14795. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  14796. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  14797. this._value = value;
  14798. this.unit = unit;
  14799. return this;
  14800. };
  14801. /**
  14802. * Gets the value accordingly to its unit
  14803. * @param host defines the root host
  14804. * @returns the value
  14805. */
  14806. ValueAndUnit.prototype.getValue = function (host) {
  14807. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  14808. var width = 0;
  14809. var height = 0;
  14810. if (host.idealWidth) {
  14811. width = (this._value * host.getSize().width) / host.idealWidth;
  14812. }
  14813. if (host.idealHeight) {
  14814. height = (this._value * host.getSize().height) / host.idealHeight;
  14815. }
  14816. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  14817. return window.innerWidth < window.innerHeight ? width : height;
  14818. }
  14819. if (host.idealWidth) { // horizontal
  14820. return width;
  14821. }
  14822. if (host.idealHeight) { // vertical
  14823. return height;
  14824. }
  14825. }
  14826. return this._value;
  14827. };
  14828. /**
  14829. * Gets a string representation of the value
  14830. * @param host defines the root host
  14831. * @param decimals defines an optional number of decimals to display
  14832. * @returns a string
  14833. */
  14834. ValueAndUnit.prototype.toString = function (host, decimals) {
  14835. switch (this.unit) {
  14836. case ValueAndUnit.UNITMODE_PERCENTAGE:
  14837. var percentage = this.getValue(host) * 100;
  14838. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  14839. case ValueAndUnit.UNITMODE_PIXEL:
  14840. var pixels = this.getValue(host);
  14841. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  14842. }
  14843. return this.unit.toString();
  14844. };
  14845. /**
  14846. * Store a value parsed from a string
  14847. * @param source defines the source string
  14848. * @returns true if the value was successfully parsed
  14849. */
  14850. ValueAndUnit.prototype.fromString = function (source) {
  14851. var match = ValueAndUnit._Regex.exec(source.toString());
  14852. if (!match || match.length === 0) {
  14853. return false;
  14854. }
  14855. var sourceValue = parseFloat(match[1]);
  14856. var sourceUnit = this._originalUnit;
  14857. if (!this.negativeValueAllowed) {
  14858. if (sourceValue < 0) {
  14859. sourceValue = 0;
  14860. }
  14861. }
  14862. if (match.length === 4) {
  14863. switch (match[3]) {
  14864. case "px":
  14865. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  14866. break;
  14867. case "%":
  14868. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  14869. sourceValue /= 100.0;
  14870. break;
  14871. }
  14872. }
  14873. if (sourceValue === this._value && sourceUnit === this.unit) {
  14874. return false;
  14875. }
  14876. this._value = sourceValue;
  14877. this.unit = sourceUnit;
  14878. return true;
  14879. };
  14880. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  14881. /** UNITMODE_PERCENTAGE */
  14882. get: function () {
  14883. return ValueAndUnit._UNITMODE_PERCENTAGE;
  14884. },
  14885. enumerable: false,
  14886. configurable: true
  14887. });
  14888. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  14889. /** UNITMODE_PIXEL */
  14890. get: function () {
  14891. return ValueAndUnit._UNITMODE_PIXEL;
  14892. },
  14893. enumerable: false,
  14894. configurable: true
  14895. });
  14896. // Static
  14897. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  14898. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  14899. ValueAndUnit._UNITMODE_PIXEL = 1;
  14900. return ValueAndUnit;
  14901. }());
  14902. /***/ }),
  14903. /***/ "./2D/xmlLoader.ts":
  14904. /*!*************************!*\
  14905. !*** ./2D/xmlLoader.ts ***!
  14906. \*************************/
  14907. /*! exports provided: XmlLoader */
  14908. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14909. "use strict";
  14910. __webpack_require__.r(__webpack_exports__);
  14911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  14912. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  14913. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  14914. /**
  14915. * Class used to load GUI via XML.
  14916. */
  14917. var XmlLoader = /** @class */ (function () {
  14918. /**
  14919. * Create a new xml loader
  14920. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  14921. */
  14922. function XmlLoader(parentClass) {
  14923. if (parentClass === void 0) { parentClass = null; }
  14924. this._nodes = {};
  14925. this._nodeTypes = {
  14926. element: 1,
  14927. attribute: 2,
  14928. text: 3
  14929. };
  14930. this._isLoaded = false;
  14931. this._objectAttributes = {
  14932. "textHorizontalAlignment": 1,
  14933. "textVerticalAlignment": 2,
  14934. "horizontalAlignment": 3,
  14935. "verticalAlignment": 4,
  14936. "stretch": 5,
  14937. };
  14938. if (parentClass) {
  14939. this._parentClass = parentClass;
  14940. }
  14941. }
  14942. XmlLoader.prototype._getChainElement = function (attributeValue) {
  14943. var element = window;
  14944. if (this._parentClass) {
  14945. element = this._parentClass;
  14946. }
  14947. var value = attributeValue;
  14948. value = value.split(".");
  14949. for (var i = 0; i < value.length; i++) {
  14950. element = element[value[i]];
  14951. }
  14952. return element;
  14953. };
  14954. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  14955. var attribute = attributeName.split(".");
  14956. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  14957. return className[attribute[1]];
  14958. };
  14959. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  14960. if (linkParent === void 0) { linkParent = true; }
  14961. try {
  14962. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  14963. var guiNode = new className();
  14964. if (parent && linkParent) {
  14965. parent.addControl(guiNode);
  14966. }
  14967. for (var i = 0; i < node.attributes.length; i++) {
  14968. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  14969. continue;
  14970. }
  14971. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  14972. var element = this._getChainElement(node.attributes[i].value);
  14973. guiNode[node.attributes[i].name].add(element);
  14974. continue;
  14975. }
  14976. else if (node.attributes[i].name == "linkWithMesh") {
  14977. if (this._parentClass) {
  14978. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  14979. }
  14980. else {
  14981. guiNode.linkWithMesh(window[node.attributes[i].value]);
  14982. }
  14983. }
  14984. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  14985. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  14986. guiNode[node.attributes[i].name] = element;
  14987. }
  14988. else if (!this._objectAttributes[node.attributes[i].name]) {
  14989. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  14990. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  14991. }
  14992. else {
  14993. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  14994. }
  14995. }
  14996. else {
  14997. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  14998. }
  14999. }
  15000. if (!node.attributes.getNamedItem("id")) {
  15001. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  15002. return guiNode;
  15003. }
  15004. var id = node.attributes.getNamedItem("id").value;
  15005. if (id.startsWith("{{") && id.endsWith("}}")) {
  15006. id = this._getChainElement(id.substring(2, id.length - 2));
  15007. }
  15008. if (!this._nodes[id]) {
  15009. this._nodes[id] = guiNode;
  15010. }
  15011. else {
  15012. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  15013. }
  15014. return guiNode;
  15015. }
  15016. catch (e) {
  15017. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  15018. }
  15019. };
  15020. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  15021. var width;
  15022. var height;
  15023. var columns;
  15024. var rows = node.children;
  15025. var cells;
  15026. var isPixel = false;
  15027. var cellNode;
  15028. var rowNumber = -1;
  15029. var columnNumber = -1;
  15030. var totalColumnsNumber = 0;
  15031. for (var i = 0; i < rows.length; i++) {
  15032. if (rows[i].nodeType != this._nodeTypes.element) {
  15033. continue;
  15034. }
  15035. if (rows[i].nodeName != "Row") {
  15036. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  15037. }
  15038. rowNumber += 1;
  15039. columns = rows[i].children;
  15040. if (!rows[i].attributes.getNamedItem("height")) {
  15041. throw "XmlLoader Exception : Height must be defined for grid rows";
  15042. }
  15043. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  15044. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  15045. guiNode.addRowDefinition(height, isPixel);
  15046. for (var j = 0; j < columns.length; j++) {
  15047. if (columns[j].nodeType != this._nodeTypes.element) {
  15048. continue;
  15049. }
  15050. if (columns[j].nodeName != "Column") {
  15051. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  15052. }
  15053. columnNumber += 1;
  15054. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  15055. 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.";
  15056. }
  15057. if (rowNumber == 0) {
  15058. if (!columns[j].attributes.getNamedItem("width")) {
  15059. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  15060. }
  15061. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  15062. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  15063. guiNode.addColumnDefinition(width, isPixel);
  15064. }
  15065. cells = columns[j].children;
  15066. for (var k = 0; k < cells.length; k++) {
  15067. if (cells[k].nodeType != this._nodeTypes.element) {
  15068. continue;
  15069. }
  15070. cellNode = this._createGuiElement(cells[k], guiNode, false);
  15071. guiNode.addControl(cellNode, rowNumber, columnNumber);
  15072. if (cells[k].firstChild) {
  15073. this._parseXml(cells[k].firstChild, cellNode);
  15074. }
  15075. }
  15076. }
  15077. if (rowNumber == 0) {
  15078. totalColumnsNumber = columnNumber;
  15079. }
  15080. columnNumber = -1;
  15081. }
  15082. if (node.nextSibling) {
  15083. this._parseXml(node.nextSibling, parent);
  15084. }
  15085. };
  15086. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  15087. if (node.firstChild) {
  15088. this._parseXml(node.firstChild, guiNode);
  15089. }
  15090. if (node.nextSibling) {
  15091. this._parseXml(node.nextSibling, parent);
  15092. }
  15093. };
  15094. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  15095. if (this._parentClass) {
  15096. this._parentClass[variable] = source[iterator];
  15097. }
  15098. else {
  15099. window[variable] = source[iterator];
  15100. }
  15101. if (node.firstChild) {
  15102. this._parseXml(node.firstChild, guiNode, true);
  15103. }
  15104. };
  15105. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  15106. var dataSource = node.attributes.getNamedItem("dataSource").value;
  15107. if (!dataSource.includes(" in ")) {
  15108. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  15109. }
  15110. else {
  15111. var isArray = true;
  15112. var splittedSource = dataSource.split(" in ");
  15113. if (splittedSource.length < 2) {
  15114. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  15115. }
  15116. var source = splittedSource[1];
  15117. if (source.startsWith("{") && source.endsWith("}")) {
  15118. isArray = false;
  15119. }
  15120. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  15121. source = source.substring(1, source.length - 1);
  15122. }
  15123. if (this._parentClass) {
  15124. source = this._parentClass[source];
  15125. }
  15126. else {
  15127. source = window[source];
  15128. }
  15129. if (isArray) {
  15130. for (var i = 0; i < source.length; i++) {
  15131. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  15132. }
  15133. }
  15134. else {
  15135. for (var i in source) {
  15136. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  15137. }
  15138. }
  15139. if (node.nextSibling) {
  15140. this._parseXml(node.nextSibling, parent);
  15141. }
  15142. }
  15143. };
  15144. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  15145. if (generated === void 0) { generated = false; }
  15146. if (node.nodeType != this._nodeTypes.element) {
  15147. if (node.nextSibling) {
  15148. this._parseXml(node.nextSibling, parent, generated);
  15149. }
  15150. return;
  15151. }
  15152. if (generated) {
  15153. node.setAttribute("id", parent.id + (parent._children.length + 1));
  15154. }
  15155. var guiNode = this._createGuiElement(node, parent);
  15156. if (node.nodeName == "Grid") {
  15157. this._parseGrid(node, guiNode, parent);
  15158. }
  15159. else if (!node.attributes.getNamedItem("dataSource")) {
  15160. this._parseElement(node, guiNode, parent);
  15161. }
  15162. else {
  15163. this._parseElementsFromSource(node, guiNode, parent);
  15164. }
  15165. };
  15166. /**
  15167. * Gets if the loading has finished.
  15168. * @returns whether the loading has finished or not
  15169. */
  15170. XmlLoader.prototype.isLoaded = function () {
  15171. return this._isLoaded;
  15172. };
  15173. /**
  15174. * Gets a loaded node / control by id.
  15175. * @param id the Controls id set in the xml
  15176. * @returns element of type Control
  15177. */
  15178. XmlLoader.prototype.getNodeById = function (id) {
  15179. return this._nodes[id];
  15180. };
  15181. /**
  15182. * Gets all loaded nodes / controls
  15183. * @returns Array of controls
  15184. */
  15185. XmlLoader.prototype.getNodes = function () {
  15186. return this._nodes;
  15187. };
  15188. /**
  15189. * Initiates the xml layout loading
  15190. * @param xmlFile defines the xml layout to load
  15191. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  15192. * @param callback defines the callback called on layout load.
  15193. */
  15194. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  15195. var xhttp = new XMLHttpRequest();
  15196. xhttp.onreadystatechange = function () {
  15197. if (xhttp.readyState == 4 && xhttp.status == 200) {
  15198. if (!xhttp.responseXML) {
  15199. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  15200. }
  15201. var xmlDoc = xhttp.responseXML.documentElement;
  15202. this._parseXml(xmlDoc.firstChild, rootNode);
  15203. this._isLoaded = true;
  15204. if (callback) {
  15205. callback();
  15206. }
  15207. }
  15208. }.bind(this);
  15209. xhttp.open("GET", xmlFile, true);
  15210. xhttp.send();
  15211. };
  15212. return XmlLoader;
  15213. }());
  15214. /***/ }),
  15215. /***/ "./3D/controls/abstractButton3D.ts":
  15216. /*!*****************************************!*\
  15217. !*** ./3D/controls/abstractButton3D.ts ***!
  15218. \*****************************************/
  15219. /*! exports provided: AbstractButton3D */
  15220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15221. "use strict";
  15222. __webpack_require__.r(__webpack_exports__);
  15223. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  15224. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15225. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  15226. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  15227. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15228. /**
  15229. * Class used as a root to all buttons
  15230. */
  15231. var AbstractButton3D = /** @class */ (function (_super) {
  15232. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  15233. /**
  15234. * Creates a new button
  15235. * @param name defines the control name
  15236. */
  15237. function AbstractButton3D(name) {
  15238. return _super.call(this, name) || this;
  15239. }
  15240. AbstractButton3D.prototype._getTypeName = function () {
  15241. return "AbstractButton3D";
  15242. };
  15243. // Mesh association
  15244. AbstractButton3D.prototype._createNode = function (scene) {
  15245. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  15246. };
  15247. return AbstractButton3D;
  15248. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  15249. /***/ }),
  15250. /***/ "./3D/controls/button3D.ts":
  15251. /*!*********************************!*\
  15252. !*** ./3D/controls/button3D.ts ***!
  15253. \*********************************/
  15254. /*! exports provided: Button3D */
  15255. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15256. "use strict";
  15257. __webpack_require__.r(__webpack_exports__);
  15258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  15259. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15260. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  15261. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15262. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  15263. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  15264. /**
  15265. * Class used to create a button in 3D
  15266. */
  15267. var Button3D = /** @class */ (function (_super) {
  15268. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  15269. /**
  15270. * Creates a new button
  15271. * @param name defines the control name
  15272. */
  15273. function Button3D(name) {
  15274. var _this = _super.call(this, name) || this;
  15275. _this._contentResolution = 512;
  15276. _this._contentScaleRatio = 2;
  15277. // Default animations
  15278. _this.pointerEnterAnimation = function () {
  15279. if (!_this.mesh) {
  15280. return;
  15281. }
  15282. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  15283. };
  15284. _this.pointerOutAnimation = function () {
  15285. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  15286. };
  15287. _this.pointerDownAnimation = function () {
  15288. if (!_this.mesh) {
  15289. return;
  15290. }
  15291. _this.mesh.scaling.scaleInPlace(0.95);
  15292. };
  15293. _this.pointerUpAnimation = function () {
  15294. if (!_this.mesh) {
  15295. return;
  15296. }
  15297. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15298. };
  15299. return _this;
  15300. }
  15301. Object.defineProperty(Button3D.prototype, "contentResolution", {
  15302. /**
  15303. * Gets or sets the texture resolution used to render content (512 by default)
  15304. */
  15305. get: function () {
  15306. return this._contentResolution;
  15307. },
  15308. set: function (value) {
  15309. if (this._contentResolution === value) {
  15310. return;
  15311. }
  15312. this._contentResolution = value;
  15313. this._resetContent();
  15314. },
  15315. enumerable: false,
  15316. configurable: true
  15317. });
  15318. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  15319. /**
  15320. * Gets or sets the texture scale ratio used to render content (2 by default)
  15321. */
  15322. get: function () {
  15323. return this._contentScaleRatio;
  15324. },
  15325. set: function (value) {
  15326. if (this._contentScaleRatio === value) {
  15327. return;
  15328. }
  15329. this._contentScaleRatio = value;
  15330. this._resetContent();
  15331. },
  15332. enumerable: false,
  15333. configurable: true
  15334. });
  15335. Button3D.prototype._disposeFacadeTexture = function () {
  15336. if (this._facadeTexture) {
  15337. this._facadeTexture.dispose();
  15338. this._facadeTexture = null;
  15339. }
  15340. };
  15341. Button3D.prototype._resetContent = function () {
  15342. this._disposeFacadeTexture();
  15343. this.content = this._content;
  15344. };
  15345. Object.defineProperty(Button3D.prototype, "content", {
  15346. /**
  15347. * Gets or sets the GUI 2D content used to display the button's facade
  15348. */
  15349. get: function () {
  15350. return this._content;
  15351. },
  15352. set: function (value) {
  15353. this._content = value;
  15354. if (!this._host || !this._host.utilityLayer) {
  15355. return;
  15356. }
  15357. if (!this._facadeTexture) {
  15358. 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);
  15359. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  15360. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  15361. this._facadeTexture.premulAlpha = true;
  15362. }
  15363. else {
  15364. this._facadeTexture.rootContainer.clearControls();
  15365. }
  15366. this._facadeTexture.addControl(value);
  15367. this._applyFacade(this._facadeTexture);
  15368. },
  15369. enumerable: false,
  15370. configurable: true
  15371. });
  15372. /**
  15373. * Apply the facade texture (created from the content property).
  15374. * This function can be overloaded by child classes
  15375. * @param facadeTexture defines the AdvancedDynamicTexture to use
  15376. */
  15377. Button3D.prototype._applyFacade = function (facadeTexture) {
  15378. this._currentMaterial.emissiveTexture = facadeTexture;
  15379. };
  15380. Button3D.prototype._getTypeName = function () {
  15381. return "Button3D";
  15382. };
  15383. // Mesh association
  15384. Button3D.prototype._createNode = function (scene) {
  15385. var faceUV = new Array(6);
  15386. for (var i = 0; i < 6; i++) {
  15387. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  15388. }
  15389. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  15390. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  15391. width: 1.0,
  15392. height: 1.0,
  15393. depth: 0.08,
  15394. faceUV: faceUV
  15395. }, scene);
  15396. return mesh;
  15397. };
  15398. Button3D.prototype._affectMaterial = function (mesh) {
  15399. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  15400. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  15401. mesh.material = material;
  15402. this._currentMaterial = material;
  15403. this._resetContent();
  15404. };
  15405. /**
  15406. * Releases all associated resources
  15407. */
  15408. Button3D.prototype.dispose = function () {
  15409. _super.prototype.dispose.call(this);
  15410. this._disposeFacadeTexture();
  15411. if (this._currentMaterial) {
  15412. this._currentMaterial.dispose();
  15413. }
  15414. };
  15415. return Button3D;
  15416. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  15417. /***/ }),
  15418. /***/ "./3D/controls/container3D.ts":
  15419. /*!************************************!*\
  15420. !*** ./3D/controls/container3D.ts ***!
  15421. \************************************/
  15422. /*! exports provided: Container3D */
  15423. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15424. "use strict";
  15425. __webpack_require__.r(__webpack_exports__);
  15426. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  15427. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15428. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  15429. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  15430. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15431. /**
  15432. * Class used to create containers for controls
  15433. */
  15434. var Container3D = /** @class */ (function (_super) {
  15435. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  15436. /**
  15437. * Creates a new container
  15438. * @param name defines the container name
  15439. */
  15440. function Container3D(name) {
  15441. var _this = _super.call(this, name) || this;
  15442. _this._blockLayout = false;
  15443. /**
  15444. * Gets the list of child controls
  15445. */
  15446. _this._children = new Array();
  15447. return _this;
  15448. }
  15449. Object.defineProperty(Container3D.prototype, "children", {
  15450. /**
  15451. * Gets the list of child controls
  15452. */
  15453. get: function () {
  15454. return this._children;
  15455. },
  15456. enumerable: false,
  15457. configurable: true
  15458. });
  15459. Object.defineProperty(Container3D.prototype, "blockLayout", {
  15460. /**
  15461. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  15462. * This is helpful to optimize layout operation when adding multiple children in a row
  15463. */
  15464. get: function () {
  15465. return this._blockLayout;
  15466. },
  15467. set: function (value) {
  15468. if (this._blockLayout === value) {
  15469. return;
  15470. }
  15471. this._blockLayout = value;
  15472. if (!this._blockLayout) {
  15473. this._arrangeChildren();
  15474. }
  15475. },
  15476. enumerable: false,
  15477. configurable: true
  15478. });
  15479. /**
  15480. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  15481. * @returns the current container
  15482. */
  15483. Container3D.prototype.updateLayout = function () {
  15484. this._arrangeChildren();
  15485. return this;
  15486. };
  15487. /**
  15488. * Gets a boolean indicating if the given control is in the children of this control
  15489. * @param control defines the control to check
  15490. * @returns true if the control is in the child list
  15491. */
  15492. Container3D.prototype.containsControl = function (control) {
  15493. return this._children.indexOf(control) !== -1;
  15494. };
  15495. /**
  15496. * Adds a control to the children of this control
  15497. * @param control defines the control to add
  15498. * @returns the current container
  15499. */
  15500. Container3D.prototype.addControl = function (control) {
  15501. var index = this._children.indexOf(control);
  15502. if (index !== -1) {
  15503. return this;
  15504. }
  15505. control.parent = this;
  15506. control._host = this._host;
  15507. this._children.push(control);
  15508. if (this._host.utilityLayer) {
  15509. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  15510. if (control.node) {
  15511. control.node.parent = this.node;
  15512. }
  15513. if (!this.blockLayout) {
  15514. this._arrangeChildren();
  15515. }
  15516. }
  15517. return this;
  15518. };
  15519. /**
  15520. * This function will be called everytime a new control is added
  15521. */
  15522. Container3D.prototype._arrangeChildren = function () {
  15523. };
  15524. Container3D.prototype._createNode = function (scene) {
  15525. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  15526. };
  15527. /**
  15528. * Removes a control from the children of this control
  15529. * @param control defines the control to remove
  15530. * @returns the current container
  15531. */
  15532. Container3D.prototype.removeControl = function (control) {
  15533. var index = this._children.indexOf(control);
  15534. if (index !== -1) {
  15535. this._children.splice(index, 1);
  15536. control.parent = null;
  15537. control._disposeNode();
  15538. }
  15539. return this;
  15540. };
  15541. Container3D.prototype._getTypeName = function () {
  15542. return "Container3D";
  15543. };
  15544. /**
  15545. * Releases all associated resources
  15546. */
  15547. Container3D.prototype.dispose = function () {
  15548. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15549. var control = _a[_i];
  15550. control.dispose();
  15551. }
  15552. this._children = [];
  15553. _super.prototype.dispose.call(this);
  15554. };
  15555. /** Control rotation will remain unchanged */
  15556. Container3D.UNSET_ORIENTATION = 0;
  15557. /** Control will rotate to make it look at sphere central axis */
  15558. Container3D.FACEORIGIN_ORIENTATION = 1;
  15559. /** Control will rotate to make it look back at sphere central axis */
  15560. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  15561. /** Control will rotate to look at z axis (0, 0, 1) */
  15562. Container3D.FACEFORWARD_ORIENTATION = 3;
  15563. /** Control will rotate to look at negative z axis (0, 0, -1) */
  15564. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  15565. return Container3D;
  15566. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  15567. /***/ }),
  15568. /***/ "./3D/controls/control3D.ts":
  15569. /*!**********************************!*\
  15570. !*** ./3D/controls/control3D.ts ***!
  15571. \**********************************/
  15572. /*! exports provided: Control3D */
  15573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15574. "use strict";
  15575. __webpack_require__.r(__webpack_exports__);
  15576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  15577. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  15578. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15579. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15580. /**
  15581. * Class used as base class for controls
  15582. */
  15583. var Control3D = /** @class */ (function () {
  15584. /**
  15585. * Creates a new control
  15586. * @param name defines the control name
  15587. */
  15588. function Control3D(
  15589. /** Defines the control name */
  15590. name) {
  15591. this.name = name;
  15592. this._downCount = 0;
  15593. this._enterCount = -1;
  15594. this._downPointerIds = {}; // Store number of pointer downs per ID, from near and far interactions
  15595. this._isVisible = true;
  15596. /**
  15597. * An event triggered when the pointer move over the control
  15598. */
  15599. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15600. /**
  15601. * An event triggered when the pointer move out of the control
  15602. */
  15603. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15604. /**
  15605. * An event triggered when the pointer taps the control
  15606. */
  15607. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15608. /**
  15609. * An event triggered when pointer is up
  15610. */
  15611. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15612. /**
  15613. * An event triggered when a control is clicked on (with a mouse)
  15614. */
  15615. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15616. /**
  15617. * An event triggered when pointer enters the control
  15618. */
  15619. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15620. // Behaviors
  15621. this._behaviors = new Array();
  15622. }
  15623. Object.defineProperty(Control3D.prototype, "position", {
  15624. /** Gets or sets the control position in world space */
  15625. get: function () {
  15626. if (!this._node) {
  15627. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  15628. }
  15629. return this._node.position;
  15630. },
  15631. set: function (value) {
  15632. if (!this._node) {
  15633. return;
  15634. }
  15635. this._node.position = value;
  15636. },
  15637. enumerable: false,
  15638. configurable: true
  15639. });
  15640. Object.defineProperty(Control3D.prototype, "scaling", {
  15641. /** Gets or sets the control scaling in world space */
  15642. get: function () {
  15643. if (!this._node) {
  15644. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  15645. }
  15646. return this._node.scaling;
  15647. },
  15648. set: function (value) {
  15649. if (!this._node) {
  15650. return;
  15651. }
  15652. this._node.scaling = value;
  15653. },
  15654. enumerable: false,
  15655. configurable: true
  15656. });
  15657. Object.defineProperty(Control3D.prototype, "behaviors", {
  15658. /**
  15659. * Gets the list of attached behaviors
  15660. * @see https://doc.babylonjs.com/features/behaviour
  15661. */
  15662. get: function () {
  15663. return this._behaviors;
  15664. },
  15665. enumerable: false,
  15666. configurable: true
  15667. });
  15668. /**
  15669. * Attach a behavior to the control
  15670. * @see https://doc.babylonjs.com/features/behaviour
  15671. * @param behavior defines the behavior to attach
  15672. * @returns the current control
  15673. */
  15674. Control3D.prototype.addBehavior = function (behavior) {
  15675. var _this = this;
  15676. var index = this._behaviors.indexOf(behavior);
  15677. if (index !== -1) {
  15678. return this;
  15679. }
  15680. behavior.init();
  15681. var scene = this._host.scene;
  15682. if (scene.isLoading) {
  15683. // We defer the attach when the scene will be loaded
  15684. scene.onDataLoadedObservable.addOnce(function () {
  15685. behavior.attach(_this);
  15686. });
  15687. }
  15688. else {
  15689. behavior.attach(this);
  15690. }
  15691. this._behaviors.push(behavior);
  15692. return this;
  15693. };
  15694. /**
  15695. * Remove an attached behavior
  15696. * @see https://doc.babylonjs.com/features/behaviour
  15697. * @param behavior defines the behavior to attach
  15698. * @returns the current control
  15699. */
  15700. Control3D.prototype.removeBehavior = function (behavior) {
  15701. var index = this._behaviors.indexOf(behavior);
  15702. if (index === -1) {
  15703. return this;
  15704. }
  15705. this._behaviors[index].detach();
  15706. this._behaviors.splice(index, 1);
  15707. return this;
  15708. };
  15709. /**
  15710. * Gets an attached behavior by name
  15711. * @param name defines the name of the behavior to look for
  15712. * @see https://doc.babylonjs.com/features/behaviour
  15713. * @returns null if behavior was not found else the requested behavior
  15714. */
  15715. Control3D.prototype.getBehaviorByName = function (name) {
  15716. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  15717. var behavior = _a[_i];
  15718. if (behavior.name === name) {
  15719. return behavior;
  15720. }
  15721. }
  15722. return null;
  15723. };
  15724. Object.defineProperty(Control3D.prototype, "isVisible", {
  15725. /** Gets or sets a boolean indicating if the control is visible */
  15726. get: function () {
  15727. return this._isVisible;
  15728. },
  15729. set: function (value) {
  15730. if (this._isVisible === value) {
  15731. return;
  15732. }
  15733. this._isVisible = value;
  15734. var mesh = this.mesh;
  15735. if (mesh) {
  15736. mesh.setEnabled(value);
  15737. }
  15738. },
  15739. enumerable: false,
  15740. configurable: true
  15741. });
  15742. Object.defineProperty(Control3D.prototype, "typeName", {
  15743. /**
  15744. * Gets a string representing the class name
  15745. */
  15746. get: function () {
  15747. return this._getTypeName();
  15748. },
  15749. enumerable: false,
  15750. configurable: true
  15751. });
  15752. /**
  15753. * Get the current class name of the control.
  15754. * @returns current class name
  15755. */
  15756. Control3D.prototype.getClassName = function () {
  15757. return this._getTypeName();
  15758. };
  15759. Control3D.prototype._getTypeName = function () {
  15760. return "Control3D";
  15761. };
  15762. Object.defineProperty(Control3D.prototype, "node", {
  15763. /**
  15764. * Gets the transform node used by this control
  15765. */
  15766. get: function () {
  15767. return this._node;
  15768. },
  15769. enumerable: false,
  15770. configurable: true
  15771. });
  15772. Object.defineProperty(Control3D.prototype, "mesh", {
  15773. /**
  15774. * Gets the mesh used to render this control
  15775. */
  15776. get: function () {
  15777. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  15778. return this._node;
  15779. }
  15780. return null;
  15781. },
  15782. enumerable: false,
  15783. configurable: true
  15784. });
  15785. /**
  15786. * Link the control as child of the given node
  15787. * @param node defines the node to link to. Use null to unlink the control
  15788. * @returns the current control
  15789. */
  15790. Control3D.prototype.linkToTransformNode = function (node) {
  15791. if (this._node) {
  15792. this._node.parent = node;
  15793. }
  15794. return this;
  15795. };
  15796. /** @hidden **/
  15797. Control3D.prototype._prepareNode = function (scene) {
  15798. if (!this._node) {
  15799. this._node = this._createNode(scene);
  15800. if (!this.node) {
  15801. return;
  15802. }
  15803. this._injectGUI3DMetadata(this._node).control = this; // Store the control on the metadata field in order to get it when picking
  15804. this._node.position = this.position;
  15805. this._node.scaling = this.scaling;
  15806. var mesh = this.mesh;
  15807. if (mesh) {
  15808. mesh.isPickable = true;
  15809. this._affectMaterial(mesh);
  15810. }
  15811. }
  15812. };
  15813. Control3D.prototype._injectGUI3DMetadata = function (node) {
  15814. var _a, _b;
  15815. node.metadata = (_a = node.metadata) !== null && _a !== void 0 ? _a : {};
  15816. node.metadata.GUI3D = (_b = node.metadata.GUI3D) !== null && _b !== void 0 ? _b : {};
  15817. return node.metadata.GUI3D;
  15818. };
  15819. /**
  15820. * Node creation.
  15821. * Can be overriden by children
  15822. * @param scene defines the scene where the node must be attached
  15823. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  15824. */
  15825. Control3D.prototype._createNode = function (scene) {
  15826. // Do nothing by default
  15827. return null;
  15828. };
  15829. /**
  15830. * Affect a material to the given mesh
  15831. * @param mesh defines the mesh which will represent the control
  15832. */
  15833. Control3D.prototype._affectMaterial = function (mesh) {
  15834. mesh.material = null;
  15835. };
  15836. // Pointers
  15837. /** @hidden */
  15838. Control3D.prototype._onPointerMove = function (target, coordinates) {
  15839. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  15840. };
  15841. /** @hidden */
  15842. Control3D.prototype._onPointerEnter = function (target) {
  15843. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  15844. this._enterCount = 0;
  15845. }
  15846. this._enterCount++;
  15847. if (this._enterCount > 1) {
  15848. return false;
  15849. }
  15850. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  15851. if (this.pointerEnterAnimation) {
  15852. this.pointerEnterAnimation();
  15853. }
  15854. return true;
  15855. };
  15856. /** @hidden */
  15857. Control3D.prototype._onPointerOut = function (target) {
  15858. this._enterCount--;
  15859. if (this._enterCount > 0) {
  15860. return;
  15861. }
  15862. this._enterCount = 0;
  15863. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  15864. if (this.pointerOutAnimation) {
  15865. this.pointerOutAnimation();
  15866. }
  15867. };
  15868. /** @hidden */
  15869. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  15870. this._downCount++;
  15871. this._downPointerIds[pointerId] = this._downPointerIds[pointerId] + 1 || 1;
  15872. if (this._downCount !== 1) {
  15873. return false;
  15874. }
  15875. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  15876. if (this.pointerDownAnimation) {
  15877. this.pointerDownAnimation();
  15878. }
  15879. return true;
  15880. };
  15881. /** @hidden */
  15882. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  15883. this._downCount--;
  15884. this._downPointerIds[pointerId]--;
  15885. if (this._downPointerIds[pointerId] <= 0) {
  15886. delete this._downPointerIds[pointerId];
  15887. }
  15888. if (this._downCount < 0) {
  15889. // Handle if forcePointerUp was called prior to this
  15890. this._downCount = 0;
  15891. return;
  15892. }
  15893. if (this._downCount == 0) {
  15894. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  15895. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  15896. }
  15897. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  15898. if (this.pointerUpAnimation) {
  15899. this.pointerUpAnimation();
  15900. }
  15901. }
  15902. };
  15903. /** @hidden */
  15904. Control3D.prototype.forcePointerUp = function (pointerId) {
  15905. if (pointerId === void 0) { pointerId = null; }
  15906. if (pointerId !== null) {
  15907. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  15908. }
  15909. else {
  15910. for (var key in this._downPointerIds) {
  15911. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  15912. }
  15913. if (this._downCount > 0) {
  15914. this._downCount = 1;
  15915. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  15916. }
  15917. }
  15918. };
  15919. /** @hidden */
  15920. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  15921. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15922. this._onPointerMove(this, pickedPoint);
  15923. var previousControlOver = this._host._lastControlOver[pointerId];
  15924. if (previousControlOver && previousControlOver !== this) {
  15925. previousControlOver._onPointerOut(this);
  15926. }
  15927. if (previousControlOver !== this) {
  15928. this._onPointerEnter(this);
  15929. }
  15930. this._host._lastControlOver[pointerId] = this;
  15931. return true;
  15932. }
  15933. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  15934. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  15935. this._host._lastControlDown[pointerId] = this;
  15936. this._host._lastPickedControl = this;
  15937. return true;
  15938. }
  15939. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP || type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) {
  15940. if (this._host._lastControlDown[pointerId]) {
  15941. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  15942. }
  15943. delete this._host._lastControlDown[pointerId];
  15944. return true;
  15945. }
  15946. return false;
  15947. };
  15948. /** @hidden */
  15949. Control3D.prototype._disposeNode = function () {
  15950. if (this._node) {
  15951. this._node.dispose();
  15952. this._node = null;
  15953. }
  15954. };
  15955. /**
  15956. * Releases all associated resources
  15957. */
  15958. Control3D.prototype.dispose = function () {
  15959. this.onPointerDownObservable.clear();
  15960. this.onPointerEnterObservable.clear();
  15961. this.onPointerMoveObservable.clear();
  15962. this.onPointerOutObservable.clear();
  15963. this.onPointerUpObservable.clear();
  15964. this.onPointerClickObservable.clear();
  15965. this._disposeNode();
  15966. // Behaviors
  15967. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  15968. var behavior = _a[_i];
  15969. behavior.detach();
  15970. }
  15971. };
  15972. return Control3D;
  15973. }());
  15974. /***/ }),
  15975. /***/ "./3D/controls/cylinderPanel.ts":
  15976. /*!**************************************!*\
  15977. !*** ./3D/controls/cylinderPanel.ts ***!
  15978. \**************************************/
  15979. /*! exports provided: CylinderPanel */
  15980. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15981. "use strict";
  15982. __webpack_require__.r(__webpack_exports__);
  15983. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  15984. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15985. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15986. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15987. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15988. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15989. /**
  15990. * Class used to create a container panel deployed on the surface of a cylinder
  15991. */
  15992. var CylinderPanel = /** @class */ (function (_super) {
  15993. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  15994. function CylinderPanel() {
  15995. var _this = _super !== null && _super.apply(this, arguments) || this;
  15996. _this._radius = 5.0;
  15997. return _this;
  15998. }
  15999. Object.defineProperty(CylinderPanel.prototype, "radius", {
  16000. /**
  16001. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  16002. */
  16003. get: function () {
  16004. return this._radius;
  16005. },
  16006. set: function (value) {
  16007. var _this = this;
  16008. if (this._radius === value) {
  16009. return;
  16010. }
  16011. this._radius = value;
  16012. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16013. _this._arrangeChildren();
  16014. });
  16015. },
  16016. enumerable: false,
  16017. configurable: true
  16018. });
  16019. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  16020. var mesh = control.mesh;
  16021. if (!mesh) {
  16022. return;
  16023. }
  16024. var newPos = this._cylindricalMapping(nodePosition);
  16025. control.position = newPos;
  16026. switch (this.orientation) {
  16027. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  16028. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  16029. break;
  16030. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  16031. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  16032. break;
  16033. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  16034. break;
  16035. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  16036. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  16037. break;
  16038. }
  16039. };
  16040. CylinderPanel.prototype._cylindricalMapping = function (source) {
  16041. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  16042. var yAngle = (source.x / this._radius);
  16043. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16044. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16045. };
  16046. return CylinderPanel;
  16047. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  16048. /***/ }),
  16049. /***/ "./3D/controls/holographicButton.ts":
  16050. /*!******************************************!*\
  16051. !*** ./3D/controls/holographicButton.ts ***!
  16052. \******************************************/
  16053. /*! exports provided: HolographicButton */
  16054. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16055. "use strict";
  16056. __webpack_require__.r(__webpack_exports__);
  16057. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  16058. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16059. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  16060. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Misc/observable");
  16061. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  16062. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16063. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  16064. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  16065. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  16066. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  16067. /**
  16068. * Class used to create a holographic button in 3D
  16069. */
  16070. var HolographicButton = /** @class */ (function (_super) {
  16071. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  16072. /**
  16073. * Creates a new button
  16074. * @param name defines the control name
  16075. */
  16076. function HolographicButton(name, shareMaterials) {
  16077. if (shareMaterials === void 0) { shareMaterials = true; }
  16078. var _this = _super.call(this, name) || this;
  16079. _this._shareMaterials = true;
  16080. _this._shareMaterials = shareMaterials;
  16081. // Default animations
  16082. _this.pointerEnterAnimation = function () {
  16083. if (!_this.mesh) {
  16084. return;
  16085. }
  16086. _this._frontPlate.setEnabled(true);
  16087. };
  16088. _this.pointerOutAnimation = function () {
  16089. if (!_this.mesh) {
  16090. return;
  16091. }
  16092. _this._frontPlate.setEnabled(false);
  16093. };
  16094. return _this;
  16095. }
  16096. HolographicButton.prototype._disposeTooltip = function () {
  16097. this._tooltipFade = null;
  16098. if (this._tooltipTextBlock) {
  16099. this._tooltipTextBlock.dispose();
  16100. }
  16101. if (this._tooltipTexture) {
  16102. this._tooltipTexture.dispose();
  16103. }
  16104. if (this._tooltipMesh) {
  16105. this._tooltipMesh.dispose();
  16106. }
  16107. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  16108. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  16109. };
  16110. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  16111. get: function () {
  16112. return this._backPlate.renderingGroupId;
  16113. },
  16114. /**
  16115. * Rendering ground id of all the mesh in the button
  16116. */
  16117. set: function (id) {
  16118. this._backPlate.renderingGroupId = id;
  16119. this._textPlate.renderingGroupId = id;
  16120. this._frontPlate.renderingGroupId = id;
  16121. if (this._tooltipMesh) {
  16122. this._tooltipMesh.renderingGroupId = id;
  16123. }
  16124. },
  16125. enumerable: false,
  16126. configurable: true
  16127. });
  16128. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  16129. get: function () {
  16130. if (this._tooltipTextBlock) {
  16131. return this._tooltipTextBlock.text;
  16132. }
  16133. return null;
  16134. },
  16135. /**
  16136. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  16137. */
  16138. set: function (text) {
  16139. var _this = this;
  16140. if (!text) {
  16141. this._disposeTooltip();
  16142. return;
  16143. }
  16144. if (!this._tooltipFade) {
  16145. // Create tooltip with mesh and text
  16146. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  16147. 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);
  16148. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  16149. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  16150. tooltipBackground.material = mat;
  16151. tooltipBackground.isPickable = false;
  16152. this._tooltipMesh.addChild(tooltipBackground);
  16153. tooltipBackground.position.z = 0.05;
  16154. this._tooltipMesh.scaling.y = 1 / 3;
  16155. this._tooltipMesh.position.y = 0.7;
  16156. this._tooltipMesh.position.z = -0.15;
  16157. this._tooltipMesh.isPickable = false;
  16158. this._tooltipMesh.parent = this._backPlate;
  16159. // Create text texture for the tooltip
  16160. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  16161. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  16162. this._tooltipTextBlock.scaleY = 3;
  16163. this._tooltipTextBlock.color = "white";
  16164. this._tooltipTextBlock.fontSize = 130;
  16165. this._tooltipTexture.addControl(this._tooltipTextBlock);
  16166. // Add hover action to tooltip
  16167. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  16168. this._tooltipFade.delay = 500;
  16169. this._tooltipMesh.addBehavior(this._tooltipFade);
  16170. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  16171. if (_this._tooltipFade) {
  16172. _this._tooltipFade.fadeIn(true);
  16173. }
  16174. });
  16175. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  16176. if (_this._tooltipFade) {
  16177. _this._tooltipFade.fadeIn(false);
  16178. }
  16179. });
  16180. }
  16181. if (this._tooltipTextBlock) {
  16182. this._tooltipTextBlock.text = text;
  16183. }
  16184. },
  16185. enumerable: false,
  16186. configurable: true
  16187. });
  16188. Object.defineProperty(HolographicButton.prototype, "text", {
  16189. /**
  16190. * Gets or sets text for the button
  16191. */
  16192. get: function () {
  16193. return this._text;
  16194. },
  16195. set: function (value) {
  16196. if (this._text === value) {
  16197. return;
  16198. }
  16199. this._text = value;
  16200. this._rebuildContent();
  16201. },
  16202. enumerable: false,
  16203. configurable: true
  16204. });
  16205. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  16206. /**
  16207. * Gets or sets the image url for the button
  16208. */
  16209. get: function () {
  16210. return this._imageUrl;
  16211. },
  16212. set: function (value) {
  16213. if (this._imageUrl === value) {
  16214. return;
  16215. }
  16216. this._imageUrl = value;
  16217. this._rebuildContent();
  16218. },
  16219. enumerable: false,
  16220. configurable: true
  16221. });
  16222. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  16223. /**
  16224. * Gets the back material used by this button
  16225. */
  16226. get: function () {
  16227. return this._backMaterial;
  16228. },
  16229. enumerable: false,
  16230. configurable: true
  16231. });
  16232. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  16233. /**
  16234. * Gets the front material used by this button
  16235. */
  16236. get: function () {
  16237. return this._frontMaterial;
  16238. },
  16239. enumerable: false,
  16240. configurable: true
  16241. });
  16242. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  16243. /**
  16244. * Gets the plate material used by this button
  16245. */
  16246. get: function () {
  16247. return this._plateMaterial;
  16248. },
  16249. enumerable: false,
  16250. configurable: true
  16251. });
  16252. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  16253. /**
  16254. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  16255. */
  16256. get: function () {
  16257. return this._shareMaterials;
  16258. },
  16259. enumerable: false,
  16260. configurable: true
  16261. });
  16262. HolographicButton.prototype._getTypeName = function () {
  16263. return "HolographicButton";
  16264. };
  16265. HolographicButton.prototype._rebuildContent = function () {
  16266. this._disposeFacadeTexture();
  16267. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  16268. panel.isVertical = true;
  16269. if (this._imageUrl) {
  16270. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  16271. image.source = this._imageUrl;
  16272. image.paddingTop = "40px";
  16273. image.height = "180px";
  16274. image.width = "100px";
  16275. image.paddingBottom = "40px";
  16276. panel.addControl(image);
  16277. }
  16278. if (this._text) {
  16279. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  16280. text.text = this._text;
  16281. text.color = "white";
  16282. text.height = "30px";
  16283. text.fontSize = 24;
  16284. panel.addControl(text);
  16285. }
  16286. if (this._frontPlate) {
  16287. this.content = panel;
  16288. }
  16289. };
  16290. // Mesh association
  16291. HolographicButton.prototype._createNode = function (scene) {
  16292. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  16293. width: 1.0,
  16294. height: 1.0,
  16295. depth: 0.08
  16296. }, scene);
  16297. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  16298. width: 1.0,
  16299. height: 1.0,
  16300. depth: 0.08
  16301. }, scene);
  16302. this._frontPlate.parent = this._backPlate;
  16303. this._frontPlate.position.z = -0.08;
  16304. this._frontPlate.isPickable = false;
  16305. this._frontPlate.setEnabled(false);
  16306. this._textPlate = _super.prototype._createNode.call(this, scene);
  16307. this._textPlate.parent = this._backPlate;
  16308. this._textPlate.position.z = -0.08;
  16309. this._textPlate.isPickable = false;
  16310. return this._backPlate;
  16311. };
  16312. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  16313. this._plateMaterial.emissiveTexture = facadeTexture;
  16314. this._plateMaterial.opacityTexture = facadeTexture;
  16315. };
  16316. HolographicButton.prototype._createBackMaterial = function (mesh) {
  16317. var _this = this;
  16318. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  16319. this._backMaterial.renderHoverLight = true;
  16320. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  16321. if (pickedPoint) {
  16322. _this._backMaterial.hoverPosition = pickedPoint;
  16323. _this._backMaterial.hoverColor.a = 1.0;
  16324. }
  16325. else {
  16326. _this._backMaterial.hoverColor.a = 0;
  16327. }
  16328. });
  16329. };
  16330. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  16331. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  16332. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  16333. this._frontMaterial.alpha = 0.5; // Additive
  16334. this._frontMaterial.renderBorders = true;
  16335. };
  16336. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  16337. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  16338. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  16339. };
  16340. HolographicButton.prototype._affectMaterial = function (mesh) {
  16341. // Back
  16342. if (this._shareMaterials) {
  16343. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  16344. this._createBackMaterial(mesh);
  16345. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  16346. }
  16347. else {
  16348. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  16349. }
  16350. // Front
  16351. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  16352. this._createFrontMaterial(mesh);
  16353. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  16354. }
  16355. else {
  16356. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  16357. }
  16358. }
  16359. else {
  16360. this._createBackMaterial(mesh);
  16361. this._createFrontMaterial(mesh);
  16362. }
  16363. this._createPlateMaterial(mesh);
  16364. this._backPlate.material = this._backMaterial;
  16365. this._frontPlate.material = this._frontMaterial;
  16366. this._textPlate.material = this._plateMaterial;
  16367. this._rebuildContent();
  16368. };
  16369. /**
  16370. * Releases all associated resources
  16371. */
  16372. HolographicButton.prototype.dispose = function () {
  16373. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  16374. this._disposeTooltip();
  16375. if (!this.shareMaterials) {
  16376. this._backMaterial.dispose();
  16377. this._frontMaterial.dispose();
  16378. this._plateMaterial.dispose();
  16379. if (this._pickedPointObserver) {
  16380. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  16381. this._pickedPointObserver = null;
  16382. }
  16383. }
  16384. };
  16385. return HolographicButton;
  16386. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  16387. /***/ }),
  16388. /***/ "./3D/controls/index.ts":
  16389. /*!******************************!*\
  16390. !*** ./3D/controls/index.ts ***!
  16391. \******************************/
  16392. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, TouchButton3D, TouchMeshButton3D, TouchHolographicButton, VolumeBasedPanel */
  16393. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16394. "use strict";
  16395. __webpack_require__.r(__webpack_exports__);
  16396. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  16397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16398. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  16399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16400. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  16402. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  16403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  16404. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  16405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  16406. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  16407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  16408. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  16409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  16410. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  16411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  16412. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  16413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  16414. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  16415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  16416. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  16417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  16418. /* harmony import */ var _touchButton3D__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./touchButton3D */ "./3D/controls/touchButton3D.ts");
  16419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchButton3D", function() { return _touchButton3D__WEBPACK_IMPORTED_MODULE_11__["TouchButton3D"]; });
  16420. /* harmony import */ var _touchMeshButton3D__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./touchMeshButton3D */ "./3D/controls/touchMeshButton3D.ts");
  16421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchMeshButton3D", function() { return _touchMeshButton3D__WEBPACK_IMPORTED_MODULE_12__["TouchMeshButton3D"]; });
  16422. /* harmony import */ var _touchHolographicButton__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./touchHolographicButton */ "./3D/controls/touchHolographicButton.ts");
  16423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchHolographicButton", function() { return _touchHolographicButton__WEBPACK_IMPORTED_MODULE_13__["TouchHolographicButton"]; });
  16424. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_14__["VolumeBasedPanel"]; });
  16426. /***/ }),
  16427. /***/ "./3D/controls/meshButton3D.ts":
  16428. /*!*************************************!*\
  16429. !*** ./3D/controls/meshButton3D.ts ***!
  16430. \*************************************/
  16431. /*! exports provided: MeshButton3D */
  16432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16433. "use strict";
  16434. __webpack_require__.r(__webpack_exports__);
  16435. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  16436. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16437. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  16438. /**
  16439. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  16440. */
  16441. var MeshButton3D = /** @class */ (function (_super) {
  16442. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  16443. /**
  16444. * Creates a new 3D button based on a mesh
  16445. * @param mesh mesh to become a 3D button
  16446. * @param name defines the control name
  16447. */
  16448. function MeshButton3D(mesh, name) {
  16449. var _this = _super.call(this, name) || this;
  16450. _this._currentMesh = mesh;
  16451. /**
  16452. * Provides a default behavior on hover/out & up/down
  16453. * Override those function to create your own desired behavior specific to your mesh
  16454. */
  16455. _this.pointerEnterAnimation = function () {
  16456. if (!_this.mesh) {
  16457. return;
  16458. }
  16459. _this.mesh.scaling.scaleInPlace(1.1);
  16460. };
  16461. _this.pointerOutAnimation = function () {
  16462. if (!_this.mesh) {
  16463. return;
  16464. }
  16465. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  16466. };
  16467. _this.pointerDownAnimation = function () {
  16468. if (!_this.mesh) {
  16469. return;
  16470. }
  16471. _this.mesh.scaling.scaleInPlace(0.95);
  16472. };
  16473. _this.pointerUpAnimation = function () {
  16474. if (!_this.mesh) {
  16475. return;
  16476. }
  16477. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  16478. };
  16479. return _this;
  16480. }
  16481. MeshButton3D.prototype._getTypeName = function () {
  16482. return "MeshButton3D";
  16483. };
  16484. // Mesh association
  16485. MeshButton3D.prototype._createNode = function (scene) {
  16486. var _this = this;
  16487. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  16488. _this._injectGUI3DMetadata(mesh).control = _this;
  16489. });
  16490. return this._currentMesh;
  16491. };
  16492. MeshButton3D.prototype._affectMaterial = function (mesh) {
  16493. };
  16494. return MeshButton3D;
  16495. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  16496. /***/ }),
  16497. /***/ "./3D/controls/planePanel.ts":
  16498. /*!***********************************!*\
  16499. !*** ./3D/controls/planePanel.ts ***!
  16500. \***********************************/
  16501. /*! exports provided: PlanePanel */
  16502. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16503. "use strict";
  16504. __webpack_require__.r(__webpack_exports__);
  16505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  16506. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16507. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  16508. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16509. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16510. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16511. /**
  16512. * Class used to create a container panel deployed on the surface of a plane
  16513. */
  16514. var PlanePanel = /** @class */ (function (_super) {
  16515. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  16516. function PlanePanel() {
  16517. return _super !== null && _super.apply(this, arguments) || this;
  16518. }
  16519. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  16520. var mesh = control.mesh;
  16521. if (!mesh) {
  16522. return;
  16523. }
  16524. control.position = nodePosition.clone();
  16525. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  16526. target.copyFrom(nodePosition);
  16527. switch (this.orientation) {
  16528. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  16529. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  16530. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  16531. mesh.lookAt(target);
  16532. break;
  16533. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  16534. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  16535. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  16536. mesh.lookAt(target);
  16537. break;
  16538. }
  16539. };
  16540. return PlanePanel;
  16541. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  16542. /***/ }),
  16543. /***/ "./3D/controls/scatterPanel.ts":
  16544. /*!*************************************!*\
  16545. !*** ./3D/controls/scatterPanel.ts ***!
  16546. \*************************************/
  16547. /*! exports provided: ScatterPanel */
  16548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16549. "use strict";
  16550. __webpack_require__.r(__webpack_exports__);
  16551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  16552. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16553. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  16554. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16555. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16556. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16557. /**
  16558. * Class used to create a container panel where items get randomized planar mapping
  16559. */
  16560. var ScatterPanel = /** @class */ (function (_super) {
  16561. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  16562. function ScatterPanel() {
  16563. var _this = _super !== null && _super.apply(this, arguments) || this;
  16564. _this._iteration = 100.0;
  16565. return _this;
  16566. }
  16567. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  16568. /**
  16569. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  16570. */
  16571. get: function () {
  16572. return this._iteration;
  16573. },
  16574. set: function (value) {
  16575. var _this = this;
  16576. if (this._iteration === value) {
  16577. return;
  16578. }
  16579. this._iteration = value;
  16580. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16581. _this._arrangeChildren();
  16582. });
  16583. },
  16584. enumerable: false,
  16585. configurable: true
  16586. });
  16587. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  16588. var mesh = control.mesh;
  16589. var newPos = this._scatterMapping(nodePosition);
  16590. if (!mesh) {
  16591. return;
  16592. }
  16593. switch (this.orientation) {
  16594. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  16595. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  16596. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  16597. break;
  16598. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  16599. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  16600. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  16601. break;
  16602. }
  16603. control.position = newPos;
  16604. };
  16605. ScatterPanel.prototype._scatterMapping = function (source) {
  16606. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  16607. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  16608. return source;
  16609. };
  16610. ScatterPanel.prototype._finalProcessing = function () {
  16611. var meshes = [];
  16612. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  16613. var child = _a[_i];
  16614. if (!child.mesh) {
  16615. continue;
  16616. }
  16617. meshes.push(child.mesh);
  16618. }
  16619. for (var count = 0; count < this._iteration; count++) {
  16620. meshes.sort(function (a, b) {
  16621. var distance1 = a.position.lengthSquared();
  16622. var distance2 = b.position.lengthSquared();
  16623. if (distance1 < distance2) {
  16624. return 1;
  16625. }
  16626. else if (distance1 > distance2) {
  16627. return -1;
  16628. }
  16629. return 0;
  16630. });
  16631. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  16632. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  16633. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  16634. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  16635. for (var i = 0; i < meshes.length - 1; i++) {
  16636. for (var j = i + 1; j < meshes.length; j++) {
  16637. if (i != j) {
  16638. meshes[j].position.subtractToRef(meshes[i].position, difference);
  16639. // Ignore Z axis
  16640. difference2D.x = difference.x;
  16641. difference2D.y = difference.y;
  16642. var combinedRadius = cellSize;
  16643. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  16644. var minSeparation = Math.min(distance, radiusPaddingSquared);
  16645. distance -= minSeparation;
  16646. if (distance < (Math.pow(combinedRadius, 2.0))) {
  16647. difference2D.normalize();
  16648. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  16649. meshes[j].position.addInPlace(difference);
  16650. meshes[i].position.subtractInPlace(difference);
  16651. }
  16652. }
  16653. }
  16654. }
  16655. }
  16656. };
  16657. return ScatterPanel;
  16658. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  16659. /***/ }),
  16660. /***/ "./3D/controls/spherePanel.ts":
  16661. /*!************************************!*\
  16662. !*** ./3D/controls/spherePanel.ts ***!
  16663. \************************************/
  16664. /*! exports provided: SpherePanel */
  16665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16666. "use strict";
  16667. __webpack_require__.r(__webpack_exports__);
  16668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  16669. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16670. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  16671. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16672. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  16673. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16674. /**
  16675. * Class used to create a container panel deployed on the surface of a sphere
  16676. */
  16677. var SpherePanel = /** @class */ (function (_super) {
  16678. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  16679. function SpherePanel() {
  16680. var _this = _super !== null && _super.apply(this, arguments) || this;
  16681. _this._radius = 5.0;
  16682. return _this;
  16683. }
  16684. Object.defineProperty(SpherePanel.prototype, "radius", {
  16685. /**
  16686. * Gets or sets the radius of the sphere where to project controls (5 by default)
  16687. */
  16688. get: function () {
  16689. return this._radius;
  16690. },
  16691. set: function (value) {
  16692. var _this = this;
  16693. if (this._radius === value) {
  16694. return;
  16695. }
  16696. this._radius = value;
  16697. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16698. _this._arrangeChildren();
  16699. });
  16700. },
  16701. enumerable: false,
  16702. configurable: true
  16703. });
  16704. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  16705. var mesh = control.mesh;
  16706. if (!mesh) {
  16707. return;
  16708. }
  16709. var newPos = this._sphericalMapping(nodePosition);
  16710. control.position = newPos;
  16711. switch (this.orientation) {
  16712. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  16713. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  16714. break;
  16715. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  16716. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  16717. break;
  16718. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  16719. break;
  16720. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  16721. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  16722. break;
  16723. }
  16724. };
  16725. SpherePanel.prototype._sphericalMapping = function (source) {
  16726. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  16727. var xAngle = (source.y / this._radius);
  16728. var yAngle = -(source.x / this._radius);
  16729. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16730. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16731. };
  16732. return SpherePanel;
  16733. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  16734. /***/ }),
  16735. /***/ "./3D/controls/stackPanel3D.ts":
  16736. /*!*************************************!*\
  16737. !*** ./3D/controls/stackPanel3D.ts ***!
  16738. \*************************************/
  16739. /*! exports provided: StackPanel3D */
  16740. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16741. "use strict";
  16742. __webpack_require__.r(__webpack_exports__);
  16743. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  16744. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16745. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  16746. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  16747. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  16748. /**
  16749. * Class used to create a stack panel in 3D on XY plane
  16750. */
  16751. var StackPanel3D = /** @class */ (function (_super) {
  16752. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  16753. /**
  16754. * Creates new StackPanel
  16755. * @param isVertical
  16756. */
  16757. function StackPanel3D(isVertical) {
  16758. if (isVertical === void 0) { isVertical = false; }
  16759. var _this = _super.call(this) || this;
  16760. _this._isVertical = false;
  16761. /**
  16762. * Gets or sets the distance between elements
  16763. */
  16764. _this.margin = 0.1;
  16765. _this._isVertical = isVertical;
  16766. return _this;
  16767. }
  16768. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  16769. /**
  16770. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  16771. */
  16772. get: function () {
  16773. return this._isVertical;
  16774. },
  16775. set: function (value) {
  16776. var _this = this;
  16777. if (this._isVertical === value) {
  16778. return;
  16779. }
  16780. this._isVertical = value;
  16781. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  16782. _this._arrangeChildren();
  16783. });
  16784. },
  16785. enumerable: false,
  16786. configurable: true
  16787. });
  16788. StackPanel3D.prototype._arrangeChildren = function () {
  16789. var width = 0;
  16790. var height = 0;
  16791. var controlCount = 0;
  16792. var extendSizes = [];
  16793. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  16794. // Measure
  16795. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  16796. var child = _a[_i];
  16797. if (!child.mesh) {
  16798. continue;
  16799. }
  16800. controlCount++;
  16801. child.mesh.computeWorldMatrix(true);
  16802. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16803. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  16804. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  16805. extendSizes.push(extendSize);
  16806. if (this._isVertical) {
  16807. height += extendSize.y;
  16808. }
  16809. else {
  16810. width += extendSize.x;
  16811. }
  16812. }
  16813. if (this._isVertical) {
  16814. height += (controlCount - 1) * this.margin / 2;
  16815. }
  16816. else {
  16817. width += (controlCount - 1) * this.margin / 2;
  16818. }
  16819. // Arrange
  16820. var offset;
  16821. if (this._isVertical) {
  16822. offset = -height;
  16823. }
  16824. else {
  16825. offset = -width;
  16826. }
  16827. var index = 0;
  16828. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  16829. var child = _c[_b];
  16830. if (!child.mesh) {
  16831. continue;
  16832. }
  16833. controlCount--;
  16834. var extendSize = extendSizes[index++];
  16835. if (this._isVertical) {
  16836. child.position.y = offset + extendSize.y;
  16837. child.position.x = 0;
  16838. offset += extendSize.y * 2;
  16839. }
  16840. else {
  16841. child.position.x = offset + extendSize.x;
  16842. child.position.y = 0;
  16843. offset += extendSize.x * 2;
  16844. }
  16845. offset += (controlCount > 0 ? this.margin : 0);
  16846. }
  16847. };
  16848. return StackPanel3D;
  16849. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  16850. /***/ }),
  16851. /***/ "./3D/controls/touchButton3D.ts":
  16852. /*!**************************************!*\
  16853. !*** ./3D/controls/touchButton3D.ts ***!
  16854. \**************************************/
  16855. /*! exports provided: TouchButton3D */
  16856. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16857. "use strict";
  16858. __webpack_require__.r(__webpack_exports__);
  16859. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchButton3D", function() { return TouchButton3D; });
  16860. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16861. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  16862. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16863. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  16864. // Assumptions: absolute position of button mesh is inside the mesh
  16865. /**
  16866. * Enum for Button States
  16867. */
  16868. var ButtonState;
  16869. (function (ButtonState) {
  16870. /** None */
  16871. ButtonState[ButtonState["None"] = 0] = "None";
  16872. /** Pointer Entered */
  16873. ButtonState[ButtonState["Hover"] = 1] = "Hover";
  16874. /** Pointer Down */
  16875. ButtonState[ButtonState["Press"] = 2] = "Press";
  16876. })(ButtonState || (ButtonState = {}));
  16877. /**
  16878. * Class used to create a touchable button in 3D
  16879. */
  16880. var TouchButton3D = /** @class */ (function (_super) {
  16881. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TouchButton3D, _super);
  16882. /**
  16883. * Creates a new touchable button
  16884. * @param name defines the control name
  16885. * @param collisionMesh mesh to track collisions with
  16886. */
  16887. function TouchButton3D(name, collisionMesh) {
  16888. var _this = _super.call(this, name) || this;
  16889. _this._collidableInitialized = false;
  16890. _this._frontOffset = 0;
  16891. _this._backOffset = 0;
  16892. _this._hoverOffset = 0;
  16893. _this._pushThroughBackOffset = 0;
  16894. _this._activeInteractions = new Map();
  16895. _this._previousHeight = new Map();
  16896. _this._tempButtonForwardRay = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Ray"](babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  16897. if (collisionMesh) {
  16898. _this.collisionMesh = collisionMesh;
  16899. }
  16900. return _this;
  16901. }
  16902. Object.defineProperty(TouchButton3D.prototype, "collidableFrontDirection", {
  16903. /**
  16904. * Sets the front-facing direction of the button
  16905. * @param frontDir the forward direction of the button
  16906. */
  16907. set: function (frontWorldDir) {
  16908. this._collidableFrontDirection = frontWorldDir.normalize();
  16909. // Zero out the scale to force it to be proplerly updated in _updateDistanceOffsets
  16910. this._lastKnownCollidableScale = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  16911. this._updateDistanceOffsets();
  16912. },
  16913. enumerable: false,
  16914. configurable: true
  16915. });
  16916. TouchButton3D.prototype._getWorldMatrixData = function (mesh) {
  16917. var translation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  16918. var rotation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  16919. var scale = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  16920. mesh.getWorldMatrix().decompose(scale, rotation, translation);
  16921. return { translation: translation, rotation: rotation, scale: scale };
  16922. };
  16923. Object.defineProperty(TouchButton3D.prototype, "collisionMesh", {
  16924. /**
  16925. * Sets the mesh used for testing input collision
  16926. * @param collisionMesh the new collision mesh for the button
  16927. */
  16928. set: function (collisionMesh) {
  16929. if (this._collisionMesh) {
  16930. this._collisionMesh.dispose();
  16931. }
  16932. // parent the mesh to sync transforms
  16933. if (!collisionMesh.parent && this.mesh) {
  16934. collisionMesh.setParent(this.mesh);
  16935. }
  16936. this._collisionMesh = collisionMesh;
  16937. this._collisionMesh.metadata = this;
  16938. this.collidableFrontDirection = collisionMesh.forward;
  16939. this._collidableInitialized = true;
  16940. },
  16941. enumerable: false,
  16942. configurable: true
  16943. });
  16944. /*
  16945. * Given a point, and two points on a line, this returns the distance between
  16946. * the point and the closest point on the line. The closest point on the line
  16947. * does not have to be between the two given points.
  16948. *
  16949. * Based off the 3D point-line distance equation
  16950. *
  16951. * Assumes lineDirection is normalized
  16952. */
  16953. TouchButton3D.prototype._getShortestDistancePointToLine = function (point, linePoint, lineDirection) {
  16954. var pointToLine = linePoint.subtract(point);
  16955. var cross = lineDirection.cross(pointToLine);
  16956. return cross.length();
  16957. };
  16958. /*
  16959. * Checks to see if collidable is in a position to interact with the button
  16960. * - check if collidable has a plane height off the button that is within range
  16961. * - check that collidable + normal ray intersect the bounding sphere
  16962. */
  16963. TouchButton3D.prototype._isPrimedForInteraction = function (collidable) {
  16964. // Check if the collidable has an appropriate planar height
  16965. var heightFromCenter = this._getHeightFromButtonCenter(collidable);
  16966. if (heightFromCenter > this._hoverOffset || heightFromCenter < this._pushThroughBackOffset) {
  16967. return false;
  16968. }
  16969. // Check if the collidable or its hover ray lands within the bounding sphere of the button
  16970. var distanceFromCenter = this._getShortestDistancePointToLine(this._collisionMesh.getAbsolutePosition(), collidable, this._collidableFrontDirection);
  16971. return distanceFromCenter <= this._collisionMesh.getBoundingInfo().boundingSphere.radiusWorld;
  16972. };
  16973. /*
  16974. * Returns a Vector3 of the collidable's projected position on the button
  16975. * Returns the collidable's position if it is inside the button
  16976. */
  16977. TouchButton3D.prototype._getPointOnButton = function (collidable) {
  16978. var heightFromCenter = this._getHeightFromButtonCenter(collidable);
  16979. if (heightFromCenter <= this._frontOffset && heightFromCenter >= this._backOffset) {
  16980. // The collidable is in the button, return its position
  16981. return collidable;
  16982. }
  16983. else if (heightFromCenter > this._frontOffset) {
  16984. // The collidable is in front of the button, project it to the surface
  16985. var collidableDistanceToFront = (this._frontOffset - heightFromCenter);
  16986. return collidable.add(this._collidableFrontDirection.scale(collidableDistanceToFront));
  16987. }
  16988. else {
  16989. // The collidable is behind the button, project it to its back
  16990. var collidableDistanceToBack = (this._backOffset - heightFromCenter);
  16991. return collidable.add(this._collidableFrontDirection.scale(collidableDistanceToBack));
  16992. }
  16993. };
  16994. /*
  16995. * Updates the distance values.
  16996. * Should be called when the front direction changes, or the mesh size changes
  16997. *
  16998. * Sets the following values:
  16999. * _frontOffset
  17000. * _backOffset
  17001. * _hoverOffset
  17002. * _pushThroughBackOffset
  17003. *
  17004. * Requires population of:
  17005. * _collisionMesh
  17006. * _collidableFrontDirection
  17007. */
  17008. TouchButton3D.prototype._updateDistanceOffsets = function () {
  17009. var worldMatrixData = this._getWorldMatrixData(this._collisionMesh);
  17010. if (!worldMatrixData.scale.equalsWithEpsilon(this._lastKnownCollidableScale)) {
  17011. var collisionMeshPos = this._collisionMesh.getAbsolutePosition();
  17012. this._tempButtonForwardRay.origin = collisionMeshPos;
  17013. this._tempButtonForwardRay.direction = this._collidableFrontDirection;
  17014. var frontPickingInfo = this._tempButtonForwardRay.intersectsMesh(this._collisionMesh);
  17015. this._tempButtonForwardRay.direction = this._tempButtonForwardRay.direction.negate();
  17016. var backPickingInfo = this._tempButtonForwardRay.intersectsMesh(this._collisionMesh);
  17017. this._frontOffset = 0;
  17018. this._backOffset = 0;
  17019. if (frontPickingInfo.hit && backPickingInfo.hit) {
  17020. this._frontOffset = this._getDistanceOffPlane(frontPickingInfo.pickedPoint, this._collidableFrontDirection, collisionMeshPos);
  17021. this._backOffset = this._getDistanceOffPlane(backPickingInfo.pickedPoint, this._collidableFrontDirection, collisionMeshPos);
  17022. }
  17023. // For now, set the hover height equal to the thickness of the button
  17024. var buttonThickness = this._frontOffset - this._backOffset;
  17025. this._hoverOffset = this._frontOffset + (buttonThickness * 1.25);
  17026. this._pushThroughBackOffset = this._backOffset - (buttonThickness * 1.5);
  17027. this._lastKnownCollidableScale = this._getWorldMatrixData(this._collisionMesh).scale;
  17028. }
  17029. };
  17030. // Returns the distance in front of the center of the button
  17031. // Returned value is negative when collidable is past the center
  17032. TouchButton3D.prototype._getHeightFromButtonCenter = function (collidablePos) {
  17033. return this._getDistanceOffPlane(collidablePos, this._collidableFrontDirection, this._collisionMesh.getAbsolutePosition());
  17034. };
  17035. // Returns the distance from pointOnPlane to point along planeNormal
  17036. TouchButton3D.prototype._getDistanceOffPlane = function (point, planeNormal, pointOnPlane) {
  17037. var d = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(pointOnPlane, planeNormal);
  17038. var abc = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(point, planeNormal);
  17039. return abc - d;
  17040. };
  17041. // Updates the stored state of the button, and fire pointer events
  17042. TouchButton3D.prototype._updateButtonState = function (id, newState, pointOnButton) {
  17043. var dummyPointerId = 0;
  17044. var buttonIndex = 0; // Left click
  17045. var buttonStateForId = this._activeInteractions.get(id) || ButtonState.None;
  17046. // Take into account all inputs interacting with the button to avoid state flickering
  17047. var previousPushDepth = 0;
  17048. this._activeInteractions.forEach(function (value, key) {
  17049. previousPushDepth = Math.max(previousPushDepth, value);
  17050. });
  17051. if (buttonStateForId != newState) {
  17052. if (newState == ButtonState.None) {
  17053. this._activeInteractions.delete(id);
  17054. }
  17055. else {
  17056. this._activeInteractions.set(id, newState);
  17057. }
  17058. }
  17059. var newPushDepth = 0;
  17060. this._activeInteractions.forEach(function (value, key) {
  17061. newPushDepth = Math.max(newPushDepth, value);
  17062. });
  17063. if (newPushDepth == ButtonState.Press) {
  17064. if (previousPushDepth == ButtonState.Hover) {
  17065. this._onPointerDown(this, pointOnButton, dummyPointerId, buttonIndex);
  17066. }
  17067. else if (previousPushDepth == ButtonState.Press) {
  17068. this._onPointerMove(this, pointOnButton);
  17069. }
  17070. }
  17071. else if (newPushDepth == ButtonState.Hover) {
  17072. if (previousPushDepth == ButtonState.None) {
  17073. this._onPointerEnter(this);
  17074. }
  17075. else if (previousPushDepth == ButtonState.Press) {
  17076. this._onPointerUp(this, pointOnButton, dummyPointerId, buttonIndex, false);
  17077. }
  17078. else {
  17079. this._onPointerMove(this, pointOnButton);
  17080. }
  17081. }
  17082. else if (newPushDepth == ButtonState.None) {
  17083. if (previousPushDepth == ButtonState.Hover) {
  17084. this._onPointerOut(this);
  17085. }
  17086. else if (previousPushDepth == ButtonState.Press) {
  17087. this._onPointerUp(this, pointOnButton, dummyPointerId, buttonIndex, false);
  17088. this._onPointerOut(this);
  17089. }
  17090. }
  17091. };
  17092. // Decides whether to change button state based on the planar depth of the input source
  17093. /** @hidden */
  17094. TouchButton3D.prototype._collisionCheckForStateChange = function (mesh) {
  17095. if (this._collidableInitialized) {
  17096. this._updateDistanceOffsets();
  17097. var collidablePosition = mesh.getAbsolutePosition();
  17098. var inRange = this._isPrimedForInteraction(collidablePosition);
  17099. var uniqueId = mesh.uniqueId;
  17100. var activeInteraction = this._activeInteractions.get(uniqueId);
  17101. if (inRange) {
  17102. var pointOnButton = this._getPointOnButton(collidablePosition);
  17103. var heightFromCenter_1 = this._getHeightFromButtonCenter(collidablePosition);
  17104. var flickerDelta_1 = 0.003;
  17105. this._lastTouchPoint = pointOnButton;
  17106. var isGreater = function (compareHeight) {
  17107. return heightFromCenter_1 >= (compareHeight + flickerDelta_1);
  17108. };
  17109. var isLower = function (compareHeight) {
  17110. return heightFromCenter_1 <= (compareHeight - flickerDelta_1);
  17111. };
  17112. // Update button state and fire events
  17113. switch (activeInteraction || ButtonState.None) {
  17114. case ButtonState.None:
  17115. if (isGreater(this._frontOffset) &&
  17116. isLower(this._hoverOffset)) {
  17117. this._updateButtonState(uniqueId, ButtonState.Hover, pointOnButton);
  17118. }
  17119. break;
  17120. case ButtonState.Hover:
  17121. if (isGreater(this._hoverOffset)) {
  17122. this._updateButtonState(uniqueId, ButtonState.None, pointOnButton);
  17123. }
  17124. else if (isLower(this._frontOffset)) {
  17125. this._updateButtonState(uniqueId, ButtonState.Press, pointOnButton);
  17126. }
  17127. break;
  17128. case ButtonState.Press:
  17129. if (isGreater(this._frontOffset)) {
  17130. this._updateButtonState(uniqueId, ButtonState.Hover, pointOnButton);
  17131. }
  17132. else if (isLower(this._pushThroughBackOffset)) {
  17133. this._updateButtonState(uniqueId, ButtonState.None, pointOnButton);
  17134. }
  17135. break;
  17136. }
  17137. this._previousHeight.set(uniqueId, heightFromCenter_1);
  17138. }
  17139. else if ((activeInteraction != undefined) && (activeInteraction != ButtonState.None)) {
  17140. this._updateButtonState(uniqueId, ButtonState.None, this._lastTouchPoint);
  17141. this._previousHeight.delete(uniqueId);
  17142. }
  17143. }
  17144. };
  17145. TouchButton3D.prototype._getTypeName = function () {
  17146. return "TouchButton3D";
  17147. };
  17148. // Mesh association
  17149. TouchButton3D.prototype._createNode = function (scene) {
  17150. return _super.prototype._createNode.call(this, scene);
  17151. };
  17152. /**
  17153. * Releases all associated resources
  17154. */
  17155. TouchButton3D.prototype.dispose = function () {
  17156. _super.prototype.dispose.call(this);
  17157. if (this._collisionMesh) {
  17158. this._collisionMesh.dispose();
  17159. }
  17160. };
  17161. return TouchButton3D;
  17162. }(_button3D__WEBPACK_IMPORTED_MODULE_2__["Button3D"]));
  17163. /***/ }),
  17164. /***/ "./3D/controls/touchHolographicButton.ts":
  17165. /*!***********************************************!*\
  17166. !*** ./3D/controls/touchHolographicButton.ts ***!
  17167. \***********************************************/
  17168. /*! exports provided: TouchHolographicButton */
  17169. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17170. "use strict";
  17171. __webpack_require__.r(__webpack_exports__);
  17172. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchHolographicButton", function() { return TouchHolographicButton; });
  17173. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  17174. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Misc/observable");
  17175. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__);
  17176. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  17177. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  17178. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  17179. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  17180. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  17181. /* harmony import */ var _touchButton3D__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./touchButton3D */ "./3D/controls/touchButton3D.ts");
  17182. /**
  17183. * Class used to create a holographic button in 3D
  17184. */
  17185. var TouchHolographicButton = /** @class */ (function (_super) {
  17186. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TouchHolographicButton, _super);
  17187. /**
  17188. * Creates a new button
  17189. * @param name defines the control name
  17190. */
  17191. function TouchHolographicButton(name, shareMaterials) {
  17192. if (shareMaterials === void 0) { shareMaterials = true; }
  17193. var _this = _super.call(this, name) || this;
  17194. _this._shareMaterials = true;
  17195. _this._shareMaterials = shareMaterials;
  17196. // Default animations
  17197. _this.pointerEnterAnimation = function () {
  17198. if (!_this.mesh) {
  17199. return;
  17200. }
  17201. _this._frontPlate.setEnabled(true);
  17202. };
  17203. _this.pointerOutAnimation = function () {
  17204. if (!_this.mesh) {
  17205. return;
  17206. }
  17207. _this._frontPlate.setEnabled(false);
  17208. };
  17209. return _this;
  17210. }
  17211. TouchHolographicButton.prototype._disposeTooltip = function () {
  17212. this._tooltipFade = null;
  17213. if (this._tooltipTextBlock) {
  17214. this._tooltipTextBlock.dispose();
  17215. }
  17216. if (this._tooltipTexture) {
  17217. this._tooltipTexture.dispose();
  17218. }
  17219. if (this._tooltipMesh) {
  17220. this._tooltipMesh.dispose();
  17221. }
  17222. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  17223. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  17224. };
  17225. Object.defineProperty(TouchHolographicButton.prototype, "renderingGroupId", {
  17226. get: function () {
  17227. return this._backPlate.renderingGroupId;
  17228. },
  17229. /**
  17230. * Rendering ground id of all the mesh in the button
  17231. */
  17232. set: function (id) {
  17233. this._backPlate.renderingGroupId = id;
  17234. this._textPlate.renderingGroupId = id;
  17235. this._frontPlate.renderingGroupId = id;
  17236. if (this._tooltipMesh) {
  17237. this._tooltipMesh.renderingGroupId = id;
  17238. }
  17239. },
  17240. enumerable: false,
  17241. configurable: true
  17242. });
  17243. Object.defineProperty(TouchHolographicButton.prototype, "tooltipText", {
  17244. get: function () {
  17245. if (this._tooltipTextBlock) {
  17246. return this._tooltipTextBlock.text;
  17247. }
  17248. return null;
  17249. },
  17250. /**
  17251. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  17252. */
  17253. set: function (text) {
  17254. var _this = this;
  17255. if (!text) {
  17256. this._disposeTooltip();
  17257. return;
  17258. }
  17259. if (!this._tooltipFade) {
  17260. // Create tooltip with mesh and text
  17261. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  17262. var tooltipBackground = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  17263. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", this._backPlate._scene);
  17264. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#212121");
  17265. tooltipBackground.material = mat;
  17266. tooltipBackground.isPickable = false;
  17267. this._tooltipMesh.addChild(tooltipBackground);
  17268. tooltipBackground.position.z = 0.05;
  17269. this._tooltipMesh.scaling.y = 1 / 3;
  17270. this._tooltipMesh.position.y = 0.7;
  17271. this._tooltipMesh.position.z = -0.15;
  17272. this._tooltipMesh.isPickable = false;
  17273. this._tooltipMesh.parent = this._backPlate;
  17274. // Create text texture for the tooltip
  17275. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_6__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  17276. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_5__["TextBlock"]();
  17277. this._tooltipTextBlock.scaleY = 3;
  17278. this._tooltipTextBlock.color = "white";
  17279. this._tooltipTextBlock.fontSize = 130;
  17280. this._tooltipTexture.addControl(this._tooltipTextBlock);
  17281. // Add hover action to tooltip
  17282. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]();
  17283. this._tooltipFade.delay = 500;
  17284. this._tooltipMesh.addBehavior(this._tooltipFade);
  17285. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  17286. if (_this._tooltipFade) {
  17287. _this._tooltipFade.fadeIn(true);
  17288. }
  17289. });
  17290. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  17291. if (_this._tooltipFade) {
  17292. _this._tooltipFade.fadeIn(false);
  17293. }
  17294. });
  17295. }
  17296. if (this._tooltipTextBlock) {
  17297. this._tooltipTextBlock.text = text;
  17298. }
  17299. },
  17300. enumerable: false,
  17301. configurable: true
  17302. });
  17303. Object.defineProperty(TouchHolographicButton.prototype, "text", {
  17304. /**
  17305. * Gets or sets text for the button
  17306. */
  17307. get: function () {
  17308. return this._text;
  17309. },
  17310. set: function (value) {
  17311. if (this._text === value) {
  17312. return;
  17313. }
  17314. this._text = value;
  17315. this._rebuildContent();
  17316. },
  17317. enumerable: false,
  17318. configurable: true
  17319. });
  17320. Object.defineProperty(TouchHolographicButton.prototype, "imageUrl", {
  17321. /**
  17322. * Gets or sets the image url for the button
  17323. */
  17324. get: function () {
  17325. return this._imageUrl;
  17326. },
  17327. set: function (value) {
  17328. if (this._imageUrl === value) {
  17329. return;
  17330. }
  17331. this._imageUrl = value;
  17332. this._rebuildContent();
  17333. },
  17334. enumerable: false,
  17335. configurable: true
  17336. });
  17337. Object.defineProperty(TouchHolographicButton.prototype, "backMaterial", {
  17338. /**
  17339. * Gets the back material used by this button
  17340. */
  17341. get: function () {
  17342. return this._backMaterial;
  17343. },
  17344. enumerable: false,
  17345. configurable: true
  17346. });
  17347. Object.defineProperty(TouchHolographicButton.prototype, "frontMaterial", {
  17348. /**
  17349. * Gets the front material used by this button
  17350. */
  17351. get: function () {
  17352. return this._frontMaterial;
  17353. },
  17354. enumerable: false,
  17355. configurable: true
  17356. });
  17357. Object.defineProperty(TouchHolographicButton.prototype, "plateMaterial", {
  17358. /**
  17359. * Gets the plate material used by this button
  17360. */
  17361. get: function () {
  17362. return this._plateMaterial;
  17363. },
  17364. enumerable: false,
  17365. configurable: true
  17366. });
  17367. Object.defineProperty(TouchHolographicButton.prototype, "shareMaterials", {
  17368. /**
  17369. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  17370. */
  17371. get: function () {
  17372. return this._shareMaterials;
  17373. },
  17374. enumerable: false,
  17375. configurable: true
  17376. });
  17377. TouchHolographicButton.prototype._getTypeName = function () {
  17378. return "TouchHolographicButton";
  17379. };
  17380. TouchHolographicButton.prototype._rebuildContent = function () {
  17381. this._disposeFacadeTexture();
  17382. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  17383. panel.isVertical = true;
  17384. if (this._imageUrl) {
  17385. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_4__["Image"]();
  17386. image.source = this._imageUrl;
  17387. image.paddingTop = "40px";
  17388. image.height = "180px";
  17389. image.width = "100px";
  17390. image.paddingBottom = "40px";
  17391. panel.addControl(image);
  17392. }
  17393. if (this._text) {
  17394. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_5__["TextBlock"]();
  17395. text.text = this._text;
  17396. text.color = "white";
  17397. text.height = "30px";
  17398. text.fontSize = 24;
  17399. panel.addControl(text);
  17400. }
  17401. if (this._frontPlate) {
  17402. this.content = panel;
  17403. }
  17404. };
  17405. // Mesh association
  17406. TouchHolographicButton.prototype._createNode = function (scene) {
  17407. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  17408. width: 1.0,
  17409. height: 1.0,
  17410. depth: 0.08
  17411. }, scene);
  17412. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  17413. width: 1.0,
  17414. height: 1.0,
  17415. depth: 0.4
  17416. }, scene);
  17417. this._frontPlate.parent = this._backPlate;
  17418. this._frontPlate.position.z = -0.08;
  17419. this._frontPlate.isPickable = false;
  17420. this._frontPlate.setEnabled(false);
  17421. this._textPlate = _super.prototype._createNode.call(this, scene);
  17422. this._textPlate.parent = this._backPlate;
  17423. this._textPlate.position.z = -0.08;
  17424. this._textPlate.isPickable = false;
  17425. this.collisionMesh = this._frontPlate;
  17426. this.collidableFrontDirection = this._frontPlate.forward.negate(); // Mesh is facing the wrong way
  17427. return this._backPlate;
  17428. };
  17429. TouchHolographicButton.prototype._applyFacade = function (facadeTexture) {
  17430. this._plateMaterial.emissiveTexture = facadeTexture;
  17431. this._plateMaterial.opacityTexture = facadeTexture;
  17432. };
  17433. TouchHolographicButton.prototype._createBackMaterial = function (mesh) {
  17434. var _this = this;
  17435. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_2__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  17436. this._backMaterial.renderHoverLight = true;
  17437. this._backMaterial.albedoColor = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.1, 0.1, 0.4);
  17438. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  17439. if (pickedPoint) {
  17440. _this._backMaterial.hoverPosition = pickedPoint;
  17441. _this._backMaterial.hoverColor.a = 1.0;
  17442. }
  17443. else {
  17444. _this._backMaterial.hoverColor.a = 0;
  17445. }
  17446. });
  17447. };
  17448. TouchHolographicButton.prototype._createFrontMaterial = function (mesh) {
  17449. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_2__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  17450. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  17451. this._frontMaterial.alpha = 0.3; // Additive
  17452. this._frontMaterial.renderBorders = false;
  17453. };
  17454. TouchHolographicButton.prototype._createPlateMaterial = function (mesh) {
  17455. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  17456. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  17457. };
  17458. TouchHolographicButton.prototype._affectMaterial = function (mesh) {
  17459. // Back
  17460. if (this._shareMaterials) {
  17461. if (!this._host._touchSharedMaterials["backFluentMaterial"]) {
  17462. this._createBackMaterial(mesh);
  17463. this._host._touchSharedMaterials["backFluentMaterial"] = this._backMaterial;
  17464. }
  17465. else {
  17466. this._backMaterial = this._host._touchSharedMaterials["backFluentMaterial"];
  17467. }
  17468. // Front
  17469. if (!this._host._touchSharedMaterials["frontFluentMaterial"]) {
  17470. this._createFrontMaterial(mesh);
  17471. this._host._touchSharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  17472. }
  17473. else {
  17474. this._frontMaterial = this._host._touchSharedMaterials["frontFluentMaterial"];
  17475. }
  17476. }
  17477. else {
  17478. this._createBackMaterial(mesh);
  17479. this._createFrontMaterial(mesh);
  17480. }
  17481. this._createPlateMaterial(mesh);
  17482. this._backPlate.material = this._backMaterial;
  17483. this._frontPlate.material = this._frontMaterial;
  17484. this._textPlate.material = this._plateMaterial;
  17485. this._rebuildContent();
  17486. };
  17487. /**
  17488. * Releases all associated resources
  17489. */
  17490. TouchHolographicButton.prototype.dispose = function () {
  17491. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  17492. this._disposeTooltip();
  17493. if (!this.shareMaterials) {
  17494. this._backMaterial.dispose();
  17495. this._frontMaterial.dispose();
  17496. this._plateMaterial.dispose();
  17497. if (this._pickedPointObserver) {
  17498. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  17499. this._pickedPointObserver = null;
  17500. }
  17501. }
  17502. };
  17503. return TouchHolographicButton;
  17504. }(_touchButton3D__WEBPACK_IMPORTED_MODULE_7__["TouchButton3D"]));
  17505. /***/ }),
  17506. /***/ "./3D/controls/touchMeshButton3D.ts":
  17507. /*!******************************************!*\
  17508. !*** ./3D/controls/touchMeshButton3D.ts ***!
  17509. \******************************************/
  17510. /*! exports provided: TouchMeshButton3D */
  17511. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17512. "use strict";
  17513. __webpack_require__.r(__webpack_exports__);
  17514. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchMeshButton3D", function() { return TouchMeshButton3D; });
  17515. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  17516. /* harmony import */ var _touchButton3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchButton3D */ "./3D/controls/touchButton3D.ts");
  17517. /**
  17518. * Class used to create an interactable object. It's a touchable 3D button using a mesh coming from the current scene
  17519. */
  17520. var TouchMeshButton3D = /** @class */ (function (_super) {
  17521. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TouchMeshButton3D, _super);
  17522. /**
  17523. * Creates a new 3D button based on a mesh
  17524. * @param mesh mesh to become a 3D button
  17525. * @param collisionMesh mesh to track collisions with
  17526. * @param name defines the control name
  17527. */
  17528. function TouchMeshButton3D(mesh, options, name) {
  17529. var _this = this;
  17530. if (options.useDynamicMesh) {
  17531. _this = _super.call(this, name, options.collisionMesh) || this;
  17532. }
  17533. else {
  17534. var newCollisionMesh = options.collisionMesh.clone("", options.collisionMesh.parent);
  17535. newCollisionMesh.isVisible = false;
  17536. _this = _super.call(this, name, newCollisionMesh) || this;
  17537. }
  17538. _this._currentMesh = mesh;
  17539. /**
  17540. * Provides a default behavior on hover/out & up/down
  17541. * Override those function to create your own desired behavior specific to your mesh
  17542. */
  17543. _this.pointerEnterAnimation = function () {
  17544. if (!_this.mesh) {
  17545. return;
  17546. }
  17547. _this.mesh.scaling.scaleInPlace(1.1);
  17548. };
  17549. _this.pointerOutAnimation = function () {
  17550. if (!_this.mesh) {
  17551. return;
  17552. }
  17553. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  17554. };
  17555. _this.pointerDownAnimation = function () {
  17556. if (!_this.mesh) {
  17557. return;
  17558. }
  17559. _this.mesh.scaling.scaleInPlace(0.95);
  17560. };
  17561. _this.pointerUpAnimation = function () {
  17562. if (!_this.mesh) {
  17563. return;
  17564. }
  17565. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  17566. };
  17567. return _this;
  17568. }
  17569. TouchMeshButton3D.prototype._getTypeName = function () {
  17570. return "TouchMeshButton3D";
  17571. };
  17572. // Mesh association
  17573. TouchMeshButton3D.prototype._createNode = function (scene) {
  17574. var _this = this;
  17575. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  17576. mesh.metadata = _this;
  17577. });
  17578. return this._currentMesh;
  17579. };
  17580. TouchMeshButton3D.prototype._affectMaterial = function (mesh) {
  17581. };
  17582. return TouchMeshButton3D;
  17583. }(_touchButton3D__WEBPACK_IMPORTED_MODULE_1__["TouchButton3D"]));
  17584. /***/ }),
  17585. /***/ "./3D/controls/volumeBasedPanel.ts":
  17586. /*!*****************************************!*\
  17587. !*** ./3D/controls/volumeBasedPanel.ts ***!
  17588. \*****************************************/
  17589. /*! exports provided: VolumeBasedPanel */
  17590. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17591. "use strict";
  17592. __webpack_require__.r(__webpack_exports__);
  17593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  17594. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  17595. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  17596. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  17597. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  17598. /**
  17599. * Abstract class used to create a container panel deployed on the surface of a volume
  17600. */
  17601. var VolumeBasedPanel = /** @class */ (function (_super) {
  17602. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  17603. /**
  17604. * Creates new VolumeBasedPanel
  17605. */
  17606. function VolumeBasedPanel() {
  17607. var _this = _super.call(this) || this;
  17608. _this._columns = 10;
  17609. _this._rows = 0;
  17610. _this._rowThenColum = true;
  17611. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  17612. /**
  17613. * Gets or sets the distance between elements
  17614. */
  17615. _this.margin = 0;
  17616. return _this;
  17617. }
  17618. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  17619. /**
  17620. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  17621. * | Value | Type | Description |
  17622. * | ----- | ----------------------------------- | ----------- |
  17623. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  17624. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  17625. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  17626. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  17627. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  17628. */
  17629. get: function () {
  17630. return this._orientation;
  17631. },
  17632. set: function (value) {
  17633. var _this = this;
  17634. if (this._orientation === value) {
  17635. return;
  17636. }
  17637. this._orientation = value;
  17638. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  17639. _this._arrangeChildren();
  17640. });
  17641. },
  17642. enumerable: false,
  17643. configurable: true
  17644. });
  17645. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  17646. /**
  17647. * Gets or sets the number of columns requested (10 by default).
  17648. * The panel will automatically compute the number of rows based on number of child controls.
  17649. */
  17650. get: function () {
  17651. return this._columns;
  17652. },
  17653. set: function (value) {
  17654. var _this = this;
  17655. if (this._columns === value) {
  17656. return;
  17657. }
  17658. this._columns = value;
  17659. this._rowThenColum = true;
  17660. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  17661. _this._arrangeChildren();
  17662. });
  17663. },
  17664. enumerable: false,
  17665. configurable: true
  17666. });
  17667. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  17668. /**
  17669. * Gets or sets a the number of rows requested.
  17670. * The panel will automatically compute the number of columns based on number of child controls.
  17671. */
  17672. get: function () {
  17673. return this._rows;
  17674. },
  17675. set: function (value) {
  17676. var _this = this;
  17677. if (this._rows === value) {
  17678. return;
  17679. }
  17680. this._rows = value;
  17681. this._rowThenColum = false;
  17682. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  17683. _this._arrangeChildren();
  17684. });
  17685. },
  17686. enumerable: false,
  17687. configurable: true
  17688. });
  17689. VolumeBasedPanel.prototype._arrangeChildren = function () {
  17690. this._cellWidth = 0;
  17691. this._cellHeight = 0;
  17692. var rows = 0;
  17693. var columns = 0;
  17694. var controlCount = 0;
  17695. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  17696. // Measure
  17697. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  17698. var child = _a[_i];
  17699. if (!child.mesh) {
  17700. continue;
  17701. }
  17702. controlCount++;
  17703. child.mesh.computeWorldMatrix(true);
  17704. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  17705. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  17706. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  17707. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  17708. boundingBox.max.subtractToRef(boundingBox.min, diff);
  17709. diff.scaleInPlace(0.5);
  17710. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  17711. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  17712. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  17713. }
  17714. this._cellWidth += this.margin * 2;
  17715. this._cellHeight += this.margin * 2;
  17716. // Arrange
  17717. if (this._rowThenColum) {
  17718. columns = this._columns;
  17719. rows = Math.ceil(controlCount / this._columns);
  17720. }
  17721. else {
  17722. rows = this._rows;
  17723. columns = Math.ceil(controlCount / this._rows);
  17724. }
  17725. var startOffsetX = (columns * 0.5) * this._cellWidth;
  17726. var startOffsetY = (rows * 0.5) * this._cellHeight;
  17727. var nodeGrid = [];
  17728. var cellCounter = 0;
  17729. if (this._rowThenColum) {
  17730. for (var r = 0; r < rows; r++) {
  17731. for (var c = 0; c < columns; c++) {
  17732. 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));
  17733. cellCounter++;
  17734. if (cellCounter > controlCount) {
  17735. break;
  17736. }
  17737. }
  17738. }
  17739. }
  17740. else {
  17741. for (var c = 0; c < columns; c++) {
  17742. for (var r = 0; r < rows; r++) {
  17743. 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));
  17744. cellCounter++;
  17745. if (cellCounter > controlCount) {
  17746. break;
  17747. }
  17748. }
  17749. }
  17750. }
  17751. cellCounter = 0;
  17752. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  17753. var child = _c[_b];
  17754. if (!child.mesh) {
  17755. continue;
  17756. }
  17757. this._mapGridNode(child, nodeGrid[cellCounter]);
  17758. cellCounter++;
  17759. }
  17760. this._finalProcessing();
  17761. };
  17762. /** Child classes can implement this function to provide additional processing */
  17763. VolumeBasedPanel.prototype._finalProcessing = function () {
  17764. };
  17765. return VolumeBasedPanel;
  17766. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  17767. /***/ }),
  17768. /***/ "./3D/gui3DManager.ts":
  17769. /*!****************************!*\
  17770. !*** ./3D/gui3DManager.ts ***!
  17771. \****************************/
  17772. /*! exports provided: GUI3DManager */
  17773. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17774. "use strict";
  17775. __webpack_require__.r(__webpack_exports__);
  17776. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  17777. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  17778. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  17779. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  17780. /* harmony import */ var _controls_touchButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/touchButton3D */ "./3D/controls/touchButton3D.ts");
  17781. /**
  17782. * Class used to manage 3D user interface
  17783. * @see https://doc.babylonjs.com/how_to/gui3d
  17784. */
  17785. var GUI3DManager = /** @class */ (function () {
  17786. /**
  17787. * Creates a new GUI3DManager
  17788. * @param scene
  17789. */
  17790. function GUI3DManager(scene) {
  17791. var _this = this;
  17792. this._touchableButtons = new Set();
  17793. /** @hidden */
  17794. this._lastControlOver = {};
  17795. /** @hidden */
  17796. this._lastControlDown = {};
  17797. /**
  17798. * Observable raised when the point picked by the pointer events changed
  17799. */
  17800. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  17801. // Shared resources
  17802. /** @hidden */
  17803. this._sharedMaterials = {};
  17804. /** @hidden */
  17805. this._touchSharedMaterials = {};
  17806. this._processTouchControls = function () {
  17807. var utilityLayerScene = _this._utilityLayer ? _this._utilityLayer.utilityLayerScene : null;
  17808. if (utilityLayerScene) {
  17809. var touchMeshes_1 = utilityLayerScene.getMeshesByTags("touchEnabled");
  17810. _this._touchableButtons.forEach(function (button) {
  17811. touchMeshes_1.forEach(function (mesh) {
  17812. button._collisionCheckForStateChange(mesh);
  17813. });
  17814. });
  17815. }
  17816. };
  17817. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  17818. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  17819. _this._sceneDisposeObserver = null;
  17820. _this._utilityLayer = null;
  17821. _this.dispose();
  17822. });
  17823. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  17824. this._utilityLayer.onlyCheckPointerDownEvents = false;
  17825. this._utilityLayer.pickUtilitySceneFirst = false;
  17826. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  17827. var _a, _b, _c;
  17828. return mesh && ((_c = (_b = (_a = mesh.metadata) === null || _a === void 0 ? void 0 : _a.GUI3D) === null || _b === void 0 ? void 0 : _b.control) === null || _c === void 0 ? void 0 : _c._node);
  17829. };
  17830. // Root
  17831. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  17832. this._rootContainer._host = this;
  17833. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  17834. // Events
  17835. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  17836. _this._handlePointerOut(pointerId, true);
  17837. });
  17838. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  17839. _this._doPicking(pi);
  17840. });
  17841. // Scene
  17842. this._utilityLayer.utilityLayerScene.autoClear = false;
  17843. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  17844. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  17845. }
  17846. Object.defineProperty(GUI3DManager.prototype, "scene", {
  17847. /** Gets the hosting scene */
  17848. get: function () {
  17849. return this._scene;
  17850. },
  17851. enumerable: false,
  17852. configurable: true
  17853. });
  17854. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  17855. /** Gets associated utility layer */
  17856. get: function () {
  17857. return this._utilityLayer;
  17858. },
  17859. enumerable: false,
  17860. configurable: true
  17861. });
  17862. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  17863. var previousControlOver = this._lastControlOver[pointerId];
  17864. if (previousControlOver) {
  17865. previousControlOver._onPointerOut(previousControlOver);
  17866. delete this._lastControlOver[pointerId];
  17867. }
  17868. if (isPointerUp) {
  17869. if (this._lastControlDown[pointerId]) {
  17870. this._lastControlDown[pointerId].forcePointerUp();
  17871. delete this._lastControlDown[pointerId];
  17872. }
  17873. }
  17874. this.onPickedPointChangedObservable.notifyObservers(null);
  17875. };
  17876. GUI3DManager.prototype._doPicking = function (pi) {
  17877. var _a, _b;
  17878. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  17879. return false;
  17880. }
  17881. var pointerEvent = (pi.event);
  17882. var pointerId = pointerEvent.pointerId || 0;
  17883. var buttonIndex = pointerEvent.button;
  17884. var pickingInfo = pi.pickInfo;
  17885. if (!pickingInfo || !pickingInfo.hit) {
  17886. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  17887. return false;
  17888. }
  17889. var control = ((_b = (_a = pickingInfo.pickedMesh.metadata) === null || _a === void 0 ? void 0 : _a.GUI3D) === null || _b === void 0 ? void 0 : _b.control);
  17890. if (pickingInfo.pickedPoint) {
  17891. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  17892. }
  17893. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  17894. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  17895. if (this._lastControlOver[pointerId]) {
  17896. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  17897. }
  17898. delete this._lastControlOver[pointerId];
  17899. }
  17900. }
  17901. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  17902. if (this._lastControlDown[pointerEvent.pointerId]) {
  17903. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  17904. delete this._lastControlDown[pointerEvent.pointerId];
  17905. }
  17906. if (pointerEvent.pointerType === "touch") {
  17907. this._handlePointerOut(pointerId, false);
  17908. }
  17909. }
  17910. return true;
  17911. };
  17912. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  17913. /**
  17914. * Gets the root container
  17915. */
  17916. get: function () {
  17917. return this._rootContainer;
  17918. },
  17919. enumerable: false,
  17920. configurable: true
  17921. });
  17922. /**
  17923. * Gets a boolean indicating if the given control is in the root child list
  17924. * @param control defines the control to check
  17925. * @returns true if the control is in the root child list
  17926. */
  17927. GUI3DManager.prototype.containsControl = function (control) {
  17928. return this._rootContainer.containsControl(control);
  17929. };
  17930. /**
  17931. * Adds a control to the root child list
  17932. * @param control defines the control to add
  17933. * @returns the current manager
  17934. */
  17935. GUI3DManager.prototype.addControl = function (control) {
  17936. this._rootContainer.addControl(control);
  17937. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  17938. if (utilityLayerScene && (control instanceof _controls_touchButton3D__WEBPACK_IMPORTED_MODULE_2__["TouchButton3D"])) {
  17939. if (this._touchableButtons.size == 0) {
  17940. utilityLayerScene.registerBeforeRender(this._processTouchControls);
  17941. }
  17942. this._touchableButtons.add(control);
  17943. }
  17944. return this;
  17945. };
  17946. /**
  17947. * Removes a control from the root child list
  17948. * @param control defines the control to remove
  17949. * @returns the current container
  17950. */
  17951. GUI3DManager.prototype.removeControl = function (control) {
  17952. this._rootContainer.removeControl(control);
  17953. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  17954. if (utilityLayerScene && (control instanceof _controls_touchButton3D__WEBPACK_IMPORTED_MODULE_2__["TouchButton3D"])) {
  17955. this._touchableButtons.delete(control);
  17956. if (this._touchableButtons.size == 0) {
  17957. utilityLayerScene.unregisterBeforeRender(this._processTouchControls);
  17958. }
  17959. }
  17960. return this;
  17961. };
  17962. /**
  17963. * Releases all associated resources
  17964. */
  17965. GUI3DManager.prototype.dispose = function () {
  17966. this._rootContainer.dispose();
  17967. for (var materialName in this._sharedMaterials) {
  17968. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  17969. continue;
  17970. }
  17971. this._sharedMaterials[materialName].dispose();
  17972. }
  17973. this._sharedMaterials = {};
  17974. for (var materialName in this._touchSharedMaterials) {
  17975. if (!this._touchSharedMaterials.hasOwnProperty(materialName)) {
  17976. continue;
  17977. }
  17978. this._touchSharedMaterials[materialName].dispose();
  17979. }
  17980. this._touchSharedMaterials = {};
  17981. if (this._pointerOutObserver && this._utilityLayer) {
  17982. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  17983. this._pointerOutObserver = null;
  17984. }
  17985. this.onPickedPointChangedObservable.clear();
  17986. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  17987. if (utilityLayerScene) {
  17988. if (this._touchableButtons.size != 0) {
  17989. utilityLayerScene.unregisterBeforeRender(this._processTouchControls);
  17990. }
  17991. if (this._pointerObserver) {
  17992. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  17993. this._pointerObserver = null;
  17994. }
  17995. }
  17996. if (this._scene) {
  17997. if (this._sceneDisposeObserver) {
  17998. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  17999. this._sceneDisposeObserver = null;
  18000. }
  18001. }
  18002. if (this._utilityLayer) {
  18003. this._utilityLayer.dispose();
  18004. }
  18005. };
  18006. return GUI3DManager;
  18007. }());
  18008. /***/ }),
  18009. /***/ "./3D/index.ts":
  18010. /*!*********************!*\
  18011. !*** ./3D/index.ts ***!
  18012. \*********************/
  18013. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, TouchButton3D, TouchMeshButton3D, TouchHolographicButton, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  18014. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18015. "use strict";
  18016. __webpack_require__.r(__webpack_exports__);
  18017. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  18018. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  18019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  18020. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  18021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  18022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  18023. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  18024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  18025. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  18026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  18027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  18028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  18029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TouchButton3D"]; });
  18030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchMeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TouchMeshButton3D"]; });
  18031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchHolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TouchHolographicButton"]; });
  18032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  18033. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  18034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  18035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  18036. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  18037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  18038. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  18039. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  18040. /***/ }),
  18041. /***/ "./3D/materials/fluentMaterial.ts":
  18042. /*!****************************************!*\
  18043. !*** ./3D/materials/fluentMaterial.ts ***!
  18044. \****************************************/
  18045. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  18046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18047. "use strict";
  18048. __webpack_require__.r(__webpack_exports__);
  18049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  18050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  18051. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  18052. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  18053. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  18054. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  18055. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  18056. /** @hidden */
  18057. var FluentMaterialDefines = /** @class */ (function (_super) {
  18058. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  18059. function FluentMaterialDefines() {
  18060. var _this = _super.call(this) || this;
  18061. _this.INNERGLOW = false;
  18062. _this.BORDER = false;
  18063. _this.HOVERLIGHT = false;
  18064. _this.TEXTURE = false;
  18065. _this.rebuild();
  18066. return _this;
  18067. }
  18068. return FluentMaterialDefines;
  18069. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  18070. /**
  18071. * Class used to render controls with fluent desgin
  18072. */
  18073. var FluentMaterial = /** @class */ (function (_super) {
  18074. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  18075. /**
  18076. * Creates a new Fluent material
  18077. * @param name defines the name of the material
  18078. * @param scene defines the hosting scene
  18079. */
  18080. function FluentMaterial(name, scene) {
  18081. var _this = _super.call(this, name, scene) || this;
  18082. /**
  18083. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  18084. */
  18085. _this.innerGlowColorIntensity = 0.5;
  18086. /**
  18087. * Gets or sets the inner glow color (white by default)
  18088. */
  18089. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  18090. /**
  18091. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  18092. */
  18093. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  18094. /**
  18095. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  18096. */
  18097. _this.renderBorders = false;
  18098. /**
  18099. * Gets or sets border width (default is 0.5)
  18100. */
  18101. _this.borderWidth = 0.5;
  18102. /**
  18103. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  18104. */
  18105. _this.edgeSmoothingValue = 0.02;
  18106. /**
  18107. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  18108. */
  18109. _this.borderMinValue = 0.1;
  18110. /**
  18111. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  18112. */
  18113. _this.renderHoverLight = false;
  18114. /**
  18115. * Gets or sets the radius used to render the hover light (default is 1.0)
  18116. */
  18117. _this.hoverRadius = 1.0;
  18118. /**
  18119. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  18120. */
  18121. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  18122. /**
  18123. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  18124. */
  18125. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  18126. return _this;
  18127. }
  18128. FluentMaterial.prototype.needAlphaBlending = function () {
  18129. return this.alpha !== 1.0;
  18130. };
  18131. FluentMaterial.prototype.needAlphaTesting = function () {
  18132. return false;
  18133. };
  18134. FluentMaterial.prototype.getAlphaTestTexture = function () {
  18135. return null;
  18136. };
  18137. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  18138. if (this.isFrozen) {
  18139. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  18140. return true;
  18141. }
  18142. }
  18143. if (!subMesh._materialDefines) {
  18144. subMesh._materialDefines = new FluentMaterialDefines();
  18145. }
  18146. var scene = this.getScene();
  18147. var defines = subMesh._materialDefines;
  18148. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  18149. if (defines._renderId === scene.getRenderId()) {
  18150. return true;
  18151. }
  18152. }
  18153. if (defines._areTexturesDirty) {
  18154. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  18155. defines.BORDER = this.renderBorders;
  18156. defines.HOVERLIGHT = this.renderHoverLight;
  18157. if (this._albedoTexture) {
  18158. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  18159. return false;
  18160. }
  18161. else {
  18162. defines.TEXTURE = true;
  18163. }
  18164. }
  18165. else {
  18166. defines.TEXTURE = false;
  18167. }
  18168. }
  18169. var engine = scene.getEngine();
  18170. // Get correct effect
  18171. if (defines.isDirty) {
  18172. defines.markAsProcessed();
  18173. scene.resetCachedMaterial();
  18174. //Attributes
  18175. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  18176. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  18177. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  18178. var shaderName = "fluent";
  18179. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  18180. "hoverColor", "hoverPosition", "hoverRadius"
  18181. ];
  18182. var samplers = ["albedoSampler"];
  18183. var uniformBuffers = new Array();
  18184. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  18185. uniformsNames: uniforms,
  18186. uniformBuffersNames: uniformBuffers,
  18187. samplers: samplers,
  18188. defines: defines,
  18189. maxSimultaneousLights: 4
  18190. });
  18191. var join = defines.toString();
  18192. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  18193. attributes: attribs,
  18194. uniformsNames: uniforms,
  18195. uniformBuffersNames: uniformBuffers,
  18196. samplers: samplers,
  18197. defines: join,
  18198. fallbacks: null,
  18199. onCompiled: this.onCompiled,
  18200. onError: this.onError,
  18201. indexParameters: { maxSimultaneousLights: 4 }
  18202. }, engine));
  18203. }
  18204. if (!subMesh.effect || !subMesh.effect.isReady()) {
  18205. return false;
  18206. }
  18207. defines._renderId = scene.getRenderId();
  18208. subMesh.effect._wasPreviouslyReady = true;
  18209. return true;
  18210. };
  18211. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  18212. var scene = this.getScene();
  18213. var defines = subMesh._materialDefines;
  18214. if (!defines) {
  18215. return;
  18216. }
  18217. var effect = subMesh.effect;
  18218. if (!effect) {
  18219. return;
  18220. }
  18221. this._activeEffect = effect;
  18222. // Matrices
  18223. this.bindOnlyWorldMatrix(world);
  18224. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  18225. if (this._mustRebind(scene, effect)) {
  18226. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  18227. if (defines.INNERGLOW) {
  18228. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  18229. }
  18230. if (defines.BORDER) {
  18231. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  18232. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  18233. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  18234. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  18235. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  18236. }
  18237. if (defines.HOVERLIGHT) {
  18238. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  18239. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  18240. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  18241. }
  18242. if (defines.TEXTURE) {
  18243. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  18244. }
  18245. }
  18246. this._afterBind(mesh, this._activeEffect);
  18247. };
  18248. FluentMaterial.prototype.getActiveTextures = function () {
  18249. var activeTextures = _super.prototype.getActiveTextures.call(this);
  18250. return activeTextures;
  18251. };
  18252. FluentMaterial.prototype.hasTexture = function (texture) {
  18253. if (_super.prototype.hasTexture.call(this, texture)) {
  18254. return true;
  18255. }
  18256. return false;
  18257. };
  18258. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  18259. _super.prototype.dispose.call(this, forceDisposeEffect);
  18260. };
  18261. FluentMaterial.prototype.clone = function (name) {
  18262. var _this = this;
  18263. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  18264. };
  18265. FluentMaterial.prototype.serialize = function () {
  18266. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  18267. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  18268. return serializationObject;
  18269. };
  18270. FluentMaterial.prototype.getClassName = function () {
  18271. return "FluentMaterial";
  18272. };
  18273. // Statics
  18274. FluentMaterial.Parse = function (source, scene, rootUrl) {
  18275. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  18276. };
  18277. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18278. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  18279. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  18280. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  18281. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18282. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  18283. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  18284. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18285. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  18286. ], FluentMaterial.prototype, "albedoColor", void 0);
  18287. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18288. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  18289. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  18290. ], FluentMaterial.prototype, "renderBorders", void 0);
  18291. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18292. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  18293. ], FluentMaterial.prototype, "borderWidth", void 0);
  18294. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18295. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  18296. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  18297. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18298. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  18299. ], FluentMaterial.prototype, "borderMinValue", void 0);
  18300. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18301. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  18302. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  18303. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  18304. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18305. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  18306. ], FluentMaterial.prototype, "hoverRadius", void 0);
  18307. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18308. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  18309. ], FluentMaterial.prototype, "hoverColor", void 0);
  18310. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18311. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  18312. ], FluentMaterial.prototype, "hoverPosition", void 0);
  18313. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18314. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  18315. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  18316. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  18317. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  18318. ], FluentMaterial.prototype, "albedoTexture", void 0);
  18319. return FluentMaterial;
  18320. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  18321. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  18322. /***/ }),
  18323. /***/ "./3D/materials/index.ts":
  18324. /*!*******************************!*\
  18325. !*** ./3D/materials/index.ts ***!
  18326. \*******************************/
  18327. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  18328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18329. "use strict";
  18330. __webpack_require__.r(__webpack_exports__);
  18331. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  18332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  18333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  18334. /***/ }),
  18335. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  18336. /*!*************************************************!*\
  18337. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  18338. \*************************************************/
  18339. /*! exports provided: fluentPixelShader */
  18340. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18341. "use strict";
  18342. __webpack_require__.r(__webpack_exports__);
  18343. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  18344. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  18345. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  18346. var name = 'fluentPixelShader';
  18347. 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}";
  18348. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  18349. /** @hidden */
  18350. var fluentPixelShader = { name: name, shader: shader };
  18351. /***/ }),
  18352. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  18353. /*!***********************************************!*\
  18354. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  18355. \***********************************************/
  18356. /*! exports provided: fluentVertexShader */
  18357. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18358. "use strict";
  18359. __webpack_require__.r(__webpack_exports__);
  18360. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  18361. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  18362. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  18363. var name = 'fluentVertexShader';
  18364. 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";
  18365. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  18366. /** @hidden */
  18367. var fluentVertexShader = { name: name, shader: shader };
  18368. /***/ }),
  18369. /***/ "./3D/vector3WithInfo.ts":
  18370. /*!*******************************!*\
  18371. !*** ./3D/vector3WithInfo.ts ***!
  18372. \*******************************/
  18373. /*! exports provided: Vector3WithInfo */
  18374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18375. "use strict";
  18376. __webpack_require__.r(__webpack_exports__);
  18377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  18378. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  18379. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  18380. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  18381. /**
  18382. * Class used to transport Vector3 information for pointer events
  18383. */
  18384. var Vector3WithInfo = /** @class */ (function (_super) {
  18385. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  18386. /**
  18387. * Creates a new Vector3WithInfo
  18388. * @param source defines the vector3 data to transport
  18389. * @param buttonIndex defines the current mouse button index
  18390. */
  18391. function Vector3WithInfo(source,
  18392. /** defines the current mouse button index */
  18393. buttonIndex) {
  18394. if (buttonIndex === void 0) { buttonIndex = 0; }
  18395. var _this = _super.call(this, source.x, source.y, source.z) || this;
  18396. _this.buttonIndex = buttonIndex;
  18397. return _this;
  18398. }
  18399. return Vector3WithInfo;
  18400. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  18401. /***/ }),
  18402. /***/ "./index.ts":
  18403. /*!******************!*\
  18404. !*** ./index.ts ***!
  18405. \******************/
  18406. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, FocusableButton, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, ToggleButton, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, TouchButton3D, TouchMeshButton3D, TouchHolographicButton, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  18407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18408. "use strict";
  18409. __webpack_require__.r(__webpack_exports__);
  18410. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  18411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  18412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  18413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  18414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  18415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  18416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  18417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["FocusableButton"]; });
  18418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  18419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  18420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  18421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  18422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  18423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  18424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  18425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  18426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  18427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  18428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  18429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  18430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  18431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  18432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  18433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  18434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  18435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ToggleButton"]; });
  18436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  18437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  18438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  18439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  18440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  18441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  18442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  18443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  18444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  18445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  18446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  18447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  18448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  18449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  18450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  18451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  18452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  18453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  18454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  18455. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  18456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  18457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  18458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  18459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  18460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  18461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  18462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  18463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  18464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  18465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  18466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  18467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["TouchButton3D"]; });
  18468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchMeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["TouchMeshButton3D"]; });
  18469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchHolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["TouchHolographicButton"]; });
  18470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  18471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  18472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  18473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  18474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  18475. /***/ }),
  18476. /***/ "./legacy/legacy.ts":
  18477. /*!**************************!*\
  18478. !*** ./legacy/legacy.ts ***!
  18479. \**************************/
  18480. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, FocusableButton, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, TextWrapper, ToggleButton, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, TouchButton3D, TouchMeshButton3D, TouchHolographicButton, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  18481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18482. "use strict";
  18483. __webpack_require__.r(__webpack_exports__);
  18484. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  18485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  18486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  18487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  18488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  18489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  18490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  18491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FocusableButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FocusableButton"]; });
  18492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  18493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  18494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  18495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  18496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  18497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  18498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  18499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  18500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  18501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  18502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  18503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  18504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  18505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  18506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  18507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  18508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapper"]; });
  18509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToggleButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToggleButton"]; });
  18510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  18511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  18512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  18513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  18514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  18515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  18516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  18517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  18518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  18519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  18520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  18521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  18522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  18523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  18524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  18525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  18526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  18527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  18528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  18529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  18530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  18531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  18532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  18533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  18534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  18535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  18536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  18537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  18538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  18539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  18540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchButton3D"]; });
  18541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchMeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchMeshButton3D"]; });
  18542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchHolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchHolographicButton"]; });
  18543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  18544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  18545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  18546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  18547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  18548. /**
  18549. * Legacy support, defining window.BABYLON.GUI (global variable).
  18550. *
  18551. * This is the entry point for the UMD module.
  18552. * The entry point for a future ESM package should be index.ts
  18553. */
  18554. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  18555. if (typeof globalObject !== "undefined") {
  18556. globalObject.BABYLON = globalObject.BABYLON || {};
  18557. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  18558. }
  18559. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  18560. /***/ }),
  18561. /***/ "babylonjs/Misc/observable":
  18562. /*!****************************************************************************************************!*\
  18563. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  18564. \****************************************************************************************************/
  18565. /*! no static exports found */
  18566. /***/ (function(module, exports) {
  18567. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  18568. /***/ })
  18569. /******/ });
  18570. });
  18571. //# sourceMappingURL=babylon.gui.js.map