babylon.gui.js 762 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485
  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:/Dev/Babylon/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 (b.hasOwnProperty(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, exports) {
  230. for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, 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 (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  310. __setModuleDefault(result, mod);
  311. return result;
  312. }
  313. function __importDefault(mod) {
  314. return (mod && mod.__esModule) ? mod : { default: mod };
  315. }
  316. function __classPrivateFieldGet(receiver, privateMap) {
  317. if (!privateMap.has(receiver)) {
  318. throw new TypeError("attempted to get private field on non-instance");
  319. }
  320. return privateMap.get(receiver);
  321. }
  322. function __classPrivateFieldSet(receiver, privateMap, value) {
  323. if (!privateMap.has(receiver)) {
  324. throw new TypeError("attempted to set private field on non-instance");
  325. }
  326. privateMap.set(receiver, value);
  327. return value;
  328. }
  329. /***/ }),
  330. /***/ "../../node_modules/webpack/buildin/global.js":
  331. /*!***********************************!*\
  332. !*** (webpack)/buildin/global.js ***!
  333. \***********************************/
  334. /*! no static exports found */
  335. /***/ (function(module, exports) {
  336. var g;
  337. // This works in non-strict mode
  338. g = (function() {
  339. return this;
  340. })();
  341. try {
  342. // This works if eval is allowed (see CSP)
  343. g = g || new Function("return this")();
  344. } catch (e) {
  345. // This works if the window reference is available
  346. if (typeof window === "object") g = window;
  347. }
  348. // g can still be undefined, but nothing to do about it...
  349. // We return undefined, instead of nothing here, so it's
  350. // easier to handle this case. if(!global) { ...}
  351. module.exports = g;
  352. /***/ }),
  353. /***/ "./2D/adtInstrumentation.ts":
  354. /*!**********************************!*\
  355. !*** ./2D/adtInstrumentation.ts ***!
  356. \**********************************/
  357. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  359. "use strict";
  360. __webpack_require__.r(__webpack_exports__);
  361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  362. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Misc/observable");
  363. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  364. /**
  365. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  366. */
  367. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  368. /**
  369. * Instantiates a new advanced dynamic texture instrumentation.
  370. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  371. * @param texture Defines the AdvancedDynamicTexture to instrument
  372. */
  373. function AdvancedDynamicTextureInstrumentation(
  374. /**
  375. * Define the instrumented AdvancedDynamicTexture.
  376. */
  377. texture) {
  378. this.texture = texture;
  379. this._captureRenderTime = false;
  380. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  381. this._captureLayoutTime = false;
  382. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  383. // Observers
  384. this._onBeginRenderObserver = null;
  385. this._onEndRenderObserver = null;
  386. this._onBeginLayoutObserver = null;
  387. this._onEndLayoutObserver = null;
  388. }
  389. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  390. // Properties
  391. /**
  392. * Gets the perf counter used to capture render time
  393. */
  394. get: function () {
  395. return this._renderTime;
  396. },
  397. enumerable: false,
  398. configurable: true
  399. });
  400. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  401. /**
  402. * Gets the perf counter used to capture layout time
  403. */
  404. get: function () {
  405. return this._layoutTime;
  406. },
  407. enumerable: false,
  408. configurable: true
  409. });
  410. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  411. /**
  412. * Enable or disable the render time capture
  413. */
  414. get: function () {
  415. return this._captureRenderTime;
  416. },
  417. set: function (value) {
  418. var _this = this;
  419. if (value === this._captureRenderTime) {
  420. return;
  421. }
  422. this._captureRenderTime = value;
  423. if (value) {
  424. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  425. _this._renderTime.beginMonitoring();
  426. });
  427. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  428. _this._renderTime.endMonitoring(true);
  429. });
  430. }
  431. else {
  432. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  433. this._onBeginRenderObserver = null;
  434. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  435. this._onEndRenderObserver = null;
  436. }
  437. },
  438. enumerable: false,
  439. configurable: true
  440. });
  441. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  442. /**
  443. * Enable or disable the layout time capture
  444. */
  445. get: function () {
  446. return this._captureLayoutTime;
  447. },
  448. set: function (value) {
  449. var _this = this;
  450. if (value === this._captureLayoutTime) {
  451. return;
  452. }
  453. this._captureLayoutTime = value;
  454. if (value) {
  455. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  456. _this._layoutTime.beginMonitoring();
  457. });
  458. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  459. _this._layoutTime.endMonitoring(true);
  460. });
  461. }
  462. else {
  463. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  464. this._onBeginLayoutObserver = null;
  465. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  466. this._onEndLayoutObserver = null;
  467. }
  468. },
  469. enumerable: false,
  470. configurable: true
  471. });
  472. /**
  473. * Dispose and release associated resources.
  474. */
  475. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  476. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  477. this._onBeginRenderObserver = null;
  478. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  479. this._onEndRenderObserver = null;
  480. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  481. this._onBeginLayoutObserver = null;
  482. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  483. this._onEndLayoutObserver = null;
  484. this.texture = null;
  485. };
  486. return AdvancedDynamicTextureInstrumentation;
  487. }());
  488. /***/ }),
  489. /***/ "./2D/advancedDynamicTexture.ts":
  490. /*!**************************************!*\
  491. !*** ./2D/advancedDynamicTexture.ts ***!
  492. \**************************************/
  493. /*! exports provided: AdvancedDynamicTexture */
  494. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  495. "use strict";
  496. __webpack_require__.r(__webpack_exports__);
  497. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  498. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  499. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  500. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  501. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  502. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  503. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  504. /**
  505. * Class used to create texture to support 2D GUI elements
  506. * @see https://doc.babylonjs.com/how_to/gui
  507. */
  508. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  509. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  510. /**
  511. * Creates a new AdvancedDynamicTexture
  512. * @param name defines the name of the texture
  513. * @param width defines the width of the texture
  514. * @param height defines the height of the texture
  515. * @param scene defines the hosting scene
  516. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  517. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  518. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  519. */
  520. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode, invertY) {
  521. if (width === void 0) { width = 0; }
  522. if (height === void 0) { height = 0; }
  523. if (generateMipMaps === void 0) { generateMipMaps = false; }
  524. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  525. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA, invertY) || this;
  526. _this._isDirty = false;
  527. /** @hidden */
  528. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  529. /** @hidden */
  530. _this._lastControlOver = {};
  531. /** @hidden */
  532. _this._lastControlDown = {};
  533. /** @hidden */
  534. _this._capturingControl = {};
  535. /** @hidden */
  536. _this._linkedControls = new Array();
  537. _this._isFullscreen = false;
  538. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  539. _this._idealWidth = 0;
  540. _this._idealHeight = 0;
  541. _this._useSmallestIdeal = false;
  542. _this._renderAtIdealSize = false;
  543. _this._blockNextFocusCheck = false;
  544. _this._renderScale = 1;
  545. _this._cursorChanged = false;
  546. _this._defaultMousePointerId = 0;
  547. /** @hidden */
  548. _this._numLayoutCalls = 0;
  549. /** @hidden */
  550. _this._numRenderCalls = 0;
  551. /**
  552. * Define type to string to ensure compatibility across browsers
  553. * Safari doesn't support DataTransfer constructor
  554. */
  555. _this._clipboardData = "";
  556. /**
  557. * Observable event triggered each time an clipboard event is received from the rendering canvas
  558. */
  559. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  560. /**
  561. * Observable event triggered each time a pointer down is intercepted by a control
  562. */
  563. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  564. /**
  565. * Observable event triggered before layout is evaluated
  566. */
  567. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  568. /**
  569. * Observable event triggered after the layout was evaluated
  570. */
  571. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  572. /**
  573. * Observable event triggered before the texture is rendered
  574. */
  575. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  576. /**
  577. * Observable event triggered after the texture was rendered
  578. */
  579. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  580. /**
  581. * Gets or sets a boolean defining if alpha is stored as premultiplied
  582. */
  583. _this.premulAlpha = false;
  584. _this._useInvalidateRectOptimization = true;
  585. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  586. _this._invalidatedRectangle = null;
  587. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  588. /** @hidden */
  589. _this.onClipboardCopy = function (rawEvt) {
  590. var evt = rawEvt;
  591. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  592. _this.onClipboardObservable.notifyObservers(ev);
  593. evt.preventDefault();
  594. };
  595. /** @hidden */
  596. _this.onClipboardCut = function (rawEvt) {
  597. var evt = rawEvt;
  598. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  599. _this.onClipboardObservable.notifyObservers(ev);
  600. evt.preventDefault();
  601. };
  602. /** @hidden */
  603. _this.onClipboardPaste = function (rawEvt) {
  604. var evt = rawEvt;
  605. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  606. _this.onClipboardObservable.notifyObservers(ev);
  607. evt.preventDefault();
  608. };
  609. scene = _this.getScene();
  610. if (!scene || !_this._texture) {
  611. return _this;
  612. }
  613. _this._rootElement = scene.getEngine().getInputElement();
  614. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  615. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  616. if (!_this._focusedControl) {
  617. return;
  618. }
  619. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  620. _this._focusedControl.processKeyboard(info.event);
  621. }
  622. info.skipOnPointerObservable = true;
  623. });
  624. _this._rootContainer._link(_this);
  625. _this.hasAlpha = true;
  626. if (!width || !height) {
  627. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  628. _this._onResize();
  629. }
  630. _this._texture.isReady = true;
  631. return _this;
  632. }
  633. Object.defineProperty(AdvancedDynamicTexture.prototype, "numLayoutCalls", {
  634. /** Gets the number of layout calls made the last time the ADT has been rendered */
  635. get: function () {
  636. return this._numLayoutCalls;
  637. },
  638. enumerable: false,
  639. configurable: true
  640. });
  641. Object.defineProperty(AdvancedDynamicTexture.prototype, "numRenderCalls", {
  642. /** Gets the number of render calls made the last time the ADT has been rendered */
  643. get: function () {
  644. return this._numRenderCalls;
  645. },
  646. enumerable: false,
  647. configurable: true
  648. });
  649. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  650. /**
  651. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  652. * Useful when you want more antialiasing
  653. */
  654. get: function () {
  655. return this._renderScale;
  656. },
  657. set: function (value) {
  658. if (value === this._renderScale) {
  659. return;
  660. }
  661. this._renderScale = value;
  662. this._onResize();
  663. },
  664. enumerable: false,
  665. configurable: true
  666. });
  667. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  668. /** Gets or sets the background color */
  669. get: function () {
  670. return this._background;
  671. },
  672. set: function (value) {
  673. if (this._background === value) {
  674. return;
  675. }
  676. this._background = value;
  677. this.markAsDirty();
  678. },
  679. enumerable: false,
  680. configurable: true
  681. });
  682. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  683. /**
  684. * Gets or sets the ideal width used to design controls.
  685. * The GUI will then rescale everything accordingly
  686. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  687. */
  688. get: function () {
  689. return this._idealWidth;
  690. },
  691. set: function (value) {
  692. if (this._idealWidth === value) {
  693. return;
  694. }
  695. this._idealWidth = value;
  696. this.markAsDirty();
  697. this._rootContainer._markAllAsDirty();
  698. },
  699. enumerable: false,
  700. configurable: true
  701. });
  702. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  703. /**
  704. * Gets or sets the ideal height used to design controls.
  705. * The GUI will then rescale everything accordingly
  706. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  707. */
  708. get: function () {
  709. return this._idealHeight;
  710. },
  711. set: function (value) {
  712. if (this._idealHeight === value) {
  713. return;
  714. }
  715. this._idealHeight = value;
  716. this.markAsDirty();
  717. this._rootContainer._markAllAsDirty();
  718. },
  719. enumerable: false,
  720. configurable: true
  721. });
  722. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  723. /**
  724. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  725. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  726. */
  727. get: function () {
  728. return this._useSmallestIdeal;
  729. },
  730. set: function (value) {
  731. if (this._useSmallestIdeal === value) {
  732. return;
  733. }
  734. this._useSmallestIdeal = value;
  735. this.markAsDirty();
  736. this._rootContainer._markAllAsDirty();
  737. },
  738. enumerable: false,
  739. configurable: true
  740. });
  741. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  742. /**
  743. * Gets or sets a boolean indicating if adaptive scaling must be used
  744. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  745. */
  746. get: function () {
  747. return this._renderAtIdealSize;
  748. },
  749. set: function (value) {
  750. if (this._renderAtIdealSize === value) {
  751. return;
  752. }
  753. this._renderAtIdealSize = value;
  754. this._onResize();
  755. },
  756. enumerable: false,
  757. configurable: true
  758. });
  759. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealRatio", {
  760. /**
  761. * Gets the ratio used when in "ideal mode"
  762. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  763. * */
  764. get: function () {
  765. var rwidth = 0;
  766. var rheight = 0;
  767. if (this._idealWidth) {
  768. rwidth = (this.getSize().width) / this._idealWidth;
  769. }
  770. if (this._idealHeight) {
  771. rheight = (this.getSize().height) / this._idealHeight;
  772. }
  773. if (this._useSmallestIdeal && this._idealWidth && this._idealHeight) {
  774. return window.innerWidth < window.innerHeight ? rwidth : rheight;
  775. }
  776. if (this._idealWidth) { // horizontal
  777. return rwidth;
  778. }
  779. if (this._idealHeight) { // vertical
  780. return rheight;
  781. }
  782. return 1;
  783. },
  784. enumerable: false,
  785. configurable: true
  786. });
  787. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  788. /**
  789. * Gets the underlying layer used to render the texture when in fullscreen mode
  790. */
  791. get: function () {
  792. return this._layerToDispose;
  793. },
  794. enumerable: false,
  795. configurable: true
  796. });
  797. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  798. /**
  799. * Gets the root container control
  800. */
  801. get: function () {
  802. return this._rootContainer;
  803. },
  804. enumerable: false,
  805. configurable: true
  806. });
  807. /**
  808. * Returns an array containing the root container.
  809. * This is mostly used to let the Inspector introspects the ADT
  810. * @returns an array containing the rootContainer
  811. */
  812. AdvancedDynamicTexture.prototype.getChildren = function () {
  813. return [this._rootContainer];
  814. };
  815. /**
  816. * Will return all controls that are inside this texture
  817. * @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
  818. * @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
  819. * @return all child controls
  820. */
  821. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  822. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  823. };
  824. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  825. /**
  826. * Gets or sets the current focused control
  827. */
  828. get: function () {
  829. return this._focusedControl;
  830. },
  831. set: function (control) {
  832. if (this._focusedControl == control) {
  833. return;
  834. }
  835. if (this._focusedControl) {
  836. this._focusedControl.onBlur();
  837. }
  838. if (control) {
  839. control.onFocus();
  840. }
  841. this._focusedControl = control;
  842. },
  843. enumerable: false,
  844. configurable: true
  845. });
  846. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  847. /**
  848. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  849. */
  850. get: function () {
  851. if (!this.layer) {
  852. return true;
  853. }
  854. return (!this.layer.isBackground);
  855. },
  856. set: function (value) {
  857. if (!this.layer) {
  858. return;
  859. }
  860. if (this.layer.isBackground === !value) {
  861. return;
  862. }
  863. this.layer.isBackground = !value;
  864. },
  865. enumerable: false,
  866. configurable: true
  867. });
  868. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  869. /**
  870. * Gets or set information about clipboardData
  871. */
  872. get: function () {
  873. return this._clipboardData;
  874. },
  875. set: function (value) {
  876. this._clipboardData = value;
  877. },
  878. enumerable: false,
  879. configurable: true
  880. });
  881. /**
  882. * Get the current class name of the texture useful for serialization or dynamic coding.
  883. * @returns "AdvancedDynamicTexture"
  884. */
  885. AdvancedDynamicTexture.prototype.getClassName = function () {
  886. return "AdvancedDynamicTexture";
  887. };
  888. /**
  889. * Function used to execute a function on all controls
  890. * @param func defines the function to execute
  891. * @param container defines the container where controls belong. If null the root container will be used
  892. */
  893. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  894. if (!container) {
  895. container = this._rootContainer;
  896. }
  897. func(container);
  898. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  899. var child = _a[_i];
  900. if (child.children) {
  901. this.executeOnAllControls(func, child);
  902. continue;
  903. }
  904. func(child);
  905. }
  906. };
  907. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  908. /**
  909. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  910. */
  911. get: function () {
  912. return this._useInvalidateRectOptimization;
  913. },
  914. set: function (value) {
  915. this._useInvalidateRectOptimization = value;
  916. },
  917. enumerable: false,
  918. configurable: true
  919. });
  920. /**
  921. * Invalidates a rectangle area on the gui texture
  922. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  923. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  924. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  925. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  926. */
  927. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  928. if (!this._useInvalidateRectOptimization) {
  929. return;
  930. }
  931. if (!this._invalidatedRectangle) {
  932. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  933. }
  934. else {
  935. // Compute intersection
  936. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  937. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  938. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  939. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  940. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  941. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  942. }
  943. };
  944. /**
  945. * Marks the texture as dirty forcing a complete update
  946. */
  947. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  948. this._isDirty = true;
  949. };
  950. /**
  951. * Helper function used to create a new style
  952. * @returns a new style
  953. * @see https://doc.babylonjs.com/how_to/gui#styles
  954. */
  955. AdvancedDynamicTexture.prototype.createStyle = function () {
  956. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  957. };
  958. /**
  959. * Adds a new control to the root container
  960. * @param control defines the control to add
  961. * @returns the current texture
  962. */
  963. AdvancedDynamicTexture.prototype.addControl = function (control) {
  964. this._rootContainer.addControl(control);
  965. return this;
  966. };
  967. /**
  968. * Removes a control from the root container
  969. * @param control defines the control to remove
  970. * @returns the current texture
  971. */
  972. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  973. this._rootContainer.removeControl(control);
  974. return this;
  975. };
  976. /**
  977. * Release all resources
  978. */
  979. AdvancedDynamicTexture.prototype.dispose = function () {
  980. var scene = this.getScene();
  981. if (!scene) {
  982. return;
  983. }
  984. this._rootElement = null;
  985. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  986. if (this._resizeObserver) {
  987. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  988. }
  989. if (this._pointerMoveObserver) {
  990. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  991. }
  992. if (this._pointerObserver) {
  993. scene.onPointerObservable.remove(this._pointerObserver);
  994. }
  995. if (this._preKeyboardObserver) {
  996. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  997. }
  998. if (this._canvasPointerOutObserver) {
  999. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  1000. }
  1001. if (this._canvasBlurObserver) {
  1002. scene.getEngine().onCanvasBlurObservable.remove(this._canvasBlurObserver);
  1003. }
  1004. if (this._layerToDispose) {
  1005. this._layerToDispose.texture = null;
  1006. this._layerToDispose.dispose();
  1007. this._layerToDispose = null;
  1008. }
  1009. this._rootContainer.dispose();
  1010. this.onClipboardObservable.clear();
  1011. this.onControlPickedObservable.clear();
  1012. this.onBeginRenderObservable.clear();
  1013. this.onEndRenderObservable.clear();
  1014. this.onBeginLayoutObservable.clear();
  1015. this.onEndLayoutObservable.clear();
  1016. _super.prototype.dispose.call(this);
  1017. };
  1018. AdvancedDynamicTexture.prototype._onResize = function () {
  1019. var scene = this.getScene();
  1020. if (!scene) {
  1021. return;
  1022. }
  1023. // Check size
  1024. var engine = scene.getEngine();
  1025. var textureSize = this.getSize();
  1026. var renderWidth = engine.getRenderWidth() * this._renderScale;
  1027. var renderHeight = engine.getRenderHeight() * this._renderScale;
  1028. if (this._renderAtIdealSize) {
  1029. if (this._idealWidth) {
  1030. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  1031. renderWidth = this._idealWidth;
  1032. }
  1033. else if (this._idealHeight) {
  1034. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  1035. renderHeight = this._idealHeight;
  1036. }
  1037. }
  1038. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  1039. this.scaleTo(renderWidth, renderHeight);
  1040. this.markAsDirty();
  1041. if (this._idealWidth || this._idealHeight) {
  1042. this._rootContainer._markAllAsDirty();
  1043. }
  1044. }
  1045. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  1046. };
  1047. /** @hidden */
  1048. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  1049. var engine = scene.getEngine();
  1050. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  1051. };
  1052. /**
  1053. * Get screen coordinates for a vector3
  1054. * @param position defines the position to project
  1055. * @param worldMatrix defines the world matrix to use
  1056. * @returns the projected position
  1057. */
  1058. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  1059. var scene = this.getScene();
  1060. if (!scene) {
  1061. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  1062. }
  1063. var globalViewport = this._getGlobalViewport(scene);
  1064. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1065. projectedPosition.scaleInPlace(this.renderScale);
  1066. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  1067. };
  1068. /**
  1069. * Get screen coordinates for a vector3
  1070. * @param position defines the position to project
  1071. * @param worldMatrix defines the world matrix to use
  1072. * @returns the projected position with Z
  1073. */
  1074. AdvancedDynamicTexture.prototype.getProjectedPositionWithZ = function (position, worldMatrix) {
  1075. var scene = this.getScene();
  1076. if (!scene) {
  1077. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  1078. }
  1079. var globalViewport = this._getGlobalViewport(scene);
  1080. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  1081. projectedPosition.scaleInPlace(this.renderScale);
  1082. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"](projectedPosition.x, projectedPosition.y, projectedPosition.z);
  1083. };
  1084. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  1085. if (this._layerToDispose) {
  1086. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  1087. return;
  1088. }
  1089. }
  1090. if (this._isFullscreen && this._linkedControls.length) {
  1091. var scene = this.getScene();
  1092. if (!scene) {
  1093. return;
  1094. }
  1095. var globalViewport = this._getGlobalViewport(scene);
  1096. var _loop_1 = function (control) {
  1097. if (!control.isVisible) {
  1098. return "continue";
  1099. }
  1100. var mesh = control._linkedMesh;
  1101. if (!mesh || mesh.isDisposed()) {
  1102. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1103. control.linkWithMesh(null);
  1104. });
  1105. return "continue";
  1106. }
  1107. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1108. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1109. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1110. control.notRenderable = true;
  1111. return "continue";
  1112. }
  1113. control.notRenderable = false;
  1114. // Account for RenderScale.
  1115. projectedPosition.scaleInPlace(this_1.renderScale);
  1116. control._moveToProjectedPosition(projectedPosition);
  1117. };
  1118. var this_1 = this;
  1119. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  1120. var control = _a[_i];
  1121. _loop_1(control);
  1122. }
  1123. }
  1124. if (!this._isDirty && !this._rootContainer.isDirty) {
  1125. return;
  1126. }
  1127. this._isDirty = false;
  1128. this._render();
  1129. this.update(true, this.premulAlpha);
  1130. };
  1131. AdvancedDynamicTexture.prototype._render = function () {
  1132. var textureSize = this.getSize();
  1133. var renderWidth = textureSize.width;
  1134. var renderHeight = textureSize.height;
  1135. var context = this.getContext();
  1136. context.font = "18px Arial";
  1137. context.strokeStyle = "white";
  1138. // Layout
  1139. this.onBeginLayoutObservable.notifyObservers(this);
  1140. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1141. this._numLayoutCalls = 0;
  1142. this._rootContainer._layout(measure, context);
  1143. this.onEndLayoutObservable.notifyObservers(this);
  1144. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1145. // Clear
  1146. if (this._invalidatedRectangle) {
  1147. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1148. }
  1149. else {
  1150. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1151. }
  1152. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1153. if (this._background) {
  1154. context.save();
  1155. context.fillStyle = this._background;
  1156. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1157. context.restore();
  1158. }
  1159. // Render
  1160. this.onBeginRenderObservable.notifyObservers(this);
  1161. this._numRenderCalls = 0;
  1162. this._rootContainer._render(context, this._invalidatedRectangle);
  1163. this.onEndRenderObservable.notifyObservers(this);
  1164. this._invalidatedRectangle = null;
  1165. };
  1166. /** @hidden */
  1167. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1168. if (this._rootElement) {
  1169. this._rootElement.style.cursor = cursor;
  1170. this._cursorChanged = true;
  1171. }
  1172. };
  1173. /** @hidden */
  1174. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1175. this._lastControlDown[pointerId] = control;
  1176. this.onControlPickedObservable.notifyObservers(control);
  1177. };
  1178. AdvancedDynamicTexture.prototype._doPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  1179. var scene = this.getScene();
  1180. if (!scene) {
  1181. return;
  1182. }
  1183. var engine = scene.getEngine();
  1184. var textureSize = this.getSize();
  1185. if (this._isFullscreen) {
  1186. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1187. var viewport = camera.viewport;
  1188. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1189. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1190. }
  1191. if (this._capturingControl[pointerId]) {
  1192. this._capturingControl[pointerId]._processObservables(type, x, y, pi, pointerId, buttonIndex);
  1193. return;
  1194. }
  1195. this._cursorChanged = false;
  1196. if (!this._rootContainer._processPicking(x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY)) {
  1197. this._changeCursor("");
  1198. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1199. if (this._lastControlOver[pointerId]) {
  1200. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId], pi);
  1201. delete this._lastControlOver[pointerId];
  1202. }
  1203. }
  1204. }
  1205. if (!this._cursorChanged) {
  1206. this._changeCursor("");
  1207. }
  1208. this._manageFocus();
  1209. };
  1210. /** @hidden */
  1211. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1212. for (var pointerId in list) {
  1213. if (!list.hasOwnProperty(pointerId)) {
  1214. continue;
  1215. }
  1216. var lastControlOver = list[pointerId];
  1217. if (lastControlOver === control) {
  1218. delete list[pointerId];
  1219. }
  1220. }
  1221. };
  1222. /** @hidden */
  1223. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1224. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1225. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1226. };
  1227. /** Attach to all scene events required to support pointer events */
  1228. AdvancedDynamicTexture.prototype.attach = function () {
  1229. var _this = this;
  1230. var scene = this.getScene();
  1231. if (!scene) {
  1232. return;
  1233. }
  1234. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1235. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1236. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1237. return;
  1238. }
  1239. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1240. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1241. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN
  1242. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  1243. return;
  1244. }
  1245. if (!scene) {
  1246. return;
  1247. }
  1248. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE && pi.event.pointerId) {
  1249. _this._defaultMousePointerId = pi.event.pointerId; // This is required to make sure we have the correct pointer ID for wheel
  1250. }
  1251. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1252. var engine = scene.getEngine();
  1253. if (!camera) {
  1254. tempViewport.x = 0;
  1255. tempViewport.y = 0;
  1256. tempViewport.width = engine.getRenderWidth();
  1257. tempViewport.height = engine.getRenderHeight();
  1258. }
  1259. else {
  1260. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1261. }
  1262. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1263. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1264. _this._shouldBlockPointer = false;
  1265. // Do picking modifies _shouldBlockPointer
  1266. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1267. _this._doPicking(x, y, pi, pi.type, pointerId, pi.event.button, pi.event.deltaX, pi.event.deltaY);
  1268. // Avoid overwriting a true skipOnPointerObservable to false
  1269. if (_this._shouldBlockPointer) {
  1270. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1271. }
  1272. });
  1273. this._attachToOnPointerOut(scene);
  1274. this._attachToOnBlur(scene);
  1275. };
  1276. /**
  1277. * Register the clipboard Events onto the canvas
  1278. */
  1279. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1280. self.addEventListener("copy", this.onClipboardCopy, false);
  1281. self.addEventListener("cut", this.onClipboardCut, false);
  1282. self.addEventListener("paste", this.onClipboardPaste, false);
  1283. };
  1284. /**
  1285. * Unregister the clipboard Events from the canvas
  1286. */
  1287. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1288. self.removeEventListener("copy", this.onClipboardCopy);
  1289. self.removeEventListener("cut", this.onClipboardCut);
  1290. self.removeEventListener("paste", this.onClipboardPaste);
  1291. };
  1292. /**
  1293. * Connect the texture to a hosting mesh to enable interactions
  1294. * @param mesh defines the mesh to attach to
  1295. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1296. */
  1297. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1298. var _this = this;
  1299. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1300. var scene = this.getScene();
  1301. if (!scene) {
  1302. return;
  1303. }
  1304. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1305. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1306. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1307. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1308. return;
  1309. }
  1310. var pointerId = pi.event.pointerId || _this._defaultMousePointerId;
  1311. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1312. var uv = pi.pickInfo.getTextureCoordinates();
  1313. if (uv) {
  1314. var size = _this.getSize();
  1315. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi, pi.type, pointerId, pi.event.button);
  1316. }
  1317. }
  1318. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1319. if (_this._lastControlDown[pointerId]) {
  1320. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1321. }
  1322. delete _this._lastControlDown[pointerId];
  1323. if (_this.focusedControl) {
  1324. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1325. var canMoveFocus = true;
  1326. if (friendlyControls) {
  1327. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1328. var control = friendlyControls_1[_i];
  1329. // Same host, no need to keep the focus
  1330. if (_this === control._host) {
  1331. continue;
  1332. }
  1333. // Different hosts
  1334. var otherHost = control._host;
  1335. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1336. canMoveFocus = false;
  1337. break;
  1338. }
  1339. }
  1340. }
  1341. if (canMoveFocus) {
  1342. _this.focusedControl = null;
  1343. }
  1344. }
  1345. }
  1346. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1347. if (_this._lastControlOver[pointerId]) {
  1348. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], pi, true);
  1349. }
  1350. delete _this._lastControlOver[pointerId];
  1351. }
  1352. });
  1353. mesh.enablePointerMoveEvents = supportPointerMove;
  1354. this._attachToOnPointerOut(scene);
  1355. this._attachToOnBlur(scene);
  1356. };
  1357. /**
  1358. * Move the focus to a specific control
  1359. * @param control defines the control which will receive the focus
  1360. */
  1361. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1362. this.focusedControl = control;
  1363. this._lastPickedControl = control;
  1364. this._blockNextFocusCheck = true;
  1365. };
  1366. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1367. if (this._blockNextFocusCheck) {
  1368. this._blockNextFocusCheck = false;
  1369. this._lastPickedControl = this._focusedControl;
  1370. return;
  1371. }
  1372. // Focus management
  1373. if (this._focusedControl) {
  1374. if (this._focusedControl !== this._lastPickedControl) {
  1375. if (this._lastPickedControl.isFocusInvisible) {
  1376. return;
  1377. }
  1378. this.focusedControl = null;
  1379. }
  1380. }
  1381. };
  1382. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1383. var _this = this;
  1384. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1385. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1386. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId], null);
  1387. }
  1388. delete _this._lastControlOver[pointerEvent.pointerId];
  1389. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1390. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1391. delete _this._lastControlDown[pointerEvent.pointerId];
  1392. }
  1393. });
  1394. };
  1395. AdvancedDynamicTexture.prototype._attachToOnBlur = function (scene) {
  1396. var _this = this;
  1397. this._canvasBlurObserver = scene.getEngine().onCanvasBlurObservable.add(function (pointerEvent) {
  1398. Object.entries(_this._lastControlDown).forEach(function (_a) {
  1399. var key = _a[0], value = _a[1];
  1400. value._onCanvasBlur();
  1401. });
  1402. _this._lastControlDown = {};
  1403. });
  1404. };
  1405. // Statics
  1406. /**
  1407. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1408. * @param mesh defines the mesh which will receive the texture
  1409. * @param width defines the texture width (1024 by default)
  1410. * @param height defines the texture height (1024 by default)
  1411. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1412. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1413. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  1414. * @returns a new AdvancedDynamicTexture
  1415. */
  1416. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting, invertY) {
  1417. if (width === void 0) { width = 1024; }
  1418. if (height === void 0) { height = 1024; }
  1419. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1420. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1421. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, invertY);
  1422. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1423. material.backFaceCulling = false;
  1424. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1425. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1426. if (onlyAlphaTesting) {
  1427. material.diffuseTexture = result;
  1428. material.emissiveTexture = result;
  1429. result.hasAlpha = true;
  1430. }
  1431. else {
  1432. material.emissiveTexture = result;
  1433. material.opacityTexture = result;
  1434. }
  1435. mesh.material = material;
  1436. result.attachToMesh(mesh, supportPointerMove);
  1437. return result;
  1438. };
  1439. /**
  1440. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1441. * In this mode the texture will rely on a layer for its rendering.
  1442. * This allows it to be treated like any other layer.
  1443. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1444. * LayerMask is set through advancedTexture.layer.layerMask
  1445. * @param name defines name for the texture
  1446. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1447. * @param scene defines the hsoting scene
  1448. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1449. * @returns a new AdvancedDynamicTexture
  1450. */
  1451. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1452. if (foreground === void 0) { foreground = true; }
  1453. if (scene === void 0) { scene = null; }
  1454. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1455. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1456. // Display
  1457. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1458. layer.texture = result;
  1459. result._layerToDispose = layer;
  1460. result._isFullscreen = true;
  1461. // Attach
  1462. result.attach();
  1463. return result;
  1464. };
  1465. return AdvancedDynamicTexture;
  1466. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1467. /***/ }),
  1468. /***/ "./2D/controls/button.ts":
  1469. /*!*******************************!*\
  1470. !*** ./2D/controls/button.ts ***!
  1471. \*******************************/
  1472. /*! exports provided: Button */
  1473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1474. "use strict";
  1475. __webpack_require__.r(__webpack_exports__);
  1476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1477. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1478. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1479. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1480. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1481. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1482. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  1483. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1484. /**
  1485. * Class used to create 2D buttons
  1486. */
  1487. var Button = /** @class */ (function (_super) {
  1488. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1489. /**
  1490. * Creates a new Button
  1491. * @param name defines the name of the button
  1492. */
  1493. function Button(name) {
  1494. var _this = _super.call(this, name) || this;
  1495. _this.name = name;
  1496. /**
  1497. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1498. */
  1499. _this.delegatePickingToChildren = false;
  1500. _this.thickness = 1;
  1501. _this.isPointerBlocker = true;
  1502. var alphaStore = null;
  1503. _this.pointerEnterAnimation = function () {
  1504. alphaStore = _this.alpha;
  1505. _this.alpha -= 0.1;
  1506. };
  1507. _this.pointerOutAnimation = function () {
  1508. if (alphaStore !== null) {
  1509. _this.alpha = alphaStore;
  1510. }
  1511. };
  1512. _this.pointerDownAnimation = function () {
  1513. _this.scaleX -= 0.05;
  1514. _this.scaleY -= 0.05;
  1515. };
  1516. _this.pointerUpAnimation = function () {
  1517. _this.scaleX += 0.05;
  1518. _this.scaleY += 0.05;
  1519. };
  1520. return _this;
  1521. }
  1522. Object.defineProperty(Button.prototype, "image", {
  1523. /**
  1524. * Returns the image part of the button (if any)
  1525. */
  1526. get: function () {
  1527. return this._image;
  1528. },
  1529. enumerable: false,
  1530. configurable: true
  1531. });
  1532. Object.defineProperty(Button.prototype, "textBlock", {
  1533. /**
  1534. * Returns the image part of the button (if any)
  1535. */
  1536. get: function () {
  1537. return this._textBlock;
  1538. },
  1539. enumerable: false,
  1540. configurable: true
  1541. });
  1542. Button.prototype._getTypeName = function () {
  1543. return "Button";
  1544. };
  1545. // While being a container, the button behaves like a control.
  1546. /** @hidden */
  1547. Button.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  1548. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1549. return false;
  1550. }
  1551. if (!_super.prototype.contains.call(this, x, y)) {
  1552. return false;
  1553. }
  1554. if (this.delegatePickingToChildren) {
  1555. var contains = false;
  1556. for (var index = this._children.length - 1; index >= 0; index--) {
  1557. var child = this._children[index];
  1558. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1559. contains = true;
  1560. break;
  1561. }
  1562. }
  1563. if (!contains) {
  1564. return false;
  1565. }
  1566. }
  1567. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  1568. return true;
  1569. };
  1570. /** @hidden */
  1571. Button.prototype._onPointerEnter = function (target, pi) {
  1572. if (!_super.prototype._onPointerEnter.call(this, target, pi)) {
  1573. return false;
  1574. }
  1575. if (this.pointerEnterAnimation) {
  1576. this.pointerEnterAnimation();
  1577. }
  1578. return true;
  1579. };
  1580. /** @hidden */
  1581. Button.prototype._onPointerOut = function (target, pi, force) {
  1582. if (force === void 0) { force = false; }
  1583. if (this.pointerOutAnimation) {
  1584. this.pointerOutAnimation();
  1585. }
  1586. _super.prototype._onPointerOut.call(this, target, pi, force);
  1587. };
  1588. /** @hidden */
  1589. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  1590. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  1591. return false;
  1592. }
  1593. if (this.pointerDownAnimation) {
  1594. this.pointerDownAnimation();
  1595. }
  1596. return true;
  1597. };
  1598. /** @hidden */
  1599. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  1600. if (this.pointerUpAnimation) {
  1601. this.pointerUpAnimation();
  1602. }
  1603. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  1604. };
  1605. // Statics
  1606. /**
  1607. * Creates a new button made with an image and a text
  1608. * @param name defines the name of the button
  1609. * @param text defines the text of the button
  1610. * @param imageUrl defines the url of the image
  1611. * @returns a new Button
  1612. */
  1613. Button.CreateImageButton = function (name, text, imageUrl) {
  1614. var result = new Button(name);
  1615. // Adding text
  1616. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1617. textBlock.textWrapping = true;
  1618. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1619. textBlock.paddingLeft = "20%";
  1620. result.addControl(textBlock);
  1621. // Adding image
  1622. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1623. iconImage.width = "20%";
  1624. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1625. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1626. result.addControl(iconImage);
  1627. // Store
  1628. result._image = iconImage;
  1629. result._textBlock = textBlock;
  1630. return result;
  1631. };
  1632. /**
  1633. * Creates a new button made with an image
  1634. * @param name defines the name of the button
  1635. * @param imageUrl defines the url of the image
  1636. * @returns a new Button
  1637. */
  1638. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1639. var result = new Button(name);
  1640. // Adding image
  1641. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1642. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1643. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1644. result.addControl(iconImage);
  1645. // Store
  1646. result._image = iconImage;
  1647. return result;
  1648. };
  1649. /**
  1650. * Creates a new button made with a text
  1651. * @param name defines the name of the button
  1652. * @param text defines the text of the button
  1653. * @returns a new Button
  1654. */
  1655. Button.CreateSimpleButton = function (name, text) {
  1656. var result = new Button(name);
  1657. // Adding text
  1658. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1659. textBlock.textWrapping = true;
  1660. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1661. result.addControl(textBlock);
  1662. // Store
  1663. result._textBlock = textBlock;
  1664. return result;
  1665. };
  1666. /**
  1667. * Creates a new button made with an image and a centered text
  1668. * @param name defines the name of the button
  1669. * @param text defines the text of the button
  1670. * @param imageUrl defines the url of the image
  1671. * @returns a new Button
  1672. */
  1673. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1674. var result = new Button(name);
  1675. // Adding image
  1676. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1677. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1678. result.addControl(iconImage);
  1679. // Adding text
  1680. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1681. textBlock.textWrapping = true;
  1682. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1683. result.addControl(textBlock);
  1684. // Store
  1685. result._image = iconImage;
  1686. result._textBlock = textBlock;
  1687. return result;
  1688. };
  1689. return Button;
  1690. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1691. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1692. /***/ }),
  1693. /***/ "./2D/controls/checkbox.ts":
  1694. /*!*********************************!*\
  1695. !*** ./2D/controls/checkbox.ts ***!
  1696. \*********************************/
  1697. /*! exports provided: Checkbox */
  1698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1699. "use strict";
  1700. __webpack_require__.r(__webpack_exports__);
  1701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1702. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1703. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1704. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1705. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1706. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1707. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1708. /**
  1709. * Class used to represent a 2D checkbox
  1710. */
  1711. var Checkbox = /** @class */ (function (_super) {
  1712. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1713. /**
  1714. * Creates a new CheckBox
  1715. * @param name defines the control name
  1716. */
  1717. function Checkbox(name) {
  1718. var _this = _super.call(this, name) || this;
  1719. _this.name = name;
  1720. _this._isChecked = false;
  1721. _this._background = "black";
  1722. _this._checkSizeRatio = 0.8;
  1723. _this._thickness = 1;
  1724. /**
  1725. * Observable raised when isChecked property changes
  1726. */
  1727. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1728. _this.isPointerBlocker = true;
  1729. return _this;
  1730. }
  1731. Object.defineProperty(Checkbox.prototype, "thickness", {
  1732. /** Gets or sets border thickness */
  1733. get: function () {
  1734. return this._thickness;
  1735. },
  1736. set: function (value) {
  1737. if (this._thickness === value) {
  1738. return;
  1739. }
  1740. this._thickness = value;
  1741. this._markAsDirty();
  1742. },
  1743. enumerable: false,
  1744. configurable: true
  1745. });
  1746. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1747. /** Gets or sets a value indicating the ratio between overall size and check size */
  1748. get: function () {
  1749. return this._checkSizeRatio;
  1750. },
  1751. set: function (value) {
  1752. value = Math.max(Math.min(1, value), 0);
  1753. if (this._checkSizeRatio === value) {
  1754. return;
  1755. }
  1756. this._checkSizeRatio = value;
  1757. this._markAsDirty();
  1758. },
  1759. enumerable: false,
  1760. configurable: true
  1761. });
  1762. Object.defineProperty(Checkbox.prototype, "background", {
  1763. /** Gets or sets background color */
  1764. get: function () {
  1765. return this._background;
  1766. },
  1767. set: function (value) {
  1768. if (this._background === value) {
  1769. return;
  1770. }
  1771. this._background = value;
  1772. this._markAsDirty();
  1773. },
  1774. enumerable: false,
  1775. configurable: true
  1776. });
  1777. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1778. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1779. get: function () {
  1780. return this._isChecked;
  1781. },
  1782. set: function (value) {
  1783. if (this._isChecked === value) {
  1784. return;
  1785. }
  1786. this._isChecked = value;
  1787. this._markAsDirty();
  1788. this.onIsCheckedChangedObservable.notifyObservers(value);
  1789. },
  1790. enumerable: false,
  1791. configurable: true
  1792. });
  1793. Checkbox.prototype._getTypeName = function () {
  1794. return "Checkbox";
  1795. };
  1796. /** @hidden */
  1797. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1798. context.save();
  1799. this._applyStates(context);
  1800. var actualWidth = this._currentMeasure.width - this._thickness;
  1801. var actualHeight = this._currentMeasure.height - this._thickness;
  1802. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1803. context.shadowColor = this.shadowColor;
  1804. context.shadowBlur = this.shadowBlur;
  1805. context.shadowOffsetX = this.shadowOffsetX;
  1806. context.shadowOffsetY = this.shadowOffsetY;
  1807. }
  1808. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1809. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1810. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1811. context.shadowBlur = 0;
  1812. context.shadowOffsetX = 0;
  1813. context.shadowOffsetY = 0;
  1814. }
  1815. if (this._isChecked) {
  1816. context.fillStyle = this._isEnabled ? this.color : this._disabledColorItem;
  1817. var offsetWidth = actualWidth * this._checkSizeRatio;
  1818. var offseHeight = actualHeight * this._checkSizeRatio;
  1819. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1820. }
  1821. context.strokeStyle = this.color;
  1822. context.lineWidth = this._thickness;
  1823. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1824. context.restore();
  1825. };
  1826. // Events
  1827. /** @hidden */
  1828. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  1829. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  1830. return false;
  1831. }
  1832. this.isChecked = !this.isChecked;
  1833. return true;
  1834. };
  1835. /**
  1836. * Utility function to easily create a checkbox with a header
  1837. * @param title defines the label to use for the header
  1838. * @param onValueChanged defines the callback to call when value changes
  1839. * @returns a StackPanel containing the checkbox and a textBlock
  1840. */
  1841. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1842. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1843. panel.isVertical = false;
  1844. panel.height = "30px";
  1845. var checkbox = new Checkbox();
  1846. checkbox.width = "20px";
  1847. checkbox.height = "20px";
  1848. checkbox.isChecked = true;
  1849. checkbox.color = "green";
  1850. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1851. panel.addControl(checkbox);
  1852. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1853. header.text = title;
  1854. header.width = "180px";
  1855. header.paddingLeft = "5px";
  1856. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1857. header.color = "white";
  1858. panel.addControl(header);
  1859. return panel;
  1860. };
  1861. return Checkbox;
  1862. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1863. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1864. /***/ }),
  1865. /***/ "./2D/controls/colorpicker.ts":
  1866. /*!************************************!*\
  1867. !*** ./2D/controls/colorpicker.ts ***!
  1868. \************************************/
  1869. /*! exports provided: ColorPicker */
  1870. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1871. "use strict";
  1872. __webpack_require__.r(__webpack_exports__);
  1873. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1874. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1875. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  1876. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1877. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1878. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1879. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1880. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1881. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1882. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1883. /** Class used to create color pickers */
  1884. var ColorPicker = /** @class */ (function (_super) {
  1885. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1886. /**
  1887. * Creates a new ColorPicker
  1888. * @param name defines the control name
  1889. */
  1890. function ColorPicker(name) {
  1891. var _this = _super.call(this, name) || this;
  1892. _this.name = name;
  1893. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1894. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1895. _this._pointerStartedOnSquare = false;
  1896. _this._pointerStartedOnWheel = false;
  1897. _this._squareLeft = 0;
  1898. _this._squareTop = 0;
  1899. _this._squareSize = 0;
  1900. _this._h = 360;
  1901. _this._s = 1;
  1902. _this._v = 1;
  1903. _this._lastPointerDownID = -1;
  1904. /**
  1905. * Observable raised when the value changes
  1906. */
  1907. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1908. // Events
  1909. _this._pointerIsDown = false;
  1910. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1911. _this.size = "200px";
  1912. _this.isPointerBlocker = true;
  1913. return _this;
  1914. }
  1915. Object.defineProperty(ColorPicker.prototype, "value", {
  1916. /** Gets or sets the color of the color picker */
  1917. get: function () {
  1918. return this._value;
  1919. },
  1920. set: function (value) {
  1921. if (this._value.equals(value)) {
  1922. return;
  1923. }
  1924. this._value.copyFrom(value);
  1925. this._value.toHSVToRef(this._tmpColor);
  1926. this._h = this._tmpColor.r;
  1927. this._s = Math.max(this._tmpColor.g, 0.00001);
  1928. this._v = Math.max(this._tmpColor.b, 0.00001);
  1929. this._markAsDirty();
  1930. if (this._value.r <= ColorPicker._Epsilon) {
  1931. this._value.r = 0;
  1932. }
  1933. if (this._value.g <= ColorPicker._Epsilon) {
  1934. this._value.g = 0;
  1935. }
  1936. if (this._value.b <= ColorPicker._Epsilon) {
  1937. this._value.b = 0;
  1938. }
  1939. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1940. this._value.r = 1.0;
  1941. }
  1942. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1943. this._value.g = 1.0;
  1944. }
  1945. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1946. this._value.b = 1.0;
  1947. }
  1948. this.onValueChangedObservable.notifyObservers(this._value);
  1949. },
  1950. enumerable: false,
  1951. configurable: true
  1952. });
  1953. Object.defineProperty(ColorPicker.prototype, "width", {
  1954. /**
  1955. * Gets or sets control width
  1956. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1957. */
  1958. get: function () {
  1959. return this._width.toString(this._host);
  1960. },
  1961. set: function (value) {
  1962. if (this._width.toString(this._host) === value) {
  1963. return;
  1964. }
  1965. if (this._width.fromString(value)) {
  1966. this._height.fromString(value);
  1967. this._markAsDirty();
  1968. }
  1969. },
  1970. enumerable: false,
  1971. configurable: true
  1972. });
  1973. Object.defineProperty(ColorPicker.prototype, "height", {
  1974. /**
  1975. * Gets or sets control height
  1976. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  1977. */
  1978. get: function () {
  1979. return this._height.toString(this._host);
  1980. },
  1981. /** Gets or sets control height */
  1982. set: function (value) {
  1983. if (this._height.toString(this._host) === value) {
  1984. return;
  1985. }
  1986. if (this._height.fromString(value)) {
  1987. this._width.fromString(value);
  1988. this._markAsDirty();
  1989. }
  1990. },
  1991. enumerable: false,
  1992. configurable: true
  1993. });
  1994. Object.defineProperty(ColorPicker.prototype, "size", {
  1995. /** Gets or sets control size */
  1996. get: function () {
  1997. return this.width;
  1998. },
  1999. set: function (value) {
  2000. this.width = value;
  2001. },
  2002. enumerable: false,
  2003. configurable: true
  2004. });
  2005. ColorPicker.prototype._getTypeName = function () {
  2006. return "ColorPicker";
  2007. };
  2008. /** @hidden */
  2009. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  2010. if (parentMeasure.width < parentMeasure.height) {
  2011. this._currentMeasure.height = parentMeasure.width;
  2012. }
  2013. else {
  2014. this._currentMeasure.width = parentMeasure.height;
  2015. }
  2016. };
  2017. ColorPicker.prototype._updateSquareProps = function () {
  2018. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2019. var wheelThickness = radius * .2;
  2020. var innerDiameter = (radius - wheelThickness) * 2;
  2021. var squareSize = innerDiameter / (Math.sqrt(2));
  2022. var offset = radius - squareSize * .5;
  2023. this._squareLeft = this._currentMeasure.left + offset;
  2024. this._squareTop = this._currentMeasure.top + offset;
  2025. this._squareSize = squareSize;
  2026. };
  2027. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  2028. var lgh = context.createLinearGradient(left, top, width + left, top);
  2029. lgh.addColorStop(0, '#fff');
  2030. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  2031. context.fillStyle = lgh;
  2032. context.fillRect(left, top, width, height);
  2033. var lgv = context.createLinearGradient(left, top, left, height + top);
  2034. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  2035. lgv.addColorStop(1, '#000');
  2036. context.fillStyle = lgv;
  2037. context.fillRect(left, top, width, height);
  2038. };
  2039. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  2040. context.beginPath();
  2041. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  2042. context.lineWidth = 3;
  2043. context.strokeStyle = '#333333';
  2044. context.stroke();
  2045. context.beginPath();
  2046. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  2047. context.lineWidth = 3;
  2048. context.strokeStyle = '#ffffff';
  2049. context.stroke();
  2050. };
  2051. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  2052. var canvas = document.createElement("canvas");
  2053. canvas.width = radius * 2;
  2054. canvas.height = radius * 2;
  2055. var context = canvas.getContext("2d");
  2056. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  2057. var data = image.data;
  2058. var color = this._tmpColor;
  2059. var maxDistSq = radius * radius;
  2060. var innerRadius = radius - thickness;
  2061. var minDistSq = innerRadius * innerRadius;
  2062. for (var x = -radius; x < radius; x++) {
  2063. for (var y = -radius; y < radius; y++) {
  2064. var distSq = x * x + y * y;
  2065. if (distSq > maxDistSq || distSq < minDistSq) {
  2066. continue;
  2067. }
  2068. var dist = Math.sqrt(distSq);
  2069. var ang = Math.atan2(y, x);
  2070. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  2071. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  2072. data[index] = color.r * 255;
  2073. data[index + 1] = color.g * 255;
  2074. data[index + 2] = color.b * 255;
  2075. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2076. //apply less alpha to bigger color pickers
  2077. var alphaAmount = .2;
  2078. var maxAlpha = .2;
  2079. var minAlpha = .04;
  2080. var lowerRadius = 50;
  2081. var upperRadius = 150;
  2082. if (radius < lowerRadius) {
  2083. alphaAmount = maxAlpha;
  2084. }
  2085. else if (radius > upperRadius) {
  2086. alphaAmount = minAlpha;
  2087. }
  2088. else {
  2089. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  2090. }
  2091. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  2092. if (alphaRatio < alphaAmount) {
  2093. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  2094. }
  2095. else if (alphaRatio > 1 - alphaAmount) {
  2096. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  2097. }
  2098. else {
  2099. data[index + 3] = 255;
  2100. }
  2101. }
  2102. }
  2103. context.putImageData(image, 0, 0);
  2104. return canvas;
  2105. };
  2106. /** @hidden */
  2107. ColorPicker.prototype._draw = function (context) {
  2108. context.save();
  2109. this._applyStates(context);
  2110. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2111. var wheelThickness = radius * .2;
  2112. var left = this._currentMeasure.left;
  2113. var top = this._currentMeasure.top;
  2114. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  2115. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  2116. }
  2117. this._updateSquareProps();
  2118. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2119. context.shadowColor = this.shadowColor;
  2120. context.shadowBlur = this.shadowBlur;
  2121. context.shadowOffsetX = this.shadowOffsetX;
  2122. context.shadowOffsetY = this.shadowOffsetY;
  2123. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2124. }
  2125. context.drawImage(this._colorWheelCanvas, left, top);
  2126. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2127. context.shadowBlur = 0;
  2128. context.shadowOffsetX = 0;
  2129. context.shadowOffsetY = 0;
  2130. }
  2131. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2132. var cx = this._squareLeft + this._squareSize * this._s;
  2133. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2134. this._drawCircle(cx, cy, radius * .04, context);
  2135. var dist = radius - wheelThickness * .5;
  2136. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2137. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2138. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2139. context.restore();
  2140. };
  2141. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2142. if (this._pointerStartedOnWheel) {
  2143. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2144. var centerX = radius + this._currentMeasure.left;
  2145. var centerY = radius + this._currentMeasure.top;
  2146. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2147. }
  2148. else if (this._pointerStartedOnSquare) {
  2149. this._updateSquareProps();
  2150. this._s = (x - this._squareLeft) / this._squareSize;
  2151. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2152. this._s = Math.min(this._s, 1);
  2153. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2154. this._v = Math.min(this._v, 1);
  2155. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2156. }
  2157. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2158. this.value = this._tmpColor;
  2159. };
  2160. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2161. this._updateSquareProps();
  2162. var left = this._squareLeft;
  2163. var top = this._squareTop;
  2164. var size = this._squareSize;
  2165. if (x >= left && x <= left + size &&
  2166. y >= top && y <= top + size) {
  2167. return true;
  2168. }
  2169. return false;
  2170. };
  2171. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2172. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2173. var centerX = radius + this._currentMeasure.left;
  2174. var centerY = radius + this._currentMeasure.top;
  2175. var wheelThickness = radius * .2;
  2176. var innerRadius = radius - wheelThickness;
  2177. var radiusSq = radius * radius;
  2178. var innerRadiusSq = innerRadius * innerRadius;
  2179. var dx = x - centerX;
  2180. var dy = y - centerY;
  2181. var distSq = dx * dx + dy * dy;
  2182. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2183. return true;
  2184. }
  2185. return false;
  2186. };
  2187. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  2188. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  2189. return false;
  2190. }
  2191. this._pointerIsDown = true;
  2192. this._pointerStartedOnSquare = false;
  2193. this._pointerStartedOnWheel = false;
  2194. // Invert transform
  2195. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2196. var x = this._transformedPosition.x;
  2197. var y = this._transformedPosition.y;
  2198. if (this._isPointOnSquare(x, y)) {
  2199. this._pointerStartedOnSquare = true;
  2200. }
  2201. else if (this._isPointOnWheel(x, y)) {
  2202. this._pointerStartedOnWheel = true;
  2203. }
  2204. this._updateValueFromPointer(x, y);
  2205. this._host._capturingControl[pointerId] = this;
  2206. this._lastPointerDownID = pointerId;
  2207. return true;
  2208. };
  2209. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  2210. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2211. if (pointerId != this._lastPointerDownID) {
  2212. return;
  2213. }
  2214. // Invert transform
  2215. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2216. var x = this._transformedPosition.x;
  2217. var y = this._transformedPosition.y;
  2218. if (this._pointerIsDown) {
  2219. this._updateValueFromPointer(x, y);
  2220. }
  2221. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  2222. };
  2223. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  2224. this._pointerIsDown = false;
  2225. delete this._host._capturingControl[pointerId];
  2226. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick, pi);
  2227. };
  2228. ColorPicker.prototype._onCanvasBlur = function () {
  2229. this._forcePointerUp();
  2230. _super.prototype._onCanvasBlur.call(this);
  2231. };
  2232. /**
  2233. * This function expands the color picker by creating a color picker dialog with manual
  2234. * color value input and the ability to save colors into an array to be used later in
  2235. * subsequent launches of the dialogue.
  2236. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2237. * @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.
  2238. * @returns picked color as a hex string and the saved colors array as hex strings.
  2239. */
  2240. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2241. return new Promise(function (resolve, reject) {
  2242. // Default options
  2243. options.pickerWidth = options.pickerWidth || "640px";
  2244. options.pickerHeight = options.pickerHeight || "400px";
  2245. options.headerHeight = options.headerHeight || "35px";
  2246. options.lastColor = options.lastColor || "#000000";
  2247. options.swatchLimit = options.swatchLimit || 20;
  2248. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2249. // Window size settings
  2250. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2251. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2252. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2253. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2254. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2255. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2256. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2257. // Button Colors
  2258. var buttonColor = "#c0c0c0";
  2259. var buttonBackgroundColor = "#535353";
  2260. var buttonBackgroundHoverColor = "#414141";
  2261. var buttonBackgroundClickColor = "515151";
  2262. var buttonDisabledColor = "#555555";
  2263. var buttonDisabledBackgroundColor = "#454545";
  2264. var currentSwatchesOutlineColor = "#404040";
  2265. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2266. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2267. var iconColorDark = "#aaaaaa";
  2268. var iconColorLight = "#ffffff";
  2269. var closeIconColor;
  2270. // Button settings
  2271. var buttonFontSize;
  2272. var butEdit;
  2273. var buttonWidth;
  2274. var buttonHeight;
  2275. // Input Text Colors
  2276. var inputFieldLabels = ["R", "G", "B"];
  2277. var inputTextBackgroundColor = "#454545";
  2278. var inputTextColor = "#f0f0f0";
  2279. // This is the current color as set by either the picker or by entering a value
  2280. var currentColor;
  2281. // This int is used for naming swatches and serves as the index for calling them from the list
  2282. var swatchNumber;
  2283. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2284. var swatchDrawer;
  2285. var editSwatchMode = false;
  2286. // Color InputText fields that will be updated upon value change
  2287. var picker;
  2288. var rValInt;
  2289. var gValInt;
  2290. var bValInt;
  2291. var rValDec;
  2292. var gValDec;
  2293. var bValDec;
  2294. var hexVal;
  2295. var newSwatch;
  2296. var lastVal;
  2297. var activeField;
  2298. /**
  2299. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2300. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2301. * are will receive no update. This is to prevent the input from the user being overwritten.
  2302. */
  2303. function updateValues(value, inputField) {
  2304. activeField = inputField;
  2305. var pickedColor = value.toHexString();
  2306. newSwatch.background = pickedColor;
  2307. if (rValInt.name != activeField) {
  2308. rValInt.text = Math.floor(value.r * 255).toString();
  2309. }
  2310. if (gValInt.name != activeField) {
  2311. gValInt.text = Math.floor(value.g * 255).toString();
  2312. }
  2313. if (bValInt.name != activeField) {
  2314. bValInt.text = Math.floor(value.b * 255).toString();
  2315. }
  2316. if (rValDec.name != activeField) {
  2317. rValDec.text = value.r.toString();
  2318. }
  2319. if (gValDec.name != activeField) {
  2320. gValDec.text = value.g.toString();
  2321. }
  2322. if (bValDec.name != activeField) {
  2323. bValDec.text = value.b.toString();
  2324. }
  2325. if (hexVal.name != activeField) {
  2326. var minusPound = pickedColor.split("#");
  2327. hexVal.text = minusPound[1];
  2328. }
  2329. if (picker.name != activeField) {
  2330. picker.value = value;
  2331. }
  2332. }
  2333. // 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.
  2334. function updateInt(field, channel) {
  2335. var newValue = field.text;
  2336. var checkVal = /[^0-9]/g.test(newValue);
  2337. if (checkVal) {
  2338. field.text = lastVal;
  2339. return;
  2340. }
  2341. else {
  2342. if (newValue != "") {
  2343. if (Math.floor(parseInt(newValue)) < 0) {
  2344. newValue = "0";
  2345. }
  2346. else if (Math.floor(parseInt(newValue)) > 255) {
  2347. newValue = "255";
  2348. }
  2349. else if (isNaN(parseInt(newValue))) {
  2350. newValue = "0";
  2351. }
  2352. }
  2353. if (activeField == field.name) {
  2354. lastVal = newValue;
  2355. }
  2356. }
  2357. if (newValue != "") {
  2358. newValue = parseInt(newValue).toString();
  2359. field.text = newValue;
  2360. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2361. if (activeField == field.name) {
  2362. if (channel == "r") {
  2363. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2364. }
  2365. else if (channel == "g") {
  2366. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2367. }
  2368. else {
  2369. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2370. }
  2371. }
  2372. }
  2373. }
  2374. // 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.
  2375. function updateFloat(field, channel) {
  2376. var newValue = field.text;
  2377. var checkVal = /[^0-9\.]/g.test(newValue);
  2378. if (checkVal) {
  2379. field.text = lastVal;
  2380. return;
  2381. }
  2382. else {
  2383. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2384. if (parseFloat(newValue) < 0.0) {
  2385. newValue = "0.0";
  2386. }
  2387. else if (parseFloat(newValue) > 1.0) {
  2388. newValue = "1.0";
  2389. }
  2390. else if (isNaN(parseFloat(newValue))) {
  2391. newValue = "0.0";
  2392. }
  2393. }
  2394. if (activeField == field.name) {
  2395. lastVal = newValue;
  2396. }
  2397. }
  2398. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2399. newValue = parseFloat(newValue).toString();
  2400. field.text = newValue;
  2401. }
  2402. else {
  2403. newValue = "0.0";
  2404. }
  2405. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2406. if (activeField == field.name) {
  2407. if (channel == "r") {
  2408. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2409. }
  2410. else if (channel == "g") {
  2411. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2412. }
  2413. else {
  2414. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2415. }
  2416. }
  2417. }
  2418. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2419. function deleteSwatch(index) {
  2420. if (options.savedColors) {
  2421. options.savedColors.splice(index, 1);
  2422. }
  2423. if (options.savedColors && options.savedColors.length == 0) {
  2424. setEditButtonVisibility(false);
  2425. editSwatchMode = false;
  2426. }
  2427. }
  2428. // Creates and styles an individual swatch when updateSwatches is called.
  2429. function createSwatch() {
  2430. if (options.savedColors && options.savedColors[swatchNumber]) {
  2431. if (editSwatchMode) {
  2432. var icon = "b";
  2433. }
  2434. else {
  2435. var icon = "";
  2436. }
  2437. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2438. swatch.fontFamily = "BabylonJSglyphs";
  2439. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2440. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2441. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2442. if (swatchLuminence > luminanceLimit) {
  2443. swatch.color = iconColorDark;
  2444. }
  2445. else {
  2446. swatch.color = iconColorLight;
  2447. }
  2448. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2449. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2450. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2451. swatch.background = options.savedColors[swatchNumber];
  2452. swatch.thickness = 2;
  2453. var metadata_1 = swatchNumber;
  2454. swatch.pointerDownAnimation = function () {
  2455. swatch.thickness = 4;
  2456. };
  2457. swatch.pointerUpAnimation = function () {
  2458. swatch.thickness = 3;
  2459. };
  2460. swatch.pointerEnterAnimation = function () {
  2461. swatch.thickness = 3;
  2462. };
  2463. swatch.pointerOutAnimation = function () {
  2464. swatch.thickness = 2;
  2465. };
  2466. swatch.onPointerClickObservable.add(function () {
  2467. if (!editSwatchMode) {
  2468. if (options.savedColors) {
  2469. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2470. }
  2471. }
  2472. else {
  2473. deleteSwatch(metadata_1);
  2474. updateSwatches("", butSave);
  2475. }
  2476. });
  2477. return swatch;
  2478. }
  2479. else {
  2480. return null;
  2481. }
  2482. }
  2483. // Mode switch to render button text and close symbols on swatch controls
  2484. function editSwatches(mode) {
  2485. if (mode !== undefined) {
  2486. editSwatchMode = mode;
  2487. }
  2488. if (editSwatchMode) {
  2489. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2490. var thisButton = swatchDrawer.children[i];
  2491. thisButton.textBlock.text = "b";
  2492. }
  2493. if (butEdit !== undefined) {
  2494. butEdit.textBlock.text = "Done";
  2495. }
  2496. }
  2497. else {
  2498. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2499. var thisButton = swatchDrawer.children[i];
  2500. thisButton.textBlock.text = "";
  2501. }
  2502. if (butEdit !== undefined) {
  2503. butEdit.textBlock.text = "Edit";
  2504. }
  2505. }
  2506. }
  2507. /**
  2508. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2509. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2510. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2511. * saved colors there are and how many can be stored per row.
  2512. */
  2513. function updateSwatches(color, button) {
  2514. if (options.savedColors) {
  2515. if (color != "") {
  2516. options.savedColors.push(color);
  2517. }
  2518. swatchNumber = 0;
  2519. swatchDrawer.clearControls();
  2520. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2521. if (rowCount == 0) {
  2522. var gutterCount = 0;
  2523. }
  2524. else {
  2525. var gutterCount = rowCount + 1;
  2526. }
  2527. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2528. var currentRows = swatchDrawer.rowCount;
  2529. for (var i = 0; i < currentRows; i++) {
  2530. swatchDrawer.removeRowDefinition(0);
  2531. }
  2532. for (var i = 0; i < rowCount + gutterCount; i++) {
  2533. if (i % 2) {
  2534. swatchDrawer.addRowDefinition(swatchSize, true);
  2535. }
  2536. else {
  2537. swatchDrawer.addRowDefinition(gutterSize, true);
  2538. }
  2539. }
  2540. }
  2541. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2542. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2543. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2544. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2545. var totalButtonsThisRow = options.numSwatchesPerLine;
  2546. }
  2547. else {
  2548. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2549. }
  2550. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2551. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2552. if (x > options.numSwatchesPerLine) {
  2553. continue;
  2554. }
  2555. var swatch = createSwatch();
  2556. if (swatch != null) {
  2557. swatchDrawer.addControl(swatch, y, w);
  2558. w += 2;
  2559. swatchNumber++;
  2560. }
  2561. else {
  2562. continue;
  2563. }
  2564. }
  2565. }
  2566. if (options.savedColors.length >= options.swatchLimit) {
  2567. disableButton(button, true);
  2568. }
  2569. else {
  2570. disableButton(button, false);
  2571. }
  2572. }
  2573. }
  2574. // Shows or hides edit swatches button depending on if there are saved swatches
  2575. function setEditButtonVisibility(enableButton) {
  2576. if (enableButton) {
  2577. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2578. butEdit.width = buttonWidth;
  2579. butEdit.height = buttonHeight;
  2580. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2581. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2582. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2583. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2584. butEdit.thickness = 2;
  2585. butEdit.color = buttonColor;
  2586. butEdit.fontSize = buttonFontSize;
  2587. butEdit.background = buttonBackgroundColor;
  2588. butEdit.onPointerEnterObservable.add(function () {
  2589. butEdit.background = buttonBackgroundHoverColor;
  2590. });
  2591. butEdit.onPointerOutObservable.add(function () {
  2592. butEdit.background = buttonBackgroundColor;
  2593. });
  2594. butEdit.pointerDownAnimation = function () {
  2595. butEdit.background = buttonBackgroundClickColor;
  2596. };
  2597. butEdit.pointerUpAnimation = function () {
  2598. butEdit.background = buttonBackgroundHoverColor;
  2599. };
  2600. butEdit.onPointerClickObservable.add(function () {
  2601. if (editSwatchMode) {
  2602. editSwatchMode = false;
  2603. }
  2604. else {
  2605. editSwatchMode = true;
  2606. }
  2607. editSwatches();
  2608. });
  2609. pickerGrid.addControl(butEdit, 1, 0);
  2610. }
  2611. else {
  2612. pickerGrid.removeControl(butEdit);
  2613. }
  2614. }
  2615. // Called when the user hits the limit of saved colors in the drawer.
  2616. function disableButton(button, disabled) {
  2617. if (disabled) {
  2618. button.color = buttonDisabledColor;
  2619. button.background = buttonDisabledBackgroundColor;
  2620. }
  2621. else {
  2622. button.color = buttonColor;
  2623. button.background = buttonBackgroundColor;
  2624. }
  2625. }
  2626. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2627. function closePicker(color) {
  2628. if (options.savedColors && options.savedColors.length > 0) {
  2629. resolve({
  2630. savedColors: options.savedColors,
  2631. pickedColor: color
  2632. });
  2633. }
  2634. else {
  2635. resolve({
  2636. pickedColor: color
  2637. });
  2638. }
  2639. advancedTexture.removeControl(dialogContainer);
  2640. }
  2641. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2642. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2643. dialogContainer.name = "Dialog Container";
  2644. dialogContainer.width = options.pickerWidth;
  2645. if (options.savedColors) {
  2646. dialogContainer.height = containerSize;
  2647. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2648. dialogContainer.addRowDefinition(topRow, false);
  2649. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2650. }
  2651. else {
  2652. dialogContainer.height = options.pickerHeight;
  2653. dialogContainer.addRowDefinition(1.0, false);
  2654. }
  2655. advancedTexture.addControl(dialogContainer);
  2656. // Swatch drawer which contains all saved color buttons
  2657. if (options.savedColors) {
  2658. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2659. swatchDrawer.name = "Swatch Drawer";
  2660. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2661. swatchDrawer.background = buttonBackgroundColor;
  2662. swatchDrawer.width = options.pickerWidth;
  2663. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2664. if (initialRows == 0) {
  2665. var gutterCount = 0;
  2666. }
  2667. else {
  2668. var gutterCount = initialRows + 1;
  2669. }
  2670. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2671. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2672. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2673. if (i % 2 != 0) {
  2674. swatchDrawer.addRowDefinition(swatchSize, true);
  2675. }
  2676. else {
  2677. swatchDrawer.addRowDefinition(gutterSize, true);
  2678. }
  2679. }
  2680. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2681. if (i % 2 != 0) {
  2682. swatchDrawer.addColumnDefinition(swatchSize, true);
  2683. }
  2684. else {
  2685. swatchDrawer.addColumnDefinition(gutterSize, true);
  2686. }
  2687. }
  2688. dialogContainer.addControl(swatchDrawer, 1, 0);
  2689. }
  2690. // Picker container
  2691. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2692. pickerPanel.name = "Picker Panel";
  2693. pickerPanel.height = options.pickerHeight;
  2694. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2695. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2696. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2697. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2698. dialogContainer.addControl(pickerPanel, 0, 0);
  2699. // Picker container header
  2700. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2701. header.name = "Dialogue Header Bar";
  2702. header.background = "#cccccc";
  2703. header.thickness = 0;
  2704. pickerPanel.addControl(header, 0, 0);
  2705. // Header close button
  2706. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2707. closeButton.fontFamily = "BabylonJSglyphs";
  2708. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2709. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2710. closeButton.color = closeIconColor.toHexString();
  2711. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2712. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2713. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2714. closeButton.height = closeButton.width = options.headerHeight;
  2715. closeButton.background = header.background;
  2716. closeButton.thickness = 0;
  2717. closeButton.pointerDownAnimation = function () {
  2718. };
  2719. closeButton.pointerUpAnimation = function () {
  2720. closeButton.background = header.background;
  2721. };
  2722. closeButton.pointerEnterAnimation = function () {
  2723. closeButton.color = header.background;
  2724. closeButton.background = "red";
  2725. };
  2726. closeButton.pointerOutAnimation = function () {
  2727. closeButton.color = closeIconColor.toHexString();
  2728. closeButton.background = header.background;
  2729. };
  2730. closeButton.onPointerClickObservable.add(function () {
  2731. closePicker(currentSwatch.background);
  2732. });
  2733. pickerPanel.addControl(closeButton, 0, 0);
  2734. // Dialog container body
  2735. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2736. dialogBody.name = "Dialogue Body";
  2737. dialogBody.background = buttonBackgroundColor;
  2738. var dialogBodyCols = [0.4375, 0.5625];
  2739. dialogBody.addRowDefinition(1.0, false);
  2740. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2741. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2742. pickerPanel.addControl(dialogBody, 1, 0);
  2743. // Picker grid
  2744. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2745. pickerGrid.name = "Picker Grid";
  2746. pickerGrid.addRowDefinition(0.85, false);
  2747. pickerGrid.addRowDefinition(0.15, false);
  2748. dialogBody.addControl(pickerGrid, 0, 0);
  2749. // Picker control
  2750. picker = new ColorPicker();
  2751. picker.name = "GUI Color Picker";
  2752. if (options.pickerHeight < options.pickerWidth) {
  2753. picker.width = 0.89;
  2754. }
  2755. else {
  2756. picker.height = 0.89;
  2757. }
  2758. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2759. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2760. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2761. picker.onPointerDownObservable.add(function () {
  2762. activeField = picker.name;
  2763. lastVal = "";
  2764. editSwatches(false);
  2765. });
  2766. picker.onValueChangedObservable.add(function (value) {
  2767. if (activeField == picker.name) {
  2768. updateValues(value, picker.name);
  2769. }
  2770. });
  2771. pickerGrid.addControl(picker, 0, 0);
  2772. // Picker body right quarant
  2773. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2774. pickerBodyRight.name = "Dialogue Right Half";
  2775. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2776. var pickerBodyRightRows = [0.514, 0.486];
  2777. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2778. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2779. dialogBody.addControl(pickerBodyRight, 1, 1);
  2780. // Picker container swatches and buttons
  2781. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2782. pickerSwatchesButtons.name = "Swatches and Buttons";
  2783. var pickerButtonsCol = [0.417, 0.583];
  2784. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2785. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2786. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2787. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2788. // Picker Swatches quadrant
  2789. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2790. pickerSwatches.name = "New and Current Swatches";
  2791. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2792. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2793. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2794. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2795. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2796. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2797. // Active swatches
  2798. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2799. activeSwatches.name = "Active Swatches";
  2800. activeSwatches.width = 0.67;
  2801. activeSwatches.addRowDefinition(0.5, false);
  2802. activeSwatches.addRowDefinition(0.5, false);
  2803. pickerSwatches.addControl(activeSwatches, 2, 0);
  2804. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2805. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2806. if (options.pickerWidth > options.pickerHeight) {
  2807. var labelTextSize = labelHeight;
  2808. }
  2809. else {
  2810. var labelTextSize = labelWidth;
  2811. }
  2812. // New color swatch and previous color button
  2813. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2814. newText.text = "new";
  2815. newText.name = "New Color Label";
  2816. newText.color = buttonColor;
  2817. newText.fontSize = labelTextSize;
  2818. pickerSwatches.addControl(newText, 1, 0);
  2819. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2820. newSwatch.name = "New Color Swatch";
  2821. newSwatch.background = options.lastColor;
  2822. newSwatch.thickness = 0;
  2823. activeSwatches.addControl(newSwatch, 0, 0);
  2824. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2825. currentSwatch.background = options.lastColor;
  2826. currentSwatch.thickness = 0;
  2827. currentSwatch.onPointerClickObservable.add(function () {
  2828. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2829. updateValues(revertColor, currentSwatch.name);
  2830. editSwatches(false);
  2831. });
  2832. currentSwatch.pointerDownAnimation = function () { };
  2833. currentSwatch.pointerUpAnimation = function () { };
  2834. currentSwatch.pointerEnterAnimation = function () { };
  2835. currentSwatch.pointerOutAnimation = function () { };
  2836. activeSwatches.addControl(currentSwatch, 1, 0);
  2837. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2838. swatchOutline.name = "Swatch Outline";
  2839. swatchOutline.width = 0.67;
  2840. swatchOutline.thickness = 2;
  2841. swatchOutline.color = currentSwatchesOutlineColor;
  2842. swatchOutline.isHitTestVisible = false;
  2843. pickerSwatches.addControl(swatchOutline, 2, 0);
  2844. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2845. currentText.name = "Current Color Label";
  2846. currentText.text = "current";
  2847. currentText.color = buttonColor;
  2848. currentText.fontSize = labelTextSize;
  2849. pickerSwatches.addControl(currentText, 3, 0);
  2850. // Buttons grid
  2851. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2852. buttonGrid.name = "Button Grid";
  2853. buttonGrid.height = 0.8;
  2854. var buttonGridRows = 1 / 3;
  2855. buttonGrid.addRowDefinition(buttonGridRows, false);
  2856. buttonGrid.addRowDefinition(buttonGridRows, false);
  2857. buttonGrid.addRowDefinition(buttonGridRows, false);
  2858. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2859. // Determine pixel width and height for all buttons from overall panel dimensions
  2860. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2861. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2862. // Determine button type size
  2863. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2864. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2865. }
  2866. else {
  2867. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2868. }
  2869. // Panel Buttons
  2870. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2871. butOK.width = buttonWidth;
  2872. butOK.height = buttonHeight;
  2873. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2874. butOK.thickness = 2;
  2875. butOK.color = buttonColor;
  2876. butOK.fontSize = buttonFontSize;
  2877. butOK.background = buttonBackgroundColor;
  2878. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2879. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2880. butOK.pointerDownAnimation = function () {
  2881. butOK.background = buttonBackgroundClickColor;
  2882. };
  2883. butOK.pointerUpAnimation = function () {
  2884. butOK.background = buttonBackgroundHoverColor;
  2885. };
  2886. butOK.onPointerClickObservable.add(function () {
  2887. editSwatches(false);
  2888. closePicker(newSwatch.background);
  2889. });
  2890. buttonGrid.addControl(butOK, 0, 0);
  2891. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2892. butCancel.width = buttonWidth;
  2893. butCancel.height = buttonHeight;
  2894. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2895. butCancel.thickness = 2;
  2896. butCancel.color = buttonColor;
  2897. butCancel.fontSize = buttonFontSize;
  2898. butCancel.background = buttonBackgroundColor;
  2899. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2900. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2901. butCancel.pointerDownAnimation = function () {
  2902. butCancel.background = buttonBackgroundClickColor;
  2903. };
  2904. butCancel.pointerUpAnimation = function () {
  2905. butCancel.background = buttonBackgroundHoverColor;
  2906. };
  2907. butCancel.onPointerClickObservable.add(function () {
  2908. editSwatches(false);
  2909. closePicker(currentSwatch.background);
  2910. });
  2911. buttonGrid.addControl(butCancel, 1, 0);
  2912. if (options.savedColors) {
  2913. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2914. butSave.width = buttonWidth;
  2915. butSave.height = buttonHeight;
  2916. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2917. butSave.thickness = 2;
  2918. butSave.fontSize = buttonFontSize;
  2919. if (options.savedColors.length < options.swatchLimit) {
  2920. butSave.color = buttonColor;
  2921. butSave.background = buttonBackgroundColor;
  2922. }
  2923. else {
  2924. disableButton(butSave, true);
  2925. }
  2926. butSave.onPointerEnterObservable.add(function () {
  2927. if (options.savedColors) {
  2928. if (options.savedColors.length < options.swatchLimit) {
  2929. butSave.background = buttonBackgroundHoverColor;
  2930. }
  2931. }
  2932. });
  2933. butSave.onPointerOutObservable.add(function () {
  2934. if (options.savedColors) {
  2935. if (options.savedColors.length < options.swatchLimit) {
  2936. butSave.background = buttonBackgroundColor;
  2937. }
  2938. }
  2939. });
  2940. butSave.pointerDownAnimation = function () {
  2941. if (options.savedColors) {
  2942. if (options.savedColors.length < options.swatchLimit) {
  2943. butSave.background = buttonBackgroundClickColor;
  2944. }
  2945. }
  2946. };
  2947. butSave.pointerUpAnimation = function () {
  2948. if (options.savedColors) {
  2949. if (options.savedColors.length < options.swatchLimit) {
  2950. butSave.background = buttonBackgroundHoverColor;
  2951. }
  2952. }
  2953. };
  2954. butSave.onPointerClickObservable.add(function () {
  2955. if (options.savedColors) {
  2956. if (options.savedColors.length == 0) {
  2957. setEditButtonVisibility(true);
  2958. }
  2959. if (options.savedColors.length < options.swatchLimit) {
  2960. updateSwatches(newSwatch.background, butSave);
  2961. }
  2962. editSwatches(false);
  2963. }
  2964. });
  2965. if (options.savedColors.length > 0) {
  2966. setEditButtonVisibility(true);
  2967. }
  2968. buttonGrid.addControl(butSave, 2, 0);
  2969. }
  2970. // Picker color values input
  2971. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2972. pickerColorValues.name = "Dialog Lower Right";
  2973. pickerColorValues.addRowDefinition(0.02, false);
  2974. pickerColorValues.addRowDefinition(0.63, false);
  2975. pickerColorValues.addRowDefinition(0.21, false);
  2976. pickerColorValues.addRowDefinition(0.14, false);
  2977. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2978. // RGB values text boxes
  2979. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2980. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2981. rgbValuesQuadrant.name = "RGB Values";
  2982. rgbValuesQuadrant.width = 0.82;
  2983. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2984. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2985. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2986. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2987. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2988. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2989. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2990. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2991. for (var i = 0; i < inputFieldLabels.length; i++) {
  2992. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2993. labelText.text = inputFieldLabels[i];
  2994. labelText.color = buttonColor;
  2995. labelText.fontSize = buttonFontSize;
  2996. rgbValuesQuadrant.addControl(labelText, i, 0);
  2997. }
  2998. // Input fields for RGB values
  2999. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3000. rValInt.width = 0.83;
  3001. rValInt.height = 0.72;
  3002. rValInt.name = "rIntField";
  3003. rValInt.fontSize = buttonFontSize;
  3004. rValInt.text = (currentColor.r * 255).toString();
  3005. rValInt.color = inputTextColor;
  3006. rValInt.background = inputTextBackgroundColor;
  3007. rValInt.onFocusObservable.add(function () {
  3008. activeField = rValInt.name;
  3009. lastVal = rValInt.text;
  3010. editSwatches(false);
  3011. });
  3012. rValInt.onBlurObservable.add(function () {
  3013. if (rValInt.text == "") {
  3014. rValInt.text = "0";
  3015. }
  3016. updateInt(rValInt, "r");
  3017. if (activeField == rValInt.name) {
  3018. activeField = "";
  3019. }
  3020. });
  3021. rValInt.onTextChangedObservable.add(function () {
  3022. if (activeField == rValInt.name) {
  3023. updateInt(rValInt, "r");
  3024. }
  3025. });
  3026. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  3027. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3028. gValInt.width = 0.83;
  3029. gValInt.height = 0.72;
  3030. gValInt.name = "gIntField";
  3031. gValInt.fontSize = buttonFontSize;
  3032. gValInt.text = (currentColor.g * 255).toString();
  3033. gValInt.color = inputTextColor;
  3034. gValInt.background = inputTextBackgroundColor;
  3035. gValInt.onFocusObservable.add(function () {
  3036. activeField = gValInt.name;
  3037. lastVal = gValInt.text;
  3038. editSwatches(false);
  3039. });
  3040. gValInt.onBlurObservable.add(function () {
  3041. if (gValInt.text == "") {
  3042. gValInt.text = "0";
  3043. }
  3044. updateInt(gValInt, "g");
  3045. if (activeField == gValInt.name) {
  3046. activeField = "";
  3047. }
  3048. });
  3049. gValInt.onTextChangedObservable.add(function () {
  3050. if (activeField == gValInt.name) {
  3051. updateInt(gValInt, "g");
  3052. }
  3053. });
  3054. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  3055. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3056. bValInt.width = 0.83;
  3057. bValInt.height = 0.72;
  3058. bValInt.name = "bIntField";
  3059. bValInt.fontSize = buttonFontSize;
  3060. bValInt.text = (currentColor.b * 255).toString();
  3061. bValInt.color = inputTextColor;
  3062. bValInt.background = inputTextBackgroundColor;
  3063. bValInt.onFocusObservable.add(function () {
  3064. activeField = bValInt.name;
  3065. lastVal = bValInt.text;
  3066. editSwatches(false);
  3067. });
  3068. bValInt.onBlurObservable.add(function () {
  3069. if (bValInt.text == "") {
  3070. bValInt.text = "0";
  3071. }
  3072. updateInt(bValInt, "b");
  3073. if (activeField == bValInt.name) {
  3074. activeField = "";
  3075. }
  3076. });
  3077. bValInt.onTextChangedObservable.add(function () {
  3078. if (activeField == bValInt.name) {
  3079. updateInt(bValInt, "b");
  3080. }
  3081. });
  3082. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  3083. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3084. rValDec.width = 0.95;
  3085. rValDec.height = 0.72;
  3086. rValDec.name = "rDecField";
  3087. rValDec.fontSize = buttonFontSize;
  3088. rValDec.text = currentColor.r.toString();
  3089. rValDec.color = inputTextColor;
  3090. rValDec.background = inputTextBackgroundColor;
  3091. rValDec.onFocusObservable.add(function () {
  3092. activeField = rValDec.name;
  3093. lastVal = rValDec.text;
  3094. editSwatches(false);
  3095. });
  3096. rValDec.onBlurObservable.add(function () {
  3097. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  3098. rValDec.text = "0";
  3099. updateFloat(rValDec, "r");
  3100. }
  3101. if (activeField == rValDec.name) {
  3102. activeField = "";
  3103. }
  3104. });
  3105. rValDec.onTextChangedObservable.add(function () {
  3106. if (activeField == rValDec.name) {
  3107. updateFloat(rValDec, "r");
  3108. }
  3109. });
  3110. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  3111. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3112. gValDec.width = 0.95;
  3113. gValDec.height = 0.72;
  3114. gValDec.name = "gDecField";
  3115. gValDec.fontSize = buttonFontSize;
  3116. gValDec.text = currentColor.g.toString();
  3117. gValDec.color = inputTextColor;
  3118. gValDec.background = inputTextBackgroundColor;
  3119. gValDec.onFocusObservable.add(function () {
  3120. activeField = gValDec.name;
  3121. lastVal = gValDec.text;
  3122. editSwatches(false);
  3123. });
  3124. gValDec.onBlurObservable.add(function () {
  3125. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  3126. gValDec.text = "0";
  3127. updateFloat(gValDec, "g");
  3128. }
  3129. if (activeField == gValDec.name) {
  3130. activeField = "";
  3131. }
  3132. });
  3133. gValDec.onTextChangedObservable.add(function () {
  3134. if (activeField == gValDec.name) {
  3135. updateFloat(gValDec, "g");
  3136. }
  3137. });
  3138. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3139. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3140. bValDec.width = 0.95;
  3141. bValDec.height = 0.72;
  3142. bValDec.name = "bDecField";
  3143. bValDec.fontSize = buttonFontSize;
  3144. bValDec.text = currentColor.b.toString();
  3145. bValDec.color = inputTextColor;
  3146. bValDec.background = inputTextBackgroundColor;
  3147. bValDec.onFocusObservable.add(function () {
  3148. activeField = bValDec.name;
  3149. lastVal = bValDec.text;
  3150. editSwatches(false);
  3151. });
  3152. bValDec.onBlurObservable.add(function () {
  3153. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3154. bValDec.text = "0";
  3155. updateFloat(bValDec, "b");
  3156. }
  3157. if (activeField == bValDec.name) {
  3158. activeField = "";
  3159. }
  3160. });
  3161. bValDec.onTextChangedObservable.add(function () {
  3162. if (activeField == bValDec.name) {
  3163. updateFloat(bValDec, "b");
  3164. }
  3165. });
  3166. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3167. // Hex value input
  3168. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3169. hexValueQuadrant.name = "Hex Value";
  3170. hexValueQuadrant.width = 0.82;
  3171. hexValueQuadrant.addRowDefinition(1.0, false);
  3172. hexValueQuadrant.addColumnDefinition(0.1, false);
  3173. hexValueQuadrant.addColumnDefinition(0.9, false);
  3174. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3175. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3176. labelText.text = "#";
  3177. labelText.color = buttonColor;
  3178. labelText.fontSize = buttonFontSize;
  3179. hexValueQuadrant.addControl(labelText, 0, 0);
  3180. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3181. hexVal.width = 0.96;
  3182. hexVal.height = 0.72;
  3183. hexVal.name = "hexField";
  3184. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3185. hexVal.fontSize = buttonFontSize;
  3186. var minusPound = options.lastColor.split("#");
  3187. hexVal.text = minusPound[1];
  3188. hexVal.color = inputTextColor;
  3189. hexVal.background = inputTextBackgroundColor;
  3190. hexVal.onFocusObservable.add(function () {
  3191. activeField = hexVal.name;
  3192. lastVal = hexVal.text;
  3193. editSwatches(false);
  3194. });
  3195. hexVal.onBlurObservable.add(function () {
  3196. if (hexVal.text.length == 3) {
  3197. var val = hexVal.text.split("");
  3198. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3199. }
  3200. if (hexVal.text == "") {
  3201. hexVal.text = "000000";
  3202. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3203. }
  3204. if (activeField == hexVal.name) {
  3205. activeField = "";
  3206. }
  3207. });
  3208. hexVal.onTextChangedObservable.add(function () {
  3209. var newHexValue = hexVal.text;
  3210. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3211. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3212. hexVal.text = lastVal;
  3213. }
  3214. else {
  3215. if (hexVal.text.length < 6) {
  3216. var leadingZero = 6 - hexVal.text.length;
  3217. for (var i = 0; i < leadingZero; i++) {
  3218. newHexValue = "0" + newHexValue;
  3219. }
  3220. }
  3221. if (hexVal.text.length == 3) {
  3222. var val = hexVal.text.split("");
  3223. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3224. }
  3225. newHexValue = "#" + newHexValue;
  3226. if (activeField == hexVal.name) {
  3227. lastVal = hexVal.text;
  3228. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3229. }
  3230. }
  3231. });
  3232. hexValueQuadrant.addControl(hexVal, 0, 1);
  3233. if (options.savedColors && options.savedColors.length > 0) {
  3234. updateSwatches("", butSave);
  3235. }
  3236. });
  3237. };
  3238. ColorPicker._Epsilon = 0.000001;
  3239. return ColorPicker;
  3240. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3241. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3242. /***/ }),
  3243. /***/ "./2D/controls/container.ts":
  3244. /*!**********************************!*\
  3245. !*** ./2D/controls/container.ts ***!
  3246. \**********************************/
  3247. /*! exports provided: Container */
  3248. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3249. "use strict";
  3250. __webpack_require__.r(__webpack_exports__);
  3251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3252. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3253. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable");
  3254. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3255. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3256. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3257. /**
  3258. * Root class for 2D containers
  3259. * @see https://doc.babylonjs.com/how_to/gui#containers
  3260. */
  3261. var Container = /** @class */ (function (_super) {
  3262. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3263. /**
  3264. * Creates a new Container
  3265. * @param name defines the name of the container
  3266. */
  3267. function Container(name) {
  3268. var _this = _super.call(this, name) || this;
  3269. _this.name = name;
  3270. /** @hidden */
  3271. _this._children = new Array();
  3272. /** @hidden */
  3273. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3274. /** @hidden */
  3275. _this._background = "";
  3276. /** @hidden */
  3277. _this._adaptWidthToChildren = false;
  3278. /** @hidden */
  3279. _this._adaptHeightToChildren = false;
  3280. /**
  3281. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3282. */
  3283. _this.logLayoutCycleErrors = false;
  3284. /**
  3285. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3286. */
  3287. _this.maxLayoutCycle = 3;
  3288. return _this;
  3289. }
  3290. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3291. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3292. get: function () {
  3293. return this._adaptHeightToChildren;
  3294. },
  3295. set: function (value) {
  3296. if (this._adaptHeightToChildren === value) {
  3297. return;
  3298. }
  3299. this._adaptHeightToChildren = value;
  3300. if (value) {
  3301. this.height = "100%";
  3302. }
  3303. this._markAsDirty();
  3304. },
  3305. enumerable: false,
  3306. configurable: true
  3307. });
  3308. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3309. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3310. get: function () {
  3311. return this._adaptWidthToChildren;
  3312. },
  3313. set: function (value) {
  3314. if (this._adaptWidthToChildren === value) {
  3315. return;
  3316. }
  3317. this._adaptWidthToChildren = value;
  3318. if (value) {
  3319. this.width = "100%";
  3320. }
  3321. this._markAsDirty();
  3322. },
  3323. enumerable: false,
  3324. configurable: true
  3325. });
  3326. Object.defineProperty(Container.prototype, "background", {
  3327. /** Gets or sets background color */
  3328. get: function () {
  3329. return this._background;
  3330. },
  3331. set: function (value) {
  3332. if (this._background === value) {
  3333. return;
  3334. }
  3335. this._background = value;
  3336. this._markAsDirty();
  3337. },
  3338. enumerable: false,
  3339. configurable: true
  3340. });
  3341. Object.defineProperty(Container.prototype, "children", {
  3342. /** Gets the list of children */
  3343. get: function () {
  3344. return this._children;
  3345. },
  3346. enumerable: false,
  3347. configurable: true
  3348. });
  3349. Container.prototype._getTypeName = function () {
  3350. return "Container";
  3351. };
  3352. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3353. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3354. var child = _a[_i];
  3355. child._markMatrixAsDirty();
  3356. }
  3357. };
  3358. /**
  3359. * Gets a child using its name
  3360. * @param name defines the child name to look for
  3361. * @returns the child control if found
  3362. */
  3363. Container.prototype.getChildByName = function (name) {
  3364. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3365. var child = _a[_i];
  3366. if (child.name === name) {
  3367. return child;
  3368. }
  3369. }
  3370. return null;
  3371. };
  3372. /**
  3373. * Gets a child using its type and its name
  3374. * @param name defines the child name to look for
  3375. * @param type defines the child type to look for
  3376. * @returns the child control if found
  3377. */
  3378. Container.prototype.getChildByType = function (name, type) {
  3379. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3380. var child = _a[_i];
  3381. if (child.typeName === type) {
  3382. return child;
  3383. }
  3384. }
  3385. return null;
  3386. };
  3387. /**
  3388. * Search for a specific control in children
  3389. * @param control defines the control to look for
  3390. * @returns true if the control is in child list
  3391. */
  3392. Container.prototype.containsControl = function (control) {
  3393. return this.children.indexOf(control) !== -1;
  3394. };
  3395. /**
  3396. * Adds a new control to the current container
  3397. * @param control defines the control to add
  3398. * @returns the current container
  3399. */
  3400. Container.prototype.addControl = function (control) {
  3401. if (!control) {
  3402. return this;
  3403. }
  3404. var index = this._children.indexOf(control);
  3405. if (index !== -1) {
  3406. return this;
  3407. }
  3408. control._link(this._host);
  3409. control._markAllAsDirty();
  3410. this._reOrderControl(control);
  3411. this._markAsDirty();
  3412. return this;
  3413. };
  3414. /**
  3415. * Removes all controls from the current container
  3416. * @returns the current container
  3417. */
  3418. Container.prototype.clearControls = function () {
  3419. var children = this.children.slice();
  3420. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3421. var child = children_1[_i];
  3422. this.removeControl(child);
  3423. }
  3424. return this;
  3425. };
  3426. /**
  3427. * Removes a control from the current container
  3428. * @param control defines the control to remove
  3429. * @returns the current container
  3430. */
  3431. Container.prototype.removeControl = function (control) {
  3432. var index = this._children.indexOf(control);
  3433. if (index !== -1) {
  3434. this._children.splice(index, 1);
  3435. control.parent = null;
  3436. }
  3437. control.linkWithMesh(null);
  3438. if (this._host) {
  3439. this._host._cleanControlAfterRemoval(control);
  3440. }
  3441. this._markAsDirty();
  3442. return this;
  3443. };
  3444. /** @hidden */
  3445. Container.prototype._reOrderControl = function (control) {
  3446. this.removeControl(control);
  3447. var wasAdded = false;
  3448. for (var index = 0; index < this._children.length; index++) {
  3449. if (this._children[index].zIndex > control.zIndex) {
  3450. this._children.splice(index, 0, control);
  3451. wasAdded = true;
  3452. break;
  3453. }
  3454. }
  3455. if (!wasAdded) {
  3456. this._children.push(control);
  3457. }
  3458. control.parent = this;
  3459. this._markAsDirty();
  3460. };
  3461. /** @hidden */
  3462. Container.prototype._offsetLeft = function (offset) {
  3463. _super.prototype._offsetLeft.call(this, offset);
  3464. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3465. var child = _a[_i];
  3466. child._offsetLeft(offset);
  3467. }
  3468. };
  3469. /** @hidden */
  3470. Container.prototype._offsetTop = function (offset) {
  3471. _super.prototype._offsetTop.call(this, offset);
  3472. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3473. var child = _a[_i];
  3474. child._offsetTop(offset);
  3475. }
  3476. };
  3477. /** @hidden */
  3478. Container.prototype._markAllAsDirty = function () {
  3479. _super.prototype._markAllAsDirty.call(this);
  3480. for (var index = 0; index < this._children.length; index++) {
  3481. this._children[index]._markAllAsDirty();
  3482. }
  3483. };
  3484. /** @hidden */
  3485. Container.prototype._localDraw = function (context) {
  3486. if (this._background) {
  3487. context.save();
  3488. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3489. context.shadowColor = this.shadowColor;
  3490. context.shadowBlur = this.shadowBlur;
  3491. context.shadowOffsetX = this.shadowOffsetX;
  3492. context.shadowOffsetY = this.shadowOffsetY;
  3493. }
  3494. context.fillStyle = this._background;
  3495. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3496. context.restore();
  3497. }
  3498. };
  3499. /** @hidden */
  3500. Container.prototype._link = function (host) {
  3501. _super.prototype._link.call(this, host);
  3502. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3503. var child = _a[_i];
  3504. child._link(host);
  3505. }
  3506. };
  3507. /** @hidden */
  3508. Container.prototype._beforeLayout = function () {
  3509. // Do nothing
  3510. };
  3511. /** @hidden */
  3512. Container.prototype._processMeasures = function (parentMeasure, context) {
  3513. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3514. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3515. this._evaluateClippingState(parentMeasure);
  3516. }
  3517. };
  3518. /** @hidden */
  3519. Container.prototype._layout = function (parentMeasure, context) {
  3520. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3521. return false;
  3522. }
  3523. this.host._numLayoutCalls++;
  3524. if (this._isDirty) {
  3525. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3526. }
  3527. var rebuildCount = 0;
  3528. context.save();
  3529. this._applyStates(context);
  3530. this._beforeLayout();
  3531. do {
  3532. var computedWidth = -1;
  3533. var computedHeight = -1;
  3534. this._rebuildLayout = false;
  3535. this._processMeasures(parentMeasure, context);
  3536. if (!this._isClipped) {
  3537. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3538. var child = _a[_i];
  3539. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3540. if (child._layout(this._measureForChildren, context)) {
  3541. if (this.adaptWidthToChildren && child._width.isPixel) {
  3542. computedWidth = Math.max(computedWidth, child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels);
  3543. }
  3544. if (this.adaptHeightToChildren && child._height.isPixel) {
  3545. computedHeight = Math.max(computedHeight, child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels);
  3546. }
  3547. }
  3548. }
  3549. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3550. computedWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  3551. if (this.width !== computedWidth + "px") {
  3552. this.width = computedWidth + "px";
  3553. this._rebuildLayout = true;
  3554. }
  3555. }
  3556. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3557. computedHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  3558. if (this.height !== computedHeight + "px") {
  3559. this.height = computedHeight + "px";
  3560. this._rebuildLayout = true;
  3561. }
  3562. }
  3563. this._postMeasure();
  3564. }
  3565. rebuildCount++;
  3566. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3567. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3568. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3569. }
  3570. context.restore();
  3571. if (this._isDirty) {
  3572. this.invalidateRect();
  3573. this._isDirty = false;
  3574. }
  3575. return true;
  3576. };
  3577. Container.prototype._postMeasure = function () {
  3578. // Do nothing by default
  3579. };
  3580. /** @hidden */
  3581. Container.prototype._draw = function (context, invalidatedRectangle) {
  3582. this._localDraw(context);
  3583. if (this.clipChildren) {
  3584. this._clipForChildren(context);
  3585. }
  3586. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3587. var child = _a[_i];
  3588. // Only redraw parts of the screen that are invalidated
  3589. if (invalidatedRectangle) {
  3590. if (!child._intersectsRect(invalidatedRectangle)) {
  3591. continue;
  3592. }
  3593. }
  3594. child._render(context, invalidatedRectangle);
  3595. }
  3596. };
  3597. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3598. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3599. if (!this.children) {
  3600. return;
  3601. }
  3602. for (var index = 0; index < this.children.length; index++) {
  3603. var item = this.children[index];
  3604. if (!predicate || predicate(item)) {
  3605. results.push(item);
  3606. }
  3607. if (!directDescendantsOnly) {
  3608. item.getDescendantsToRef(results, false, predicate);
  3609. }
  3610. }
  3611. };
  3612. /** @hidden */
  3613. Container.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  3614. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3615. return false;
  3616. }
  3617. if (!_super.prototype.contains.call(this, x, y)) {
  3618. return false;
  3619. }
  3620. // Checking backwards to pick closest first
  3621. for (var index = this._children.length - 1; index >= 0; index--) {
  3622. var child = this._children[index];
  3623. if (child._processPicking(x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY)) {
  3624. if (child.hoverCursor) {
  3625. this._host._changeCursor(child.hoverCursor);
  3626. }
  3627. return true;
  3628. }
  3629. }
  3630. if (!this.isHitTestVisible) {
  3631. return false;
  3632. }
  3633. return this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  3634. };
  3635. /** @hidden */
  3636. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3637. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3638. this._measureForChildren.copyFrom(this._currentMeasure);
  3639. };
  3640. /** Releases associated resources */
  3641. Container.prototype.dispose = function () {
  3642. _super.prototype.dispose.call(this);
  3643. for (var index = this.children.length - 1; index >= 0; index--) {
  3644. this.children[index].dispose();
  3645. }
  3646. };
  3647. return Container;
  3648. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3649. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3650. /***/ }),
  3651. /***/ "./2D/controls/control.ts":
  3652. /*!********************************!*\
  3653. !*** ./2D/controls/control.ts ***!
  3654. \********************************/
  3655. /*! exports provided: Control */
  3656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3657. "use strict";
  3658. __webpack_require__.r(__webpack_exports__);
  3659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3660. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  3661. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3662. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3663. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3664. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3665. /**
  3666. * Root class used for all 2D controls
  3667. * @see https://doc.babylonjs.com/how_to/gui#controls
  3668. */
  3669. var Control = /** @class */ (function () {
  3670. // Functions
  3671. /**
  3672. * Creates a new control
  3673. * @param name defines the name of the control
  3674. */
  3675. function Control(
  3676. /** defines the name of the control */
  3677. name) {
  3678. this.name = name;
  3679. this._alpha = 1;
  3680. this._alphaSet = false;
  3681. this._zIndex = 0;
  3682. /** @hidden */
  3683. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3684. this._fontFamily = "Arial";
  3685. this._fontStyle = "";
  3686. this._fontWeight = "";
  3687. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3688. /** @hidden */
  3689. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3690. /** @hidden */
  3691. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3692. this._color = "";
  3693. this._style = null;
  3694. /** @hidden */
  3695. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3696. /** @hidden */
  3697. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3698. /** @hidden */
  3699. this._isDirty = true;
  3700. /** @hidden */
  3701. this._wasDirty = false;
  3702. /** @hidden */
  3703. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3704. /** @hidden */
  3705. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3706. /** @hidden */
  3707. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3708. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3709. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3710. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3711. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3712. /** @hidden */
  3713. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3714. /** @hidden */
  3715. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3716. this._scaleX = 1.0;
  3717. this._scaleY = 1.0;
  3718. this._rotation = 0;
  3719. this._transformCenterX = 0.5;
  3720. this._transformCenterY = 0.5;
  3721. /** @hidden */
  3722. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3723. /** @hidden */
  3724. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3725. /** @hidden */
  3726. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3727. this._isMatrixDirty = true;
  3728. this._isVisible = true;
  3729. this._isHighlighted = false;
  3730. this._fontSet = false;
  3731. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3732. this._downCount = 0;
  3733. this._enterCount = -1;
  3734. this._doNotRender = false;
  3735. this._downPointerIds = {};
  3736. this._isEnabled = true;
  3737. this._disabledColor = "#9a9a9a";
  3738. this._disabledColorItem = "#6a6a6a";
  3739. /** @hidden */
  3740. this._rebuildLayout = false;
  3741. /** @hidden */
  3742. this._customData = {};
  3743. /** @hidden */
  3744. this._isClipped = false;
  3745. /** @hidden */
  3746. this._automaticSize = false;
  3747. /**
  3748. * Gets or sets an object used to store user defined information for the node
  3749. */
  3750. this.metadata = null;
  3751. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3752. this.isHitTestVisible = true;
  3753. /** Gets or sets a boolean indicating if the control can block pointer events */
  3754. this.isPointerBlocker = false;
  3755. /** Gets or sets a boolean indicating if the control can be focusable */
  3756. this.isFocusInvisible = false;
  3757. /**
  3758. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3759. * 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
  3760. */
  3761. this.clipChildren = true;
  3762. /**
  3763. * Gets or sets a boolean indicating that control content must be clipped
  3764. * 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
  3765. */
  3766. this.clipContent = true;
  3767. /**
  3768. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3769. */
  3770. this.useBitmapCache = false;
  3771. this._shadowOffsetX = 0;
  3772. this._shadowOffsetY = 0;
  3773. this._shadowBlur = 0;
  3774. this._shadowColor = 'black';
  3775. /** Gets or sets the cursor to use when the control is hovered */
  3776. this.hoverCursor = "";
  3777. /** @hidden */
  3778. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3779. /** @hidden */
  3780. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3781. /**
  3782. * An event triggered when pointer wheel is scrolled
  3783. */
  3784. this.onWheelObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3785. /**
  3786. * An event triggered when the pointer move over the control.
  3787. */
  3788. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3789. /**
  3790. * An event triggered when the pointer move out of the control.
  3791. */
  3792. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3793. /**
  3794. * An event triggered when the pointer taps the control
  3795. */
  3796. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3797. /**
  3798. * An event triggered when pointer up
  3799. */
  3800. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3801. /**
  3802. * An event triggered when a control is clicked on
  3803. */
  3804. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3805. /**
  3806. * An event triggered when pointer enters the control
  3807. */
  3808. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3809. /**
  3810. * An event triggered when the control is marked as dirty
  3811. */
  3812. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3813. /**
  3814. * An event triggered before drawing the control
  3815. */
  3816. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3817. /**
  3818. * An event triggered after the control was drawn
  3819. */
  3820. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3821. /**
  3822. * An event triggered when the control has been disposed
  3823. */
  3824. this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3825. /**
  3826. * Gets or sets a fixed ratio for this control.
  3827. * When different from 0, the ratio is used to compute the "second" dimension.
  3828. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  3829. * second dimension is computed as first dimension * fixedRatio
  3830. */
  3831. this.fixedRatio = 0;
  3832. this._fixedRatioMasterIsWidth = true;
  3833. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3834. }
  3835. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3836. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3837. get: function () {
  3838. return this._shadowOffsetX;
  3839. },
  3840. set: function (value) {
  3841. if (this._shadowOffsetX === value) {
  3842. return;
  3843. }
  3844. this._shadowOffsetX = value;
  3845. this._markAsDirty();
  3846. },
  3847. enumerable: false,
  3848. configurable: true
  3849. });
  3850. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3851. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3852. get: function () {
  3853. return this._shadowOffsetY;
  3854. },
  3855. set: function (value) {
  3856. if (this._shadowOffsetY === value) {
  3857. return;
  3858. }
  3859. this._shadowOffsetY = value;
  3860. this._markAsDirty();
  3861. },
  3862. enumerable: false,
  3863. configurable: true
  3864. });
  3865. Object.defineProperty(Control.prototype, "shadowBlur", {
  3866. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3867. get: function () {
  3868. return this._shadowBlur;
  3869. },
  3870. set: function (value) {
  3871. if (this._shadowBlur === value) {
  3872. return;
  3873. }
  3874. this._shadowBlur = value;
  3875. this._markAsDirty();
  3876. },
  3877. enumerable: false,
  3878. configurable: true
  3879. });
  3880. Object.defineProperty(Control.prototype, "shadowColor", {
  3881. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3882. get: function () {
  3883. return this._shadowColor;
  3884. },
  3885. set: function (value) {
  3886. if (this._shadowColor === value) {
  3887. return;
  3888. }
  3889. this._shadowColor = value;
  3890. this._markAsDirty();
  3891. },
  3892. enumerable: false,
  3893. configurable: true
  3894. });
  3895. Object.defineProperty(Control.prototype, "typeName", {
  3896. // Properties
  3897. /** Gets the control type name */
  3898. get: function () {
  3899. return this._getTypeName();
  3900. },
  3901. enumerable: false,
  3902. configurable: true
  3903. });
  3904. /**
  3905. * Get the current class name of the control.
  3906. * @returns current class name
  3907. */
  3908. Control.prototype.getClassName = function () {
  3909. return this._getTypeName();
  3910. };
  3911. Object.defineProperty(Control.prototype, "host", {
  3912. /**
  3913. * Get the hosting AdvancedDynamicTexture
  3914. */
  3915. get: function () {
  3916. return this._host;
  3917. },
  3918. enumerable: false,
  3919. configurable: true
  3920. });
  3921. Object.defineProperty(Control.prototype, "fontOffset", {
  3922. /** Gets or set information about font offsets (used to render and align text) */
  3923. get: function () {
  3924. return this._fontOffset;
  3925. },
  3926. set: function (offset) {
  3927. this._fontOffset = offset;
  3928. },
  3929. enumerable: false,
  3930. configurable: true
  3931. });
  3932. Object.defineProperty(Control.prototype, "alpha", {
  3933. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3934. get: function () {
  3935. return this._alpha;
  3936. },
  3937. set: function (value) {
  3938. if (this._alpha === value) {
  3939. return;
  3940. }
  3941. this._alphaSet = true;
  3942. this._alpha = value;
  3943. this._markAsDirty();
  3944. },
  3945. enumerable: false,
  3946. configurable: true
  3947. });
  3948. Object.defineProperty(Control.prototype, "isHighlighted", {
  3949. /**
  3950. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3951. */
  3952. get: function () {
  3953. return this._isHighlighted;
  3954. },
  3955. set: function (value) {
  3956. if (this._isHighlighted === value) {
  3957. return;
  3958. }
  3959. this._isHighlighted = value;
  3960. this._markAsDirty();
  3961. },
  3962. enumerable: false,
  3963. configurable: true
  3964. });
  3965. Object.defineProperty(Control.prototype, "scaleX", {
  3966. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3967. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3968. */
  3969. get: function () {
  3970. return this._scaleX;
  3971. },
  3972. set: function (value) {
  3973. if (this._scaleX === value) {
  3974. return;
  3975. }
  3976. this._scaleX = value;
  3977. this._markAsDirty();
  3978. this._markMatrixAsDirty();
  3979. },
  3980. enumerable: false,
  3981. configurable: true
  3982. });
  3983. Object.defineProperty(Control.prototype, "scaleY", {
  3984. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3985. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3986. */
  3987. get: function () {
  3988. return this._scaleY;
  3989. },
  3990. set: function (value) {
  3991. if (this._scaleY === value) {
  3992. return;
  3993. }
  3994. this._scaleY = value;
  3995. this._markAsDirty();
  3996. this._markMatrixAsDirty();
  3997. },
  3998. enumerable: false,
  3999. configurable: true
  4000. });
  4001. Object.defineProperty(Control.prototype, "rotation", {
  4002. /** Gets or sets the rotation angle (0 by default)
  4003. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4004. */
  4005. get: function () {
  4006. return this._rotation;
  4007. },
  4008. set: function (value) {
  4009. if (this._rotation === value) {
  4010. return;
  4011. }
  4012. this._rotation = value;
  4013. this._markAsDirty();
  4014. this._markMatrixAsDirty();
  4015. },
  4016. enumerable: false,
  4017. configurable: true
  4018. });
  4019. Object.defineProperty(Control.prototype, "transformCenterY", {
  4020. /** Gets or sets the transformation center on Y axis (0 by default)
  4021. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4022. */
  4023. get: function () {
  4024. return this._transformCenterY;
  4025. },
  4026. set: function (value) {
  4027. if (this._transformCenterY === value) {
  4028. return;
  4029. }
  4030. this._transformCenterY = value;
  4031. this._markAsDirty();
  4032. this._markMatrixAsDirty();
  4033. },
  4034. enumerable: false,
  4035. configurable: true
  4036. });
  4037. Object.defineProperty(Control.prototype, "transformCenterX", {
  4038. /** Gets or sets the transformation center on X axis (0 by default)
  4039. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  4040. */
  4041. get: function () {
  4042. return this._transformCenterX;
  4043. },
  4044. set: function (value) {
  4045. if (this._transformCenterX === value) {
  4046. return;
  4047. }
  4048. this._transformCenterX = value;
  4049. this._markAsDirty();
  4050. this._markMatrixAsDirty();
  4051. },
  4052. enumerable: false,
  4053. configurable: true
  4054. });
  4055. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  4056. /**
  4057. * Gets or sets the horizontal alignment
  4058. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4059. */
  4060. get: function () {
  4061. return this._horizontalAlignment;
  4062. },
  4063. set: function (value) {
  4064. if (this._horizontalAlignment === value) {
  4065. return;
  4066. }
  4067. this._horizontalAlignment = value;
  4068. this._markAsDirty();
  4069. },
  4070. enumerable: false,
  4071. configurable: true
  4072. });
  4073. Object.defineProperty(Control.prototype, "verticalAlignment", {
  4074. /**
  4075. * Gets or sets the vertical alignment
  4076. * @see https://doc.babylonjs.com/how_to/gui#alignments
  4077. */
  4078. get: function () {
  4079. return this._verticalAlignment;
  4080. },
  4081. set: function (value) {
  4082. if (this._verticalAlignment === value) {
  4083. return;
  4084. }
  4085. this._verticalAlignment = value;
  4086. this._markAsDirty();
  4087. },
  4088. enumerable: false,
  4089. configurable: true
  4090. });
  4091. Object.defineProperty(Control.prototype, "width", {
  4092. /**
  4093. * Gets or sets control width
  4094. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4095. */
  4096. get: function () {
  4097. return this._width.toString(this._host);
  4098. },
  4099. set: function (value) {
  4100. this._fixedRatioMasterIsWidth = true;
  4101. if (this._width.toString(this._host) === value) {
  4102. return;
  4103. }
  4104. if (this._width.fromString(value)) {
  4105. this._markAsDirty();
  4106. }
  4107. },
  4108. enumerable: false,
  4109. configurable: true
  4110. });
  4111. Object.defineProperty(Control.prototype, "widthInPixels", {
  4112. /**
  4113. * Gets or sets the control width in pixel
  4114. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4115. */
  4116. get: function () {
  4117. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4118. },
  4119. set: function (value) {
  4120. if (isNaN(value)) {
  4121. return;
  4122. }
  4123. this._fixedRatioMasterIsWidth = true;
  4124. this.width = value + "px";
  4125. },
  4126. enumerable: false,
  4127. configurable: true
  4128. });
  4129. Object.defineProperty(Control.prototype, "height", {
  4130. /**
  4131. * Gets or sets control height
  4132. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4133. */
  4134. get: function () {
  4135. return this._height.toString(this._host);
  4136. },
  4137. set: function (value) {
  4138. this._fixedRatioMasterIsWidth = false;
  4139. if (this._height.toString(this._host) === value) {
  4140. return;
  4141. }
  4142. if (this._height.fromString(value)) {
  4143. this._markAsDirty();
  4144. }
  4145. },
  4146. enumerable: false,
  4147. configurable: true
  4148. });
  4149. Object.defineProperty(Control.prototype, "heightInPixels", {
  4150. /**
  4151. * Gets or sets control height in pixel
  4152. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4153. */
  4154. get: function () {
  4155. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4156. },
  4157. set: function (value) {
  4158. if (isNaN(value)) {
  4159. return;
  4160. }
  4161. this._fixedRatioMasterIsWidth = false;
  4162. this.height = value + "px";
  4163. },
  4164. enumerable: false,
  4165. configurable: true
  4166. });
  4167. Object.defineProperty(Control.prototype, "fontFamily", {
  4168. /** Gets or set font family */
  4169. get: function () {
  4170. if (!this._fontSet) {
  4171. return "";
  4172. }
  4173. return this._fontFamily;
  4174. },
  4175. set: function (value) {
  4176. if (this._fontFamily === value) {
  4177. return;
  4178. }
  4179. this._fontFamily = value;
  4180. this._resetFontCache();
  4181. },
  4182. enumerable: false,
  4183. configurable: true
  4184. });
  4185. Object.defineProperty(Control.prototype, "fontStyle", {
  4186. /** Gets or sets font style */
  4187. get: function () {
  4188. return this._fontStyle;
  4189. },
  4190. set: function (value) {
  4191. if (this._fontStyle === value) {
  4192. return;
  4193. }
  4194. this._fontStyle = value;
  4195. this._resetFontCache();
  4196. },
  4197. enumerable: false,
  4198. configurable: true
  4199. });
  4200. Object.defineProperty(Control.prototype, "fontWeight", {
  4201. /** Gets or sets font weight */
  4202. get: function () {
  4203. return this._fontWeight;
  4204. },
  4205. set: function (value) {
  4206. if (this._fontWeight === value) {
  4207. return;
  4208. }
  4209. this._fontWeight = value;
  4210. this._resetFontCache();
  4211. },
  4212. enumerable: false,
  4213. configurable: true
  4214. });
  4215. Object.defineProperty(Control.prototype, "style", {
  4216. /**
  4217. * Gets or sets style
  4218. * @see https://doc.babylonjs.com/how_to/gui#styles
  4219. */
  4220. get: function () {
  4221. return this._style;
  4222. },
  4223. set: function (value) {
  4224. var _this = this;
  4225. if (this._style) {
  4226. this._style.onChangedObservable.remove(this._styleObserver);
  4227. this._styleObserver = null;
  4228. }
  4229. this._style = value;
  4230. if (this._style) {
  4231. this._styleObserver = this._style.onChangedObservable.add(function () {
  4232. _this._markAsDirty();
  4233. _this._resetFontCache();
  4234. });
  4235. }
  4236. this._markAsDirty();
  4237. this._resetFontCache();
  4238. },
  4239. enumerable: false,
  4240. configurable: true
  4241. });
  4242. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4243. /** @hidden */
  4244. get: function () {
  4245. return this._fontSize.isPercentage;
  4246. },
  4247. enumerable: false,
  4248. configurable: true
  4249. });
  4250. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4251. /** Gets or sets font size in pixels */
  4252. get: function () {
  4253. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4254. if (fontSizeToUse.isPixel) {
  4255. return fontSizeToUse.getValue(this._host);
  4256. }
  4257. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4258. },
  4259. set: function (value) {
  4260. if (isNaN(value)) {
  4261. return;
  4262. }
  4263. this.fontSize = value + "px";
  4264. },
  4265. enumerable: false,
  4266. configurable: true
  4267. });
  4268. Object.defineProperty(Control.prototype, "fontSize", {
  4269. /** Gets or sets font size */
  4270. get: function () {
  4271. return this._fontSize.toString(this._host);
  4272. },
  4273. set: function (value) {
  4274. if (this._fontSize.toString(this._host) === value) {
  4275. return;
  4276. }
  4277. if (this._fontSize.fromString(value)) {
  4278. this._markAsDirty();
  4279. this._resetFontCache();
  4280. }
  4281. },
  4282. enumerable: false,
  4283. configurable: true
  4284. });
  4285. Object.defineProperty(Control.prototype, "color", {
  4286. /** Gets or sets foreground color */
  4287. get: function () {
  4288. return this._color;
  4289. },
  4290. set: function (value) {
  4291. if (this._color === value) {
  4292. return;
  4293. }
  4294. this._color = value;
  4295. this._markAsDirty();
  4296. },
  4297. enumerable: false,
  4298. configurable: true
  4299. });
  4300. Object.defineProperty(Control.prototype, "zIndex", {
  4301. /** Gets or sets z index which is used to reorder controls on the z axis */
  4302. get: function () {
  4303. return this._zIndex;
  4304. },
  4305. set: function (value) {
  4306. if (this.zIndex === value) {
  4307. return;
  4308. }
  4309. this._zIndex = value;
  4310. if (this.parent) {
  4311. this.parent._reOrderControl(this);
  4312. }
  4313. },
  4314. enumerable: false,
  4315. configurable: true
  4316. });
  4317. Object.defineProperty(Control.prototype, "notRenderable", {
  4318. /** Gets or sets a boolean indicating if the control can be rendered */
  4319. get: function () {
  4320. return this._doNotRender;
  4321. },
  4322. set: function (value) {
  4323. if (this._doNotRender === value) {
  4324. return;
  4325. }
  4326. this._doNotRender = value;
  4327. this._markAsDirty();
  4328. },
  4329. enumerable: false,
  4330. configurable: true
  4331. });
  4332. Object.defineProperty(Control.prototype, "isVisible", {
  4333. /** Gets or sets a boolean indicating if the control is visible */
  4334. get: function () {
  4335. return this._isVisible;
  4336. },
  4337. set: function (value) {
  4338. if (this._isVisible === value) {
  4339. return;
  4340. }
  4341. this._isVisible = value;
  4342. this._markAsDirty(true);
  4343. },
  4344. enumerable: false,
  4345. configurable: true
  4346. });
  4347. Object.defineProperty(Control.prototype, "isDirty", {
  4348. /** Gets a boolean indicating that the control needs to update its rendering */
  4349. get: function () {
  4350. return this._isDirty;
  4351. },
  4352. enumerable: false,
  4353. configurable: true
  4354. });
  4355. Object.defineProperty(Control.prototype, "linkedMesh", {
  4356. /**
  4357. * Gets the current linked mesh (or null if none)
  4358. */
  4359. get: function () {
  4360. return this._linkedMesh;
  4361. },
  4362. enumerable: false,
  4363. configurable: true
  4364. });
  4365. Object.defineProperty(Control.prototype, "paddingLeft", {
  4366. /**
  4367. * Gets or sets a value indicating the padding to use on the left of the control
  4368. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4369. */
  4370. get: function () {
  4371. return this._paddingLeft.toString(this._host);
  4372. },
  4373. set: function (value) {
  4374. if (this._paddingLeft.fromString(value)) {
  4375. this._markAsDirty();
  4376. }
  4377. },
  4378. enumerable: false,
  4379. configurable: true
  4380. });
  4381. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4382. /**
  4383. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4384. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4385. */
  4386. get: function () {
  4387. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4388. },
  4389. set: function (value) {
  4390. if (isNaN(value)) {
  4391. return;
  4392. }
  4393. this.paddingLeft = value + "px";
  4394. },
  4395. enumerable: false,
  4396. configurable: true
  4397. });
  4398. Object.defineProperty(Control.prototype, "paddingRight", {
  4399. /**
  4400. * Gets or sets a value indicating the padding to use on the right of the control
  4401. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4402. */
  4403. get: function () {
  4404. return this._paddingRight.toString(this._host);
  4405. },
  4406. set: function (value) {
  4407. if (this._paddingRight.fromString(value)) {
  4408. this._markAsDirty();
  4409. }
  4410. },
  4411. enumerable: false,
  4412. configurable: true
  4413. });
  4414. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4415. /**
  4416. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4417. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4418. */
  4419. get: function () {
  4420. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4421. },
  4422. set: function (value) {
  4423. if (isNaN(value)) {
  4424. return;
  4425. }
  4426. this.paddingRight = value + "px";
  4427. },
  4428. enumerable: false,
  4429. configurable: true
  4430. });
  4431. Object.defineProperty(Control.prototype, "paddingTop", {
  4432. /**
  4433. * Gets or sets a value indicating the padding to use on the top of the control
  4434. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4435. */
  4436. get: function () {
  4437. return this._paddingTop.toString(this._host);
  4438. },
  4439. set: function (value) {
  4440. if (this._paddingTop.fromString(value)) {
  4441. this._markAsDirty();
  4442. }
  4443. },
  4444. enumerable: false,
  4445. configurable: true
  4446. });
  4447. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4448. /**
  4449. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4450. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4451. */
  4452. get: function () {
  4453. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4454. },
  4455. set: function (value) {
  4456. if (isNaN(value)) {
  4457. return;
  4458. }
  4459. this.paddingTop = value + "px";
  4460. },
  4461. enumerable: false,
  4462. configurable: true
  4463. });
  4464. Object.defineProperty(Control.prototype, "paddingBottom", {
  4465. /**
  4466. * Gets or sets a value indicating the padding to use on the bottom of the control
  4467. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4468. */
  4469. get: function () {
  4470. return this._paddingBottom.toString(this._host);
  4471. },
  4472. set: function (value) {
  4473. if (this._paddingBottom.fromString(value)) {
  4474. this._markAsDirty();
  4475. }
  4476. },
  4477. enumerable: false,
  4478. configurable: true
  4479. });
  4480. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4481. /**
  4482. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4483. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4484. */
  4485. get: function () {
  4486. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4487. },
  4488. set: function (value) {
  4489. if (isNaN(value)) {
  4490. return;
  4491. }
  4492. this.paddingBottom = value + "px";
  4493. },
  4494. enumerable: false,
  4495. configurable: true
  4496. });
  4497. Object.defineProperty(Control.prototype, "left", {
  4498. /**
  4499. * Gets or sets a value indicating the left coordinate of the control
  4500. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4501. */
  4502. get: function () {
  4503. return this._left.toString(this._host);
  4504. },
  4505. set: function (value) {
  4506. if (this._left.fromString(value)) {
  4507. this._markAsDirty();
  4508. }
  4509. },
  4510. enumerable: false,
  4511. configurable: true
  4512. });
  4513. Object.defineProperty(Control.prototype, "leftInPixels", {
  4514. /**
  4515. * Gets or sets a value indicating the left coordinate in pixels of the control
  4516. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4517. */
  4518. get: function () {
  4519. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4520. },
  4521. set: function (value) {
  4522. if (isNaN(value)) {
  4523. return;
  4524. }
  4525. this.left = value + "px";
  4526. },
  4527. enumerable: false,
  4528. configurable: true
  4529. });
  4530. Object.defineProperty(Control.prototype, "top", {
  4531. /**
  4532. * Gets or sets a value indicating the top coordinate of the control
  4533. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4534. */
  4535. get: function () {
  4536. return this._top.toString(this._host);
  4537. },
  4538. set: function (value) {
  4539. if (this._top.fromString(value)) {
  4540. this._markAsDirty();
  4541. }
  4542. },
  4543. enumerable: false,
  4544. configurable: true
  4545. });
  4546. Object.defineProperty(Control.prototype, "topInPixels", {
  4547. /**
  4548. * Gets or sets a value indicating the top coordinate in pixels of the control
  4549. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  4550. */
  4551. get: function () {
  4552. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4553. },
  4554. set: function (value) {
  4555. if (isNaN(value)) {
  4556. return;
  4557. }
  4558. this.top = value + "px";
  4559. },
  4560. enumerable: false,
  4561. configurable: true
  4562. });
  4563. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4564. /**
  4565. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4566. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4567. */
  4568. get: function () {
  4569. return this._linkOffsetX.toString(this._host);
  4570. },
  4571. set: function (value) {
  4572. if (this._linkOffsetX.fromString(value)) {
  4573. this._markAsDirty();
  4574. }
  4575. },
  4576. enumerable: false,
  4577. configurable: true
  4578. });
  4579. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4580. /**
  4581. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4582. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4583. */
  4584. get: function () {
  4585. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4586. },
  4587. set: function (value) {
  4588. if (isNaN(value)) {
  4589. return;
  4590. }
  4591. this.linkOffsetX = value + "px";
  4592. },
  4593. enumerable: false,
  4594. configurable: true
  4595. });
  4596. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4597. /**
  4598. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4599. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4600. */
  4601. get: function () {
  4602. return this._linkOffsetY.toString(this._host);
  4603. },
  4604. set: function (value) {
  4605. if (this._linkOffsetY.fromString(value)) {
  4606. this._markAsDirty();
  4607. }
  4608. },
  4609. enumerable: false,
  4610. configurable: true
  4611. });
  4612. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4613. /**
  4614. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4615. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4616. */
  4617. get: function () {
  4618. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4619. },
  4620. set: function (value) {
  4621. if (isNaN(value)) {
  4622. return;
  4623. }
  4624. this.linkOffsetY = value + "px";
  4625. },
  4626. enumerable: false,
  4627. configurable: true
  4628. });
  4629. Object.defineProperty(Control.prototype, "centerX", {
  4630. /** Gets the center coordinate on X axis */
  4631. get: function () {
  4632. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4633. },
  4634. enumerable: false,
  4635. configurable: true
  4636. });
  4637. Object.defineProperty(Control.prototype, "centerY", {
  4638. /** Gets the center coordinate on Y axis */
  4639. get: function () {
  4640. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4641. },
  4642. enumerable: false,
  4643. configurable: true
  4644. });
  4645. Object.defineProperty(Control.prototype, "isEnabled", {
  4646. /** Gets or sets if control is Enabled*/
  4647. get: function () {
  4648. return this._isEnabled;
  4649. },
  4650. set: function (value) {
  4651. if (this._isEnabled === value) {
  4652. return;
  4653. }
  4654. this._isEnabled = value;
  4655. this._markAsDirty();
  4656. },
  4657. enumerable: false,
  4658. configurable: true
  4659. });
  4660. Object.defineProperty(Control.prototype, "disabledColor", {
  4661. /** Gets or sets background color of control if it's disabled*/
  4662. get: function () {
  4663. return this._disabledColor;
  4664. },
  4665. set: function (value) {
  4666. if (this._disabledColor === value) {
  4667. return;
  4668. }
  4669. this._disabledColor = value;
  4670. this._markAsDirty();
  4671. },
  4672. enumerable: false,
  4673. configurable: true
  4674. });
  4675. Object.defineProperty(Control.prototype, "disabledColorItem", {
  4676. /** Gets or sets front color of control if it's disabled*/
  4677. get: function () {
  4678. return this._disabledColorItem;
  4679. },
  4680. set: function (value) {
  4681. if (this._disabledColorItem === value) {
  4682. return;
  4683. }
  4684. this._disabledColorItem = value;
  4685. this._markAsDirty();
  4686. },
  4687. enumerable: false,
  4688. configurable: true
  4689. });
  4690. /** @hidden */
  4691. Control.prototype._getTypeName = function () {
  4692. return "Control";
  4693. };
  4694. /**
  4695. * Gets the first ascendant in the hierarchy of the given type
  4696. * @param className defines the required type
  4697. * @returns the ascendant or null if not found
  4698. */
  4699. Control.prototype.getAscendantOfClass = function (className) {
  4700. if (!this.parent) {
  4701. return null;
  4702. }
  4703. if (this.parent.getClassName() === className) {
  4704. return this.parent;
  4705. }
  4706. return this.parent.getAscendantOfClass(className);
  4707. };
  4708. /** @hidden */
  4709. Control.prototype._resetFontCache = function () {
  4710. this._fontSet = true;
  4711. this._markAsDirty();
  4712. };
  4713. /**
  4714. * Determines if a container is an ascendant of the current control
  4715. * @param container defines the container to look for
  4716. * @returns true if the container is one of the ascendant of the control
  4717. */
  4718. Control.prototype.isAscendant = function (container) {
  4719. if (!this.parent) {
  4720. return false;
  4721. }
  4722. if (this.parent === container) {
  4723. return true;
  4724. }
  4725. return this.parent.isAscendant(container);
  4726. };
  4727. /**
  4728. * Gets coordinates in local control space
  4729. * @param globalCoordinates defines the coordinates to transform
  4730. * @returns the new coordinates in local space
  4731. */
  4732. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4733. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4734. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4735. return result;
  4736. };
  4737. /**
  4738. * Gets coordinates in local control space
  4739. * @param globalCoordinates defines the coordinates to transform
  4740. * @param result defines the target vector2 where to store the result
  4741. * @returns the current control
  4742. */
  4743. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4744. result.x = globalCoordinates.x - this._currentMeasure.left;
  4745. result.y = globalCoordinates.y - this._currentMeasure.top;
  4746. return this;
  4747. };
  4748. /**
  4749. * Gets coordinates in parent local control space
  4750. * @param globalCoordinates defines the coordinates to transform
  4751. * @returns the new coordinates in parent local space
  4752. */
  4753. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4754. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4755. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4756. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4757. return result;
  4758. };
  4759. /**
  4760. * Move the current control to a vector3 position projected onto the screen.
  4761. * @param position defines the target position
  4762. * @param scene defines the hosting scene
  4763. */
  4764. Control.prototype.moveToVector3 = function (position, scene) {
  4765. if (!this._host || this.parent !== this._host._rootContainer) {
  4766. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4767. return;
  4768. }
  4769. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4770. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4771. var globalViewport = this._host._getGlobalViewport(scene);
  4772. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4773. this._moveToProjectedPosition(projectedPosition);
  4774. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4775. this.notRenderable = true;
  4776. return;
  4777. }
  4778. this.notRenderable = false;
  4779. };
  4780. /**
  4781. * Will store all controls that have this control as ascendant in a given array
  4782. * @param results defines the array where to store the descendants
  4783. * @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
  4784. * @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
  4785. */
  4786. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4787. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4788. // Do nothing by default
  4789. };
  4790. /**
  4791. * Will return all controls that have this control as ascendant
  4792. * @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
  4793. * @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
  4794. * @return all child controls
  4795. */
  4796. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4797. var results = new Array();
  4798. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4799. return results;
  4800. };
  4801. /**
  4802. * Link current control with a target mesh
  4803. * @param mesh defines the mesh to link with
  4804. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  4805. */
  4806. Control.prototype.linkWithMesh = function (mesh) {
  4807. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4808. if (mesh) {
  4809. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4810. }
  4811. return;
  4812. }
  4813. var index = this._host._linkedControls.indexOf(this);
  4814. if (index !== -1) {
  4815. this._linkedMesh = mesh;
  4816. if (!mesh) {
  4817. this._host._linkedControls.splice(index, 1);
  4818. }
  4819. return;
  4820. }
  4821. else if (!mesh) {
  4822. return;
  4823. }
  4824. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4825. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4826. this._linkedMesh = mesh;
  4827. this._host._linkedControls.push(this);
  4828. };
  4829. /** @hidden */
  4830. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4831. var oldLeft = this._left.getValue(this._host);
  4832. var oldTop = this._top.getValue(this._host);
  4833. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4834. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4835. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4836. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4837. newLeft = oldLeft;
  4838. }
  4839. if (Math.abs(newTop - oldTop) < 0.5) {
  4840. newTop = oldTop;
  4841. }
  4842. }
  4843. this.left = newLeft + "px";
  4844. this.top = newTop + "px";
  4845. this._left.ignoreAdaptiveScaling = true;
  4846. this._top.ignoreAdaptiveScaling = true;
  4847. this._markAsDirty();
  4848. };
  4849. /** @hidden */
  4850. Control.prototype._offsetLeft = function (offset) {
  4851. this._isDirty = true;
  4852. this._currentMeasure.left += offset;
  4853. };
  4854. /** @hidden */
  4855. Control.prototype._offsetTop = function (offset) {
  4856. this._isDirty = true;
  4857. this._currentMeasure.top += offset;
  4858. };
  4859. /** @hidden */
  4860. Control.prototype._markMatrixAsDirty = function () {
  4861. this._isMatrixDirty = true;
  4862. this._flagDescendantsAsMatrixDirty();
  4863. };
  4864. /** @hidden */
  4865. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4866. // No child
  4867. };
  4868. /** @hidden */
  4869. Control.prototype._intersectsRect = function (rect) {
  4870. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4871. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4872. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4873. return false;
  4874. }
  4875. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4876. return false;
  4877. }
  4878. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4879. return false;
  4880. }
  4881. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4882. return false;
  4883. }
  4884. return true;
  4885. };
  4886. /** @hidden */
  4887. Control.prototype.invalidateRect = function () {
  4888. this._transform();
  4889. if (this.host && this.host.useInvalidateRectOptimization) {
  4890. // Rotate by transform to get the measure transformed to global space
  4891. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4892. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4893. // the previous measure is used to properly clear a control that is scaled down
  4894. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4895. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4896. // Expand rect based on shadows
  4897. var shadowOffsetX = this.shadowOffsetX;
  4898. var shadowOffsetY = this.shadowOffsetY;
  4899. var shadowBlur = this.shadowBlur;
  4900. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4901. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4902. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4903. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4904. 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));
  4905. }
  4906. else {
  4907. 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));
  4908. }
  4909. }
  4910. };
  4911. /** @hidden */
  4912. Control.prototype._markAsDirty = function (force) {
  4913. if (force === void 0) { force = false; }
  4914. if (!this._isVisible && !force) {
  4915. return;
  4916. }
  4917. this._isDirty = true;
  4918. // Redraw only this rectangle
  4919. if (this._host) {
  4920. this._host.markAsDirty();
  4921. }
  4922. };
  4923. /** @hidden */
  4924. Control.prototype._markAllAsDirty = function () {
  4925. this._markAsDirty();
  4926. if (this._font) {
  4927. this._prepareFont();
  4928. }
  4929. };
  4930. /** @hidden */
  4931. Control.prototype._link = function (host) {
  4932. this._host = host;
  4933. if (this._host) {
  4934. this.uniqueId = this._host.getScene().getUniqueId();
  4935. }
  4936. };
  4937. /** @hidden */
  4938. Control.prototype._transform = function (context) {
  4939. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4940. return;
  4941. }
  4942. // postTranslate
  4943. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4944. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4945. if (context) {
  4946. context.translate(offsetX, offsetY);
  4947. // rotate
  4948. context.rotate(this._rotation);
  4949. // scale
  4950. context.scale(this._scaleX, this._scaleY);
  4951. // preTranslate
  4952. context.translate(-offsetX, -offsetY);
  4953. }
  4954. // Need to update matrices?
  4955. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4956. this._cachedOffsetX = offsetX;
  4957. this._cachedOffsetY = offsetY;
  4958. this._isMatrixDirty = false;
  4959. this._flagDescendantsAsMatrixDirty();
  4960. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4961. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4962. }
  4963. };
  4964. /** @hidden */
  4965. Control.prototype._renderHighlight = function (context) {
  4966. if (!this.isHighlighted) {
  4967. return;
  4968. }
  4969. context.save();
  4970. context.strokeStyle = "#4affff";
  4971. context.lineWidth = 2;
  4972. this._renderHighlightSpecific(context);
  4973. context.restore();
  4974. };
  4975. /** @hidden */
  4976. Control.prototype._renderHighlightSpecific = function (context) {
  4977. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4978. };
  4979. /** @hidden */
  4980. Control.prototype._applyStates = function (context) {
  4981. if (this._isFontSizeInPercentage) {
  4982. this._fontSet = true;
  4983. }
  4984. if (this._fontSet) {
  4985. this._prepareFont();
  4986. this._fontSet = false;
  4987. }
  4988. if (this._font) {
  4989. context.font = this._font;
  4990. }
  4991. if (this._color) {
  4992. context.fillStyle = this._color;
  4993. }
  4994. if (Control.AllowAlphaInheritance) {
  4995. context.globalAlpha *= this._alpha;
  4996. }
  4997. else if (this._alphaSet) {
  4998. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4999. }
  5000. };
  5001. /** @hidden */
  5002. Control.prototype._layout = function (parentMeasure, context) {
  5003. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  5004. return false;
  5005. }
  5006. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  5007. this.host._numLayoutCalls++;
  5008. this._currentMeasure.addAndTransformToRef(this._transformMatrix, -this.paddingLeftInPixels | 0, -this.paddingTopInPixels | 0, this.paddingRightInPixels | 0, this.paddingBottomInPixels | 0, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  5009. context.save();
  5010. this._applyStates(context);
  5011. var rebuildCount = 0;
  5012. do {
  5013. this._rebuildLayout = false;
  5014. this._processMeasures(parentMeasure, context);
  5015. rebuildCount++;
  5016. } while (this._rebuildLayout && rebuildCount < 3);
  5017. if (rebuildCount >= 3) {
  5018. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  5019. }
  5020. context.restore();
  5021. this.invalidateRect();
  5022. this._evaluateClippingState(parentMeasure);
  5023. }
  5024. this._wasDirty = this._isDirty;
  5025. this._isDirty = false;
  5026. return true;
  5027. };
  5028. /** @hidden */
  5029. Control.prototype._processMeasures = function (parentMeasure, context) {
  5030. this._currentMeasure.copyFrom(parentMeasure);
  5031. // Let children take some pre-measurement actions
  5032. this._preMeasure(parentMeasure, context);
  5033. this._measure();
  5034. this._computeAlignment(parentMeasure, context);
  5035. // Convert to int values
  5036. this._currentMeasure.left = this._currentMeasure.left | 0;
  5037. this._currentMeasure.top = this._currentMeasure.top | 0;
  5038. this._currentMeasure.width = this._currentMeasure.width | 0;
  5039. this._currentMeasure.height = this._currentMeasure.height | 0;
  5040. // Let children add more features
  5041. this._additionalProcessing(parentMeasure, context);
  5042. this._cachedParentMeasure.copyFrom(parentMeasure);
  5043. if (this.onDirtyObservable.hasObservers()) {
  5044. this.onDirtyObservable.notifyObservers(this);
  5045. }
  5046. };
  5047. Control.prototype._evaluateClippingState = function (parentMeasure) {
  5048. if (this.parent && this.parent.clipChildren) {
  5049. // Early clip
  5050. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  5051. this._isClipped = true;
  5052. return;
  5053. }
  5054. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  5055. this._isClipped = true;
  5056. return;
  5057. }
  5058. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  5059. this._isClipped = true;
  5060. return;
  5061. }
  5062. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  5063. this._isClipped = true;
  5064. return;
  5065. }
  5066. }
  5067. this._isClipped = false;
  5068. };
  5069. /** @hidden */
  5070. Control.prototype._measure = function () {
  5071. // Width / Height
  5072. if (this._width.isPixel) {
  5073. this._currentMeasure.width = this._width.getValue(this._host);
  5074. }
  5075. else {
  5076. this._currentMeasure.width *= this._width.getValue(this._host);
  5077. }
  5078. if (this._height.isPixel) {
  5079. this._currentMeasure.height = this._height.getValue(this._host);
  5080. }
  5081. else {
  5082. this._currentMeasure.height *= this._height.getValue(this._host);
  5083. }
  5084. if (this.fixedRatio !== 0) {
  5085. if (this._fixedRatioMasterIsWidth) {
  5086. this._currentMeasure.height = this._currentMeasure.width * this.fixedRatio;
  5087. }
  5088. else {
  5089. this._currentMeasure.width = this._currentMeasure.height * this.fixedRatio;
  5090. }
  5091. }
  5092. };
  5093. /** @hidden */
  5094. Control.prototype._computeAlignment = function (parentMeasure, context) {
  5095. var width = this._currentMeasure.width;
  5096. var height = this._currentMeasure.height;
  5097. var parentWidth = parentMeasure.width;
  5098. var parentHeight = parentMeasure.height;
  5099. // Left / top
  5100. var x = 0;
  5101. var y = 0;
  5102. switch (this.horizontalAlignment) {
  5103. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  5104. x = 0;
  5105. break;
  5106. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  5107. x = parentWidth - width;
  5108. break;
  5109. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  5110. x = (parentWidth - width) / 2;
  5111. break;
  5112. }
  5113. switch (this.verticalAlignment) {
  5114. case Control.VERTICAL_ALIGNMENT_TOP:
  5115. y = 0;
  5116. break;
  5117. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  5118. y = parentHeight - height;
  5119. break;
  5120. case Control.VERTICAL_ALIGNMENT_CENTER:
  5121. y = (parentHeight - height) / 2;
  5122. break;
  5123. }
  5124. if (this._paddingLeft.isPixel) {
  5125. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  5126. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  5127. }
  5128. else {
  5129. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  5130. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  5131. }
  5132. if (this._paddingRight.isPixel) {
  5133. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  5134. }
  5135. else {
  5136. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  5137. }
  5138. if (this._paddingTop.isPixel) {
  5139. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  5140. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  5141. }
  5142. else {
  5143. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  5144. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  5145. }
  5146. if (this._paddingBottom.isPixel) {
  5147. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  5148. }
  5149. else {
  5150. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  5151. }
  5152. if (this._left.isPixel) {
  5153. this._currentMeasure.left += this._left.getValue(this._host);
  5154. }
  5155. else {
  5156. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  5157. }
  5158. if (this._top.isPixel) {
  5159. this._currentMeasure.top += this._top.getValue(this._host);
  5160. }
  5161. else {
  5162. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  5163. }
  5164. this._currentMeasure.left += x;
  5165. this._currentMeasure.top += y;
  5166. };
  5167. /** @hidden */
  5168. Control.prototype._preMeasure = function (parentMeasure, context) {
  5169. // Do nothing
  5170. };
  5171. /** @hidden */
  5172. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  5173. // Do nothing
  5174. };
  5175. /** @hidden */
  5176. Control.prototype._clipForChildren = function (context) {
  5177. // DO nothing
  5178. };
  5179. Control.prototype._clip = function (context, invalidatedRectangle) {
  5180. context.beginPath();
  5181. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5182. if (invalidatedRectangle) {
  5183. // Rotate the invalidated rect into the control's space
  5184. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5185. // Get the intersection of the rect in context space and the current context
  5186. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5187. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5188. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5189. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5190. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5191. Control._ClipMeasure.copyFrom(intersection);
  5192. }
  5193. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5194. var shadowOffsetX = this.shadowOffsetX;
  5195. var shadowOffsetY = this.shadowOffsetY;
  5196. var shadowBlur = this.shadowBlur;
  5197. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5198. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5199. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5200. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5201. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5202. }
  5203. else {
  5204. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5205. }
  5206. context.clip();
  5207. };
  5208. /** @hidden */
  5209. Control.prototype._render = function (context, invalidatedRectangle) {
  5210. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5211. this._isDirty = false;
  5212. return false;
  5213. }
  5214. this.host._numRenderCalls++;
  5215. context.save();
  5216. this._applyStates(context);
  5217. // Transform
  5218. this._transform(context);
  5219. // Clip
  5220. if (this.clipContent) {
  5221. this._clip(context, invalidatedRectangle);
  5222. }
  5223. if (this.onBeforeDrawObservable.hasObservers()) {
  5224. this.onBeforeDrawObservable.notifyObservers(this);
  5225. }
  5226. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5227. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5228. }
  5229. else {
  5230. this._draw(context, invalidatedRectangle);
  5231. }
  5232. if (this.useBitmapCache && this._wasDirty) {
  5233. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5234. }
  5235. this._renderHighlight(context);
  5236. if (this.onAfterDrawObservable.hasObservers()) {
  5237. this.onAfterDrawObservable.notifyObservers(this);
  5238. }
  5239. context.restore();
  5240. return true;
  5241. };
  5242. /** @hidden */
  5243. Control.prototype._draw = function (context, invalidatedRectangle) {
  5244. // Do nothing
  5245. };
  5246. /**
  5247. * Tests if a given coordinates belong to the current control
  5248. * @param x defines x coordinate to test
  5249. * @param y defines y coordinate to test
  5250. * @returns true if the coordinates are inside the control
  5251. */
  5252. Control.prototype.contains = function (x, y) {
  5253. // Invert transform
  5254. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5255. x = this._transformedPosition.x;
  5256. y = this._transformedPosition.y;
  5257. // Check
  5258. if (x < this._currentMeasure.left) {
  5259. return false;
  5260. }
  5261. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5262. return false;
  5263. }
  5264. if (y < this._currentMeasure.top) {
  5265. return false;
  5266. }
  5267. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5268. return false;
  5269. }
  5270. if (this.isPointerBlocker) {
  5271. this._host._shouldBlockPointer = true;
  5272. }
  5273. return true;
  5274. };
  5275. /** @hidden */
  5276. Control.prototype._processPicking = function (x, y, pi, type, pointerId, buttonIndex, deltaX, deltaY) {
  5277. if (!this._isEnabled) {
  5278. return false;
  5279. }
  5280. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5281. return false;
  5282. }
  5283. if (!this.contains(x, y)) {
  5284. return false;
  5285. }
  5286. this._processObservables(type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY);
  5287. return true;
  5288. };
  5289. /** @hidden */
  5290. Control.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  5291. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this, pi);
  5292. if (canNotify && this.parent != null) {
  5293. this.parent._onPointerMove(target, coordinates, pointerId, pi);
  5294. }
  5295. };
  5296. /** @hidden */
  5297. Control.prototype._onPointerEnter = function (target, pi) {
  5298. if (!this._isEnabled) {
  5299. return false;
  5300. }
  5301. if (this._enterCount > 0) {
  5302. return false;
  5303. }
  5304. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5305. this._enterCount = 0;
  5306. }
  5307. this._enterCount++;
  5308. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this, pi);
  5309. if (canNotify && this.parent != null) {
  5310. this.parent._onPointerEnter(target, pi);
  5311. }
  5312. return true;
  5313. };
  5314. /** @hidden */
  5315. Control.prototype._onPointerOut = function (target, pi, force) {
  5316. if (force === void 0) { force = false; }
  5317. if (!force && (!this._isEnabled || target === this)) {
  5318. return;
  5319. }
  5320. this._enterCount = 0;
  5321. var canNotify = true;
  5322. if (!target.isAscendant(this)) {
  5323. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this, pi);
  5324. }
  5325. if (canNotify && this.parent != null) {
  5326. this.parent._onPointerOut(target, pi, force);
  5327. }
  5328. };
  5329. /** @hidden */
  5330. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  5331. // Prevent pointerout to lose control context.
  5332. // Event redundancy is checked inside the function.
  5333. this._onPointerEnter(this, pi);
  5334. if (this._downCount !== 0) {
  5335. return false;
  5336. }
  5337. this._downCount++;
  5338. this._downPointerIds[pointerId] = true;
  5339. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5340. if (canNotify && this.parent != null) {
  5341. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex, pi);
  5342. }
  5343. return true;
  5344. };
  5345. /** @hidden */
  5346. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick, pi) {
  5347. if (!this._isEnabled) {
  5348. return;
  5349. }
  5350. this._downCount = 0;
  5351. delete this._downPointerIds[pointerId];
  5352. var canNotifyClick = notifyClick;
  5353. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5354. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5355. }
  5356. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this, pi);
  5357. if (canNotify && this.parent != null) {
  5358. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick, pi);
  5359. }
  5360. };
  5361. /** @hidden */
  5362. Control.prototype._forcePointerUp = function (pointerId) {
  5363. if (pointerId === void 0) { pointerId = null; }
  5364. if (pointerId !== null) {
  5365. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5366. }
  5367. else {
  5368. for (var key in this._downPointerIds) {
  5369. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5370. }
  5371. }
  5372. };
  5373. /** @hidden */
  5374. Control.prototype._onWheelScroll = function (deltaX, deltaY) {
  5375. if (!this._isEnabled) {
  5376. return;
  5377. }
  5378. var canNotify = this.onWheelObservable.notifyObservers(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"](deltaX, deltaY));
  5379. if (canNotify && this.parent != null) {
  5380. this.parent._onWheelScroll(deltaX, deltaY);
  5381. }
  5382. };
  5383. /** @hidden */
  5384. Control.prototype._onCanvasBlur = function () { };
  5385. /** @hidden */
  5386. Control.prototype._processObservables = function (type, x, y, pi, pointerId, buttonIndex, deltaX, deltaY) {
  5387. if (!this._isEnabled) {
  5388. return false;
  5389. }
  5390. this._dummyVector2.copyFromFloats(x, y);
  5391. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5392. this._onPointerMove(this, this._dummyVector2, pointerId, pi);
  5393. var previousControlOver = this._host._lastControlOver[pointerId];
  5394. if (previousControlOver && previousControlOver !== this) {
  5395. previousControlOver._onPointerOut(this, pi);
  5396. }
  5397. if (previousControlOver !== this) {
  5398. this._onPointerEnter(this, pi);
  5399. }
  5400. this._host._lastControlOver[pointerId] = this;
  5401. return true;
  5402. }
  5403. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5404. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex, pi);
  5405. this._host._registerLastControlDown(this, pointerId);
  5406. this._host._lastPickedControl = this;
  5407. return true;
  5408. }
  5409. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5410. if (this._host._lastControlDown[pointerId]) {
  5411. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true, pi);
  5412. }
  5413. delete this._host._lastControlDown[pointerId];
  5414. return true;
  5415. }
  5416. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERWHEEL) {
  5417. if (this._host._lastControlOver[pointerId]) {
  5418. this._host._lastControlOver[pointerId]._onWheelScroll(deltaX, deltaY);
  5419. return true;
  5420. }
  5421. }
  5422. return false;
  5423. };
  5424. Control.prototype._prepareFont = function () {
  5425. if (!this._font && !this._fontSet) {
  5426. return;
  5427. }
  5428. if (this._style) {
  5429. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5430. }
  5431. else {
  5432. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5433. }
  5434. this._fontOffset = Control._GetFontOffset(this._font);
  5435. };
  5436. /** Releases associated resources */
  5437. Control.prototype.dispose = function () {
  5438. this.onDirtyObservable.clear();
  5439. this.onBeforeDrawObservable.clear();
  5440. this.onAfterDrawObservable.clear();
  5441. this.onPointerDownObservable.clear();
  5442. this.onPointerEnterObservable.clear();
  5443. this.onPointerMoveObservable.clear();
  5444. this.onPointerOutObservable.clear();
  5445. this.onPointerUpObservable.clear();
  5446. this.onPointerClickObservable.clear();
  5447. this.onWheelObservable.clear();
  5448. if (this._styleObserver && this._style) {
  5449. this._style.onChangedObservable.remove(this._styleObserver);
  5450. this._styleObserver = null;
  5451. }
  5452. if (this.parent) {
  5453. this.parent.removeControl(this);
  5454. this.parent = null;
  5455. }
  5456. if (this._host) {
  5457. var index = this._host._linkedControls.indexOf(this);
  5458. if (index > -1) {
  5459. this.linkWithMesh(null);
  5460. }
  5461. }
  5462. // Callback
  5463. this.onDisposeObservable.notifyObservers(this);
  5464. this.onDisposeObservable.clear();
  5465. };
  5466. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5467. /** HORIZONTAL_ALIGNMENT_LEFT */
  5468. get: function () {
  5469. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5470. },
  5471. enumerable: false,
  5472. configurable: true
  5473. });
  5474. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5475. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5476. get: function () {
  5477. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5478. },
  5479. enumerable: false,
  5480. configurable: true
  5481. });
  5482. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5483. /** HORIZONTAL_ALIGNMENT_CENTER */
  5484. get: function () {
  5485. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5486. },
  5487. enumerable: false,
  5488. configurable: true
  5489. });
  5490. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5491. /** VERTICAL_ALIGNMENT_TOP */
  5492. get: function () {
  5493. return Control._VERTICAL_ALIGNMENT_TOP;
  5494. },
  5495. enumerable: false,
  5496. configurable: true
  5497. });
  5498. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5499. /** VERTICAL_ALIGNMENT_BOTTOM */
  5500. get: function () {
  5501. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5502. },
  5503. enumerable: false,
  5504. configurable: true
  5505. });
  5506. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5507. /** VERTICAL_ALIGNMENT_CENTER */
  5508. get: function () {
  5509. return Control._VERTICAL_ALIGNMENT_CENTER;
  5510. },
  5511. enumerable: false,
  5512. configurable: true
  5513. });
  5514. /** @hidden */
  5515. Control._GetFontOffset = function (font) {
  5516. if (Control._FontHeightSizes[font]) {
  5517. return Control._FontHeightSizes[font];
  5518. }
  5519. var text = document.createElement("span");
  5520. text.innerHTML = "Hg";
  5521. text.style.font = font;
  5522. var block = document.createElement("div");
  5523. block.style.display = "inline-block";
  5524. block.style.width = "1px";
  5525. block.style.height = "0px";
  5526. block.style.verticalAlign = "bottom";
  5527. var div = document.createElement("div");
  5528. div.style.whiteSpace = "nowrap";
  5529. div.appendChild(text);
  5530. div.appendChild(block);
  5531. document.body.appendChild(div);
  5532. var fontAscent = 0;
  5533. var fontHeight = 0;
  5534. try {
  5535. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5536. block.style.verticalAlign = "baseline";
  5537. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5538. }
  5539. finally {
  5540. document.body.removeChild(div);
  5541. }
  5542. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5543. Control._FontHeightSizes[font] = result;
  5544. return result;
  5545. };
  5546. /** @hidden */
  5547. Control.drawEllipse = function (x, y, width, height, context) {
  5548. context.translate(x, y);
  5549. context.scale(width, height);
  5550. context.beginPath();
  5551. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5552. context.closePath();
  5553. context.scale(1 / width, 1 / height);
  5554. context.translate(-x, -y);
  5555. };
  5556. /**
  5557. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5558. */
  5559. Control.AllowAlphaInheritance = false;
  5560. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5561. // Statics
  5562. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5563. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5564. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5565. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5566. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5567. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5568. Control._FontHeightSizes = {};
  5569. /**
  5570. * Creates a stack panel that can be used to render headers
  5571. * @param control defines the control to associate with the header
  5572. * @param text defines the text of the header
  5573. * @param size defines the size of the header
  5574. * @param options defines options used to configure the header
  5575. * @returns a new StackPanel
  5576. * @ignore
  5577. * @hidden
  5578. */
  5579. Control.AddHeader = function () { };
  5580. return Control;
  5581. }());
  5582. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5583. /***/ }),
  5584. /***/ "./2D/controls/displayGrid.ts":
  5585. /*!************************************!*\
  5586. !*** ./2D/controls/displayGrid.ts ***!
  5587. \************************************/
  5588. /*! exports provided: DisplayGrid */
  5589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5590. "use strict";
  5591. __webpack_require__.r(__webpack_exports__);
  5592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5593. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5594. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5595. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  5596. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5597. /** Class used to render a grid */
  5598. var DisplayGrid = /** @class */ (function (_super) {
  5599. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5600. /**
  5601. * Creates a new GridDisplayRectangle
  5602. * @param name defines the control name
  5603. */
  5604. function DisplayGrid(name) {
  5605. var _this = _super.call(this, name) || this;
  5606. _this.name = name;
  5607. _this._cellWidth = 20;
  5608. _this._cellHeight = 20;
  5609. _this._minorLineTickness = 1;
  5610. _this._minorLineColor = "DarkGray";
  5611. _this._majorLineTickness = 2;
  5612. _this._majorLineColor = "White";
  5613. _this._majorLineFrequency = 5;
  5614. _this._background = "Black";
  5615. _this._displayMajorLines = true;
  5616. _this._displayMinorLines = true;
  5617. return _this;
  5618. }
  5619. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5620. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5621. get: function () {
  5622. return this._displayMinorLines;
  5623. },
  5624. set: function (value) {
  5625. if (this._displayMinorLines === value) {
  5626. return;
  5627. }
  5628. this._displayMinorLines = value;
  5629. this._markAsDirty();
  5630. },
  5631. enumerable: false,
  5632. configurable: true
  5633. });
  5634. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5635. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5636. get: function () {
  5637. return this._displayMajorLines;
  5638. },
  5639. set: function (value) {
  5640. if (this._displayMajorLines === value) {
  5641. return;
  5642. }
  5643. this._displayMajorLines = value;
  5644. this._markAsDirty();
  5645. },
  5646. enumerable: false,
  5647. configurable: true
  5648. });
  5649. Object.defineProperty(DisplayGrid.prototype, "background", {
  5650. /** Gets or sets background color (Black by default) */
  5651. get: function () {
  5652. return this._background;
  5653. },
  5654. set: function (value) {
  5655. if (this._background === value) {
  5656. return;
  5657. }
  5658. this._background = value;
  5659. this._markAsDirty();
  5660. },
  5661. enumerable: false,
  5662. configurable: true
  5663. });
  5664. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5665. /** Gets or sets the width of each cell (20 by default) */
  5666. get: function () {
  5667. return this._cellWidth;
  5668. },
  5669. set: function (value) {
  5670. this._cellWidth = value;
  5671. this._markAsDirty();
  5672. },
  5673. enumerable: false,
  5674. configurable: true
  5675. });
  5676. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5677. /** Gets or sets the height of each cell (20 by default) */
  5678. get: function () {
  5679. return this._cellHeight;
  5680. },
  5681. set: function (value) {
  5682. this._cellHeight = value;
  5683. this._markAsDirty();
  5684. },
  5685. enumerable: false,
  5686. configurable: true
  5687. });
  5688. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5689. /** Gets or sets the tickness of minor lines (1 by default) */
  5690. get: function () {
  5691. return this._minorLineTickness;
  5692. },
  5693. set: function (value) {
  5694. this._minorLineTickness = value;
  5695. this._markAsDirty();
  5696. },
  5697. enumerable: false,
  5698. configurable: true
  5699. });
  5700. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5701. /** Gets or sets the color of minor lines (DarkGray by default) */
  5702. get: function () {
  5703. return this._minorLineColor;
  5704. },
  5705. set: function (value) {
  5706. this._minorLineColor = value;
  5707. this._markAsDirty();
  5708. },
  5709. enumerable: false,
  5710. configurable: true
  5711. });
  5712. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5713. /** Gets or sets the tickness of major lines (2 by default) */
  5714. get: function () {
  5715. return this._majorLineTickness;
  5716. },
  5717. set: function (value) {
  5718. this._majorLineTickness = value;
  5719. this._markAsDirty();
  5720. },
  5721. enumerable: false,
  5722. configurable: true
  5723. });
  5724. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5725. /** Gets or sets the color of major lines (White by default) */
  5726. get: function () {
  5727. return this._majorLineColor;
  5728. },
  5729. set: function (value) {
  5730. this._majorLineColor = value;
  5731. this._markAsDirty();
  5732. },
  5733. enumerable: false,
  5734. configurable: true
  5735. });
  5736. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5737. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5738. get: function () {
  5739. return this._majorLineFrequency;
  5740. },
  5741. set: function (value) {
  5742. this._majorLineFrequency = value;
  5743. this._markAsDirty();
  5744. },
  5745. enumerable: false,
  5746. configurable: true
  5747. });
  5748. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5749. context.save();
  5750. this._applyStates(context);
  5751. if (this._isEnabled) {
  5752. if (this._background) {
  5753. context.fillStyle = this._background;
  5754. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5755. }
  5756. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5757. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5758. // Minor lines
  5759. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5760. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5761. if (this._displayMinorLines) {
  5762. context.strokeStyle = this._minorLineColor;
  5763. context.lineWidth = this._minorLineTickness;
  5764. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5765. var cellX = left + x * this.cellWidth;
  5766. context.beginPath();
  5767. context.moveTo(cellX, this._currentMeasure.top);
  5768. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5769. context.stroke();
  5770. }
  5771. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5772. var cellY = top_1 + y * this.cellHeight;
  5773. context.beginPath();
  5774. context.moveTo(this._currentMeasure.left, cellY);
  5775. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5776. context.stroke();
  5777. }
  5778. }
  5779. // Major lines
  5780. if (this._displayMajorLines) {
  5781. context.strokeStyle = this._majorLineColor;
  5782. context.lineWidth = this._majorLineTickness;
  5783. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5784. var cellX = left + x * this.cellWidth;
  5785. context.beginPath();
  5786. context.moveTo(cellX, this._currentMeasure.top);
  5787. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5788. context.stroke();
  5789. }
  5790. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5791. var cellY = top_1 + y * this.cellHeight;
  5792. context.moveTo(this._currentMeasure.left, cellY);
  5793. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5794. context.closePath();
  5795. context.stroke();
  5796. }
  5797. }
  5798. }
  5799. context.restore();
  5800. };
  5801. DisplayGrid.prototype._getTypeName = function () {
  5802. return "DisplayGrid";
  5803. };
  5804. return DisplayGrid;
  5805. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5806. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5807. /***/ }),
  5808. /***/ "./2D/controls/ellipse.ts":
  5809. /*!********************************!*\
  5810. !*** ./2D/controls/ellipse.ts ***!
  5811. \********************************/
  5812. /*! exports provided: Ellipse */
  5813. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5814. "use strict";
  5815. __webpack_require__.r(__webpack_exports__);
  5816. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5817. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5818. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5819. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5820. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  5821. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5822. /** Class used to create 2D ellipse containers */
  5823. var Ellipse = /** @class */ (function (_super) {
  5824. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5825. /**
  5826. * Creates a new Ellipse
  5827. * @param name defines the control name
  5828. */
  5829. function Ellipse(name) {
  5830. var _this = _super.call(this, name) || this;
  5831. _this.name = name;
  5832. _this._thickness = 1;
  5833. return _this;
  5834. }
  5835. Object.defineProperty(Ellipse.prototype, "thickness", {
  5836. /** Gets or sets border thickness */
  5837. get: function () {
  5838. return this._thickness;
  5839. },
  5840. set: function (value) {
  5841. if (this._thickness === value) {
  5842. return;
  5843. }
  5844. this._thickness = value;
  5845. this._markAsDirty();
  5846. },
  5847. enumerable: false,
  5848. configurable: true
  5849. });
  5850. Ellipse.prototype._getTypeName = function () {
  5851. return "Ellipse";
  5852. };
  5853. Ellipse.prototype._localDraw = function (context) {
  5854. context.save();
  5855. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5856. context.shadowColor = this.shadowColor;
  5857. context.shadowBlur = this.shadowBlur;
  5858. context.shadowOffsetX = this.shadowOffsetX;
  5859. context.shadowOffsetY = this.shadowOffsetY;
  5860. }
  5861. _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);
  5862. if (this._background) {
  5863. context.fillStyle = this._background;
  5864. context.fill();
  5865. }
  5866. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5867. context.shadowBlur = 0;
  5868. context.shadowOffsetX = 0;
  5869. context.shadowOffsetY = 0;
  5870. }
  5871. if (this._thickness) {
  5872. if (this.color) {
  5873. context.strokeStyle = this.color;
  5874. }
  5875. context.lineWidth = this._thickness;
  5876. context.stroke();
  5877. }
  5878. context.restore();
  5879. };
  5880. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5881. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5882. this._measureForChildren.width -= 2 * this._thickness;
  5883. this._measureForChildren.height -= 2 * this._thickness;
  5884. this._measureForChildren.left += this._thickness;
  5885. this._measureForChildren.top += this._thickness;
  5886. };
  5887. Ellipse.prototype._clipForChildren = function (context) {
  5888. _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);
  5889. context.clip();
  5890. };
  5891. return Ellipse;
  5892. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5893. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5894. /***/ }),
  5895. /***/ "./2D/controls/grid.ts":
  5896. /*!*****************************!*\
  5897. !*** ./2D/controls/grid.ts ***!
  5898. \*****************************/
  5899. /*! exports provided: Grid */
  5900. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5901. "use strict";
  5902. __webpack_require__.r(__webpack_exports__);
  5903. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5904. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5905. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5906. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5907. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5908. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  5909. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5910. /**
  5911. * Class used to create a 2D grid container
  5912. */
  5913. var Grid = /** @class */ (function (_super) {
  5914. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5915. /**
  5916. * Creates a new Grid
  5917. * @param name defines control name
  5918. */
  5919. function Grid(name) {
  5920. var _this = _super.call(this, name) || this;
  5921. _this.name = name;
  5922. _this._rowDefinitions = new Array();
  5923. _this._columnDefinitions = new Array();
  5924. _this._cells = {};
  5925. _this._childControls = new Array();
  5926. return _this;
  5927. }
  5928. Object.defineProperty(Grid.prototype, "columnCount", {
  5929. /**
  5930. * Gets the number of columns
  5931. */
  5932. get: function () {
  5933. return this._columnDefinitions.length;
  5934. },
  5935. enumerable: false,
  5936. configurable: true
  5937. });
  5938. Object.defineProperty(Grid.prototype, "rowCount", {
  5939. /**
  5940. * Gets the number of rows
  5941. */
  5942. get: function () {
  5943. return this._rowDefinitions.length;
  5944. },
  5945. enumerable: false,
  5946. configurable: true
  5947. });
  5948. Object.defineProperty(Grid.prototype, "children", {
  5949. /** Gets the list of children */
  5950. get: function () {
  5951. return this._childControls;
  5952. },
  5953. enumerable: false,
  5954. configurable: true
  5955. });
  5956. Object.defineProperty(Grid.prototype, "cells", {
  5957. /** Gets the list of cells (e.g. the containers) */
  5958. get: function () {
  5959. return this._cells;
  5960. },
  5961. enumerable: false,
  5962. configurable: true
  5963. });
  5964. /**
  5965. * Gets the definition of a specific row
  5966. * @param index defines the index of the row
  5967. * @returns the row definition
  5968. */
  5969. Grid.prototype.getRowDefinition = function (index) {
  5970. if (index < 0 || index >= this._rowDefinitions.length) {
  5971. return null;
  5972. }
  5973. return this._rowDefinitions[index];
  5974. };
  5975. /**
  5976. * Gets the definition of a specific column
  5977. * @param index defines the index of the column
  5978. * @returns the column definition
  5979. */
  5980. Grid.prototype.getColumnDefinition = function (index) {
  5981. if (index < 0 || index >= this._columnDefinitions.length) {
  5982. return null;
  5983. }
  5984. return this._columnDefinitions[index];
  5985. };
  5986. /**
  5987. * Adds a new row to the grid
  5988. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5989. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5990. * @returns the current grid
  5991. */
  5992. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5993. if (isPixel === void 0) { isPixel = false; }
  5994. 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));
  5995. this._markAsDirty();
  5996. return this;
  5997. };
  5998. /**
  5999. * Adds a new column to the grid
  6000. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6001. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6002. * @returns the current grid
  6003. */
  6004. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  6005. if (isPixel === void 0) { isPixel = false; }
  6006. 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));
  6007. this._markAsDirty();
  6008. return this;
  6009. };
  6010. /**
  6011. * Update a row definition
  6012. * @param index defines the index of the row to update
  6013. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  6014. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  6015. * @returns the current grid
  6016. */
  6017. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  6018. if (isPixel === void 0) { isPixel = false; }
  6019. if (index < 0 || index >= this._rowDefinitions.length) {
  6020. return this;
  6021. }
  6022. var current = this._rowDefinitions[index];
  6023. if (current && current.isPixel === isPixel && current.internalValue === height) {
  6024. return this;
  6025. }
  6026. 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);
  6027. this._markAsDirty();
  6028. return this;
  6029. };
  6030. /**
  6031. * Update a column definition
  6032. * @param index defines the index of the column to update
  6033. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  6034. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  6035. * @returns the current grid
  6036. */
  6037. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  6038. if (isPixel === void 0) { isPixel = false; }
  6039. if (index < 0 || index >= this._columnDefinitions.length) {
  6040. return this;
  6041. }
  6042. var current = this._columnDefinitions[index];
  6043. if (current && current.isPixel === isPixel && current.internalValue === width) {
  6044. return this;
  6045. }
  6046. 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);
  6047. this._markAsDirty();
  6048. return this;
  6049. };
  6050. /**
  6051. * Gets the list of children stored in a specific cell
  6052. * @param row defines the row to check
  6053. * @param column defines the column to check
  6054. * @returns the list of controls
  6055. */
  6056. Grid.prototype.getChildrenAt = function (row, column) {
  6057. var cell = this._cells[row + ":" + column];
  6058. if (!cell) {
  6059. return null;
  6060. }
  6061. return cell.children;
  6062. };
  6063. /**
  6064. * Gets a string representing the child cell info (row x column)
  6065. * @param child defines the control to get info from
  6066. * @returns a string containing the child cell info (row x column)
  6067. */
  6068. Grid.prototype.getChildCellInfo = function (child) {
  6069. return child._tag;
  6070. };
  6071. Grid.prototype._removeCell = function (cell, key) {
  6072. if (!cell) {
  6073. return;
  6074. }
  6075. _super.prototype.removeControl.call(this, cell);
  6076. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  6077. var control = _a[_i];
  6078. var childIndex = this._childControls.indexOf(control);
  6079. if (childIndex !== -1) {
  6080. this._childControls.splice(childIndex, 1);
  6081. }
  6082. }
  6083. delete this._cells[key];
  6084. };
  6085. Grid.prototype._offsetCell = function (previousKey, key) {
  6086. if (!this._cells[key]) {
  6087. return;
  6088. }
  6089. this._cells[previousKey] = this._cells[key];
  6090. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  6091. var control = _a[_i];
  6092. control._tag = previousKey;
  6093. }
  6094. delete this._cells[key];
  6095. };
  6096. /**
  6097. * Remove a column definition at specified index
  6098. * @param index defines the index of the column to remove
  6099. * @returns the current grid
  6100. */
  6101. Grid.prototype.removeColumnDefinition = function (index) {
  6102. if (index < 0 || index >= this._columnDefinitions.length) {
  6103. return this;
  6104. }
  6105. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6106. var key = x + ":" + index;
  6107. var cell = this._cells[key];
  6108. this._removeCell(cell, key);
  6109. }
  6110. for (var x = 0; x < this._rowDefinitions.length; x++) {
  6111. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  6112. var previousKey = x + ":" + (y - 1);
  6113. var key = x + ":" + y;
  6114. this._offsetCell(previousKey, key);
  6115. }
  6116. }
  6117. this._columnDefinitions.splice(index, 1);
  6118. this._markAsDirty();
  6119. return this;
  6120. };
  6121. /**
  6122. * Remove a row definition at specified index
  6123. * @param index defines the index of the row to remove
  6124. * @returns the current grid
  6125. */
  6126. Grid.prototype.removeRowDefinition = function (index) {
  6127. if (index < 0 || index >= this._rowDefinitions.length) {
  6128. return this;
  6129. }
  6130. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6131. var key = index + ":" + y;
  6132. var cell = this._cells[key];
  6133. this._removeCell(cell, key);
  6134. }
  6135. for (var y = 0; y < this._columnDefinitions.length; y++) {
  6136. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  6137. var previousKey = x - 1 + ":" + y;
  6138. var key = x + ":" + y;
  6139. this._offsetCell(previousKey, key);
  6140. }
  6141. }
  6142. this._rowDefinitions.splice(index, 1);
  6143. this._markAsDirty();
  6144. return this;
  6145. };
  6146. /**
  6147. * Adds a new control to the current grid
  6148. * @param control defines the control to add
  6149. * @param row defines the row where to add the control (0 by default)
  6150. * @param column defines the column where to add the control (0 by default)
  6151. * @returns the current grid
  6152. */
  6153. Grid.prototype.addControl = function (control, row, column) {
  6154. if (row === void 0) { row = 0; }
  6155. if (column === void 0) { column = 0; }
  6156. if (this._rowDefinitions.length === 0) {
  6157. // Add default row definition
  6158. this.addRowDefinition(1, false);
  6159. }
  6160. if (this._columnDefinitions.length === 0) {
  6161. // Add default column definition
  6162. this.addColumnDefinition(1, false);
  6163. }
  6164. if (this._childControls.indexOf(control) !== -1) {
  6165. 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");
  6166. return this;
  6167. }
  6168. var x = Math.min(row, this._rowDefinitions.length - 1);
  6169. var y = Math.min(column, this._columnDefinitions.length - 1);
  6170. var key = x + ":" + y;
  6171. var goodContainer = this._cells[key];
  6172. if (!goodContainer) {
  6173. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  6174. this._cells[key] = goodContainer;
  6175. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  6176. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  6177. _super.prototype.addControl.call(this, goodContainer);
  6178. }
  6179. goodContainer.addControl(control);
  6180. this._childControls.push(control);
  6181. control._tag = key;
  6182. control.parent = this;
  6183. this._markAsDirty();
  6184. return this;
  6185. };
  6186. /**
  6187. * Removes a control from the current container
  6188. * @param control defines the control to remove
  6189. * @returns the current container
  6190. */
  6191. Grid.prototype.removeControl = function (control) {
  6192. var index = this._childControls.indexOf(control);
  6193. if (index !== -1) {
  6194. this._childControls.splice(index, 1);
  6195. }
  6196. var cell = this._cells[control._tag];
  6197. if (cell) {
  6198. cell.removeControl(control);
  6199. control._tag = null;
  6200. }
  6201. this._markAsDirty();
  6202. return this;
  6203. };
  6204. Grid.prototype._getTypeName = function () {
  6205. return "Grid";
  6206. };
  6207. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6208. var widths = [];
  6209. var heights = [];
  6210. var lefts = [];
  6211. var tops = [];
  6212. var availableWidth = this._currentMeasure.width;
  6213. var globalWidthPercentage = 0;
  6214. var availableHeight = this._currentMeasure.height;
  6215. var globalHeightPercentage = 0;
  6216. // Heights
  6217. var index = 0;
  6218. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6219. var value = _a[_i];
  6220. if (value.isPixel) {
  6221. var height = value.getValue(this._host);
  6222. availableHeight -= height;
  6223. heights[index] = height;
  6224. }
  6225. else {
  6226. globalHeightPercentage += value.internalValue;
  6227. }
  6228. index++;
  6229. }
  6230. var top = 0;
  6231. index = 0;
  6232. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6233. var value = _c[_b];
  6234. tops.push(top);
  6235. if (!value.isPixel) {
  6236. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6237. top += height;
  6238. heights[index] = height;
  6239. }
  6240. else {
  6241. top += value.getValue(this._host);
  6242. }
  6243. index++;
  6244. }
  6245. // Widths
  6246. index = 0;
  6247. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6248. var value = _e[_d];
  6249. if (value.isPixel) {
  6250. var width = value.getValue(this._host);
  6251. availableWidth -= width;
  6252. widths[index] = width;
  6253. }
  6254. else {
  6255. globalWidthPercentage += value.internalValue;
  6256. }
  6257. index++;
  6258. }
  6259. var left = 0;
  6260. index = 0;
  6261. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6262. var value = _g[_f];
  6263. lefts.push(left);
  6264. if (!value.isPixel) {
  6265. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6266. left += width;
  6267. widths[index] = width;
  6268. }
  6269. else {
  6270. left += value.getValue(this._host);
  6271. }
  6272. index++;
  6273. }
  6274. definitionCallback(lefts, tops, widths, heights);
  6275. };
  6276. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6277. var _this = this;
  6278. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6279. // Setting child sizes
  6280. for (var key in _this._cells) {
  6281. if (!_this._cells.hasOwnProperty(key)) {
  6282. continue;
  6283. }
  6284. var split = key.split(":");
  6285. var x = parseInt(split[0]);
  6286. var y = parseInt(split[1]);
  6287. var cell = _this._cells[key];
  6288. cell.left = lefts[y] + "px";
  6289. cell.top = tops[x] + "px";
  6290. cell.width = widths[y] + "px";
  6291. cell.height = heights[x] + "px";
  6292. cell._left.ignoreAdaptiveScaling = true;
  6293. cell._top.ignoreAdaptiveScaling = true;
  6294. cell._width.ignoreAdaptiveScaling = true;
  6295. cell._height.ignoreAdaptiveScaling = true;
  6296. }
  6297. });
  6298. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6299. };
  6300. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6301. for (var key in this._cells) {
  6302. if (!this._cells.hasOwnProperty(key)) {
  6303. continue;
  6304. }
  6305. var child = this._cells[key];
  6306. child._markMatrixAsDirty();
  6307. }
  6308. };
  6309. Grid.prototype._renderHighlightSpecific = function (context) {
  6310. var _this = this;
  6311. _super.prototype._renderHighlightSpecific.call(this, context);
  6312. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6313. // Columns
  6314. for (var index = 0; index < lefts.length; index++) {
  6315. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6316. context.beginPath();
  6317. context.moveTo(left, _this._currentMeasure.top);
  6318. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6319. context.stroke();
  6320. }
  6321. // Rows
  6322. for (var index = 0; index < tops.length; index++) {
  6323. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6324. context.beginPath();
  6325. context.moveTo(_this._currentMeasure.left, top_1);
  6326. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6327. context.stroke();
  6328. }
  6329. });
  6330. context.restore();
  6331. };
  6332. /** Releases associated resources */
  6333. Grid.prototype.dispose = function () {
  6334. _super.prototype.dispose.call(this);
  6335. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6336. var control = _a[_i];
  6337. control.dispose();
  6338. }
  6339. this._childControls = [];
  6340. };
  6341. return Grid;
  6342. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6343. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6344. /***/ }),
  6345. /***/ "./2D/controls/image.ts":
  6346. /*!******************************!*\
  6347. !*** ./2D/controls/image.ts ***!
  6348. \******************************/
  6349. /*! exports provided: Image */
  6350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6351. "use strict";
  6352. __webpack_require__.r(__webpack_exports__);
  6353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6355. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  6356. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6357. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6358. /**
  6359. * Class used to create 2D images
  6360. */
  6361. var Image = /** @class */ (function (_super) {
  6362. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6363. /**
  6364. * Creates a new Image
  6365. * @param name defines the control name
  6366. * @param url defines the image url
  6367. */
  6368. function Image(name, url) {
  6369. if (url === void 0) { url = null; }
  6370. var _this = _super.call(this, name) || this;
  6371. _this.name = name;
  6372. _this._workingCanvas = null;
  6373. _this._loaded = false;
  6374. _this._stretch = Image.STRETCH_FILL;
  6375. _this._autoScale = false;
  6376. _this._sourceLeft = 0;
  6377. _this._sourceTop = 0;
  6378. _this._sourceWidth = 0;
  6379. _this._sourceHeight = 0;
  6380. _this._svgAttributesComputationCompleted = false;
  6381. _this._isSVG = false;
  6382. _this._cellWidth = 0;
  6383. _this._cellHeight = 0;
  6384. _this._cellId = -1;
  6385. _this._populateNinePatchSlicesFromImage = false;
  6386. _this._imageDataCache = { data: null, key: "" };
  6387. /**
  6388. * Observable notified when the content is loaded
  6389. */
  6390. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6391. /**
  6392. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6393. */
  6394. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6395. _this.source = url;
  6396. return _this;
  6397. }
  6398. Object.defineProperty(Image.prototype, "isLoaded", {
  6399. /**
  6400. * Gets a boolean indicating that the content is loaded
  6401. */
  6402. get: function () {
  6403. return this._loaded;
  6404. },
  6405. enumerable: false,
  6406. configurable: true
  6407. });
  6408. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6409. /**
  6410. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6411. */
  6412. get: function () {
  6413. return this._populateNinePatchSlicesFromImage;
  6414. },
  6415. set: function (value) {
  6416. if (this._populateNinePatchSlicesFromImage === value) {
  6417. return;
  6418. }
  6419. this._populateNinePatchSlicesFromImage = value;
  6420. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6421. this._extractNinePatchSliceDataFromImage();
  6422. }
  6423. },
  6424. enumerable: false,
  6425. configurable: true
  6426. });
  6427. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6428. /**
  6429. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6430. * Beware using this as this will comsume more memory as the image has to be stored twice
  6431. */
  6432. get: function () {
  6433. return this._detectPointerOnOpaqueOnly;
  6434. },
  6435. set: function (value) {
  6436. if (this._detectPointerOnOpaqueOnly === value) {
  6437. return;
  6438. }
  6439. this._detectPointerOnOpaqueOnly = value;
  6440. },
  6441. enumerable: false,
  6442. configurable: true
  6443. });
  6444. Object.defineProperty(Image.prototype, "sliceLeft", {
  6445. /**
  6446. * Gets or sets the left value for slicing (9-patch)
  6447. */
  6448. get: function () {
  6449. return this._sliceLeft;
  6450. },
  6451. set: function (value) {
  6452. if (this._sliceLeft === value) {
  6453. return;
  6454. }
  6455. this._sliceLeft = value;
  6456. this._markAsDirty();
  6457. },
  6458. enumerable: false,
  6459. configurable: true
  6460. });
  6461. Object.defineProperty(Image.prototype, "sliceRight", {
  6462. /**
  6463. * Gets or sets the right value for slicing (9-patch)
  6464. */
  6465. get: function () {
  6466. return this._sliceRight;
  6467. },
  6468. set: function (value) {
  6469. if (this._sliceRight === value) {
  6470. return;
  6471. }
  6472. this._sliceRight = value;
  6473. this._markAsDirty();
  6474. },
  6475. enumerable: false,
  6476. configurable: true
  6477. });
  6478. Object.defineProperty(Image.prototype, "sliceTop", {
  6479. /**
  6480. * Gets or sets the top value for slicing (9-patch)
  6481. */
  6482. get: function () {
  6483. return this._sliceTop;
  6484. },
  6485. set: function (value) {
  6486. if (this._sliceTop === value) {
  6487. return;
  6488. }
  6489. this._sliceTop = value;
  6490. this._markAsDirty();
  6491. },
  6492. enumerable: false,
  6493. configurable: true
  6494. });
  6495. Object.defineProperty(Image.prototype, "sliceBottom", {
  6496. /**
  6497. * Gets or sets the bottom value for slicing (9-patch)
  6498. */
  6499. get: function () {
  6500. return this._sliceBottom;
  6501. },
  6502. set: function (value) {
  6503. if (this._sliceBottom === value) {
  6504. return;
  6505. }
  6506. this._sliceBottom = value;
  6507. this._markAsDirty();
  6508. },
  6509. enumerable: false,
  6510. configurable: true
  6511. });
  6512. Object.defineProperty(Image.prototype, "sourceLeft", {
  6513. /**
  6514. * Gets or sets the left coordinate in the source image
  6515. */
  6516. get: function () {
  6517. return this._sourceLeft;
  6518. },
  6519. set: function (value) {
  6520. if (this._sourceLeft === value) {
  6521. return;
  6522. }
  6523. this._sourceLeft = value;
  6524. this._markAsDirty();
  6525. },
  6526. enumerable: false,
  6527. configurable: true
  6528. });
  6529. Object.defineProperty(Image.prototype, "sourceTop", {
  6530. /**
  6531. * Gets or sets the top coordinate in the source image
  6532. */
  6533. get: function () {
  6534. return this._sourceTop;
  6535. },
  6536. set: function (value) {
  6537. if (this._sourceTop === value) {
  6538. return;
  6539. }
  6540. this._sourceTop = value;
  6541. this._markAsDirty();
  6542. },
  6543. enumerable: false,
  6544. configurable: true
  6545. });
  6546. Object.defineProperty(Image.prototype, "sourceWidth", {
  6547. /**
  6548. * Gets or sets the width to capture in the source image
  6549. */
  6550. get: function () {
  6551. return this._sourceWidth;
  6552. },
  6553. set: function (value) {
  6554. if (this._sourceWidth === value) {
  6555. return;
  6556. }
  6557. this._sourceWidth = value;
  6558. this._markAsDirty();
  6559. },
  6560. enumerable: false,
  6561. configurable: true
  6562. });
  6563. Object.defineProperty(Image.prototype, "sourceHeight", {
  6564. /**
  6565. * Gets or sets the height to capture in the source image
  6566. */
  6567. get: function () {
  6568. return this._sourceHeight;
  6569. },
  6570. set: function (value) {
  6571. if (this._sourceHeight === value) {
  6572. return;
  6573. }
  6574. this._sourceHeight = value;
  6575. this._markAsDirty();
  6576. },
  6577. enumerable: false,
  6578. configurable: true
  6579. });
  6580. Object.defineProperty(Image.prototype, "isSVG", {
  6581. /** Indicates if the format of the image is SVG */
  6582. get: function () {
  6583. return this._isSVG;
  6584. },
  6585. enumerable: false,
  6586. configurable: true
  6587. });
  6588. Object.defineProperty(Image.prototype, "svgAttributesComputationCompleted", {
  6589. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  6590. get: function () {
  6591. return this._svgAttributesComputationCompleted;
  6592. },
  6593. enumerable: false,
  6594. configurable: true
  6595. });
  6596. Object.defineProperty(Image.prototype, "autoScale", {
  6597. /**
  6598. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6599. * @see https://doc.babylonjs.com/how_to/gui#image
  6600. */
  6601. get: function () {
  6602. return this._autoScale;
  6603. },
  6604. set: function (value) {
  6605. if (this._autoScale === value) {
  6606. return;
  6607. }
  6608. this._autoScale = value;
  6609. if (value && this._loaded) {
  6610. this.synchronizeSizeWithContent();
  6611. }
  6612. },
  6613. enumerable: false,
  6614. configurable: true
  6615. });
  6616. Object.defineProperty(Image.prototype, "stretch", {
  6617. /** Gets or sets the streching mode used by the image */
  6618. get: function () {
  6619. return this._stretch;
  6620. },
  6621. set: function (value) {
  6622. if (this._stretch === value) {
  6623. return;
  6624. }
  6625. this._stretch = value;
  6626. this._markAsDirty();
  6627. },
  6628. enumerable: false,
  6629. configurable: true
  6630. });
  6631. /** @hidden */
  6632. Image.prototype._rotate90 = function (n, preserveProperties) {
  6633. if (preserveProperties === void 0) { preserveProperties = false; }
  6634. var canvas = document.createElement('canvas');
  6635. var context = canvas.getContext('2d');
  6636. var width = this._domImage.width;
  6637. var height = this._domImage.height;
  6638. canvas.width = height;
  6639. canvas.height = width;
  6640. context.translate(canvas.width / 2, canvas.height / 2);
  6641. context.rotate(n * Math.PI / 2);
  6642. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6643. var dataUrl = canvas.toDataURL("image/jpg");
  6644. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6645. if (preserveProperties) {
  6646. rotatedImage._stretch = this._stretch;
  6647. rotatedImage._autoScale = this._autoScale;
  6648. rotatedImage._cellId = this._cellId;
  6649. rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
  6650. rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
  6651. }
  6652. this._handleRotationForSVGImage(this, rotatedImage, n);
  6653. this._imageDataCache.data = null;
  6654. return rotatedImage;
  6655. };
  6656. Image.prototype._handleRotationForSVGImage = function (srcImage, dstImage, n) {
  6657. var _this = this;
  6658. if (!srcImage._isSVG) {
  6659. return;
  6660. }
  6661. if (srcImage._svgAttributesComputationCompleted) {
  6662. this._rotate90SourceProperties(srcImage, dstImage, n);
  6663. this._markAsDirty();
  6664. }
  6665. else {
  6666. srcImage.onSVGAttributesComputedObservable.addOnce(function () {
  6667. _this._rotate90SourceProperties(srcImage, dstImage, n);
  6668. _this._markAsDirty();
  6669. });
  6670. }
  6671. };
  6672. Image.prototype._rotate90SourceProperties = function (srcImage, dstImage, n) {
  6673. var _a, _b;
  6674. var srcLeft = srcImage.sourceLeft, srcTop = srcImage.sourceTop, srcWidth = srcImage.domImage.width, srcHeight = srcImage.domImage.height;
  6675. var dstLeft = srcLeft, dstTop = srcTop, dstWidth = srcImage.sourceWidth, dstHeight = srcImage.sourceHeight;
  6676. if (n != 0) {
  6677. var mult = n < 0 ? -1 : 1;
  6678. n = n % 4;
  6679. for (var i = 0; i < Math.abs(n); ++i) {
  6680. dstLeft = -(srcTop - srcHeight / 2) * mult + srcHeight / 2;
  6681. dstTop = (srcLeft - srcWidth / 2) * mult + srcWidth / 2;
  6682. _a = [dstHeight, dstWidth], dstWidth = _a[0], dstHeight = _a[1];
  6683. if (n < 0) {
  6684. dstTop -= dstHeight;
  6685. }
  6686. else {
  6687. dstLeft -= dstWidth;
  6688. }
  6689. srcLeft = dstLeft;
  6690. srcTop = dstTop;
  6691. _b = [srcHeight, srcWidth], srcWidth = _b[0], srcHeight = _b[1];
  6692. }
  6693. }
  6694. dstImage.sourceLeft = dstLeft;
  6695. dstImage.sourceTop = dstTop;
  6696. dstImage.sourceWidth = dstWidth;
  6697. dstImage.sourceHeight = dstHeight;
  6698. };
  6699. Object.defineProperty(Image.prototype, "domImage", {
  6700. get: function () {
  6701. return this._domImage;
  6702. },
  6703. /**
  6704. * Gets or sets the internal DOM image used to render the control
  6705. */
  6706. set: function (value) {
  6707. var _this = this;
  6708. this._domImage = value;
  6709. this._loaded = false;
  6710. this._imageDataCache.data = null;
  6711. if (this._domImage.width) {
  6712. this._onImageLoaded();
  6713. }
  6714. else {
  6715. this._domImage.onload = function () {
  6716. _this._onImageLoaded();
  6717. };
  6718. }
  6719. },
  6720. enumerable: false,
  6721. configurable: true
  6722. });
  6723. Image.prototype._onImageLoaded = function () {
  6724. this._imageDataCache.data = null;
  6725. this._imageWidth = this._domImage.width;
  6726. this._imageHeight = this._domImage.height;
  6727. this._loaded = true;
  6728. if (this._populateNinePatchSlicesFromImage) {
  6729. this._extractNinePatchSliceDataFromImage();
  6730. }
  6731. if (this._autoScale) {
  6732. this.synchronizeSizeWithContent();
  6733. }
  6734. this.onImageLoadedObservable.notifyObservers(this);
  6735. this._markAsDirty();
  6736. };
  6737. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6738. if (!this._workingCanvas) {
  6739. this._workingCanvas = document.createElement('canvas');
  6740. }
  6741. var canvas = this._workingCanvas;
  6742. var context = canvas.getContext('2d');
  6743. var width = this._domImage.width;
  6744. var height = this._domImage.height;
  6745. canvas.width = width;
  6746. canvas.height = height;
  6747. context.drawImage(this._domImage, 0, 0, width, height);
  6748. var imageData = context.getImageData(0, 0, width, height);
  6749. // Left and right
  6750. this._sliceLeft = -1;
  6751. this._sliceRight = -1;
  6752. for (var x = 0; x < width; x++) {
  6753. var alpha = imageData.data[x * 4 + 3];
  6754. if (alpha > 127 && this._sliceLeft === -1) {
  6755. this._sliceLeft = x;
  6756. continue;
  6757. }
  6758. if (alpha < 127 && this._sliceLeft > -1) {
  6759. this._sliceRight = x;
  6760. break;
  6761. }
  6762. }
  6763. // top and bottom
  6764. this._sliceTop = -1;
  6765. this._sliceBottom = -1;
  6766. for (var y = 0; y < height; y++) {
  6767. var alpha = imageData.data[y * width * 4 + 3];
  6768. if (alpha > 127 && this._sliceTop === -1) {
  6769. this._sliceTop = y;
  6770. continue;
  6771. }
  6772. if (alpha < 127 && this._sliceTop > -1) {
  6773. this._sliceBottom = y;
  6774. break;
  6775. }
  6776. }
  6777. };
  6778. Object.defineProperty(Image.prototype, "source", {
  6779. /**
  6780. * Gets or sets image source url
  6781. */
  6782. set: function (value) {
  6783. var _this = this;
  6784. if (this._source === value) {
  6785. return;
  6786. }
  6787. this._loaded = false;
  6788. this._source = value;
  6789. this._imageDataCache.data = null;
  6790. if (value) {
  6791. value = this._svgCheck(value);
  6792. }
  6793. this._domImage = document.createElement("img");
  6794. this._domImage.onload = function () {
  6795. _this._onImageLoaded();
  6796. };
  6797. if (value) {
  6798. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6799. this._domImage.src = value;
  6800. }
  6801. },
  6802. enumerable: false,
  6803. configurable: true
  6804. });
  6805. /**
  6806. * Checks for svg document with icon id present
  6807. */
  6808. Image.prototype._svgCheck = function (value) {
  6809. var _this = this;
  6810. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6811. this._isSVG = true;
  6812. var svgsrc = value.split('#')[0];
  6813. var elemid = value.split('#')[1];
  6814. // check if object alr exist in document
  6815. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6816. if (svgExist) {
  6817. var svgDoc = svgExist.contentDocument;
  6818. // get viewbox width and height, get svg document width and height in px
  6819. if (svgDoc && svgDoc.documentElement) {
  6820. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6821. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6822. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6823. var elem = svgDoc.getElementById(elemid);
  6824. if (elem && vb && docwidth && docheight) {
  6825. this._getSVGAttribs(svgExist, elemid);
  6826. return value;
  6827. }
  6828. }
  6829. // wait for object to load
  6830. svgExist.addEventListener("load", function () {
  6831. _this._getSVGAttribs(svgExist, elemid);
  6832. });
  6833. }
  6834. else {
  6835. // create document object
  6836. var svgImage = document.createElement("object");
  6837. svgImage.data = svgsrc;
  6838. svgImage.type = "image/svg+xml";
  6839. svgImage.width = "0%";
  6840. svgImage.height = "0%";
  6841. document.body.appendChild(svgImage);
  6842. // when the object has loaded, get the element attribs
  6843. svgImage.onload = function () {
  6844. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6845. if (svgobj) {
  6846. _this._getSVGAttribs(svgobj, elemid);
  6847. }
  6848. };
  6849. }
  6850. return svgsrc;
  6851. }
  6852. else {
  6853. return value;
  6854. }
  6855. };
  6856. /**
  6857. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6858. * given external svg file and icon id
  6859. */
  6860. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6861. var svgDoc = svgsrc.contentDocument;
  6862. // get viewbox width and height, get svg document width and height in px
  6863. if (svgDoc && svgDoc.documentElement) {
  6864. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6865. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6866. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6867. // get element bbox and matrix transform
  6868. var elem = svgDoc.getElementById(elemid);
  6869. if (vb && docwidth && docheight && elem) {
  6870. var vb_width = Number(vb.split(" ")[2]);
  6871. var vb_height = Number(vb.split(" ")[3]);
  6872. var elem_bbox = elem.getBBox();
  6873. var elem_matrix_a = 1;
  6874. var elem_matrix_d = 1;
  6875. var elem_matrix_e = 0;
  6876. var elem_matrix_f = 0;
  6877. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6878. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6879. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6880. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6881. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6882. }
  6883. // compute source coordinates and dimensions
  6884. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6885. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6886. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6887. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6888. this._svgAttributesComputationCompleted = true;
  6889. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6890. }
  6891. }
  6892. };
  6893. Object.defineProperty(Image.prototype, "cellWidth", {
  6894. /**
  6895. * Gets or sets the cell width to use when animation sheet is enabled
  6896. * @see https://doc.babylonjs.com/how_to/gui#image
  6897. */
  6898. get: function () {
  6899. return this._cellWidth;
  6900. },
  6901. set: function (value) {
  6902. if (this._cellWidth === value) {
  6903. return;
  6904. }
  6905. this._cellWidth = value;
  6906. this._markAsDirty();
  6907. },
  6908. enumerable: false,
  6909. configurable: true
  6910. });
  6911. Object.defineProperty(Image.prototype, "cellHeight", {
  6912. /**
  6913. * Gets or sets the cell height to use when animation sheet is enabled
  6914. * @see https://doc.babylonjs.com/how_to/gui#image
  6915. */
  6916. get: function () {
  6917. return this._cellHeight;
  6918. },
  6919. set: function (value) {
  6920. if (this._cellHeight === value) {
  6921. return;
  6922. }
  6923. this._cellHeight = value;
  6924. this._markAsDirty();
  6925. },
  6926. enumerable: false,
  6927. configurable: true
  6928. });
  6929. Object.defineProperty(Image.prototype, "cellId", {
  6930. /**
  6931. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6932. * @see https://doc.babylonjs.com/how_to/gui#image
  6933. */
  6934. get: function () {
  6935. return this._cellId;
  6936. },
  6937. set: function (value) {
  6938. if (this._cellId === value) {
  6939. return;
  6940. }
  6941. this._cellId = value;
  6942. this._markAsDirty();
  6943. },
  6944. enumerable: false,
  6945. configurable: true
  6946. });
  6947. /**
  6948. * Tests if a given coordinates belong to the current control
  6949. * @param x defines x coordinate to test
  6950. * @param y defines y coordinate to test
  6951. * @returns true if the coordinates are inside the control
  6952. */
  6953. Image.prototype.contains = function (x, y) {
  6954. if (!_super.prototype.contains.call(this, x, y)) {
  6955. return false;
  6956. }
  6957. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6958. return true;
  6959. }
  6960. var width = this._currentMeasure.width | 0;
  6961. var height = this._currentMeasure.height | 0;
  6962. var key = width + "_" + height;
  6963. var imageData = this._imageDataCache.data;
  6964. if (!imageData || this._imageDataCache.key !== key) {
  6965. var canvas = this._workingCanvas;
  6966. var context_1 = canvas.getContext("2d");
  6967. this._imageDataCache.data = imageData = context_1.getImageData(0, 0, width, height).data;
  6968. this._imageDataCache.key = key;
  6969. }
  6970. x = (x - this._currentMeasure.left) | 0;
  6971. y = (y - this._currentMeasure.top) | 0;
  6972. var pickedPixel = imageData[(x + y * width) * 4 + 3];
  6973. return pickedPixel > 0;
  6974. };
  6975. Image.prototype._getTypeName = function () {
  6976. return "Image";
  6977. };
  6978. /** Force the control to synchronize with its content */
  6979. Image.prototype.synchronizeSizeWithContent = function () {
  6980. if (!this._loaded) {
  6981. return;
  6982. }
  6983. this.width = this._domImage.width + "px";
  6984. this.height = this._domImage.height + "px";
  6985. };
  6986. Image.prototype._processMeasures = function (parentMeasure, context) {
  6987. if (this._loaded) {
  6988. switch (this._stretch) {
  6989. case Image.STRETCH_NONE:
  6990. break;
  6991. case Image.STRETCH_FILL:
  6992. break;
  6993. case Image.STRETCH_UNIFORM:
  6994. break;
  6995. case Image.STRETCH_NINE_PATCH:
  6996. break;
  6997. case Image.STRETCH_EXTEND:
  6998. if (this._autoScale) {
  6999. this.synchronizeSizeWithContent();
  7000. }
  7001. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  7002. this.parent.adaptWidthToChildren = true;
  7003. this.parent.adaptHeightToChildren = true;
  7004. }
  7005. break;
  7006. }
  7007. }
  7008. _super.prototype._processMeasures.call(this, parentMeasure, context);
  7009. };
  7010. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  7011. if (!this._detectPointerOnOpaqueOnly) {
  7012. return;
  7013. }
  7014. if (!this._workingCanvas) {
  7015. this._workingCanvas = document.createElement('canvas');
  7016. }
  7017. var canvas = this._workingCanvas;
  7018. var width = this._currentMeasure.width;
  7019. var height = this._currentMeasure.height;
  7020. var context = canvas.getContext("2d");
  7021. canvas.width = width;
  7022. canvas.height = height;
  7023. context.clearRect(0, 0, width, height);
  7024. };
  7025. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  7026. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  7027. if (!this._detectPointerOnOpaqueOnly) {
  7028. return;
  7029. }
  7030. var canvas = this._workingCanvas;
  7031. context = canvas.getContext("2d");
  7032. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  7033. };
  7034. Image.prototype._draw = function (context) {
  7035. context.save();
  7036. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7037. context.shadowColor = this.shadowColor;
  7038. context.shadowBlur = this.shadowBlur;
  7039. context.shadowOffsetX = this.shadowOffsetX;
  7040. context.shadowOffsetY = this.shadowOffsetY;
  7041. }
  7042. var x, y, width, height;
  7043. if (this.cellId == -1) {
  7044. x = this._sourceLeft;
  7045. y = this._sourceTop;
  7046. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  7047. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  7048. }
  7049. else {
  7050. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  7051. var column = (this.cellId / rowCount) >> 0;
  7052. var row = this.cellId % rowCount;
  7053. x = this.cellWidth * row;
  7054. y = this.cellHeight * column;
  7055. width = this.cellWidth;
  7056. height = this.cellHeight;
  7057. }
  7058. this._prepareWorkingCanvasForOpaqueDetection();
  7059. this._applyStates(context);
  7060. if (this._loaded) {
  7061. switch (this._stretch) {
  7062. case Image.STRETCH_NONE:
  7063. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7064. break;
  7065. case Image.STRETCH_FILL:
  7066. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7067. break;
  7068. case Image.STRETCH_UNIFORM:
  7069. var hRatio = this._currentMeasure.width / width;
  7070. var vRatio = this._currentMeasure.height / height;
  7071. var ratio = Math.min(hRatio, vRatio);
  7072. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  7073. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  7074. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  7075. break;
  7076. case Image.STRETCH_EXTEND:
  7077. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7078. break;
  7079. case Image.STRETCH_NINE_PATCH:
  7080. this._renderNinePatch(context);
  7081. break;
  7082. }
  7083. }
  7084. context.restore();
  7085. };
  7086. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  7087. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  7088. };
  7089. Image.prototype._renderNinePatch = function (context) {
  7090. var height = this._imageHeight;
  7091. var leftWidth = this._sliceLeft;
  7092. var topHeight = this._sliceTop;
  7093. var bottomHeight = this._imageHeight - this._sliceBottom;
  7094. var rightWidth = this._imageWidth - this._sliceRight;
  7095. var left = 0;
  7096. var top = 0;
  7097. if (this._populateNinePatchSlicesFromImage) {
  7098. left = 1;
  7099. top = 1;
  7100. height -= 2;
  7101. leftWidth -= 1;
  7102. topHeight -= 1;
  7103. bottomHeight -= 1;
  7104. rightWidth -= 1;
  7105. }
  7106. var centerWidth = this._sliceRight - this._sliceLeft;
  7107. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft;
  7108. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  7109. // Corners
  7110. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  7111. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  7112. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  7113. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  7114. // Center
  7115. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight);
  7116. // Borders
  7117. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7118. this._drawImage(context, this._sliceRight, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left + this._currentMeasure.width - rightWidth, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  7119. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  7120. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  7121. };
  7122. Image.prototype.dispose = function () {
  7123. _super.prototype.dispose.call(this);
  7124. this.onImageLoadedObservable.clear();
  7125. this.onSVGAttributesComputedObservable.clear();
  7126. };
  7127. // Static
  7128. /** STRETCH_NONE */
  7129. Image.STRETCH_NONE = 0;
  7130. /** STRETCH_FILL */
  7131. Image.STRETCH_FILL = 1;
  7132. /** STRETCH_UNIFORM */
  7133. Image.STRETCH_UNIFORM = 2;
  7134. /** STRETCH_EXTEND */
  7135. Image.STRETCH_EXTEND = 3;
  7136. /** NINE_PATCH */
  7137. Image.STRETCH_NINE_PATCH = 4;
  7138. return Image;
  7139. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7140. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  7141. /***/ }),
  7142. /***/ "./2D/controls/index.ts":
  7143. /*!******************************!*\
  7144. !*** ./2D/controls/index.ts ***!
  7145. \******************************/
  7146. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name */
  7147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7148. "use strict";
  7149. __webpack_require__.r(__webpack_exports__);
  7150. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  7151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  7152. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  7153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  7154. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  7155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  7156. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  7157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  7158. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  7160. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  7161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  7162. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  7163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  7164. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  7165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  7166. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  7168. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  7169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  7170. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  7171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  7172. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  7173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  7174. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  7175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  7176. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  7177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  7178. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  7179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  7180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  7181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  7182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  7183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  7184. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  7185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  7186. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  7187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  7188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  7189. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  7190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  7191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  7192. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  7193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  7194. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  7195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  7196. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  7197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  7198. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  7199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  7200. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  7201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  7202. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  7203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  7204. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  7205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  7206. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  7207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  7208. /***/ }),
  7209. /***/ "./2D/controls/inputPassword.ts":
  7210. /*!**************************************!*\
  7211. !*** ./2D/controls/inputPassword.ts ***!
  7212. \**************************************/
  7213. /*! exports provided: InputPassword */
  7214. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7215. "use strict";
  7216. __webpack_require__.r(__webpack_exports__);
  7217. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  7218. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7219. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  7220. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  7221. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  7222. /**
  7223. * Class used to create a password control
  7224. */
  7225. var InputPassword = /** @class */ (function (_super) {
  7226. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  7227. function InputPassword() {
  7228. return _super !== null && _super.apply(this, arguments) || this;
  7229. }
  7230. InputPassword.prototype._beforeRenderText = function (text) {
  7231. var txt = "";
  7232. for (var i = 0; i < text.length; i++) {
  7233. txt += "\u2022";
  7234. }
  7235. return txt;
  7236. };
  7237. return InputPassword;
  7238. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  7239. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  7240. /***/ }),
  7241. /***/ "./2D/controls/inputText.ts":
  7242. /*!**********************************!*\
  7243. !*** ./2D/controls/inputText.ts ***!
  7244. \**********************************/
  7245. /*! exports provided: InputText */
  7246. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7247. "use strict";
  7248. __webpack_require__.r(__webpack_exports__);
  7249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  7250. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7251. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  7252. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  7253. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7254. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7255. /**
  7256. * Class used to create input text control
  7257. */
  7258. var InputText = /** @class */ (function (_super) {
  7259. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  7260. /**
  7261. * Creates a new InputText
  7262. * @param name defines the control name
  7263. * @param text defines the text of the control
  7264. */
  7265. function InputText(name, text) {
  7266. if (text === void 0) { text = ""; }
  7267. var _this = _super.call(this, name) || this;
  7268. _this.name = name;
  7269. _this._text = "";
  7270. _this._placeholderText = "";
  7271. _this._background = "#222222";
  7272. _this._focusedBackground = "#000000";
  7273. _this._focusedColor = "white";
  7274. _this._placeholderColor = "gray";
  7275. _this._thickness = 1;
  7276. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  7277. _this._autoStretchWidth = true;
  7278. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  7279. _this._isFocused = false;
  7280. _this._blinkIsEven = false;
  7281. _this._cursorOffset = 0;
  7282. _this._deadKey = false;
  7283. _this._addKey = true;
  7284. _this._currentKey = "";
  7285. _this._isTextHighlightOn = false;
  7286. _this._textHighlightColor = "#d5e0ff";
  7287. _this._highligherOpacity = 0.4;
  7288. _this._highlightedText = "";
  7289. _this._startHighlightIndex = 0;
  7290. _this._endHighlightIndex = 0;
  7291. _this._cursorIndex = -1;
  7292. _this._onFocusSelectAll = false;
  7293. _this._isPointerDown = false;
  7294. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7295. _this.promptMessage = "Please enter text:";
  7296. /** Force disable prompt on mobile device */
  7297. _this.disableMobilePrompt = false;
  7298. /** Observable raised when the text changes */
  7299. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7300. /** Observable raised just before an entered character is to be added */
  7301. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7302. /** Observable raised when the control gets the focus */
  7303. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7304. /** Observable raised when the control loses the focus */
  7305. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7306. /**Observable raised when the text is highlighted */
  7307. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7308. /**Observable raised when copy event is triggered */
  7309. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7310. /** Observable raised when cut event is triggered */
  7311. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7312. /** Observable raised when paste event is triggered */
  7313. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7314. /** Observable raised when a key event was processed */
  7315. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7316. _this.text = text;
  7317. _this.isPointerBlocker = true;
  7318. return _this;
  7319. }
  7320. Object.defineProperty(InputText.prototype, "maxWidth", {
  7321. /** Gets or sets the maximum width allowed by the control */
  7322. get: function () {
  7323. return this._maxWidth.toString(this._host);
  7324. },
  7325. set: function (value) {
  7326. if (this._maxWidth.toString(this._host) === value) {
  7327. return;
  7328. }
  7329. if (this._maxWidth.fromString(value)) {
  7330. this._markAsDirty();
  7331. }
  7332. },
  7333. enumerable: false,
  7334. configurable: true
  7335. });
  7336. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7337. /** Gets the maximum width allowed by the control in pixels */
  7338. get: function () {
  7339. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7340. },
  7341. enumerable: false,
  7342. configurable: true
  7343. });
  7344. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7345. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7346. get: function () {
  7347. return this._highligherOpacity;
  7348. },
  7349. set: function (value) {
  7350. if (this._highligherOpacity === value) {
  7351. return;
  7352. }
  7353. this._highligherOpacity = value;
  7354. this._markAsDirty();
  7355. },
  7356. enumerable: false,
  7357. configurable: true
  7358. });
  7359. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7360. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7361. get: function () {
  7362. return this._onFocusSelectAll;
  7363. },
  7364. set: function (value) {
  7365. if (this._onFocusSelectAll === value) {
  7366. return;
  7367. }
  7368. this._onFocusSelectAll = value;
  7369. this._markAsDirty();
  7370. },
  7371. enumerable: false,
  7372. configurable: true
  7373. });
  7374. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7375. /** Gets or sets the text hightlight color */
  7376. get: function () {
  7377. return this._textHighlightColor;
  7378. },
  7379. set: function (value) {
  7380. if (this._textHighlightColor === value) {
  7381. return;
  7382. }
  7383. this._textHighlightColor = value;
  7384. this._markAsDirty();
  7385. },
  7386. enumerable: false,
  7387. configurable: true
  7388. });
  7389. Object.defineProperty(InputText.prototype, "margin", {
  7390. /** Gets or sets control margin */
  7391. get: function () {
  7392. return this._margin.toString(this._host);
  7393. },
  7394. set: function (value) {
  7395. if (this._margin.toString(this._host) === value) {
  7396. return;
  7397. }
  7398. if (this._margin.fromString(value)) {
  7399. this._markAsDirty();
  7400. }
  7401. },
  7402. enumerable: false,
  7403. configurable: true
  7404. });
  7405. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7406. /** Gets control margin in pixels */
  7407. get: function () {
  7408. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7409. },
  7410. enumerable: false,
  7411. configurable: true
  7412. });
  7413. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7414. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7415. get: function () {
  7416. return this._autoStretchWidth;
  7417. },
  7418. set: function (value) {
  7419. if (this._autoStretchWidth === value) {
  7420. return;
  7421. }
  7422. this._autoStretchWidth = value;
  7423. this._markAsDirty();
  7424. },
  7425. enumerable: false,
  7426. configurable: true
  7427. });
  7428. Object.defineProperty(InputText.prototype, "thickness", {
  7429. /** Gets or sets border thickness */
  7430. get: function () {
  7431. return this._thickness;
  7432. },
  7433. set: function (value) {
  7434. if (this._thickness === value) {
  7435. return;
  7436. }
  7437. this._thickness = value;
  7438. this._markAsDirty();
  7439. },
  7440. enumerable: false,
  7441. configurable: true
  7442. });
  7443. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7444. /** Gets or sets the background color when focused */
  7445. get: function () {
  7446. return this._focusedBackground;
  7447. },
  7448. set: function (value) {
  7449. if (this._focusedBackground === value) {
  7450. return;
  7451. }
  7452. this._focusedBackground = value;
  7453. this._markAsDirty();
  7454. },
  7455. enumerable: false,
  7456. configurable: true
  7457. });
  7458. Object.defineProperty(InputText.prototype, "focusedColor", {
  7459. /** Gets or sets the background color when focused */
  7460. get: function () {
  7461. return this._focusedColor;
  7462. },
  7463. set: function (value) {
  7464. if (this._focusedColor === value) {
  7465. return;
  7466. }
  7467. this._focusedColor = value;
  7468. this._markAsDirty();
  7469. },
  7470. enumerable: false,
  7471. configurable: true
  7472. });
  7473. Object.defineProperty(InputText.prototype, "background", {
  7474. /** Gets or sets the background color */
  7475. get: function () {
  7476. return this._background;
  7477. },
  7478. set: function (value) {
  7479. if (this._background === value) {
  7480. return;
  7481. }
  7482. this._background = value;
  7483. this._markAsDirty();
  7484. },
  7485. enumerable: false,
  7486. configurable: true
  7487. });
  7488. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7489. /** Gets or sets the placeholder color */
  7490. get: function () {
  7491. return this._placeholderColor;
  7492. },
  7493. set: function (value) {
  7494. if (this._placeholderColor === value) {
  7495. return;
  7496. }
  7497. this._placeholderColor = value;
  7498. this._markAsDirty();
  7499. },
  7500. enumerable: false,
  7501. configurable: true
  7502. });
  7503. Object.defineProperty(InputText.prototype, "placeholderText", {
  7504. /** Gets or sets the text displayed when the control is empty */
  7505. get: function () {
  7506. return this._placeholderText;
  7507. },
  7508. set: function (value) {
  7509. if (this._placeholderText === value) {
  7510. return;
  7511. }
  7512. this._placeholderText = value;
  7513. this._markAsDirty();
  7514. },
  7515. enumerable: false,
  7516. configurable: true
  7517. });
  7518. Object.defineProperty(InputText.prototype, "deadKey", {
  7519. /** Gets or sets the dead key flag */
  7520. get: function () {
  7521. return this._deadKey;
  7522. },
  7523. set: function (flag) {
  7524. this._deadKey = flag;
  7525. },
  7526. enumerable: false,
  7527. configurable: true
  7528. });
  7529. Object.defineProperty(InputText.prototype, "highlightedText", {
  7530. /** Gets or sets the highlight text */
  7531. get: function () {
  7532. return this._highlightedText;
  7533. },
  7534. set: function (text) {
  7535. if (this._highlightedText === text) {
  7536. return;
  7537. }
  7538. this._highlightedText = text;
  7539. this._markAsDirty();
  7540. },
  7541. enumerable: false,
  7542. configurable: true
  7543. });
  7544. Object.defineProperty(InputText.prototype, "addKey", {
  7545. /** Gets or sets if the current key should be added */
  7546. get: function () {
  7547. return this._addKey;
  7548. },
  7549. set: function (flag) {
  7550. this._addKey = flag;
  7551. },
  7552. enumerable: false,
  7553. configurable: true
  7554. });
  7555. Object.defineProperty(InputText.prototype, "currentKey", {
  7556. /** Gets or sets the value of the current key being entered */
  7557. get: function () {
  7558. return this._currentKey;
  7559. },
  7560. set: function (key) {
  7561. this._currentKey = key;
  7562. },
  7563. enumerable: false,
  7564. configurable: true
  7565. });
  7566. Object.defineProperty(InputText.prototype, "text", {
  7567. /** Gets or sets the text displayed in the control */
  7568. get: function () {
  7569. return this._text;
  7570. },
  7571. set: function (value) {
  7572. var valueAsString = value.toString(); // Forcing convertion
  7573. if (this._text === valueAsString) {
  7574. return;
  7575. }
  7576. this._text = valueAsString;
  7577. this._markAsDirty();
  7578. this.onTextChangedObservable.notifyObservers(this);
  7579. },
  7580. enumerable: false,
  7581. configurable: true
  7582. });
  7583. Object.defineProperty(InputText.prototype, "width", {
  7584. /** Gets or sets control width */
  7585. get: function () {
  7586. return this._width.toString(this._host);
  7587. },
  7588. set: function (value) {
  7589. if (this._width.toString(this._host) === value) {
  7590. return;
  7591. }
  7592. if (this._width.fromString(value)) {
  7593. this._markAsDirty();
  7594. }
  7595. this.autoStretchWidth = false;
  7596. },
  7597. enumerable: false,
  7598. configurable: true
  7599. });
  7600. /** @hidden */
  7601. InputText.prototype.onBlur = function () {
  7602. this._isFocused = false;
  7603. this._scrollLeft = null;
  7604. this._cursorOffset = 0;
  7605. clearTimeout(this._blinkTimeout);
  7606. this._markAsDirty();
  7607. this.onBlurObservable.notifyObservers(this);
  7608. this._host.unRegisterClipboardEvents();
  7609. if (this._onClipboardObserver) {
  7610. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7611. }
  7612. var scene = this._host.getScene();
  7613. if (this._onPointerDblTapObserver && scene) {
  7614. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7615. }
  7616. };
  7617. /** @hidden */
  7618. InputText.prototype.onFocus = function () {
  7619. var _this = this;
  7620. if (!this._isEnabled) {
  7621. return;
  7622. }
  7623. this._scrollLeft = null;
  7624. this._isFocused = true;
  7625. this._blinkIsEven = false;
  7626. this._cursorOffset = 0;
  7627. this._markAsDirty();
  7628. this.onFocusObservable.notifyObservers(this);
  7629. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7630. var value = prompt(this.promptMessage);
  7631. if (value !== null) {
  7632. this.text = value;
  7633. }
  7634. this._host.focusedControl = null;
  7635. return;
  7636. }
  7637. this._host.registerClipboardEvents();
  7638. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7639. // process clipboard event, can be configured.
  7640. switch (clipboardInfo.type) {
  7641. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7642. _this._onCopyText(clipboardInfo.event);
  7643. _this.onTextCopyObservable.notifyObservers(_this);
  7644. break;
  7645. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7646. _this._onCutText(clipboardInfo.event);
  7647. _this.onTextCutObservable.notifyObservers(_this);
  7648. break;
  7649. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7650. _this._onPasteText(clipboardInfo.event);
  7651. _this.onTextPasteObservable.notifyObservers(_this);
  7652. break;
  7653. default: return;
  7654. }
  7655. });
  7656. var scene = this._host.getScene();
  7657. if (scene) {
  7658. //register the pointer double tap event
  7659. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7660. if (!_this._isFocused) {
  7661. return;
  7662. }
  7663. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7664. _this._processDblClick(pointerInfo);
  7665. }
  7666. });
  7667. }
  7668. if (this._onFocusSelectAll) {
  7669. this._selectAllText();
  7670. }
  7671. };
  7672. InputText.prototype._getTypeName = function () {
  7673. return "InputText";
  7674. };
  7675. /**
  7676. * Function called to get the list of controls that should not steal the focus from this control
  7677. * @returns an array of controls
  7678. */
  7679. InputText.prototype.keepsFocusWith = function () {
  7680. if (!this._connectedVirtualKeyboard) {
  7681. return null;
  7682. }
  7683. return [this._connectedVirtualKeyboard];
  7684. };
  7685. /** @hidden */
  7686. InputText.prototype.processKey = function (keyCode, key, evt) {
  7687. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7688. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7689. return;
  7690. }
  7691. //select all
  7692. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7693. this._selectAllText();
  7694. evt.preventDefault();
  7695. return;
  7696. }
  7697. // Specific cases
  7698. switch (keyCode) {
  7699. case 32: //SPACE
  7700. key = " "; //ie11 key for space is "Spacebar"
  7701. break;
  7702. case 191: //SLASH
  7703. if (evt) {
  7704. evt.preventDefault();
  7705. }
  7706. break;
  7707. case 8: // BACKSPACE
  7708. if (this._text && this._text.length > 0) {
  7709. //delete the highlighted text
  7710. if (this._isTextHighlightOn) {
  7711. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7712. this._isTextHighlightOn = false;
  7713. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7714. this._blinkIsEven = false;
  7715. if (evt) {
  7716. evt.preventDefault();
  7717. }
  7718. return;
  7719. }
  7720. //delete single character
  7721. if (this._cursorOffset === 0) {
  7722. this.text = this._text.substr(0, this._text.length - 1);
  7723. }
  7724. else {
  7725. var deletePosition = this._text.length - this._cursorOffset;
  7726. if (deletePosition > 0) {
  7727. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7728. }
  7729. }
  7730. }
  7731. if (evt) {
  7732. evt.preventDefault();
  7733. }
  7734. return;
  7735. case 46: // DELETE
  7736. if (this._isTextHighlightOn) {
  7737. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7738. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7739. while (decrementor > 0 && this._cursorOffset > 0) {
  7740. this._cursorOffset--;
  7741. }
  7742. this._isTextHighlightOn = false;
  7743. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7744. if (evt) {
  7745. evt.preventDefault();
  7746. }
  7747. return;
  7748. }
  7749. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7750. var deletePosition = this._text.length - this._cursorOffset;
  7751. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7752. this._cursorOffset--;
  7753. }
  7754. if (evt) {
  7755. evt.preventDefault();
  7756. }
  7757. return;
  7758. case 13: // RETURN
  7759. this._host.focusedControl = null;
  7760. this._isTextHighlightOn = false;
  7761. return;
  7762. case 35: // END
  7763. this._cursorOffset = 0;
  7764. this._blinkIsEven = false;
  7765. this._isTextHighlightOn = false;
  7766. this._markAsDirty();
  7767. return;
  7768. case 36: // HOME
  7769. this._cursorOffset = this._text.length;
  7770. this._blinkIsEven = false;
  7771. this._isTextHighlightOn = false;
  7772. this._markAsDirty();
  7773. return;
  7774. case 37: // LEFT
  7775. this._cursorOffset++;
  7776. if (this._cursorOffset > this._text.length) {
  7777. this._cursorOffset = this._text.length;
  7778. }
  7779. if (evt && evt.shiftKey) {
  7780. // update the cursor
  7781. this._blinkIsEven = false;
  7782. // shift + ctrl/cmd + <-
  7783. if (evt.ctrlKey || evt.metaKey) {
  7784. if (!this._isTextHighlightOn) {
  7785. if (this._text.length === this._cursorOffset) {
  7786. return;
  7787. }
  7788. else {
  7789. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7790. }
  7791. }
  7792. this._startHighlightIndex = 0;
  7793. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7794. this._cursorOffset = this._text.length;
  7795. this._isTextHighlightOn = true;
  7796. this._markAsDirty();
  7797. return;
  7798. }
  7799. //store the starting point
  7800. if (!this._isTextHighlightOn) {
  7801. this._isTextHighlightOn = true;
  7802. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7803. }
  7804. //if text is already highlighted
  7805. else if (this._cursorIndex === -1) {
  7806. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7807. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7808. }
  7809. //set the highlight indexes
  7810. if (this._cursorIndex < this._cursorOffset) {
  7811. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7812. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7813. }
  7814. else if (this._cursorIndex > this._cursorOffset) {
  7815. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7816. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7817. }
  7818. else {
  7819. this._isTextHighlightOn = false;
  7820. }
  7821. this._markAsDirty();
  7822. return;
  7823. }
  7824. if (this._isTextHighlightOn) {
  7825. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7826. this._isTextHighlightOn = false;
  7827. }
  7828. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7829. this._cursorOffset = this.text.length;
  7830. evt.preventDefault();
  7831. }
  7832. this._blinkIsEven = false;
  7833. this._isTextHighlightOn = false;
  7834. this._cursorIndex = -1;
  7835. this._markAsDirty();
  7836. return;
  7837. case 39: // RIGHT
  7838. this._cursorOffset--;
  7839. if (this._cursorOffset < 0) {
  7840. this._cursorOffset = 0;
  7841. }
  7842. if (evt && evt.shiftKey) {
  7843. //update the cursor
  7844. this._blinkIsEven = false;
  7845. //shift + ctrl/cmd + ->
  7846. if (evt.ctrlKey || evt.metaKey) {
  7847. if (!this._isTextHighlightOn) {
  7848. if (this._cursorOffset === 0) {
  7849. return;
  7850. }
  7851. else {
  7852. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7853. }
  7854. }
  7855. this._endHighlightIndex = this._text.length;
  7856. this._isTextHighlightOn = true;
  7857. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7858. this._cursorOffset = 0;
  7859. this._markAsDirty();
  7860. return;
  7861. }
  7862. if (!this._isTextHighlightOn) {
  7863. this._isTextHighlightOn = true;
  7864. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7865. }
  7866. //if text is already highlighted
  7867. else if (this._cursorIndex === -1) {
  7868. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7869. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7870. }
  7871. //set the highlight indexes
  7872. if (this._cursorIndex < this._cursorOffset) {
  7873. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7874. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7875. }
  7876. else if (this._cursorIndex > this._cursorOffset) {
  7877. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7878. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7879. }
  7880. else {
  7881. this._isTextHighlightOn = false;
  7882. }
  7883. this._markAsDirty();
  7884. return;
  7885. }
  7886. if (this._isTextHighlightOn) {
  7887. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7888. this._isTextHighlightOn = false;
  7889. }
  7890. //ctr + ->
  7891. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7892. this._cursorOffset = 0;
  7893. evt.preventDefault();
  7894. }
  7895. this._blinkIsEven = false;
  7896. this._isTextHighlightOn = false;
  7897. this._cursorIndex = -1;
  7898. this._markAsDirty();
  7899. return;
  7900. case 222: // Dead
  7901. if (evt) {
  7902. evt.preventDefault();
  7903. }
  7904. this._cursorIndex = -1;
  7905. this.deadKey = true;
  7906. break;
  7907. }
  7908. // Printable characters
  7909. if (key &&
  7910. ((keyCode === -1) || // Direct access
  7911. (keyCode === 32) || // Space
  7912. (keyCode > 47 && keyCode < 64) || // Numbers
  7913. (keyCode > 64 && keyCode < 91) || // Letters
  7914. (keyCode > 159 && keyCode < 193) || // Special characters
  7915. (keyCode > 218 && keyCode < 223) || // Special characters
  7916. (keyCode > 95 && keyCode < 112))) { // Numpad
  7917. this._currentKey = key;
  7918. this.onBeforeKeyAddObservable.notifyObservers(this);
  7919. key = this._currentKey;
  7920. if (this._addKey) {
  7921. if (this._isTextHighlightOn) {
  7922. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7923. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7924. this._isTextHighlightOn = false;
  7925. this._blinkIsEven = false;
  7926. this._markAsDirty();
  7927. }
  7928. else if (this._cursorOffset === 0) {
  7929. this.text += key;
  7930. }
  7931. else {
  7932. var insertPosition = this._text.length - this._cursorOffset;
  7933. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7934. }
  7935. }
  7936. }
  7937. };
  7938. /** @hidden */
  7939. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7940. //update the cursor
  7941. this._blinkIsEven = false;
  7942. if (this._cursorIndex === -1) {
  7943. this._cursorIndex = offset;
  7944. }
  7945. else {
  7946. if (this._cursorIndex < this._cursorOffset) {
  7947. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7948. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7949. }
  7950. else if (this._cursorIndex > this._cursorOffset) {
  7951. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7952. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7953. }
  7954. else {
  7955. this._isTextHighlightOn = false;
  7956. this._markAsDirty();
  7957. return;
  7958. }
  7959. }
  7960. this._isTextHighlightOn = true;
  7961. this._markAsDirty();
  7962. };
  7963. /** @hidden */
  7964. InputText.prototype._processDblClick = function (evt) {
  7965. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7966. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7967. this._endHighlightIndex = this._startHighlightIndex;
  7968. var rWord = /\w+/g, moveLeft, moveRight;
  7969. do {
  7970. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7971. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7972. } while (moveLeft || moveRight);
  7973. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7974. this.onTextHighlightObservable.notifyObservers(this);
  7975. this._isTextHighlightOn = true;
  7976. this._clickedCoordinate = null;
  7977. this._blinkIsEven = true;
  7978. this._cursorIndex = -1;
  7979. this._markAsDirty();
  7980. };
  7981. /** @hidden */
  7982. InputText.prototype._selectAllText = function () {
  7983. this._blinkIsEven = true;
  7984. this._isTextHighlightOn = true;
  7985. this._startHighlightIndex = 0;
  7986. this._endHighlightIndex = this._text.length;
  7987. this._cursorOffset = this._text.length;
  7988. this._cursorIndex = -1;
  7989. this._markAsDirty();
  7990. };
  7991. /**
  7992. * Handles the keyboard event
  7993. * @param evt Defines the KeyboardEvent
  7994. */
  7995. InputText.prototype.processKeyboard = function (evt) {
  7996. // process pressed key
  7997. this.processKey(evt.keyCode, evt.key, evt);
  7998. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7999. };
  8000. /** @hidden */
  8001. InputText.prototype._onCopyText = function (ev) {
  8002. this._isTextHighlightOn = false;
  8003. //when write permission to clipbaord data is denied
  8004. try {
  8005. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8006. }
  8007. catch (_a) { } //pass
  8008. this._host.clipboardData = this._highlightedText;
  8009. };
  8010. /** @hidden */
  8011. InputText.prototype._onCutText = function (ev) {
  8012. if (!this._highlightedText) {
  8013. return;
  8014. }
  8015. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  8016. this._isTextHighlightOn = false;
  8017. this._cursorOffset = this.text.length - this._startHighlightIndex;
  8018. //when write permission to clipbaord data is denied
  8019. try {
  8020. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  8021. }
  8022. catch (_a) { } //pass
  8023. this._host.clipboardData = this._highlightedText;
  8024. this._highlightedText = "";
  8025. };
  8026. /** @hidden */
  8027. InputText.prototype._onPasteText = function (ev) {
  8028. var data = "";
  8029. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  8030. data = ev.clipboardData.getData("text/plain");
  8031. }
  8032. else {
  8033. //get the cached data; returns blank string by default
  8034. data = this._host.clipboardData;
  8035. }
  8036. var insertPosition = this._text.length - this._cursorOffset;
  8037. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  8038. };
  8039. InputText.prototype._draw = function (context, invalidatedRectangle) {
  8040. var _this = this;
  8041. context.save();
  8042. this._applyStates(context);
  8043. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8044. context.shadowColor = this.shadowColor;
  8045. context.shadowBlur = this.shadowBlur;
  8046. context.shadowOffsetX = this.shadowOffsetX;
  8047. context.shadowOffsetY = this.shadowOffsetY;
  8048. }
  8049. // Background
  8050. if (this._isFocused) {
  8051. if (this._focusedBackground) {
  8052. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  8053. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8054. }
  8055. }
  8056. else if (this._background) {
  8057. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8058. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8059. }
  8060. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8061. context.shadowBlur = 0;
  8062. context.shadowOffsetX = 0;
  8063. context.shadowOffsetY = 0;
  8064. }
  8065. if (!this._fontOffset) {
  8066. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  8067. }
  8068. // Text
  8069. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  8070. if (this.color) {
  8071. context.fillStyle = this.color;
  8072. }
  8073. var text = this._beforeRenderText(this._text);
  8074. if (!this._isFocused && !this._text && this._placeholderText) {
  8075. text = this._placeholderText;
  8076. if (this._placeholderColor) {
  8077. context.fillStyle = this._placeholderColor;
  8078. }
  8079. }
  8080. this._textWidth = context.measureText(text).width;
  8081. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  8082. if (this._autoStretchWidth) {
  8083. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  8084. }
  8085. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  8086. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  8087. context.save();
  8088. context.beginPath();
  8089. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  8090. context.clip();
  8091. if (this._isFocused && this._textWidth > availableWidth) {
  8092. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  8093. if (!this._scrollLeft) {
  8094. this._scrollLeft = textLeft;
  8095. }
  8096. }
  8097. else {
  8098. this._scrollLeft = clipTextLeft;
  8099. }
  8100. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  8101. // Cursor
  8102. if (this._isFocused) {
  8103. // Need to move cursor
  8104. if (this._clickedCoordinate) {
  8105. var rightPosition = this._scrollLeft + this._textWidth;
  8106. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  8107. var currentSize = 0;
  8108. this._cursorOffset = 0;
  8109. var previousDist = 0;
  8110. do {
  8111. if (this._cursorOffset) {
  8112. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  8113. }
  8114. this._cursorOffset++;
  8115. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  8116. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  8117. // Find closest move
  8118. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  8119. this._cursorOffset--;
  8120. }
  8121. this._blinkIsEven = false;
  8122. this._clickedCoordinate = null;
  8123. }
  8124. // Render cursor
  8125. if (!this._blinkIsEven) {
  8126. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  8127. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  8128. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  8129. if (cursorLeft < clipTextLeft) {
  8130. this._scrollLeft += (clipTextLeft - cursorLeft);
  8131. cursorLeft = clipTextLeft;
  8132. this._markAsDirty();
  8133. }
  8134. else if (cursorLeft > clipTextLeft + availableWidth) {
  8135. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  8136. cursorLeft = clipTextLeft + availableWidth;
  8137. this._markAsDirty();
  8138. }
  8139. if (!this._isTextHighlightOn) {
  8140. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  8141. }
  8142. }
  8143. clearTimeout(this._blinkTimeout);
  8144. this._blinkTimeout = setTimeout(function () {
  8145. _this._blinkIsEven = !_this._blinkIsEven;
  8146. _this._markAsDirty();
  8147. }, 500);
  8148. //show the highlighted text
  8149. if (this._isTextHighlightOn) {
  8150. clearTimeout(this._blinkTimeout);
  8151. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  8152. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  8153. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  8154. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  8155. if (highlightCursorLeft < clipTextLeft) {
  8156. width = width - (clipTextLeft - highlightCursorLeft);
  8157. if (!width) {
  8158. // when using left arrow on text.length > availableWidth;
  8159. // assigns the width of the first letter after clipTextLeft
  8160. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  8161. }
  8162. highlightCursorLeft = clipTextLeft;
  8163. }
  8164. //for transparancy
  8165. context.globalAlpha = this._highligherOpacity;
  8166. context.fillStyle = this._textHighlightColor;
  8167. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  8168. context.globalAlpha = 1.0;
  8169. }
  8170. }
  8171. context.restore();
  8172. // Border
  8173. if (this._thickness) {
  8174. if (this._isFocused) {
  8175. if (this.focusedColor) {
  8176. context.strokeStyle = this.focusedColor;
  8177. }
  8178. }
  8179. else {
  8180. if (this.color) {
  8181. context.strokeStyle = this.color;
  8182. }
  8183. }
  8184. context.lineWidth = this._thickness;
  8185. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8186. }
  8187. context.restore();
  8188. };
  8189. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  8190. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  8191. return false;
  8192. }
  8193. this._clickedCoordinate = coordinates.x;
  8194. this._isTextHighlightOn = false;
  8195. this._highlightedText = "";
  8196. this._cursorIndex = -1;
  8197. this._isPointerDown = true;
  8198. this._host._capturingControl[pointerId] = this;
  8199. if (this._host.focusedControl === this) {
  8200. // Move cursor
  8201. clearTimeout(this._blinkTimeout);
  8202. this._markAsDirty();
  8203. return true;
  8204. }
  8205. if (!this._isEnabled) {
  8206. return false;
  8207. }
  8208. this._host.focusedControl = this;
  8209. return true;
  8210. };
  8211. InputText.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  8212. if (this._host.focusedControl === this && this._isPointerDown) {
  8213. this._clickedCoordinate = coordinates.x;
  8214. this._markAsDirty();
  8215. this._updateValueFromCursorIndex(this._cursorOffset);
  8216. }
  8217. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  8218. };
  8219. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  8220. this._isPointerDown = false;
  8221. delete this._host._capturingControl[pointerId];
  8222. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  8223. };
  8224. InputText.prototype._beforeRenderText = function (text) {
  8225. return text;
  8226. };
  8227. InputText.prototype.dispose = function () {
  8228. _super.prototype.dispose.call(this);
  8229. this.onBlurObservable.clear();
  8230. this.onFocusObservable.clear();
  8231. this.onTextChangedObservable.clear();
  8232. this.onTextCopyObservable.clear();
  8233. this.onTextCutObservable.clear();
  8234. this.onTextPasteObservable.clear();
  8235. this.onTextHighlightObservable.clear();
  8236. this.onKeyboardEventProcessedObservable.clear();
  8237. };
  8238. return InputText;
  8239. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8240. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  8241. /***/ }),
  8242. /***/ "./2D/controls/line.ts":
  8243. /*!*****************************!*\
  8244. !*** ./2D/controls/line.ts ***!
  8245. \*****************************/
  8246. /*! exports provided: Line */
  8247. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8248. "use strict";
  8249. __webpack_require__.r(__webpack_exports__);
  8250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  8251. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8252. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  8253. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  8254. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8255. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  8256. /** Class used to render 2D lines */
  8257. var Line = /** @class */ (function (_super) {
  8258. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  8259. /**
  8260. * Creates a new Line
  8261. * @param name defines the control name
  8262. */
  8263. function Line(name) {
  8264. var _this = _super.call(this, name) || this;
  8265. _this.name = name;
  8266. _this._lineWidth = 1;
  8267. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8268. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8269. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8270. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  8271. _this._dash = new Array();
  8272. _this._automaticSize = true;
  8273. _this.isHitTestVisible = false;
  8274. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8275. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8276. return _this;
  8277. }
  8278. Object.defineProperty(Line.prototype, "dash", {
  8279. /** Gets or sets the dash pattern */
  8280. get: function () {
  8281. return this._dash;
  8282. },
  8283. set: function (value) {
  8284. if (this._dash === value) {
  8285. return;
  8286. }
  8287. this._dash = value;
  8288. this._markAsDirty();
  8289. },
  8290. enumerable: false,
  8291. configurable: true
  8292. });
  8293. Object.defineProperty(Line.prototype, "connectedControl", {
  8294. /** Gets or sets the control connected with the line end */
  8295. get: function () {
  8296. return this._connectedControl;
  8297. },
  8298. set: function (value) {
  8299. var _this = this;
  8300. if (this._connectedControl === value) {
  8301. return;
  8302. }
  8303. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8304. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8305. this._connectedControlDirtyObserver = null;
  8306. }
  8307. if (value) {
  8308. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8309. }
  8310. this._connectedControl = value;
  8311. this._markAsDirty();
  8312. },
  8313. enumerable: false,
  8314. configurable: true
  8315. });
  8316. Object.defineProperty(Line.prototype, "x1", {
  8317. /** Gets or sets start coordinates on X axis */
  8318. get: function () {
  8319. return this._x1.toString(this._host);
  8320. },
  8321. set: function (value) {
  8322. if (this._x1.toString(this._host) === value) {
  8323. return;
  8324. }
  8325. if (this._x1.fromString(value)) {
  8326. this._markAsDirty();
  8327. }
  8328. },
  8329. enumerable: false,
  8330. configurable: true
  8331. });
  8332. Object.defineProperty(Line.prototype, "y1", {
  8333. /** Gets or sets start coordinates on Y axis */
  8334. get: function () {
  8335. return this._y1.toString(this._host);
  8336. },
  8337. set: function (value) {
  8338. if (this._y1.toString(this._host) === value) {
  8339. return;
  8340. }
  8341. if (this._y1.fromString(value)) {
  8342. this._markAsDirty();
  8343. }
  8344. },
  8345. enumerable: false,
  8346. configurable: true
  8347. });
  8348. Object.defineProperty(Line.prototype, "x2", {
  8349. /** Gets or sets end coordinates on X axis */
  8350. get: function () {
  8351. return this._x2.toString(this._host);
  8352. },
  8353. set: function (value) {
  8354. if (this._x2.toString(this._host) === value) {
  8355. return;
  8356. }
  8357. if (this._x2.fromString(value)) {
  8358. this._markAsDirty();
  8359. }
  8360. },
  8361. enumerable: false,
  8362. configurable: true
  8363. });
  8364. Object.defineProperty(Line.prototype, "y2", {
  8365. /** Gets or sets end coordinates on Y axis */
  8366. get: function () {
  8367. return this._y2.toString(this._host);
  8368. },
  8369. set: function (value) {
  8370. if (this._y2.toString(this._host) === value) {
  8371. return;
  8372. }
  8373. if (this._y2.fromString(value)) {
  8374. this._markAsDirty();
  8375. }
  8376. },
  8377. enumerable: false,
  8378. configurable: true
  8379. });
  8380. Object.defineProperty(Line.prototype, "lineWidth", {
  8381. /** Gets or sets line width */
  8382. get: function () {
  8383. return this._lineWidth;
  8384. },
  8385. set: function (value) {
  8386. if (this._lineWidth === value) {
  8387. return;
  8388. }
  8389. this._lineWidth = value;
  8390. this._markAsDirty();
  8391. },
  8392. enumerable: false,
  8393. configurable: true
  8394. });
  8395. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8396. /** Gets or sets horizontal alignment */
  8397. set: function (value) {
  8398. return;
  8399. },
  8400. enumerable: false,
  8401. configurable: true
  8402. });
  8403. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8404. /** Gets or sets vertical alignment */
  8405. set: function (value) {
  8406. return;
  8407. },
  8408. enumerable: false,
  8409. configurable: true
  8410. });
  8411. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8412. get: function () {
  8413. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8414. },
  8415. enumerable: false,
  8416. configurable: true
  8417. });
  8418. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8419. get: function () {
  8420. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8421. },
  8422. enumerable: false,
  8423. configurable: true
  8424. });
  8425. Line.prototype._getTypeName = function () {
  8426. return "Line";
  8427. };
  8428. Line.prototype._draw = function (context) {
  8429. context.save();
  8430. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8431. context.shadowColor = this.shadowColor;
  8432. context.shadowBlur = this.shadowBlur;
  8433. context.shadowOffsetX = this.shadowOffsetX;
  8434. context.shadowOffsetY = this.shadowOffsetY;
  8435. }
  8436. this._applyStates(context);
  8437. context.strokeStyle = this.color;
  8438. context.lineWidth = this._lineWidth;
  8439. context.setLineDash(this._dash);
  8440. context.beginPath();
  8441. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8442. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8443. context.stroke();
  8444. context.restore();
  8445. };
  8446. Line.prototype._measure = function () {
  8447. // Width / Height
  8448. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8449. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8450. };
  8451. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8452. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8453. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8454. };
  8455. /**
  8456. * Move one end of the line given 3D cartesian coordinates.
  8457. * @param position Targeted world position
  8458. * @param scene Scene
  8459. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8460. */
  8461. Line.prototype.moveToVector3 = function (position, scene, end) {
  8462. if (end === void 0) { end = false; }
  8463. if (!this._host || this.parent !== this._host._rootContainer) {
  8464. 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");
  8465. return;
  8466. }
  8467. var globalViewport = this._host._getGlobalViewport(scene);
  8468. 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);
  8469. this._moveToProjectedPosition(projectedPosition, end);
  8470. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8471. this.notRenderable = true;
  8472. return;
  8473. }
  8474. this.notRenderable = false;
  8475. };
  8476. /**
  8477. * Move one end of the line to a position in screen absolute space.
  8478. * @param projectedPosition Position in screen absolute space (X, Y)
  8479. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8480. */
  8481. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8482. if (end === void 0) { end = false; }
  8483. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8484. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8485. if (end) {
  8486. this.x2 = x;
  8487. this.y2 = y;
  8488. this._x2.ignoreAdaptiveScaling = true;
  8489. this._y2.ignoreAdaptiveScaling = true;
  8490. }
  8491. else {
  8492. this.x1 = x;
  8493. this.y1 = y;
  8494. this._x1.ignoreAdaptiveScaling = true;
  8495. this._y1.ignoreAdaptiveScaling = true;
  8496. }
  8497. };
  8498. return Line;
  8499. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8500. babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8501. /***/ }),
  8502. /***/ "./2D/controls/multiLine.ts":
  8503. /*!**********************************!*\
  8504. !*** ./2D/controls/multiLine.ts ***!
  8505. \**********************************/
  8506. /*! exports provided: MultiLine */
  8507. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8508. "use strict";
  8509. __webpack_require__.r(__webpack_exports__);
  8510. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8511. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8512. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Misc/observable");
  8513. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8514. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8515. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8516. /**
  8517. * Class used to create multi line control
  8518. */
  8519. var MultiLine = /** @class */ (function (_super) {
  8520. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8521. /**
  8522. * Creates a new MultiLine
  8523. * @param name defines the control name
  8524. */
  8525. function MultiLine(name) {
  8526. var _this = _super.call(this, name) || this;
  8527. _this.name = name;
  8528. _this._lineWidth = 1;
  8529. /** Function called when a point is updated */
  8530. _this.onPointUpdate = function () {
  8531. _this._markAsDirty();
  8532. };
  8533. _this._automaticSize = true;
  8534. _this.isHitTestVisible = false;
  8535. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8536. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8537. _this._dash = [];
  8538. _this._points = [];
  8539. return _this;
  8540. }
  8541. Object.defineProperty(MultiLine.prototype, "dash", {
  8542. /** Gets or sets dash pattern */
  8543. get: function () {
  8544. return this._dash;
  8545. },
  8546. set: function (value) {
  8547. if (this._dash === value) {
  8548. return;
  8549. }
  8550. this._dash = value;
  8551. this._markAsDirty();
  8552. },
  8553. enumerable: false,
  8554. configurable: true
  8555. });
  8556. /**
  8557. * Gets point stored at specified index
  8558. * @param index defines the index to look for
  8559. * @returns the requested point if found
  8560. */
  8561. MultiLine.prototype.getAt = function (index) {
  8562. if (!this._points[index]) {
  8563. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8564. }
  8565. return this._points[index];
  8566. };
  8567. /**
  8568. * Adds new points to the point collection
  8569. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8570. * @returns the list of created MultiLinePoint
  8571. */
  8572. MultiLine.prototype.add = function () {
  8573. var _this = this;
  8574. var items = [];
  8575. for (var _i = 0; _i < arguments.length; _i++) {
  8576. items[_i] = arguments[_i];
  8577. }
  8578. return items.map(function (item) { return _this.push(item); });
  8579. };
  8580. /**
  8581. * Adds a new point to the point collection
  8582. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8583. * @returns the created MultiLinePoint
  8584. */
  8585. MultiLine.prototype.push = function (item) {
  8586. var point = this.getAt(this._points.length);
  8587. if (item == null) {
  8588. return point;
  8589. }
  8590. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8591. point.mesh = item;
  8592. }
  8593. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8594. point.control = item;
  8595. }
  8596. else if (item.x != null && item.y != null) {
  8597. point.x = item.x;
  8598. point.y = item.y;
  8599. }
  8600. return point;
  8601. };
  8602. /**
  8603. * Remove a specific value or point from the active point collection
  8604. * @param value defines the value or point to remove
  8605. */
  8606. MultiLine.prototype.remove = function (value) {
  8607. var index;
  8608. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8609. index = this._points.indexOf(value);
  8610. if (index === -1) {
  8611. return;
  8612. }
  8613. }
  8614. else {
  8615. index = value;
  8616. }
  8617. var point = this._points[index];
  8618. if (!point) {
  8619. return;
  8620. }
  8621. point.dispose();
  8622. this._points.splice(index, 1);
  8623. };
  8624. /**
  8625. * Resets this object to initial state (no point)
  8626. */
  8627. MultiLine.prototype.reset = function () {
  8628. while (this._points.length > 0) {
  8629. this.remove(this._points.length - 1);
  8630. }
  8631. };
  8632. /**
  8633. * Resets all links
  8634. */
  8635. MultiLine.prototype.resetLinks = function () {
  8636. this._points.forEach(function (point) {
  8637. if (point != null) {
  8638. point.resetLinks();
  8639. }
  8640. });
  8641. };
  8642. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8643. /** Gets or sets line width */
  8644. get: function () {
  8645. return this._lineWidth;
  8646. },
  8647. set: function (value) {
  8648. if (this._lineWidth === value) {
  8649. return;
  8650. }
  8651. this._lineWidth = value;
  8652. this._markAsDirty();
  8653. },
  8654. enumerable: false,
  8655. configurable: true
  8656. });
  8657. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8658. set: function (value) {
  8659. return;
  8660. },
  8661. enumerable: false,
  8662. configurable: true
  8663. });
  8664. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8665. set: function (value) {
  8666. return;
  8667. },
  8668. enumerable: false,
  8669. configurable: true
  8670. });
  8671. MultiLine.prototype._getTypeName = function () {
  8672. return "MultiLine";
  8673. };
  8674. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8675. context.save();
  8676. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8677. context.shadowColor = this.shadowColor;
  8678. context.shadowBlur = this.shadowBlur;
  8679. context.shadowOffsetX = this.shadowOffsetX;
  8680. context.shadowOffsetY = this.shadowOffsetY;
  8681. }
  8682. this._applyStates(context);
  8683. context.strokeStyle = this.color;
  8684. context.lineWidth = this._lineWidth;
  8685. context.setLineDash(this._dash);
  8686. context.beginPath();
  8687. var first = true; //first index is not necessarily 0
  8688. var previousPoint;
  8689. this._points.forEach(function (point) {
  8690. if (!point) {
  8691. return;
  8692. }
  8693. if (first) {
  8694. context.moveTo(point._point.x, point._point.y);
  8695. first = false;
  8696. }
  8697. else {
  8698. if (point._point.z < 1 && previousPoint.z < 1) {
  8699. context.lineTo(point._point.x, point._point.y);
  8700. }
  8701. else {
  8702. context.moveTo(point._point.x, point._point.y);
  8703. }
  8704. }
  8705. previousPoint = point._point;
  8706. });
  8707. context.stroke();
  8708. context.restore();
  8709. };
  8710. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8711. var _this = this;
  8712. this._minX = null;
  8713. this._minY = null;
  8714. this._maxX = null;
  8715. this._maxY = null;
  8716. this._points.forEach(function (point, index) {
  8717. if (!point) {
  8718. return;
  8719. }
  8720. point.translate();
  8721. if (_this._minX == null || point._point.x < _this._minX) {
  8722. _this._minX = point._point.x;
  8723. }
  8724. if (_this._minY == null || point._point.y < _this._minY) {
  8725. _this._minY = point._point.y;
  8726. }
  8727. if (_this._maxX == null || point._point.x > _this._maxX) {
  8728. _this._maxX = point._point.x;
  8729. }
  8730. if (_this._maxY == null || point._point.y > _this._maxY) {
  8731. _this._maxY = point._point.y;
  8732. }
  8733. });
  8734. if (this._minX == null) {
  8735. this._minX = 0;
  8736. }
  8737. if (this._minY == null) {
  8738. this._minY = 0;
  8739. }
  8740. if (this._maxX == null) {
  8741. this._maxX = 0;
  8742. }
  8743. if (this._maxY == null) {
  8744. this._maxY = 0;
  8745. }
  8746. };
  8747. MultiLine.prototype._measure = function () {
  8748. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8749. return;
  8750. }
  8751. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8752. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8753. };
  8754. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8755. if (this._minX == null || this._minY == null) {
  8756. return;
  8757. }
  8758. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8759. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8760. };
  8761. MultiLine.prototype.dispose = function () {
  8762. this.reset();
  8763. _super.prototype.dispose.call(this);
  8764. };
  8765. return MultiLine;
  8766. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8767. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8768. /***/ }),
  8769. /***/ "./2D/controls/radioButton.ts":
  8770. /*!************************************!*\
  8771. !*** ./2D/controls/radioButton.ts ***!
  8772. \************************************/
  8773. /*! exports provided: RadioButton */
  8774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8775. "use strict";
  8776. __webpack_require__.r(__webpack_exports__);
  8777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8778. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8779. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  8780. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8781. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8782. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8783. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8784. /**
  8785. * Class used to create radio button controls
  8786. */
  8787. var RadioButton = /** @class */ (function (_super) {
  8788. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8789. /**
  8790. * Creates a new RadioButton
  8791. * @param name defines the control name
  8792. */
  8793. function RadioButton(name) {
  8794. var _this = _super.call(this, name) || this;
  8795. _this.name = name;
  8796. _this._isChecked = false;
  8797. _this._background = "black";
  8798. _this._checkSizeRatio = 0.8;
  8799. _this._thickness = 1;
  8800. /** Gets or sets group name */
  8801. _this.group = "";
  8802. /** Observable raised when isChecked is changed */
  8803. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8804. _this.isPointerBlocker = true;
  8805. return _this;
  8806. }
  8807. Object.defineProperty(RadioButton.prototype, "thickness", {
  8808. /** Gets or sets border thickness */
  8809. get: function () {
  8810. return this._thickness;
  8811. },
  8812. set: function (value) {
  8813. if (this._thickness === value) {
  8814. return;
  8815. }
  8816. this._thickness = value;
  8817. this._markAsDirty();
  8818. },
  8819. enumerable: false,
  8820. configurable: true
  8821. });
  8822. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8823. /** Gets or sets a value indicating the ratio between overall size and check size */
  8824. get: function () {
  8825. return this._checkSizeRatio;
  8826. },
  8827. set: function (value) {
  8828. value = Math.max(Math.min(1, value), 0);
  8829. if (this._checkSizeRatio === value) {
  8830. return;
  8831. }
  8832. this._checkSizeRatio = value;
  8833. this._markAsDirty();
  8834. },
  8835. enumerable: false,
  8836. configurable: true
  8837. });
  8838. Object.defineProperty(RadioButton.prototype, "background", {
  8839. /** Gets or sets background color */
  8840. get: function () {
  8841. return this._background;
  8842. },
  8843. set: function (value) {
  8844. if (this._background === value) {
  8845. return;
  8846. }
  8847. this._background = value;
  8848. this._markAsDirty();
  8849. },
  8850. enumerable: false,
  8851. configurable: true
  8852. });
  8853. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8854. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8855. get: function () {
  8856. return this._isChecked;
  8857. },
  8858. set: function (value) {
  8859. var _this = this;
  8860. if (this._isChecked === value) {
  8861. return;
  8862. }
  8863. this._isChecked = value;
  8864. this._markAsDirty();
  8865. this.onIsCheckedChangedObservable.notifyObservers(value);
  8866. if (this._isChecked && this._host) {
  8867. // Update all controls from same group
  8868. this._host.executeOnAllControls(function (control) {
  8869. if (control === _this) {
  8870. return;
  8871. }
  8872. if (control.group === undefined) {
  8873. return;
  8874. }
  8875. var childRadio = control;
  8876. if (childRadio.group === _this.group) {
  8877. childRadio.isChecked = false;
  8878. }
  8879. });
  8880. }
  8881. },
  8882. enumerable: false,
  8883. configurable: true
  8884. });
  8885. RadioButton.prototype._getTypeName = function () {
  8886. return "RadioButton";
  8887. };
  8888. RadioButton.prototype._draw = function (context) {
  8889. context.save();
  8890. this._applyStates(context);
  8891. var actualWidth = this._currentMeasure.width - this._thickness;
  8892. var actualHeight = this._currentMeasure.height - this._thickness;
  8893. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8894. context.shadowColor = this.shadowColor;
  8895. context.shadowBlur = this.shadowBlur;
  8896. context.shadowOffsetX = this.shadowOffsetX;
  8897. context.shadowOffsetY = this.shadowOffsetY;
  8898. }
  8899. // Outer
  8900. _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);
  8901. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8902. context.fill();
  8903. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8904. context.shadowBlur = 0;
  8905. context.shadowOffsetX = 0;
  8906. context.shadowOffsetY = 0;
  8907. }
  8908. context.strokeStyle = this.color;
  8909. context.lineWidth = this._thickness;
  8910. context.stroke();
  8911. // Inner
  8912. if (this._isChecked) {
  8913. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8914. var offsetWidth = actualWidth * this._checkSizeRatio;
  8915. var offseHeight = actualHeight * this._checkSizeRatio;
  8916. _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);
  8917. context.fill();
  8918. }
  8919. context.restore();
  8920. };
  8921. // Events
  8922. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  8923. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  8924. return false;
  8925. }
  8926. if (!this.isChecked) {
  8927. this.isChecked = true;
  8928. }
  8929. return true;
  8930. };
  8931. /**
  8932. * Utility function to easily create a radio button with a header
  8933. * @param title defines the label to use for the header
  8934. * @param group defines the group to use for the radio button
  8935. * @param isChecked defines the initial state of the radio button
  8936. * @param onValueChanged defines the callback to call when value changes
  8937. * @returns a StackPanel containing the radio button and a textBlock
  8938. */
  8939. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8940. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8941. panel.isVertical = false;
  8942. panel.height = "30px";
  8943. var radio = new RadioButton();
  8944. radio.width = "20px";
  8945. radio.height = "20px";
  8946. radio.isChecked = isChecked;
  8947. radio.color = "green";
  8948. radio.group = group;
  8949. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8950. panel.addControl(radio);
  8951. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8952. header.text = title;
  8953. header.width = "180px";
  8954. header.paddingLeft = "5px";
  8955. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8956. header.color = "white";
  8957. panel.addControl(header);
  8958. return panel;
  8959. };
  8960. return RadioButton;
  8961. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8962. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8963. /***/ }),
  8964. /***/ "./2D/controls/rectangle.ts":
  8965. /*!**********************************!*\
  8966. !*** ./2D/controls/rectangle.ts ***!
  8967. \**********************************/
  8968. /*! exports provided: Rectangle */
  8969. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8970. "use strict";
  8971. __webpack_require__.r(__webpack_exports__);
  8972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8973. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8974. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8975. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  8976. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8977. /** Class used to create rectangle container */
  8978. var Rectangle = /** @class */ (function (_super) {
  8979. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8980. /**
  8981. * Creates a new Rectangle
  8982. * @param name defines the control name
  8983. */
  8984. function Rectangle(name) {
  8985. var _this = _super.call(this, name) || this;
  8986. _this.name = name;
  8987. _this._thickness = 1;
  8988. _this._cornerRadius = 0;
  8989. return _this;
  8990. }
  8991. Object.defineProperty(Rectangle.prototype, "thickness", {
  8992. /** Gets or sets border thickness */
  8993. get: function () {
  8994. return this._thickness;
  8995. },
  8996. set: function (value) {
  8997. if (this._thickness === value) {
  8998. return;
  8999. }
  9000. this._thickness = value;
  9001. this._markAsDirty();
  9002. },
  9003. enumerable: false,
  9004. configurable: true
  9005. });
  9006. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  9007. /** Gets or sets the corner radius angle */
  9008. get: function () {
  9009. return this._cornerRadius;
  9010. },
  9011. set: function (value) {
  9012. if (value < 0) {
  9013. value = 0;
  9014. }
  9015. if (this._cornerRadius === value) {
  9016. return;
  9017. }
  9018. this._cornerRadius = value;
  9019. this._markAsDirty();
  9020. },
  9021. enumerable: false,
  9022. configurable: true
  9023. });
  9024. Rectangle.prototype._getTypeName = function () {
  9025. return "Rectangle";
  9026. };
  9027. Rectangle.prototype._localDraw = function (context) {
  9028. context.save();
  9029. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9030. context.shadowColor = this.shadowColor;
  9031. context.shadowBlur = this.shadowBlur;
  9032. context.shadowOffsetX = this.shadowOffsetX;
  9033. context.shadowOffsetY = this.shadowOffsetY;
  9034. }
  9035. if (this._background) {
  9036. context.fillStyle = this._background;
  9037. if (this._cornerRadius) {
  9038. this._drawRoundedRect(context, this._thickness / 2);
  9039. context.fill();
  9040. }
  9041. else {
  9042. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  9043. }
  9044. }
  9045. if (this._thickness) {
  9046. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  9047. context.shadowBlur = 0;
  9048. context.shadowOffsetX = 0;
  9049. context.shadowOffsetY = 0;
  9050. }
  9051. if (this.color) {
  9052. context.strokeStyle = this.color;
  9053. }
  9054. context.lineWidth = this._thickness;
  9055. if (this._cornerRadius) {
  9056. this._drawRoundedRect(context, this._thickness / 2);
  9057. context.stroke();
  9058. }
  9059. else {
  9060. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  9061. }
  9062. }
  9063. context.restore();
  9064. };
  9065. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  9066. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9067. this._measureForChildren.width -= 2 * this._thickness;
  9068. this._measureForChildren.height -= 2 * this._thickness;
  9069. this._measureForChildren.left += this._thickness;
  9070. this._measureForChildren.top += this._thickness;
  9071. };
  9072. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  9073. if (offset === void 0) { offset = 0; }
  9074. var x = this._currentMeasure.left + offset;
  9075. var y = this._currentMeasure.top + offset;
  9076. var width = this._currentMeasure.width - offset * 2;
  9077. var height = this._currentMeasure.height - offset * 2;
  9078. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  9079. context.beginPath();
  9080. context.moveTo(x + radius, y);
  9081. context.lineTo(x + width - radius, y);
  9082. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  9083. context.lineTo(x + width, y + height - radius);
  9084. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  9085. context.lineTo(x + radius, y + height);
  9086. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  9087. context.lineTo(x, y + radius);
  9088. context.quadraticCurveTo(x, y, x + radius, y);
  9089. context.closePath();
  9090. };
  9091. Rectangle.prototype._clipForChildren = function (context) {
  9092. if (this._cornerRadius) {
  9093. this._drawRoundedRect(context, this._thickness);
  9094. context.clip();
  9095. }
  9096. };
  9097. return Rectangle;
  9098. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9099. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  9100. /***/ }),
  9101. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  9102. /*!***************************************************!*\
  9103. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  9104. \***************************************************/
  9105. /*! exports provided: ScrollViewer */
  9106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9107. "use strict";
  9108. __webpack_require__.r(__webpack_exports__);
  9109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  9110. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9111. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  9112. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  9113. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9114. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  9115. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  9116. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  9117. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  9118. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__);
  9119. /**
  9120. * Class used to hold a viewer window and sliders in a grid
  9121. */
  9122. var ScrollViewer = /** @class */ (function (_super) {
  9123. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  9124. /**
  9125. * Creates a new ScrollViewer
  9126. * @param name of ScrollViewer
  9127. */
  9128. function ScrollViewer(name, isImageBased) {
  9129. var _this = _super.call(this, name) || this;
  9130. _this._barSize = 20;
  9131. _this._pointerIsOver = false;
  9132. _this._wheelPrecision = 0.05;
  9133. _this._thumbLength = 0.5;
  9134. _this._thumbHeight = 1;
  9135. _this._barImageHeight = 1;
  9136. _this._horizontalBarImageHeight = 1;
  9137. _this._verticalBarImageHeight = 1;
  9138. _this._oldWindowContentsWidth = 0;
  9139. _this._oldWindowContentsHeight = 0;
  9140. _this._forceHorizontalBar = false;
  9141. _this._forceVerticalBar = false;
  9142. _this._useImageBar = isImageBased ? isImageBased : false;
  9143. _this.onDirtyObservable.add(function () {
  9144. _this._horizontalBarSpace.color = _this.color;
  9145. _this._verticalBarSpace.color = _this.color;
  9146. _this._dragSpace.color = _this.color;
  9147. });
  9148. _this.onPointerEnterObservable.add(function () {
  9149. _this._pointerIsOver = true;
  9150. });
  9151. _this.onPointerOutObservable.add(function () {
  9152. _this._pointerIsOver = false;
  9153. });
  9154. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_2__["Grid"]();
  9155. if (_this._useImageBar) {
  9156. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9157. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_6__["ImageScrollBar"]();
  9158. }
  9159. else {
  9160. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9161. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_5__["ScrollBar"]();
  9162. }
  9163. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_4__["_ScrollViewerWindow"]("scrollViewer_window");
  9164. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9165. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9166. _this._grid.addColumnDefinition(1);
  9167. _this._grid.addColumnDefinition(0, true);
  9168. _this._grid.addRowDefinition(1);
  9169. _this._grid.addRowDefinition(0, true);
  9170. _super.prototype.addControl.call(_this, _this._grid);
  9171. _this._grid.addControl(_this._window, 0, 0);
  9172. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9173. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9174. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9175. _this._verticalBarSpace.thickness = 1;
  9176. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  9177. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  9178. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9179. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9180. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9181. _this._horizontalBarSpace.thickness = 1;
  9182. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  9183. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  9184. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9185. _this._dragSpace.thickness = 1;
  9186. _this._grid.addControl(_this._dragSpace, 1, 1);
  9187. // Colors
  9188. if (!_this._useImageBar) {
  9189. _this.barColor = "grey";
  9190. _this.barBackground = "transparent";
  9191. }
  9192. return _this;
  9193. }
  9194. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  9195. /**
  9196. * Gets the horizontal scrollbar
  9197. */
  9198. get: function () {
  9199. return this._horizontalBar;
  9200. },
  9201. enumerable: false,
  9202. configurable: true
  9203. });
  9204. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  9205. /**
  9206. * Gets the vertical scrollbar
  9207. */
  9208. get: function () {
  9209. return this._verticalBar;
  9210. },
  9211. enumerable: false,
  9212. configurable: true
  9213. });
  9214. /**
  9215. * Adds a new control to the current container
  9216. * @param control defines the control to add
  9217. * @returns the current container
  9218. */
  9219. ScrollViewer.prototype.addControl = function (control) {
  9220. if (!control) {
  9221. return this;
  9222. }
  9223. this._window.addControl(control);
  9224. return this;
  9225. };
  9226. /**
  9227. * Removes a control from the current container
  9228. * @param control defines the control to remove
  9229. * @returns the current container
  9230. */
  9231. ScrollViewer.prototype.removeControl = function (control) {
  9232. this._window.removeControl(control);
  9233. return this;
  9234. };
  9235. Object.defineProperty(ScrollViewer.prototype, "children", {
  9236. /** Gets the list of children */
  9237. get: function () {
  9238. return this._window.children;
  9239. },
  9240. enumerable: false,
  9241. configurable: true
  9242. });
  9243. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  9244. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  9245. var child = _a[_i];
  9246. child._markMatrixAsDirty();
  9247. }
  9248. };
  9249. Object.defineProperty(ScrollViewer.prototype, "freezeControls", {
  9250. /**
  9251. * Freezes or unfreezes the controls in the window.
  9252. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  9253. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  9254. */
  9255. get: function () {
  9256. return this._window.freezeControls;
  9257. },
  9258. set: function (value) {
  9259. this._window.freezeControls = value;
  9260. },
  9261. enumerable: false,
  9262. configurable: true
  9263. });
  9264. Object.defineProperty(ScrollViewer.prototype, "bucketWidth", {
  9265. /** Gets the bucket width */
  9266. get: function () {
  9267. return this._window.bucketWidth;
  9268. },
  9269. enumerable: false,
  9270. configurable: true
  9271. });
  9272. Object.defineProperty(ScrollViewer.prototype, "bucketHeight", {
  9273. /** Gets the bucket height */
  9274. get: function () {
  9275. return this._window.bucketHeight;
  9276. },
  9277. enumerable: false,
  9278. configurable: true
  9279. });
  9280. /**
  9281. * Sets the bucket sizes.
  9282. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  9283. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  9284. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  9285. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  9286. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  9287. * used), that's why it is not enabled by default.
  9288. * @param width width of the bucket
  9289. * @param height height of the bucket
  9290. */
  9291. ScrollViewer.prototype.setBucketSizes = function (width, height) {
  9292. this._window.setBucketSizes(width, height);
  9293. };
  9294. Object.defineProperty(ScrollViewer.prototype, "forceHorizontalBar", {
  9295. /**
  9296. * Forces the horizontal scroll bar to be displayed
  9297. */
  9298. get: function () {
  9299. return this._forceHorizontalBar;
  9300. },
  9301. set: function (value) {
  9302. this._grid.setRowDefinition(1, value ? this._barSize : 0, true);
  9303. this._horizontalBar.isVisible = value;
  9304. this._forceHorizontalBar = value;
  9305. },
  9306. enumerable: false,
  9307. configurable: true
  9308. });
  9309. Object.defineProperty(ScrollViewer.prototype, "forceVerticalBar", {
  9310. /**
  9311. * Forces the vertical scroll bar to be displayed
  9312. */
  9313. get: function () {
  9314. return this._forceVerticalBar;
  9315. },
  9316. set: function (value) {
  9317. this._grid.setColumnDefinition(1, value ? this._barSize : 0, true);
  9318. this._verticalBar.isVisible = value;
  9319. this._forceVerticalBar = value;
  9320. },
  9321. enumerable: false,
  9322. configurable: true
  9323. });
  9324. /** Reset the scroll viewer window to initial size */
  9325. ScrollViewer.prototype.resetWindow = function () {
  9326. this._window.width = "100%";
  9327. this._window.height = "100%";
  9328. };
  9329. ScrollViewer.prototype._getTypeName = function () {
  9330. return "ScrollViewer";
  9331. };
  9332. ScrollViewer.prototype._buildClientSizes = function () {
  9333. var ratio = this.host.idealRatio;
  9334. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible || this.forceVerticalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9335. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible || this.forceHorizontalBar ? this._barSize * ratio : 0) - 2 * this.thickness;
  9336. this._clientWidth = this._window.parentClientWidth;
  9337. this._clientHeight = this._window.parentClientHeight;
  9338. };
  9339. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  9340. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9341. this._buildClientSizes();
  9342. };
  9343. ScrollViewer.prototype._postMeasure = function () {
  9344. _super.prototype._postMeasure.call(this);
  9345. this._updateScroller();
  9346. this._setWindowPosition(false);
  9347. };
  9348. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  9349. /**
  9350. * Gets or sets the mouse wheel precision
  9351. * from 0 to 1 with a default value of 0.05
  9352. * */
  9353. get: function () {
  9354. return this._wheelPrecision;
  9355. },
  9356. set: function (value) {
  9357. if (this._wheelPrecision === value) {
  9358. return;
  9359. }
  9360. if (value < 0) {
  9361. value = 0;
  9362. }
  9363. if (value > 1) {
  9364. value = 1;
  9365. }
  9366. this._wheelPrecision = value;
  9367. },
  9368. enumerable: false,
  9369. configurable: true
  9370. });
  9371. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  9372. /** Gets or sets the scroll bar container background color */
  9373. get: function () {
  9374. return this._horizontalBarSpace.background;
  9375. },
  9376. set: function (color) {
  9377. if (this._horizontalBarSpace.background === color) {
  9378. return;
  9379. }
  9380. this._horizontalBarSpace.background = color;
  9381. this._verticalBarSpace.background = color;
  9382. },
  9383. enumerable: false,
  9384. configurable: true
  9385. });
  9386. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9387. /** Gets or sets the bar color */
  9388. get: function () {
  9389. return this._barColor;
  9390. },
  9391. set: function (color) {
  9392. if (this._barColor === color) {
  9393. return;
  9394. }
  9395. this._barColor = color;
  9396. this._horizontalBar.color = color;
  9397. this._verticalBar.color = color;
  9398. },
  9399. enumerable: false,
  9400. configurable: true
  9401. });
  9402. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9403. /** Gets or sets the bar image */
  9404. get: function () {
  9405. return this._barImage;
  9406. },
  9407. set: function (value) {
  9408. if (this._barImage === value) {
  9409. return;
  9410. }
  9411. this._barImage = value;
  9412. var hb = this._horizontalBar;
  9413. var vb = this._verticalBar;
  9414. hb.thumbImage = value;
  9415. vb.thumbImage = value;
  9416. },
  9417. enumerable: false,
  9418. configurable: true
  9419. });
  9420. Object.defineProperty(ScrollViewer.prototype, "horizontalThumbImage", {
  9421. /** Gets or sets the horizontal bar image */
  9422. get: function () {
  9423. return this._horizontalBarImage;
  9424. },
  9425. set: function (value) {
  9426. if (this._horizontalBarImage === value) {
  9427. return;
  9428. }
  9429. this._horizontalBarImage = value;
  9430. var hb = this._horizontalBar;
  9431. hb.thumbImage = value;
  9432. },
  9433. enumerable: false,
  9434. configurable: true
  9435. });
  9436. Object.defineProperty(ScrollViewer.prototype, "verticalThumbImage", {
  9437. /** Gets or sets the vertical bar image */
  9438. get: function () {
  9439. return this._verticalBarImage;
  9440. },
  9441. set: function (value) {
  9442. if (this._verticalBarImage === value) {
  9443. return;
  9444. }
  9445. this._verticalBarImage = value;
  9446. var vb = this._verticalBar;
  9447. vb.thumbImage = value;
  9448. },
  9449. enumerable: false,
  9450. configurable: true
  9451. });
  9452. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9453. /** Gets or sets the size of the bar */
  9454. get: function () {
  9455. return this._barSize;
  9456. },
  9457. set: function (value) {
  9458. if (this._barSize === value) {
  9459. return;
  9460. }
  9461. this._barSize = value;
  9462. this._markAsDirty();
  9463. if (this._horizontalBar.isVisible) {
  9464. this._grid.setRowDefinition(1, this._barSize, true);
  9465. }
  9466. if (this._verticalBar.isVisible) {
  9467. this._grid.setColumnDefinition(1, this._barSize, true);
  9468. }
  9469. },
  9470. enumerable: false,
  9471. configurable: true
  9472. });
  9473. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9474. /** Gets or sets the length of the thumb */
  9475. get: function () {
  9476. return this._thumbLength;
  9477. },
  9478. set: function (value) {
  9479. if (this._thumbLength === value) {
  9480. return;
  9481. }
  9482. if (value <= 0) {
  9483. value = 0.1;
  9484. }
  9485. if (value > 1) {
  9486. value = 1;
  9487. }
  9488. this._thumbLength = value;
  9489. var hb = this._horizontalBar;
  9490. var vb = this._verticalBar;
  9491. hb.thumbLength = value;
  9492. vb.thumbLength = value;
  9493. this._markAsDirty();
  9494. },
  9495. enumerable: false,
  9496. configurable: true
  9497. });
  9498. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9499. /** Gets or sets the height of the thumb */
  9500. get: function () {
  9501. return this._thumbHeight;
  9502. },
  9503. set: function (value) {
  9504. if (this._thumbHeight === value) {
  9505. return;
  9506. }
  9507. if (value <= 0) {
  9508. value = 0.1;
  9509. }
  9510. if (value > 1) {
  9511. value = 1;
  9512. }
  9513. this._thumbHeight = value;
  9514. var hb = this._horizontalBar;
  9515. var vb = this._verticalBar;
  9516. hb.thumbHeight = value;
  9517. vb.thumbHeight = value;
  9518. this._markAsDirty();
  9519. },
  9520. enumerable: false,
  9521. configurable: true
  9522. });
  9523. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9524. /** Gets or sets the height of the bar image */
  9525. get: function () {
  9526. return this._barImageHeight;
  9527. },
  9528. set: function (value) {
  9529. if (this._barImageHeight === value) {
  9530. return;
  9531. }
  9532. if (value <= 0) {
  9533. value = 0.1;
  9534. }
  9535. if (value > 1) {
  9536. value = 1;
  9537. }
  9538. this._barImageHeight = value;
  9539. var hb = this._horizontalBar;
  9540. var vb = this._verticalBar;
  9541. hb.barImageHeight = value;
  9542. vb.barImageHeight = value;
  9543. this._markAsDirty();
  9544. },
  9545. enumerable: false,
  9546. configurable: true
  9547. });
  9548. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImageHeight", {
  9549. /** Gets or sets the height of the horizontal bar image */
  9550. get: function () {
  9551. return this._horizontalBarImageHeight;
  9552. },
  9553. set: function (value) {
  9554. if (this._horizontalBarImageHeight === value) {
  9555. return;
  9556. }
  9557. if (value <= 0) {
  9558. value = 0.1;
  9559. }
  9560. if (value > 1) {
  9561. value = 1;
  9562. }
  9563. this._horizontalBarImageHeight = value;
  9564. var hb = this._horizontalBar;
  9565. hb.barImageHeight = value;
  9566. this._markAsDirty();
  9567. },
  9568. enumerable: false,
  9569. configurable: true
  9570. });
  9571. Object.defineProperty(ScrollViewer.prototype, "verticalBarImageHeight", {
  9572. /** Gets or sets the height of the vertical bar image */
  9573. get: function () {
  9574. return this._verticalBarImageHeight;
  9575. },
  9576. set: function (value) {
  9577. if (this._verticalBarImageHeight === value) {
  9578. return;
  9579. }
  9580. if (value <= 0) {
  9581. value = 0.1;
  9582. }
  9583. if (value > 1) {
  9584. value = 1;
  9585. }
  9586. this._verticalBarImageHeight = value;
  9587. var vb = this._verticalBar;
  9588. vb.barImageHeight = value;
  9589. this._markAsDirty();
  9590. },
  9591. enumerable: false,
  9592. configurable: true
  9593. });
  9594. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9595. /** Gets or sets the bar background */
  9596. get: function () {
  9597. return this._barBackground;
  9598. },
  9599. set: function (color) {
  9600. if (this._barBackground === color) {
  9601. return;
  9602. }
  9603. this._barBackground = color;
  9604. var hb = this._horizontalBar;
  9605. var vb = this._verticalBar;
  9606. hb.background = color;
  9607. vb.background = color;
  9608. this._dragSpace.background = color;
  9609. },
  9610. enumerable: false,
  9611. configurable: true
  9612. });
  9613. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9614. /** Gets or sets the bar background image */
  9615. get: function () {
  9616. return this._barBackgroundImage;
  9617. },
  9618. set: function (value) {
  9619. if (this._barBackgroundImage === value) {
  9620. }
  9621. this._barBackgroundImage = value;
  9622. var hb = this._horizontalBar;
  9623. var vb = this._verticalBar;
  9624. hb.backgroundImage = value;
  9625. vb.backgroundImage = value;
  9626. },
  9627. enumerable: false,
  9628. configurable: true
  9629. });
  9630. Object.defineProperty(ScrollViewer.prototype, "horizontalBarImage", {
  9631. /** Gets or sets the horizontal bar background image */
  9632. get: function () {
  9633. return this._horizontalBarBackgroundImage;
  9634. },
  9635. set: function (value) {
  9636. if (this._horizontalBarBackgroundImage === value) {
  9637. }
  9638. this._horizontalBarBackgroundImage = value;
  9639. var hb = this._horizontalBar;
  9640. hb.backgroundImage = value;
  9641. },
  9642. enumerable: false,
  9643. configurable: true
  9644. });
  9645. Object.defineProperty(ScrollViewer.prototype, "verticalBarImage", {
  9646. /** Gets or sets the vertical bar background image */
  9647. get: function () {
  9648. return this._verticalBarBackgroundImage;
  9649. },
  9650. set: function (value) {
  9651. if (this._verticalBarBackgroundImage === value) {
  9652. }
  9653. this._verticalBarBackgroundImage = value;
  9654. var vb = this._verticalBar;
  9655. vb.backgroundImage = value;
  9656. },
  9657. enumerable: false,
  9658. configurable: true
  9659. });
  9660. ScrollViewer.prototype._setWindowPosition = function (force) {
  9661. if (force === void 0) { force = true; }
  9662. var ratio = this.host.idealRatio;
  9663. var windowContentsWidth = this._window._currentMeasure.width;
  9664. var windowContentsHeight = this._window._currentMeasure.height;
  9665. if (!force && this._oldWindowContentsWidth === windowContentsWidth && this._oldWindowContentsHeight === windowContentsHeight) {
  9666. return;
  9667. }
  9668. this._oldWindowContentsWidth = windowContentsWidth;
  9669. this._oldWindowContentsHeight = windowContentsHeight;
  9670. var _endLeft = this._clientWidth - windowContentsWidth;
  9671. var _endTop = this._clientHeight - windowContentsHeight;
  9672. var newLeft = (this._horizontalBar.value / ratio) * _endLeft + "px";
  9673. var newTop = (this._verticalBar.value / ratio) * _endTop + "px";
  9674. if (newLeft !== this._window.left) {
  9675. this._window.left = newLeft;
  9676. if (!this.freezeControls) {
  9677. this._rebuildLayout = true;
  9678. }
  9679. }
  9680. if (newTop !== this._window.top) {
  9681. this._window.top = newTop;
  9682. if (!this.freezeControls) {
  9683. this._rebuildLayout = true;
  9684. }
  9685. }
  9686. };
  9687. /** @hidden */
  9688. ScrollViewer.prototype._updateScroller = function () {
  9689. var windowContentsWidth = this._window._currentMeasure.width;
  9690. var windowContentsHeight = this._window._currentMeasure.height;
  9691. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth && !this.forceHorizontalBar) {
  9692. this._grid.setRowDefinition(1, 0, true);
  9693. this._horizontalBar.isVisible = false;
  9694. this._horizontalBar.value = 0;
  9695. this._rebuildLayout = true;
  9696. }
  9697. else if (!this._horizontalBar.isVisible && (windowContentsWidth > this._clientWidth || this.forceHorizontalBar)) {
  9698. this._grid.setRowDefinition(1, this._barSize, true);
  9699. this._horizontalBar.isVisible = true;
  9700. this._rebuildLayout = true;
  9701. }
  9702. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight && !this.forceVerticalBar) {
  9703. this._grid.setColumnDefinition(1, 0, true);
  9704. this._verticalBar.isVisible = false;
  9705. this._verticalBar.value = 0;
  9706. this._rebuildLayout = true;
  9707. }
  9708. else if (!this._verticalBar.isVisible && (windowContentsHeight > this._clientHeight || this.forceVerticalBar)) {
  9709. this._grid.setColumnDefinition(1, this._barSize, true);
  9710. this._verticalBar.isVisible = true;
  9711. this._rebuildLayout = true;
  9712. }
  9713. this._buildClientSizes();
  9714. var ratio = this.host.idealRatio;
  9715. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientWidth / ratio) + "px";
  9716. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * (this._clientHeight / ratio) + "px";
  9717. };
  9718. ScrollViewer.prototype._link = function (host) {
  9719. _super.prototype._link.call(this, host);
  9720. this._attachWheel();
  9721. };
  9722. /** @hidden */
  9723. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9724. var _this = this;
  9725. barControl.paddingLeft = 0;
  9726. barControl.width = "100%";
  9727. barControl.height = "100%";
  9728. barControl.barOffset = 0;
  9729. barControl.value = 0;
  9730. barControl.maximum = 1;
  9731. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9732. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9733. barControl.isVertical = isVertical;
  9734. barControl.rotation = rotation;
  9735. barControl.isVisible = false;
  9736. barContainer.addControl(barControl);
  9737. barControl.onValueChangedObservable.add(function (value) {
  9738. _this._setWindowPosition();
  9739. });
  9740. };
  9741. /** @hidden */
  9742. ScrollViewer.prototype._attachWheel = function () {
  9743. var _this = this;
  9744. if (!this._host || this._onWheelObserver) {
  9745. return;
  9746. }
  9747. this._onWheelObserver = this.onWheelObservable.add(function (pi) {
  9748. if (!_this._pointerIsOver) {
  9749. return;
  9750. }
  9751. if (_this._verticalBar.isVisible == true) {
  9752. if (pi.y < 0 && _this._verticalBar.value > 0) {
  9753. _this._verticalBar.value -= _this._wheelPrecision;
  9754. }
  9755. else if (pi.y > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9756. _this._verticalBar.value += _this._wheelPrecision;
  9757. }
  9758. }
  9759. if (_this._horizontalBar.isVisible == true) {
  9760. if (pi.x < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9761. _this._horizontalBar.value += _this._wheelPrecision;
  9762. }
  9763. else if (pi.x > 0 && _this._horizontalBar.value > 0) {
  9764. _this._horizontalBar.value -= _this._wheelPrecision;
  9765. }
  9766. }
  9767. });
  9768. };
  9769. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9770. if (!this.isHighlighted) {
  9771. return;
  9772. }
  9773. _super.prototype._renderHighlightSpecific.call(this, context);
  9774. this._grid._renderHighlightSpecific(context);
  9775. context.restore();
  9776. };
  9777. /** Releases associated resources */
  9778. ScrollViewer.prototype.dispose = function () {
  9779. this.onWheelObservable.remove(this._onWheelObserver);
  9780. this._onWheelObserver = null;
  9781. _super.prototype.dispose.call(this);
  9782. };
  9783. return ScrollViewer;
  9784. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9785. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9786. /***/ }),
  9787. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9788. /*!*********************************************************!*\
  9789. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9790. \*********************************************************/
  9791. /*! exports provided: _ScrollViewerWindow */
  9792. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9793. "use strict";
  9794. __webpack_require__.r(__webpack_exports__);
  9795. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9796. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9797. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  9798. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9799. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9800. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9801. /**
  9802. * Class used to hold a the container for ScrollViewer
  9803. * @hidden
  9804. */
  9805. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9806. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9807. /**
  9808. * Creates a new ScrollViewerWindow
  9809. * @param name of ScrollViewerWindow
  9810. */
  9811. function _ScrollViewerWindow(name) {
  9812. var _this = _super.call(this, name) || this;
  9813. _this._freezeControls = false;
  9814. _this._bucketWidth = 0;
  9815. _this._bucketHeight = 0;
  9816. _this._buckets = {};
  9817. return _this;
  9818. }
  9819. Object.defineProperty(_ScrollViewerWindow.prototype, "freezeControls", {
  9820. get: function () {
  9821. return this._freezeControls;
  9822. },
  9823. set: function (value) {
  9824. if (this._freezeControls === value) {
  9825. return;
  9826. }
  9827. if (!value) {
  9828. this._restoreMeasures();
  9829. }
  9830. // trigger a full normal layout calculation to be sure all children have their measures up to date
  9831. this._freezeControls = false;
  9832. var textureSize = this.host.getSize();
  9833. var renderWidth = textureSize.width;
  9834. var renderHeight = textureSize.height;
  9835. var context = this.host.getContext();
  9836. var measure = new _measure__WEBPACK_IMPORTED_MODULE_1__["Measure"](0, 0, renderWidth, renderHeight);
  9837. this.host._numLayoutCalls = 0;
  9838. this.host._rootContainer._layout(measure, context);
  9839. // in freeze mode, prepare children measures accordingly
  9840. if (value) {
  9841. this._updateMeasures();
  9842. if (this._useBuckets()) {
  9843. this._makeBuckets();
  9844. }
  9845. }
  9846. this._freezeControls = value;
  9847. this.host.markAsDirty(); // redraw with the (new) current settings
  9848. },
  9849. enumerable: false,
  9850. configurable: true
  9851. });
  9852. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketWidth", {
  9853. get: function () {
  9854. return this._bucketWidth;
  9855. },
  9856. enumerable: false,
  9857. configurable: true
  9858. });
  9859. Object.defineProperty(_ScrollViewerWindow.prototype, "bucketHeight", {
  9860. get: function () {
  9861. return this._bucketHeight;
  9862. },
  9863. enumerable: false,
  9864. configurable: true
  9865. });
  9866. _ScrollViewerWindow.prototype.setBucketSizes = function (width, height) {
  9867. this._bucketWidth = width;
  9868. this._bucketHeight = height;
  9869. if (this._useBuckets()) {
  9870. if (this._freezeControls) {
  9871. this._makeBuckets();
  9872. }
  9873. }
  9874. else {
  9875. this._buckets = {};
  9876. }
  9877. };
  9878. _ScrollViewerWindow.prototype._useBuckets = function () {
  9879. return this._bucketWidth > 0 && this._bucketHeight > 0;
  9880. };
  9881. _ScrollViewerWindow.prototype._makeBuckets = function () {
  9882. this._buckets = {};
  9883. this._bucketLen = Math.ceil(this.widthInPixels / this._bucketWidth);
  9884. this._dispatchInBuckets(this._children);
  9885. this._oldLeft = null;
  9886. this._oldTop = null;
  9887. };
  9888. _ScrollViewerWindow.prototype._dispatchInBuckets = function (children) {
  9889. for (var i = 0; i < children.length; ++i) {
  9890. var child = children[i];
  9891. 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);
  9892. while (bStartY <= bEndY) {
  9893. for (var x = bStartX; x <= bEndX; ++x) {
  9894. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9895. if (!lstc) {
  9896. lstc = [];
  9897. this._buckets[bucket] = lstc;
  9898. }
  9899. lstc.push(child);
  9900. }
  9901. bStartY++;
  9902. }
  9903. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9904. this._dispatchInBuckets(child._children);
  9905. }
  9906. }
  9907. };
  9908. // reset left and top measures for the window and all its children
  9909. _ScrollViewerWindow.prototype._updateMeasures = function () {
  9910. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9911. this._measureForChildren.left -= left;
  9912. this._measureForChildren.top -= top;
  9913. this._currentMeasure.left -= left;
  9914. this._currentMeasure.top -= top;
  9915. this._customData.origLeftForChildren = this._measureForChildren.left;
  9916. this._customData.origTopForChildren = this._measureForChildren.top;
  9917. this._customData.origLeft = this._currentMeasure.left;
  9918. this._customData.origTop = this._currentMeasure.top;
  9919. this._updateChildrenMeasures(this._children, left, top);
  9920. };
  9921. _ScrollViewerWindow.prototype._updateChildrenMeasures = function (children, left, top) {
  9922. for (var i = 0; i < children.length; ++i) {
  9923. var child = children[i];
  9924. child._currentMeasure.left -= left;
  9925. child._currentMeasure.top -= top;
  9926. child._customData._origLeft = child._currentMeasure.left; // save the original left and top values for each child
  9927. child._customData._origTop = child._currentMeasure.top;
  9928. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9929. this._updateChildrenMeasures(child._children, left, top);
  9930. }
  9931. }
  9932. };
  9933. _ScrollViewerWindow.prototype._restoreMeasures = function () {
  9934. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9935. this._measureForChildren.left = this._customData.origLeftForChildren + left;
  9936. this._measureForChildren.top = this._customData.origTopForChildren + top;
  9937. this._currentMeasure.left = this._customData.origLeft + left;
  9938. this._currentMeasure.top = this._customData.origTop + top;
  9939. };
  9940. _ScrollViewerWindow.prototype._getTypeName = function () {
  9941. return "ScrollViewerWindow";
  9942. };
  9943. /** @hidden */
  9944. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9945. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9946. this._parentMeasure = parentMeasure;
  9947. this._measureForChildren.left = this._currentMeasure.left;
  9948. this._measureForChildren.top = this._currentMeasure.top;
  9949. this._measureForChildren.width = parentMeasure.width;
  9950. this._measureForChildren.height = parentMeasure.height;
  9951. };
  9952. /** @hidden */
  9953. _ScrollViewerWindow.prototype._layout = function (parentMeasure, context) {
  9954. if (this._freezeControls) {
  9955. this.invalidateRect(); // will trigger a redraw of the window
  9956. return false;
  9957. }
  9958. return _super.prototype._layout.call(this, parentMeasure, context);
  9959. };
  9960. _ScrollViewerWindow.prototype._scrollChildren = function (children, left, top) {
  9961. for (var i = 0; i < children.length; ++i) {
  9962. var child = children[i];
  9963. child._currentMeasure.left = child._customData._origLeft + left;
  9964. child._currentMeasure.top = child._customData._origTop + top;
  9965. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9966. if (child instanceof _container__WEBPACK_IMPORTED_MODULE_2__["Container"] && child._children.length > 0) {
  9967. this._scrollChildren(child._children, left, top);
  9968. }
  9969. }
  9970. };
  9971. _ScrollViewerWindow.prototype._scrollChildrenWithBuckets = function (left, top, scrollLeft, scrollTop) {
  9972. 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);
  9973. while (bStartY <= bEndY) {
  9974. for (var x = bStartX; x <= bEndX; ++x) {
  9975. var bucket = bStartY * this._bucketLen + x, lstc = this._buckets[bucket];
  9976. if (lstc) {
  9977. for (var i = 0; i < lstc.length; ++i) {
  9978. var child = lstc[i];
  9979. child._currentMeasure.left = child._customData._origLeft + scrollLeft;
  9980. child._currentMeasure.top = child._customData._origTop + scrollTop;
  9981. child._isClipped = false; // clipping will be handled by _draw and the call to _intersectsRect()
  9982. }
  9983. }
  9984. }
  9985. bStartY++;
  9986. }
  9987. };
  9988. /** @hidden */
  9989. _ScrollViewerWindow.prototype._draw = function (context, invalidatedRectangle) {
  9990. if (!this._freezeControls) {
  9991. _super.prototype._draw.call(this, context, invalidatedRectangle);
  9992. return;
  9993. }
  9994. this._localDraw(context);
  9995. if (this.clipChildren) {
  9996. this._clipForChildren(context);
  9997. }
  9998. var left = this.leftInPixels | 0, top = this.topInPixels | 0;
  9999. if (this._useBuckets()) {
  10000. if (this._oldLeft !== null && this._oldTop !== null) {
  10001. this._scrollChildrenWithBuckets(this._oldLeft, this._oldTop, left, top);
  10002. this._scrollChildrenWithBuckets(left, top, left, top);
  10003. }
  10004. else {
  10005. this._scrollChildren(this._children, left, top);
  10006. }
  10007. }
  10008. else {
  10009. this._scrollChildren(this._children, left, top);
  10010. }
  10011. this._oldLeft = left;
  10012. this._oldTop = top;
  10013. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  10014. var child = _a[_i];
  10015. if (!child._intersectsRect(this._parentMeasure)) {
  10016. continue;
  10017. }
  10018. child._render(context, this._parentMeasure);
  10019. }
  10020. };
  10021. _ScrollViewerWindow.prototype._postMeasure = function () {
  10022. if (this._freezeControls) {
  10023. _super.prototype._postMeasure.call(this);
  10024. return;
  10025. }
  10026. var maxWidth = this.parentClientWidth;
  10027. var maxHeight = this.parentClientHeight;
  10028. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10029. var child = _a[_i];
  10030. if (!child.isVisible || child.notRenderable) {
  10031. continue;
  10032. }
  10033. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  10034. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  10035. }
  10036. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  10037. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  10038. }
  10039. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width + child.paddingRightInPixels);
  10040. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height + child.paddingBottomInPixels);
  10041. }
  10042. if (this._currentMeasure.width !== maxWidth) {
  10043. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10044. this._currentMeasure.width = maxWidth;
  10045. this._rebuildLayout = true;
  10046. this._isDirty = true;
  10047. }
  10048. if (this._currentMeasure.height !== maxHeight) {
  10049. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  10050. this._currentMeasure.height = maxHeight;
  10051. this._rebuildLayout = true;
  10052. this._isDirty = true;
  10053. }
  10054. _super.prototype._postMeasure.call(this);
  10055. };
  10056. return _ScrollViewerWindow;
  10057. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  10058. /***/ }),
  10059. /***/ "./2D/controls/selector.ts":
  10060. /*!*********************************!*\
  10061. !*** ./2D/controls/selector.ts ***!
  10062. \*********************************/
  10063. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  10064. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10065. "use strict";
  10066. __webpack_require__.r(__webpack_exports__);
  10067. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  10068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  10069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  10070. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  10071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  10072. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10073. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  10074. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  10075. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  10076. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  10077. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  10078. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  10079. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  10080. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  10081. /** Class used to create a RadioGroup
  10082. * which contains groups of radio buttons
  10083. */
  10084. var SelectorGroup = /** @class */ (function () {
  10085. /**
  10086. * Creates a new SelectorGroup
  10087. * @param name of group, used as a group heading
  10088. */
  10089. function SelectorGroup(
  10090. /** name of SelectorGroup */
  10091. name) {
  10092. this.name = name;
  10093. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10094. this._selectors = new Array();
  10095. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10096. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10097. this._groupHeader = this._addGroupHeader(name);
  10098. }
  10099. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  10100. /** Gets the groupPanel of the SelectorGroup */
  10101. get: function () {
  10102. return this._groupPanel;
  10103. },
  10104. enumerable: false,
  10105. configurable: true
  10106. });
  10107. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  10108. /** Gets the selectors array */
  10109. get: function () {
  10110. return this._selectors;
  10111. },
  10112. enumerable: false,
  10113. configurable: true
  10114. });
  10115. Object.defineProperty(SelectorGroup.prototype, "header", {
  10116. /** Gets and sets the group header */
  10117. get: function () {
  10118. return this._groupHeader.text;
  10119. },
  10120. set: function (label) {
  10121. if (this._groupHeader.text === "label") {
  10122. return;
  10123. }
  10124. this._groupHeader.text = label;
  10125. },
  10126. enumerable: false,
  10127. configurable: true
  10128. });
  10129. /** @hidden */
  10130. SelectorGroup.prototype._addGroupHeader = function (text) {
  10131. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  10132. groupHeading.width = 0.9;
  10133. groupHeading.height = "30px";
  10134. groupHeading.textWrapping = true;
  10135. groupHeading.color = "black";
  10136. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10137. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10138. groupHeading.left = "2px";
  10139. this._groupPanel.addControl(groupHeading);
  10140. return groupHeading;
  10141. };
  10142. /** @hidden*/
  10143. SelectorGroup.prototype._getSelector = function (selectorNb) {
  10144. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10145. return;
  10146. }
  10147. return this._selectors[selectorNb];
  10148. };
  10149. /** Removes the selector at the given position
  10150. * @param selectorNb the position of the selector within the group
  10151. */
  10152. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  10153. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  10154. return;
  10155. }
  10156. this._groupPanel.removeControl(this._selectors[selectorNb]);
  10157. this._selectors.splice(selectorNb, 1);
  10158. };
  10159. return SelectorGroup;
  10160. }());
  10161. /** Class used to create a CheckboxGroup
  10162. * which contains groups of checkbox buttons
  10163. */
  10164. var CheckboxGroup = /** @class */ (function (_super) {
  10165. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  10166. function CheckboxGroup() {
  10167. return _super !== null && _super.apply(this, arguments) || this;
  10168. }
  10169. /** Adds a checkbox as a control
  10170. * @param text is the label for the selector
  10171. * @param func is the function called when the Selector is checked
  10172. * @param checked is true when Selector is checked
  10173. */
  10174. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  10175. if (func === void 0) { func = function (s) { }; }
  10176. if (checked === void 0) { checked = false; }
  10177. var checked = checked || false;
  10178. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  10179. button.width = "20px";
  10180. button.height = "20px";
  10181. button.color = "#364249";
  10182. button.background = "#CCCCCC";
  10183. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10184. button.onIsCheckedChangedObservable.add(function (state) {
  10185. func(state);
  10186. });
  10187. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  10188. _selector.height = "30px";
  10189. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10190. _selector.left = "4px";
  10191. this.groupPanel.addControl(_selector);
  10192. this.selectors.push(_selector);
  10193. button.isChecked = checked;
  10194. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10195. button.color = this.groupPanel.parent.parent.buttonColor;
  10196. button.background = this.groupPanel.parent.parent.buttonBackground;
  10197. }
  10198. };
  10199. /** @hidden */
  10200. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10201. this.selectors[selectorNb].children[1].text = label;
  10202. };
  10203. /** @hidden */
  10204. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10205. this.selectors[selectorNb].children[1].color = color;
  10206. };
  10207. /** @hidden */
  10208. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10209. this.selectors[selectorNb].children[0].color = color;
  10210. };
  10211. /** @hidden */
  10212. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10213. this.selectors[selectorNb].children[0].background = color;
  10214. };
  10215. return CheckboxGroup;
  10216. }(SelectorGroup));
  10217. /** Class used to create a RadioGroup
  10218. * which contains groups of radio buttons
  10219. */
  10220. var RadioGroup = /** @class */ (function (_super) {
  10221. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  10222. function RadioGroup() {
  10223. var _this = _super !== null && _super.apply(this, arguments) || this;
  10224. _this._selectNb = 0;
  10225. return _this;
  10226. }
  10227. /** Adds a radio button as a control
  10228. * @param label is the label for the selector
  10229. * @param func is the function called when the Selector is checked
  10230. * @param checked is true when Selector is checked
  10231. */
  10232. RadioGroup.prototype.addRadio = function (label, func, checked) {
  10233. if (func === void 0) { func = function (n) { }; }
  10234. if (checked === void 0) { checked = false; }
  10235. var nb = this._selectNb++;
  10236. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  10237. button.name = label;
  10238. button.width = "20px";
  10239. button.height = "20px";
  10240. button.color = "#364249";
  10241. button.background = "#CCCCCC";
  10242. button.group = this.name;
  10243. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10244. button.onIsCheckedChangedObservable.add(function (state) {
  10245. if (state) {
  10246. func(nb);
  10247. }
  10248. });
  10249. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  10250. _selector.height = "30px";
  10251. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10252. _selector.left = "4px";
  10253. this.groupPanel.addControl(_selector);
  10254. this.selectors.push(_selector);
  10255. button.isChecked = checked;
  10256. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10257. button.color = this.groupPanel.parent.parent.buttonColor;
  10258. button.background = this.groupPanel.parent.parent.buttonBackground;
  10259. }
  10260. };
  10261. /** @hidden */
  10262. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10263. this.selectors[selectorNb].children[1].text = label;
  10264. };
  10265. /** @hidden */
  10266. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10267. this.selectors[selectorNb].children[1].color = color;
  10268. };
  10269. /** @hidden */
  10270. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10271. this.selectors[selectorNb].children[0].color = color;
  10272. };
  10273. /** @hidden */
  10274. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10275. this.selectors[selectorNb].children[0].background = color;
  10276. };
  10277. return RadioGroup;
  10278. }(SelectorGroup));
  10279. /** Class used to create a SliderGroup
  10280. * which contains groups of slider buttons
  10281. */
  10282. var SliderGroup = /** @class */ (function (_super) {
  10283. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  10284. function SliderGroup() {
  10285. return _super !== null && _super.apply(this, arguments) || this;
  10286. }
  10287. /**
  10288. * Adds a slider to the SelectorGroup
  10289. * @param label is the label for the SliderBar
  10290. * @param func is the function called when the Slider moves
  10291. * @param unit is a string describing the units used, eg degrees or metres
  10292. * @param min is the minimum value for the Slider
  10293. * @param max is the maximum value for the Slider
  10294. * @param value is the start value for the Slider between min and max
  10295. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  10296. */
  10297. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  10298. if (func === void 0) { func = function (v) { }; }
  10299. if (unit === void 0) { unit = "Units"; }
  10300. if (min === void 0) { min = 0; }
  10301. if (max === void 0) { max = 0; }
  10302. if (value === void 0) { value = 0; }
  10303. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  10304. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  10305. button.name = unit;
  10306. button.value = value;
  10307. button.minimum = min;
  10308. button.maximum = max;
  10309. button.width = 0.9;
  10310. button.height = "20px";
  10311. button.color = "#364249";
  10312. button.background = "#CCCCCC";
  10313. button.borderColor = "black";
  10314. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10315. button.left = "4px";
  10316. button.paddingBottom = "4px";
  10317. button.onValueChangedObservable.add(function (value) {
  10318. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  10319. func(value);
  10320. });
  10321. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  10322. _selector.height = "60px";
  10323. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10324. _selector.left = "4px";
  10325. _selector.children[0].name = label;
  10326. this.groupPanel.addControl(_selector);
  10327. this.selectors.push(_selector);
  10328. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  10329. button.color = this.groupPanel.parent.parent.buttonColor;
  10330. button.background = this.groupPanel.parent.parent.buttonBackground;
  10331. }
  10332. };
  10333. /** @hidden */
  10334. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  10335. this.selectors[selectorNb].children[0].name = label;
  10336. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  10337. };
  10338. /** @hidden */
  10339. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  10340. this.selectors[selectorNb].children[0].color = color;
  10341. };
  10342. /** @hidden */
  10343. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  10344. this.selectors[selectorNb].children[1].color = color;
  10345. };
  10346. /** @hidden */
  10347. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  10348. this.selectors[selectorNb].children[1].background = color;
  10349. };
  10350. return SliderGroup;
  10351. }(SelectorGroup));
  10352. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  10353. * @see https://doc.babylonjs.com/how_to/selector
  10354. */
  10355. var SelectionPanel = /** @class */ (function (_super) {
  10356. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  10357. /**
  10358. * Creates a new SelectionPanel
  10359. * @param name of SelectionPanel
  10360. * @param groups is an array of SelectionGroups
  10361. */
  10362. function SelectionPanel(
  10363. /** name of SelectionPanel */
  10364. name,
  10365. /** an array of SelectionGroups */
  10366. groups) {
  10367. if (groups === void 0) { groups = []; }
  10368. var _this = _super.call(this, name) || this;
  10369. _this.name = name;
  10370. _this.groups = groups;
  10371. _this._buttonColor = "#364249";
  10372. _this._buttonBackground = "#CCCCCC";
  10373. _this._headerColor = "black";
  10374. _this._barColor = "white";
  10375. _this._barHeight = "2px";
  10376. _this._spacerHeight = "20px";
  10377. _this._bars = new Array();
  10378. _this._groups = groups;
  10379. _this.thickness = 2;
  10380. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  10381. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  10382. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10383. _this._panel.top = 5;
  10384. _this._panel.left = 5;
  10385. _this._panel.width = 0.95;
  10386. if (groups.length > 0) {
  10387. for (var i = 0; i < groups.length - 1; i++) {
  10388. _this._panel.addControl(groups[i].groupPanel);
  10389. _this._addSpacer();
  10390. }
  10391. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  10392. }
  10393. _this.addControl(_this._panel);
  10394. return _this;
  10395. }
  10396. SelectionPanel.prototype._getTypeName = function () {
  10397. return "SelectionPanel";
  10398. };
  10399. Object.defineProperty(SelectionPanel.prototype, "panel", {
  10400. /** Gets the (stack) panel of the SelectionPanel */
  10401. get: function () {
  10402. return this._panel;
  10403. },
  10404. enumerable: false,
  10405. configurable: true
  10406. });
  10407. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  10408. /** Gets or sets the headerColor */
  10409. get: function () {
  10410. return this._headerColor;
  10411. },
  10412. set: function (color) {
  10413. if (this._headerColor === color) {
  10414. return;
  10415. }
  10416. this._headerColor = color;
  10417. this._setHeaderColor();
  10418. },
  10419. enumerable: false,
  10420. configurable: true
  10421. });
  10422. SelectionPanel.prototype._setHeaderColor = function () {
  10423. for (var i = 0; i < this._groups.length; i++) {
  10424. this._groups[i].groupPanel.children[0].color = this._headerColor;
  10425. }
  10426. };
  10427. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  10428. /** Gets or sets the button color */
  10429. get: function () {
  10430. return this._buttonColor;
  10431. },
  10432. set: function (color) {
  10433. if (this._buttonColor === color) {
  10434. return;
  10435. }
  10436. this._buttonColor = color;
  10437. this._setbuttonColor();
  10438. },
  10439. enumerable: false,
  10440. configurable: true
  10441. });
  10442. SelectionPanel.prototype._setbuttonColor = function () {
  10443. for (var i = 0; i < this._groups.length; i++) {
  10444. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10445. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  10446. }
  10447. }
  10448. };
  10449. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  10450. /** Gets or sets the label color */
  10451. get: function () {
  10452. return this._labelColor;
  10453. },
  10454. set: function (color) {
  10455. if (this._labelColor === color) {
  10456. return;
  10457. }
  10458. this._labelColor = color;
  10459. this._setLabelColor();
  10460. },
  10461. enumerable: false,
  10462. configurable: true
  10463. });
  10464. SelectionPanel.prototype._setLabelColor = function () {
  10465. for (var i = 0; i < this._groups.length; i++) {
  10466. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10467. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  10468. }
  10469. }
  10470. };
  10471. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  10472. /** Gets or sets the button background */
  10473. get: function () {
  10474. return this._buttonBackground;
  10475. },
  10476. set: function (color) {
  10477. if (this._buttonBackground === color) {
  10478. return;
  10479. }
  10480. this._buttonBackground = color;
  10481. this._setButtonBackground();
  10482. },
  10483. enumerable: false,
  10484. configurable: true
  10485. });
  10486. SelectionPanel.prototype._setButtonBackground = function () {
  10487. for (var i = 0; i < this._groups.length; i++) {
  10488. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  10489. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  10490. }
  10491. }
  10492. };
  10493. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  10494. /** Gets or sets the color of separator bar */
  10495. get: function () {
  10496. return this._barColor;
  10497. },
  10498. set: function (color) {
  10499. if (this._barColor === color) {
  10500. return;
  10501. }
  10502. this._barColor = color;
  10503. this._setBarColor();
  10504. },
  10505. enumerable: false,
  10506. configurable: true
  10507. });
  10508. SelectionPanel.prototype._setBarColor = function () {
  10509. for (var i = 0; i < this._bars.length; i++) {
  10510. this._bars[i].children[0].background = this._barColor;
  10511. }
  10512. };
  10513. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  10514. /** Gets or sets the height of separator bar */
  10515. get: function () {
  10516. return this._barHeight;
  10517. },
  10518. set: function (value) {
  10519. if (this._barHeight === value) {
  10520. return;
  10521. }
  10522. this._barHeight = value;
  10523. this._setBarHeight();
  10524. },
  10525. enumerable: false,
  10526. configurable: true
  10527. });
  10528. SelectionPanel.prototype._setBarHeight = function () {
  10529. for (var i = 0; i < this._bars.length; i++) {
  10530. this._bars[i].children[0].height = this._barHeight;
  10531. }
  10532. };
  10533. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  10534. /** Gets or sets the height of spacers*/
  10535. get: function () {
  10536. return this._spacerHeight;
  10537. },
  10538. set: function (value) {
  10539. if (this._spacerHeight === value) {
  10540. return;
  10541. }
  10542. this._spacerHeight = value;
  10543. this._setSpacerHeight();
  10544. },
  10545. enumerable: false,
  10546. configurable: true
  10547. });
  10548. SelectionPanel.prototype._setSpacerHeight = function () {
  10549. for (var i = 0; i < this._bars.length; i++) {
  10550. this._bars[i].height = this._spacerHeight;
  10551. }
  10552. };
  10553. /** Adds a bar between groups */
  10554. SelectionPanel.prototype._addSpacer = function () {
  10555. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  10556. separator.width = 1;
  10557. separator.height = this._spacerHeight;
  10558. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10559. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  10560. bar.width = 1;
  10561. bar.height = this._barHeight;
  10562. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  10563. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  10564. bar.background = this._barColor;
  10565. bar.color = "transparent";
  10566. separator.addControl(bar);
  10567. this._panel.addControl(separator);
  10568. this._bars.push(separator);
  10569. };
  10570. /** Add a group to the selection panel
  10571. * @param group is the selector group to add
  10572. */
  10573. SelectionPanel.prototype.addGroup = function (group) {
  10574. if (this._groups.length > 0) {
  10575. this._addSpacer();
  10576. }
  10577. this._panel.addControl(group.groupPanel);
  10578. this._groups.push(group);
  10579. group.groupPanel.children[0].color = this._headerColor;
  10580. for (var j = 0; j < group.selectors.length; j++) {
  10581. group._setSelectorButtonColor(j, this._buttonColor);
  10582. group._setSelectorButtonBackground(j, this._buttonBackground);
  10583. }
  10584. };
  10585. /** Remove the group from the given position
  10586. * @param groupNb is the position of the group in the list
  10587. */
  10588. SelectionPanel.prototype.removeGroup = function (groupNb) {
  10589. if (groupNb < 0 || groupNb >= this._groups.length) {
  10590. return;
  10591. }
  10592. var group = this._groups[groupNb];
  10593. this._panel.removeControl(group.groupPanel);
  10594. this._groups.splice(groupNb, 1);
  10595. if (groupNb < this._bars.length) {
  10596. this._panel.removeControl(this._bars[groupNb]);
  10597. this._bars.splice(groupNb, 1);
  10598. }
  10599. };
  10600. /** Change a group header label
  10601. * @param label is the new group header label
  10602. * @param groupNb is the number of the group to relabel
  10603. * */
  10604. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  10605. if (groupNb < 0 || groupNb >= this._groups.length) {
  10606. return;
  10607. }
  10608. var group = this._groups[groupNb];
  10609. group.groupPanel.children[0].text = label;
  10610. };
  10611. /** Change selector label to the one given
  10612. * @param label is the new selector label
  10613. * @param groupNb is the number of the groupcontaining the selector
  10614. * @param selectorNb is the number of the selector within a group to relabel
  10615. * */
  10616. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  10617. if (groupNb < 0 || groupNb >= this._groups.length) {
  10618. return;
  10619. }
  10620. var group = this._groups[groupNb];
  10621. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10622. return;
  10623. }
  10624. group._setSelectorLabel(selectorNb, label);
  10625. };
  10626. /** For a given group position remove the selector at the given position
  10627. * @param groupNb is the number of the group to remove the selector from
  10628. * @param selectorNb is the number of the selector within the group
  10629. */
  10630. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  10631. if (groupNb < 0 || groupNb >= this._groups.length) {
  10632. return;
  10633. }
  10634. var group = this._groups[groupNb];
  10635. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  10636. return;
  10637. }
  10638. group.removeSelector(selectorNb);
  10639. };
  10640. /** For a given group position of correct type add a checkbox button
  10641. * @param groupNb is the number of the group to remove the selector from
  10642. * @param label is the label for the selector
  10643. * @param func is the function called when the Selector is checked
  10644. * @param checked is true when Selector is checked
  10645. */
  10646. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  10647. if (func === void 0) { func = function () { }; }
  10648. if (checked === void 0) { checked = false; }
  10649. if (groupNb < 0 || groupNb >= this._groups.length) {
  10650. return;
  10651. }
  10652. var group = this._groups[groupNb];
  10653. group.addCheckbox(label, func, checked);
  10654. };
  10655. /** For a given group position of correct type add a radio button
  10656. * @param groupNb is the number of the group to remove the selector from
  10657. * @param label is the label for the selector
  10658. * @param func is the function called when the Selector is checked
  10659. * @param checked is true when Selector is checked
  10660. */
  10661. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  10662. if (func === void 0) { func = function () { }; }
  10663. if (checked === void 0) { checked = false; }
  10664. if (groupNb < 0 || groupNb >= this._groups.length) {
  10665. return;
  10666. }
  10667. var group = this._groups[groupNb];
  10668. group.addRadio(label, func, checked);
  10669. };
  10670. /**
  10671. * For a given slider group add a slider
  10672. * @param groupNb is the number of the group to add the slider to
  10673. * @param label is the label for the Slider
  10674. * @param func is the function called when the Slider moves
  10675. * @param unit is a string describing the units used, eg degrees or metres
  10676. * @param min is the minimum value for the Slider
  10677. * @param max is the maximum value for the Slider
  10678. * @param value is the start value for the Slider between min and max
  10679. * @param onVal is the function used to format the value displayed, eg radians to degrees
  10680. */
  10681. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  10682. if (func === void 0) { func = function () { }; }
  10683. if (unit === void 0) { unit = "Units"; }
  10684. if (min === void 0) { min = 0; }
  10685. if (max === void 0) { max = 0; }
  10686. if (value === void 0) { value = 0; }
  10687. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  10688. if (groupNb < 0 || groupNb >= this._groups.length) {
  10689. return;
  10690. }
  10691. var group = this._groups[groupNb];
  10692. group.addSlider(label, func, unit, min, max, value, onVal);
  10693. };
  10694. return SelectionPanel;
  10695. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  10696. /***/ }),
  10697. /***/ "./2D/controls/sliders/baseSlider.ts":
  10698. /*!*******************************************!*\
  10699. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10700. \*******************************************/
  10701. /*! exports provided: BaseSlider */
  10702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10703. "use strict";
  10704. __webpack_require__.r(__webpack_exports__);
  10705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10706. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10707. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  10708. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10709. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10710. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10711. /**
  10712. * Class used to create slider controls
  10713. */
  10714. var BaseSlider = /** @class */ (function (_super) {
  10715. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10716. /**
  10717. * Creates a new BaseSlider
  10718. * @param name defines the control name
  10719. */
  10720. function BaseSlider(name) {
  10721. var _this = _super.call(this, name) || this;
  10722. _this.name = name;
  10723. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10724. _this._minimum = 0;
  10725. _this._maximum = 100;
  10726. _this._value = 50;
  10727. _this._isVertical = false;
  10728. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10729. _this._isThumbClamped = false;
  10730. _this._displayThumb = true;
  10731. _this._step = 0;
  10732. _this._lastPointerDownID = -1;
  10733. // Shared rendering info
  10734. _this._effectiveBarOffset = 0;
  10735. /** Observable raised when the sldier value changes */
  10736. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10737. // Events
  10738. _this._pointerIsDown = false;
  10739. _this.isPointerBlocker = true;
  10740. return _this;
  10741. }
  10742. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10743. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10744. get: function () {
  10745. return this._displayThumb;
  10746. },
  10747. set: function (value) {
  10748. if (this._displayThumb === value) {
  10749. return;
  10750. }
  10751. this._displayThumb = value;
  10752. this._markAsDirty();
  10753. },
  10754. enumerable: false,
  10755. configurable: true
  10756. });
  10757. Object.defineProperty(BaseSlider.prototype, "step", {
  10758. /** Gets or sets a step to apply to values (0 by default) */
  10759. get: function () {
  10760. return this._step;
  10761. },
  10762. set: function (value) {
  10763. if (this._step === value) {
  10764. return;
  10765. }
  10766. this._step = value;
  10767. this._markAsDirty();
  10768. },
  10769. enumerable: false,
  10770. configurable: true
  10771. });
  10772. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10773. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10774. get: function () {
  10775. return this._barOffset.toString(this._host);
  10776. },
  10777. set: function (value) {
  10778. if (this._barOffset.toString(this._host) === value) {
  10779. return;
  10780. }
  10781. if (this._barOffset.fromString(value)) {
  10782. this._markAsDirty();
  10783. }
  10784. },
  10785. enumerable: false,
  10786. configurable: true
  10787. });
  10788. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10789. /** Gets main bar offset in pixels*/
  10790. get: function () {
  10791. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10792. },
  10793. enumerable: false,
  10794. configurable: true
  10795. });
  10796. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10797. /** Gets or sets thumb width */
  10798. get: function () {
  10799. return this._thumbWidth.toString(this._host);
  10800. },
  10801. set: function (value) {
  10802. if (this._thumbWidth.toString(this._host) === value) {
  10803. return;
  10804. }
  10805. if (this._thumbWidth.fromString(value)) {
  10806. this._markAsDirty();
  10807. }
  10808. },
  10809. enumerable: false,
  10810. configurable: true
  10811. });
  10812. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10813. /** Gets thumb width in pixels */
  10814. get: function () {
  10815. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10816. },
  10817. enumerable: false,
  10818. configurable: true
  10819. });
  10820. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10821. /** Gets or sets minimum value */
  10822. get: function () {
  10823. return this._minimum;
  10824. },
  10825. set: function (value) {
  10826. if (this._minimum === value) {
  10827. return;
  10828. }
  10829. this._minimum = value;
  10830. this._markAsDirty();
  10831. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10832. },
  10833. enumerable: false,
  10834. configurable: true
  10835. });
  10836. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10837. /** Gets or sets maximum value */
  10838. get: function () {
  10839. return this._maximum;
  10840. },
  10841. set: function (value) {
  10842. if (this._maximum === value) {
  10843. return;
  10844. }
  10845. this._maximum = value;
  10846. this._markAsDirty();
  10847. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10848. },
  10849. enumerable: false,
  10850. configurable: true
  10851. });
  10852. Object.defineProperty(BaseSlider.prototype, "value", {
  10853. /** Gets or sets current value */
  10854. get: function () {
  10855. return this._value;
  10856. },
  10857. set: function (value) {
  10858. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10859. if (this._value === value) {
  10860. return;
  10861. }
  10862. this._value = value;
  10863. this._markAsDirty();
  10864. this.onValueChangedObservable.notifyObservers(this._value);
  10865. },
  10866. enumerable: false,
  10867. configurable: true
  10868. });
  10869. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10870. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10871. get: function () {
  10872. return this._isVertical;
  10873. },
  10874. set: function (value) {
  10875. if (this._isVertical === value) {
  10876. return;
  10877. }
  10878. this._isVertical = value;
  10879. this._markAsDirty();
  10880. },
  10881. enumerable: false,
  10882. configurable: true
  10883. });
  10884. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10885. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10886. get: function () {
  10887. return this._isThumbClamped;
  10888. },
  10889. set: function (value) {
  10890. if (this._isThumbClamped === value) {
  10891. return;
  10892. }
  10893. this._isThumbClamped = value;
  10894. this._markAsDirty();
  10895. },
  10896. enumerable: false,
  10897. configurable: true
  10898. });
  10899. BaseSlider.prototype._getTypeName = function () {
  10900. return "BaseSlider";
  10901. };
  10902. BaseSlider.prototype._getThumbPosition = function () {
  10903. if (this.isVertical) {
  10904. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10905. }
  10906. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10907. };
  10908. BaseSlider.prototype._getThumbThickness = function (type) {
  10909. var thumbThickness = 0;
  10910. switch (type) {
  10911. case "circle":
  10912. if (this._thumbWidth.isPixel) {
  10913. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10914. }
  10915. else {
  10916. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10917. }
  10918. break;
  10919. case "rectangle":
  10920. if (this._thumbWidth.isPixel) {
  10921. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10922. }
  10923. else {
  10924. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10925. }
  10926. }
  10927. return thumbThickness;
  10928. };
  10929. BaseSlider.prototype._prepareRenderingData = function (type) {
  10930. // Main bar
  10931. this._effectiveBarOffset = 0;
  10932. this._renderLeft = this._currentMeasure.left;
  10933. this._renderTop = this._currentMeasure.top;
  10934. this._renderWidth = this._currentMeasure.width;
  10935. this._renderHeight = this._currentMeasure.height;
  10936. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10937. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10938. this._effectiveThumbThickness = this._getThumbThickness(type);
  10939. if (this.displayThumb) {
  10940. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10941. }
  10942. //throw error when height is less than width for vertical slider
  10943. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10944. console.error("Height should be greater than width");
  10945. return;
  10946. }
  10947. if (this._barOffset.isPixel) {
  10948. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10949. }
  10950. else {
  10951. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10952. }
  10953. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10954. if (this.isVertical) {
  10955. this._renderLeft += this._effectiveBarOffset;
  10956. if (!this.isThumbClamped && this.displayThumb) {
  10957. this._renderTop += (this._effectiveThumbThickness / 2);
  10958. }
  10959. this._renderHeight = this._backgroundBoxLength;
  10960. this._renderWidth = this._backgroundBoxThickness;
  10961. }
  10962. else {
  10963. this._renderTop += this._effectiveBarOffset;
  10964. if (!this.isThumbClamped && this.displayThumb) {
  10965. this._renderLeft += (this._effectiveThumbThickness / 2);
  10966. }
  10967. this._renderHeight = this._backgroundBoxThickness;
  10968. this._renderWidth = this._backgroundBoxLength;
  10969. }
  10970. };
  10971. /** @hidden */
  10972. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10973. if (this.rotation != 0) {
  10974. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10975. x = this._transformedPosition.x;
  10976. y = this._transformedPosition.y;
  10977. }
  10978. var value;
  10979. if (this._isVertical) {
  10980. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10981. }
  10982. else {
  10983. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10984. }
  10985. var mult = (1 / this._step) | 0;
  10986. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10987. };
  10988. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  10989. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
  10990. return false;
  10991. }
  10992. this._pointerIsDown = true;
  10993. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10994. this._host._capturingControl[pointerId] = this;
  10995. this._lastPointerDownID = pointerId;
  10996. return true;
  10997. };
  10998. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
  10999. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  11000. if (pointerId != this._lastPointerDownID) {
  11001. return;
  11002. }
  11003. if (this._pointerIsDown) {
  11004. this._updateValueFromPointer(coordinates.x, coordinates.y);
  11005. }
  11006. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
  11007. };
  11008. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  11009. this._pointerIsDown = false;
  11010. delete this._host._capturingControl[pointerId];
  11011. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  11012. };
  11013. BaseSlider.prototype._onCanvasBlur = function () {
  11014. this._forcePointerUp();
  11015. _super.prototype._onCanvasBlur.call(this);
  11016. };
  11017. return BaseSlider;
  11018. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  11019. /***/ }),
  11020. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  11021. /*!*************************************************!*\
  11022. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  11023. \*************************************************/
  11024. /*! exports provided: ImageBasedSlider */
  11025. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11026. "use strict";
  11027. __webpack_require__.r(__webpack_exports__);
  11028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  11029. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11030. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11031. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11032. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  11033. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  11034. /**
  11035. * Class used to create slider controls based on images
  11036. */
  11037. var ImageBasedSlider = /** @class */ (function (_super) {
  11038. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  11039. /**
  11040. * Creates a new ImageBasedSlider
  11041. * @param name defines the control name
  11042. */
  11043. function ImageBasedSlider(name) {
  11044. var _this = _super.call(this, name) || this;
  11045. _this.name = name;
  11046. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11047. return _this;
  11048. }
  11049. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  11050. get: function () {
  11051. return this._displayThumb && this.thumbImage != null;
  11052. },
  11053. set: function (value) {
  11054. if (this._displayThumb === value) {
  11055. return;
  11056. }
  11057. this._displayThumb = value;
  11058. this._markAsDirty();
  11059. },
  11060. enumerable: false,
  11061. configurable: true
  11062. });
  11063. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  11064. /**
  11065. * Gets or sets the image used to render the background
  11066. */
  11067. get: function () {
  11068. return this._backgroundImage;
  11069. },
  11070. set: function (value) {
  11071. var _this = this;
  11072. if (this._backgroundImage === value) {
  11073. return;
  11074. }
  11075. this._backgroundImage = value;
  11076. if (value && !value.isLoaded) {
  11077. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11078. }
  11079. this._markAsDirty();
  11080. },
  11081. enumerable: false,
  11082. configurable: true
  11083. });
  11084. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  11085. /**
  11086. * Gets or sets the image used to render the value bar
  11087. */
  11088. get: function () {
  11089. return this._valueBarImage;
  11090. },
  11091. set: function (value) {
  11092. var _this = this;
  11093. if (this._valueBarImage === value) {
  11094. return;
  11095. }
  11096. this._valueBarImage = value;
  11097. if (value && !value.isLoaded) {
  11098. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11099. }
  11100. this._markAsDirty();
  11101. },
  11102. enumerable: false,
  11103. configurable: true
  11104. });
  11105. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  11106. /**
  11107. * Gets or sets the image used to render the thumb
  11108. */
  11109. get: function () {
  11110. return this._thumbImage;
  11111. },
  11112. set: function (value) {
  11113. var _this = this;
  11114. if (this._thumbImage === value) {
  11115. return;
  11116. }
  11117. this._thumbImage = value;
  11118. if (value && !value.isLoaded) {
  11119. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  11120. }
  11121. this._markAsDirty();
  11122. },
  11123. enumerable: false,
  11124. configurable: true
  11125. });
  11126. ImageBasedSlider.prototype._getTypeName = function () {
  11127. return "ImageBasedSlider";
  11128. };
  11129. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  11130. context.save();
  11131. this._applyStates(context);
  11132. this._prepareRenderingData("rectangle");
  11133. var thumbPosition = this._getThumbPosition();
  11134. var left = this._renderLeft;
  11135. var top = this._renderTop;
  11136. var width = this._renderWidth;
  11137. var height = this._renderHeight;
  11138. // Background
  11139. if (this._backgroundImage) {
  11140. this._tempMeasure.copyFromFloats(left, top, width, height);
  11141. if (this.isThumbClamped && this.displayThumb) {
  11142. if (this.isVertical) {
  11143. this._tempMeasure.height += this._effectiveThumbThickness;
  11144. }
  11145. else {
  11146. this._tempMeasure.width += this._effectiveThumbThickness;
  11147. }
  11148. }
  11149. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11150. this._backgroundImage._draw(context);
  11151. }
  11152. // Bar
  11153. if (this._valueBarImage) {
  11154. if (this.isVertical) {
  11155. if (this.isThumbClamped && this.displayThumb) {
  11156. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11157. }
  11158. else {
  11159. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  11160. }
  11161. }
  11162. else {
  11163. if (this.isThumbClamped && this.displayThumb) {
  11164. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  11165. }
  11166. else {
  11167. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  11168. }
  11169. }
  11170. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  11171. this._valueBarImage._draw(context);
  11172. }
  11173. // Thumb
  11174. if (this.displayThumb) {
  11175. if (this.isVertical) {
  11176. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11177. }
  11178. else {
  11179. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11180. }
  11181. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11182. this._thumbImage._draw(context);
  11183. }
  11184. context.restore();
  11185. };
  11186. return ImageBasedSlider;
  11187. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11188. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  11189. /***/ }),
  11190. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  11191. /*!***********************************************!*\
  11192. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  11193. \***********************************************/
  11194. /*! exports provided: ImageScrollBar */
  11195. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11196. "use strict";
  11197. __webpack_require__.r(__webpack_exports__);
  11198. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  11199. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11200. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11201. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11202. /**
  11203. * Class used to create slider controls
  11204. */
  11205. var ImageScrollBar = /** @class */ (function (_super) {
  11206. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  11207. /**
  11208. * Creates a new ImageScrollBar
  11209. * @param name defines the control name
  11210. */
  11211. function ImageScrollBar(name) {
  11212. var _this = _super.call(this, name) || this;
  11213. _this.name = name;
  11214. _this._thumbLength = 0.5;
  11215. _this._thumbHeight = 1;
  11216. _this._barImageHeight = 1;
  11217. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11218. /** Number of 90° rotation to apply on the images when in vertical mode */
  11219. _this.num90RotationInVerticalMode = 1;
  11220. return _this;
  11221. }
  11222. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  11223. /**
  11224. * Gets or sets the image used to render the background for horizontal bar
  11225. */
  11226. get: function () {
  11227. return this._backgroundBaseImage;
  11228. },
  11229. set: function (value) {
  11230. var _this = this;
  11231. if (this._backgroundBaseImage === value) {
  11232. return;
  11233. }
  11234. this._backgroundBaseImage = value;
  11235. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11236. if (!value.isLoaded) {
  11237. value.onImageLoadedObservable.addOnce(function () {
  11238. var rotatedValue = value._rotate90(_this.num90RotationInVerticalMode, true);
  11239. _this._backgroundImage = rotatedValue;
  11240. if (!rotatedValue.isLoaded) {
  11241. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11242. _this._markAsDirty();
  11243. });
  11244. }
  11245. _this._markAsDirty();
  11246. });
  11247. }
  11248. else {
  11249. this._backgroundImage = value._rotate90(this.num90RotationInVerticalMode, true);
  11250. this._markAsDirty();
  11251. }
  11252. }
  11253. else {
  11254. this._backgroundImage = value;
  11255. if (value && !value.isLoaded) {
  11256. value.onImageLoadedObservable.addOnce(function () {
  11257. _this._markAsDirty();
  11258. });
  11259. }
  11260. this._markAsDirty();
  11261. }
  11262. },
  11263. enumerable: false,
  11264. configurable: true
  11265. });
  11266. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  11267. /**
  11268. * Gets or sets the image used to render the thumb
  11269. */
  11270. get: function () {
  11271. return this._thumbBaseImage;
  11272. },
  11273. set: function (value) {
  11274. var _this = this;
  11275. if (this._thumbBaseImage === value) {
  11276. return;
  11277. }
  11278. this._thumbBaseImage = value;
  11279. if (this.isVertical && this.num90RotationInVerticalMode !== 0) {
  11280. if (!value.isLoaded) {
  11281. value.onImageLoadedObservable.addOnce(function () {
  11282. var rotatedValue = value._rotate90(-_this.num90RotationInVerticalMode, true);
  11283. _this._thumbImage = rotatedValue;
  11284. if (!rotatedValue.isLoaded) {
  11285. rotatedValue.onImageLoadedObservable.addOnce(function () {
  11286. _this._markAsDirty();
  11287. });
  11288. }
  11289. _this._markAsDirty();
  11290. });
  11291. }
  11292. else {
  11293. this._thumbImage = value._rotate90(-this.num90RotationInVerticalMode, true);
  11294. this._markAsDirty();
  11295. }
  11296. }
  11297. else {
  11298. this._thumbImage = value;
  11299. if (value && !value.isLoaded) {
  11300. value.onImageLoadedObservable.addOnce(function () {
  11301. _this._markAsDirty();
  11302. });
  11303. }
  11304. this._markAsDirty();
  11305. }
  11306. },
  11307. enumerable: false,
  11308. configurable: true
  11309. });
  11310. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  11311. /**
  11312. * Gets or sets the length of the thumb
  11313. */
  11314. get: function () {
  11315. return this._thumbLength;
  11316. },
  11317. set: function (value) {
  11318. if (this._thumbLength === value) {
  11319. return;
  11320. }
  11321. this._thumbLength = value;
  11322. this._markAsDirty();
  11323. },
  11324. enumerable: false,
  11325. configurable: true
  11326. });
  11327. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  11328. /**
  11329. * Gets or sets the height of the thumb
  11330. */
  11331. get: function () {
  11332. return this._thumbHeight;
  11333. },
  11334. set: function (value) {
  11335. if (this._thumbLength === value) {
  11336. return;
  11337. }
  11338. this._thumbHeight = value;
  11339. this._markAsDirty();
  11340. },
  11341. enumerable: false,
  11342. configurable: true
  11343. });
  11344. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  11345. /**
  11346. * Gets or sets the height of the bar image
  11347. */
  11348. get: function () {
  11349. return this._barImageHeight;
  11350. },
  11351. set: function (value) {
  11352. if (this._barImageHeight === value) {
  11353. return;
  11354. }
  11355. this._barImageHeight = value;
  11356. this._markAsDirty();
  11357. },
  11358. enumerable: false,
  11359. configurable: true
  11360. });
  11361. ImageScrollBar.prototype._getTypeName = function () {
  11362. return "ImageScrollBar";
  11363. };
  11364. ImageScrollBar.prototype._getThumbThickness = function () {
  11365. var thumbThickness = 0;
  11366. if (this._thumbWidth.isPixel) {
  11367. thumbThickness = this._thumbWidth.getValue(this._host);
  11368. }
  11369. else {
  11370. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11371. }
  11372. return thumbThickness;
  11373. };
  11374. ImageScrollBar.prototype._draw = function (context) {
  11375. context.save();
  11376. this._applyStates(context);
  11377. this._prepareRenderingData("rectangle");
  11378. var thumbPosition = this._getThumbPosition();
  11379. var left = this._renderLeft;
  11380. var top = this._renderTop;
  11381. var width = this._renderWidth;
  11382. var height = this._renderHeight;
  11383. // Background
  11384. if (this._backgroundImage) {
  11385. this._tempMeasure.copyFromFloats(left, top, width, height);
  11386. if (this.isVertical) {
  11387. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  11388. this._tempMeasure.height += this._effectiveThumbThickness;
  11389. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11390. }
  11391. else {
  11392. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  11393. this._tempMeasure.width += this._effectiveThumbThickness;
  11394. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  11395. }
  11396. this._backgroundImage._draw(context);
  11397. }
  11398. // Thumb
  11399. if (this.isVertical) {
  11400. 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);
  11401. }
  11402. else {
  11403. 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);
  11404. }
  11405. if (this._thumbImage) {
  11406. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  11407. this._thumbImage._draw(context);
  11408. }
  11409. context.restore();
  11410. };
  11411. /** @hidden */
  11412. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11413. if (this.rotation != 0) {
  11414. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11415. x = this._transformedPosition.x;
  11416. y = this._transformedPosition.y;
  11417. }
  11418. if (this._first) {
  11419. this._first = false;
  11420. this._originX = x;
  11421. this._originY = y;
  11422. // Check if move is required
  11423. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11424. if (this.isVertical) {
  11425. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11426. }
  11427. else {
  11428. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11429. }
  11430. }
  11431. }
  11432. // Delta mode
  11433. var delta = 0;
  11434. if (this.isVertical) {
  11435. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11436. }
  11437. else {
  11438. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11439. }
  11440. this.value += delta * (this.maximum - this.minimum);
  11441. this._originX = x;
  11442. this._originY = y;
  11443. };
  11444. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  11445. this._first = true;
  11446. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  11447. };
  11448. return ImageScrollBar;
  11449. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11450. /***/ }),
  11451. /***/ "./2D/controls/sliders/scrollBar.ts":
  11452. /*!******************************************!*\
  11453. !*** ./2D/controls/sliders/scrollBar.ts ***!
  11454. \******************************************/
  11455. /*! exports provided: ScrollBar */
  11456. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11457. "use strict";
  11458. __webpack_require__.r(__webpack_exports__);
  11459. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  11460. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11461. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11462. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  11463. /**
  11464. * Class used to create slider controls
  11465. */
  11466. var ScrollBar = /** @class */ (function (_super) {
  11467. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  11468. /**
  11469. * Creates a new Slider
  11470. * @param name defines the control name
  11471. */
  11472. function ScrollBar(name) {
  11473. var _this = _super.call(this, name) || this;
  11474. _this.name = name;
  11475. _this._background = "black";
  11476. _this._borderColor = "white";
  11477. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  11478. return _this;
  11479. }
  11480. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  11481. /** Gets or sets border color */
  11482. get: function () {
  11483. return this._borderColor;
  11484. },
  11485. set: function (value) {
  11486. if (this._borderColor === value) {
  11487. return;
  11488. }
  11489. this._borderColor = value;
  11490. this._markAsDirty();
  11491. },
  11492. enumerable: false,
  11493. configurable: true
  11494. });
  11495. Object.defineProperty(ScrollBar.prototype, "background", {
  11496. /** Gets or sets background color */
  11497. get: function () {
  11498. return this._background;
  11499. },
  11500. set: function (value) {
  11501. if (this._background === value) {
  11502. return;
  11503. }
  11504. this._background = value;
  11505. this._markAsDirty();
  11506. },
  11507. enumerable: false,
  11508. configurable: true
  11509. });
  11510. ScrollBar.prototype._getTypeName = function () {
  11511. return "Scrollbar";
  11512. };
  11513. ScrollBar.prototype._getThumbThickness = function () {
  11514. var thumbThickness = 0;
  11515. if (this._thumbWidth.isPixel) {
  11516. thumbThickness = this._thumbWidth.getValue(this._host);
  11517. }
  11518. else {
  11519. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  11520. }
  11521. return thumbThickness;
  11522. };
  11523. ScrollBar.prototype._draw = function (context) {
  11524. context.save();
  11525. this._applyStates(context);
  11526. this._prepareRenderingData("rectangle");
  11527. var left = this._renderLeft;
  11528. var thumbPosition = this._getThumbPosition();
  11529. context.fillStyle = this._background;
  11530. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  11531. // Value bar
  11532. context.fillStyle = this.color;
  11533. // Thumb
  11534. if (this.isVertical) {
  11535. this._tempMeasure.left = left - this._effectiveBarOffset;
  11536. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  11537. this._tempMeasure.width = this._currentMeasure.width;
  11538. this._tempMeasure.height = this._effectiveThumbThickness;
  11539. }
  11540. else {
  11541. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  11542. this._tempMeasure.top = this._currentMeasure.top;
  11543. this._tempMeasure.width = this._effectiveThumbThickness;
  11544. this._tempMeasure.height = this._currentMeasure.height;
  11545. }
  11546. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  11547. context.restore();
  11548. };
  11549. /** @hidden */
  11550. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  11551. if (this.rotation != 0) {
  11552. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  11553. x = this._transformedPosition.x;
  11554. y = this._transformedPosition.y;
  11555. }
  11556. if (this._first) {
  11557. this._first = false;
  11558. this._originX = x;
  11559. this._originY = y;
  11560. // Check if move is required
  11561. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  11562. if (this.isVertical) {
  11563. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  11564. }
  11565. else {
  11566. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  11567. }
  11568. }
  11569. }
  11570. // Delta mode
  11571. var delta = 0;
  11572. if (this.isVertical) {
  11573. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  11574. }
  11575. else {
  11576. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  11577. }
  11578. this.value += delta * (this.maximum - this.minimum);
  11579. this._originX = x;
  11580. this._originY = y;
  11581. };
  11582. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
  11583. this._first = true;
  11584. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi);
  11585. };
  11586. return ScrollBar;
  11587. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11588. /***/ }),
  11589. /***/ "./2D/controls/sliders/slider.ts":
  11590. /*!***************************************!*\
  11591. !*** ./2D/controls/sliders/slider.ts ***!
  11592. \***************************************/
  11593. /*! exports provided: Slider */
  11594. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11595. "use strict";
  11596. __webpack_require__.r(__webpack_exports__);
  11597. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  11598. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11599. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  11600. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  11601. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  11602. /**
  11603. * Class used to create slider controls
  11604. */
  11605. var Slider = /** @class */ (function (_super) {
  11606. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  11607. /**
  11608. * Creates a new Slider
  11609. * @param name defines the control name
  11610. */
  11611. function Slider(name) {
  11612. var _this = _super.call(this, name) || this;
  11613. _this.name = name;
  11614. _this._background = "black";
  11615. _this._borderColor = "white";
  11616. _this._thumbColor = "";
  11617. _this._isThumbCircle = false;
  11618. _this._displayValueBar = true;
  11619. return _this;
  11620. }
  11621. Object.defineProperty(Slider.prototype, "displayValueBar", {
  11622. /** Gets or sets a boolean indicating if the value bar must be rendered */
  11623. get: function () {
  11624. return this._displayValueBar;
  11625. },
  11626. set: function (value) {
  11627. if (this._displayValueBar === value) {
  11628. return;
  11629. }
  11630. this._displayValueBar = value;
  11631. this._markAsDirty();
  11632. },
  11633. enumerable: false,
  11634. configurable: true
  11635. });
  11636. Object.defineProperty(Slider.prototype, "borderColor", {
  11637. /** Gets or sets border color */
  11638. get: function () {
  11639. return this._borderColor;
  11640. },
  11641. set: function (value) {
  11642. if (this._borderColor === value) {
  11643. return;
  11644. }
  11645. this._borderColor = value;
  11646. this._markAsDirty();
  11647. },
  11648. enumerable: false,
  11649. configurable: true
  11650. });
  11651. Object.defineProperty(Slider.prototype, "background", {
  11652. /** Gets or sets background color */
  11653. get: function () {
  11654. return this._background;
  11655. },
  11656. set: function (value) {
  11657. if (this._background === value) {
  11658. return;
  11659. }
  11660. this._background = value;
  11661. this._markAsDirty();
  11662. },
  11663. enumerable: false,
  11664. configurable: true
  11665. });
  11666. Object.defineProperty(Slider.prototype, "thumbColor", {
  11667. /** Gets or sets thumb's color */
  11668. get: function () {
  11669. return this._thumbColor;
  11670. },
  11671. set: function (value) {
  11672. if (this._thumbColor === value) {
  11673. return;
  11674. }
  11675. this._thumbColor = value;
  11676. this._markAsDirty();
  11677. },
  11678. enumerable: false,
  11679. configurable: true
  11680. });
  11681. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  11682. /** Gets or sets a boolean indicating if the thumb should be round or square */
  11683. get: function () {
  11684. return this._isThumbCircle;
  11685. },
  11686. set: function (value) {
  11687. if (this._isThumbCircle === value) {
  11688. return;
  11689. }
  11690. this._isThumbCircle = value;
  11691. this._markAsDirty();
  11692. },
  11693. enumerable: false,
  11694. configurable: true
  11695. });
  11696. Slider.prototype._getTypeName = function () {
  11697. return "Slider";
  11698. };
  11699. Slider.prototype._draw = function (context, invalidatedRectangle) {
  11700. context.save();
  11701. this._applyStates(context);
  11702. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  11703. var left = this._renderLeft;
  11704. var top = this._renderTop;
  11705. var width = this._renderWidth;
  11706. var height = this._renderHeight;
  11707. var radius = 0;
  11708. if (this.isThumbClamped && this.isThumbCircle) {
  11709. if (this.isVertical) {
  11710. top += (this._effectiveThumbThickness / 2);
  11711. }
  11712. else {
  11713. left += (this._effectiveThumbThickness / 2);
  11714. }
  11715. radius = this._backgroundBoxThickness / 2;
  11716. }
  11717. else {
  11718. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  11719. }
  11720. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11721. context.shadowColor = this.shadowColor;
  11722. context.shadowBlur = this.shadowBlur;
  11723. context.shadowOffsetX = this.shadowOffsetX;
  11724. context.shadowOffsetY = this.shadowOffsetY;
  11725. }
  11726. var thumbPosition = this._getThumbPosition();
  11727. context.fillStyle = this._background;
  11728. if (this.isVertical) {
  11729. if (this.isThumbClamped) {
  11730. if (this.isThumbCircle) {
  11731. context.beginPath();
  11732. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11733. context.fill();
  11734. context.fillRect(left, top, width, height);
  11735. }
  11736. else {
  11737. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11738. }
  11739. }
  11740. else {
  11741. context.fillRect(left, top, width, height);
  11742. }
  11743. }
  11744. else {
  11745. if (this.isThumbClamped) {
  11746. if (this.isThumbCircle) {
  11747. context.beginPath();
  11748. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11749. context.fill();
  11750. context.fillRect(left, top, width, height);
  11751. }
  11752. else {
  11753. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11754. }
  11755. }
  11756. else {
  11757. context.fillRect(left, top, width, height);
  11758. }
  11759. }
  11760. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11761. context.shadowBlur = 0;
  11762. context.shadowOffsetX = 0;
  11763. context.shadowOffsetY = 0;
  11764. }
  11765. // Value bar
  11766. context.fillStyle = this.color;
  11767. if (this._displayValueBar) {
  11768. if (this.isVertical) {
  11769. if (this.isThumbClamped) {
  11770. if (this.isThumbCircle) {
  11771. context.beginPath();
  11772. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11773. context.fill();
  11774. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11775. }
  11776. else {
  11777. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11778. }
  11779. }
  11780. else {
  11781. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11782. }
  11783. }
  11784. else {
  11785. if (this.isThumbClamped) {
  11786. if (this.isThumbCircle) {
  11787. context.beginPath();
  11788. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11789. context.fill();
  11790. context.fillRect(left, top, thumbPosition, height);
  11791. }
  11792. else {
  11793. context.fillRect(left, top, thumbPosition, height);
  11794. }
  11795. }
  11796. else {
  11797. context.fillRect(left, top, thumbPosition, height);
  11798. }
  11799. }
  11800. }
  11801. // Thumb
  11802. context.fillStyle = this._thumbColor || this.color;
  11803. if (this.displayThumb) {
  11804. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11805. context.shadowColor = this.shadowColor;
  11806. context.shadowBlur = this.shadowBlur;
  11807. context.shadowOffsetX = this.shadowOffsetX;
  11808. context.shadowOffsetY = this.shadowOffsetY;
  11809. }
  11810. if (this._isThumbCircle) {
  11811. context.beginPath();
  11812. if (this.isVertical) {
  11813. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11814. }
  11815. else {
  11816. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11817. }
  11818. context.fill();
  11819. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11820. context.shadowBlur = 0;
  11821. context.shadowOffsetX = 0;
  11822. context.shadowOffsetY = 0;
  11823. }
  11824. context.strokeStyle = this._borderColor;
  11825. context.stroke();
  11826. }
  11827. else {
  11828. if (this.isVertical) {
  11829. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11830. }
  11831. else {
  11832. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11833. }
  11834. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11835. context.shadowBlur = 0;
  11836. context.shadowOffsetX = 0;
  11837. context.shadowOffsetY = 0;
  11838. }
  11839. context.strokeStyle = this._borderColor;
  11840. if (this.isVertical) {
  11841. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11842. }
  11843. else {
  11844. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11845. }
  11846. }
  11847. }
  11848. context.restore();
  11849. };
  11850. return Slider;
  11851. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11852. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11853. /***/ }),
  11854. /***/ "./2D/controls/stackPanel.ts":
  11855. /*!***********************************!*\
  11856. !*** ./2D/controls/stackPanel.ts ***!
  11857. \***********************************/
  11858. /*! exports provided: StackPanel */
  11859. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11860. "use strict";
  11861. __webpack_require__.r(__webpack_exports__);
  11862. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11863. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11864. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  11865. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11866. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11867. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11868. /**
  11869. * Class used to create a 2D stack panel container
  11870. */
  11871. var StackPanel = /** @class */ (function (_super) {
  11872. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11873. /**
  11874. * Creates a new StackPanel
  11875. * @param name defines control name
  11876. */
  11877. function StackPanel(name) {
  11878. var _this = _super.call(this, name) || this;
  11879. _this.name = name;
  11880. _this._isVertical = true;
  11881. _this._manualWidth = false;
  11882. _this._manualHeight = false;
  11883. _this._doNotTrackManualChanges = false;
  11884. /**
  11885. * Gets or sets a boolean indicating that layou warnings should be ignored
  11886. */
  11887. _this.ignoreLayoutWarnings = false;
  11888. return _this;
  11889. }
  11890. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11891. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11892. get: function () {
  11893. return this._isVertical;
  11894. },
  11895. set: function (value) {
  11896. if (this._isVertical === value) {
  11897. return;
  11898. }
  11899. this._isVertical = value;
  11900. this._markAsDirty();
  11901. },
  11902. enumerable: false,
  11903. configurable: true
  11904. });
  11905. Object.defineProperty(StackPanel.prototype, "width", {
  11906. get: function () {
  11907. return this._width.toString(this._host);
  11908. },
  11909. /**
  11910. * Gets or sets panel width.
  11911. * This value should not be set when in horizontal mode as it will be computed automatically
  11912. */
  11913. set: function (value) {
  11914. if (!this._doNotTrackManualChanges) {
  11915. this._manualWidth = true;
  11916. }
  11917. if (this._width.toString(this._host) === value) {
  11918. return;
  11919. }
  11920. if (this._width.fromString(value)) {
  11921. this._markAsDirty();
  11922. }
  11923. },
  11924. enumerable: false,
  11925. configurable: true
  11926. });
  11927. Object.defineProperty(StackPanel.prototype, "height", {
  11928. get: function () {
  11929. return this._height.toString(this._host);
  11930. },
  11931. /**
  11932. * Gets or sets panel height.
  11933. * This value should not be set when in vertical mode as it will be computed automatically
  11934. */
  11935. set: function (value) {
  11936. if (!this._doNotTrackManualChanges) {
  11937. this._manualHeight = true;
  11938. }
  11939. if (this._height.toString(this._host) === value) {
  11940. return;
  11941. }
  11942. if (this._height.fromString(value)) {
  11943. this._markAsDirty();
  11944. }
  11945. },
  11946. enumerable: false,
  11947. configurable: true
  11948. });
  11949. StackPanel.prototype._getTypeName = function () {
  11950. return "StackPanel";
  11951. };
  11952. /** @hidden */
  11953. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11954. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11955. var child = _a[_i];
  11956. if (this._isVertical) {
  11957. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11958. }
  11959. else {
  11960. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11961. }
  11962. }
  11963. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11964. };
  11965. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11966. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11967. this._measureForChildren.copyFrom(parentMeasure);
  11968. this._measureForChildren.left = this._currentMeasure.left;
  11969. this._measureForChildren.top = this._currentMeasure.top;
  11970. if (!this.isVertical || this._manualWidth) {
  11971. this._measureForChildren.width = this._currentMeasure.width;
  11972. }
  11973. if (this.isVertical || this._manualHeight) {
  11974. this._measureForChildren.height = this._currentMeasure.height;
  11975. }
  11976. };
  11977. StackPanel.prototype._postMeasure = function () {
  11978. var stackWidth = 0;
  11979. var stackHeight = 0;
  11980. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11981. var child = _a[_i];
  11982. if (!child.isVisible || child.notRenderable) {
  11983. continue;
  11984. }
  11985. if (this._isVertical) {
  11986. if (child.top !== stackHeight + "px") {
  11987. child.top = stackHeight + "px";
  11988. this._rebuildLayout = true;
  11989. child._top.ignoreAdaptiveScaling = true;
  11990. }
  11991. if (child._height.isPercentage && !child._automaticSize) {
  11992. if (!this.ignoreLayoutWarnings) {
  11993. 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");
  11994. }
  11995. }
  11996. else {
  11997. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11998. }
  11999. }
  12000. else {
  12001. if (child.left !== stackWidth + "px") {
  12002. child.left = stackWidth + "px";
  12003. this._rebuildLayout = true;
  12004. child._left.ignoreAdaptiveScaling = true;
  12005. }
  12006. if (child._width.isPercentage && !child._automaticSize) {
  12007. if (!this.ignoreLayoutWarnings) {
  12008. 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");
  12009. }
  12010. }
  12011. else {
  12012. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  12013. }
  12014. }
  12015. }
  12016. stackWidth += this.paddingLeftInPixels + this.paddingRightInPixels;
  12017. stackHeight += this.paddingTopInPixels + this.paddingBottomInPixels;
  12018. this._doNotTrackManualChanges = true;
  12019. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  12020. // User can now define their own height and width for stack panel.
  12021. var panelWidthChanged = false;
  12022. var panelHeightChanged = false;
  12023. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  12024. var previousHeight = this.height;
  12025. this.height = stackHeight + "px";
  12026. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  12027. }
  12028. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  12029. var previousWidth = this.width;
  12030. this.width = stackWidth + "px";
  12031. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  12032. }
  12033. if (panelHeightChanged) {
  12034. this._height.ignoreAdaptiveScaling = true;
  12035. }
  12036. if (panelWidthChanged) {
  12037. this._width.ignoreAdaptiveScaling = true;
  12038. }
  12039. this._doNotTrackManualChanges = false;
  12040. if (panelWidthChanged || panelHeightChanged) {
  12041. this._rebuildLayout = true;
  12042. }
  12043. _super.prototype._postMeasure.call(this);
  12044. };
  12045. return StackPanel;
  12046. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  12047. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  12048. /***/ }),
  12049. /***/ "./2D/controls/statics.ts":
  12050. /*!********************************!*\
  12051. !*** ./2D/controls/statics.ts ***!
  12052. \********************************/
  12053. /*! exports provided: name */
  12054. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12055. "use strict";
  12056. __webpack_require__.r(__webpack_exports__);
  12057. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  12058. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12059. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12060. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  12061. /**
  12062. * Forcing an export so that this code will execute
  12063. * @hidden
  12064. */
  12065. var name = "Statics";
  12066. /**
  12067. * Creates a stack panel that can be used to render headers
  12068. * @param control defines the control to associate with the header
  12069. * @param text defines the text of the header
  12070. * @param size defines the size of the header
  12071. * @param options defines options used to configure the header
  12072. * @returns a new StackPanel
  12073. */
  12074. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  12075. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  12076. var isHorizontal = options ? options.isHorizontal : true;
  12077. var controlFirst = options ? options.controlFirst : true;
  12078. panel.isVertical = !isHorizontal;
  12079. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  12080. header.text = text;
  12081. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  12082. if (isHorizontal) {
  12083. header.width = size;
  12084. }
  12085. else {
  12086. header.height = size;
  12087. }
  12088. if (controlFirst) {
  12089. panel.addControl(control);
  12090. panel.addControl(header);
  12091. header.paddingLeft = "5px";
  12092. }
  12093. else {
  12094. panel.addControl(header);
  12095. panel.addControl(control);
  12096. header.paddingRight = "5px";
  12097. }
  12098. header.shadowBlur = control.shadowBlur;
  12099. header.shadowColor = control.shadowColor;
  12100. header.shadowOffsetX = control.shadowOffsetX;
  12101. header.shadowOffsetY = control.shadowOffsetY;
  12102. return panel;
  12103. };
  12104. /***/ }),
  12105. /***/ "./2D/controls/textBlock.ts":
  12106. /*!**********************************!*\
  12107. !*** ./2D/controls/textBlock.ts ***!
  12108. \**********************************/
  12109. /*! exports provided: TextWrapping, TextBlock */
  12110. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12111. "use strict";
  12112. __webpack_require__.r(__webpack_exports__);
  12113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  12114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  12115. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12116. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12117. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12118. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  12119. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  12120. /**
  12121. * Enum that determines the text-wrapping mode to use.
  12122. */
  12123. var TextWrapping;
  12124. (function (TextWrapping) {
  12125. /**
  12126. * Clip the text when it's larger than Control.width; this is the default mode.
  12127. */
  12128. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  12129. /**
  12130. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  12131. */
  12132. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  12133. /**
  12134. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  12135. */
  12136. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  12137. })(TextWrapping || (TextWrapping = {}));
  12138. /**
  12139. * Class used to create text block control
  12140. */
  12141. var TextBlock = /** @class */ (function (_super) {
  12142. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  12143. /**
  12144. * Creates a new TextBlock object
  12145. * @param name defines the name of the control
  12146. * @param text defines the text to display (emptry string by default)
  12147. */
  12148. function TextBlock(
  12149. /**
  12150. * Defines the name of the control
  12151. */
  12152. name, text) {
  12153. if (text === void 0) { text = ""; }
  12154. var _this = _super.call(this, name) || this;
  12155. _this.name = name;
  12156. _this._text = "";
  12157. _this._textWrapping = TextWrapping.Clip;
  12158. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  12159. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  12160. _this._resizeToFit = false;
  12161. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  12162. _this._outlineWidth = 0;
  12163. _this._outlineColor = "white";
  12164. _this._underline = false;
  12165. _this._lineThrough = false;
  12166. /**
  12167. * An event triggered after the text is changed
  12168. */
  12169. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12170. /**
  12171. * An event triggered after the text was broken up into lines
  12172. */
  12173. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12174. _this.text = text;
  12175. return _this;
  12176. }
  12177. Object.defineProperty(TextBlock.prototype, "lines", {
  12178. /**
  12179. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  12180. */
  12181. get: function () {
  12182. return this._lines;
  12183. },
  12184. enumerable: false,
  12185. configurable: true
  12186. });
  12187. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  12188. /**
  12189. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12190. */
  12191. get: function () {
  12192. return this._resizeToFit;
  12193. },
  12194. /**
  12195. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  12196. */
  12197. set: function (value) {
  12198. if (this._resizeToFit === value) {
  12199. return;
  12200. }
  12201. this._resizeToFit = value;
  12202. if (this._resizeToFit) {
  12203. this._width.ignoreAdaptiveScaling = true;
  12204. this._height.ignoreAdaptiveScaling = true;
  12205. }
  12206. this._markAsDirty();
  12207. },
  12208. enumerable: false,
  12209. configurable: true
  12210. });
  12211. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  12212. /**
  12213. * Gets or sets a boolean indicating if text must be wrapped
  12214. */
  12215. get: function () {
  12216. return this._textWrapping;
  12217. },
  12218. /**
  12219. * Gets or sets a boolean indicating if text must be wrapped
  12220. */
  12221. set: function (value) {
  12222. if (this._textWrapping === value) {
  12223. return;
  12224. }
  12225. this._textWrapping = +value;
  12226. this._markAsDirty();
  12227. },
  12228. enumerable: false,
  12229. configurable: true
  12230. });
  12231. Object.defineProperty(TextBlock.prototype, "text", {
  12232. /**
  12233. * Gets or sets text to display
  12234. */
  12235. get: function () {
  12236. return this._text;
  12237. },
  12238. /**
  12239. * Gets or sets text to display
  12240. */
  12241. set: function (value) {
  12242. if (this._text === value) {
  12243. return;
  12244. }
  12245. this._text = value;
  12246. this._markAsDirty();
  12247. this.onTextChangedObservable.notifyObservers(this);
  12248. },
  12249. enumerable: false,
  12250. configurable: true
  12251. });
  12252. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  12253. /**
  12254. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12255. */
  12256. get: function () {
  12257. return this._textHorizontalAlignment;
  12258. },
  12259. /**
  12260. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  12261. */
  12262. set: function (value) {
  12263. if (this._textHorizontalAlignment === value) {
  12264. return;
  12265. }
  12266. this._textHorizontalAlignment = value;
  12267. this._markAsDirty();
  12268. },
  12269. enumerable: false,
  12270. configurable: true
  12271. });
  12272. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  12273. /**
  12274. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12275. */
  12276. get: function () {
  12277. return this._textVerticalAlignment;
  12278. },
  12279. /**
  12280. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  12281. */
  12282. set: function (value) {
  12283. if (this._textVerticalAlignment === value) {
  12284. return;
  12285. }
  12286. this._textVerticalAlignment = value;
  12287. this._markAsDirty();
  12288. },
  12289. enumerable: false,
  12290. configurable: true
  12291. });
  12292. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  12293. /**
  12294. * Gets or sets line spacing value
  12295. */
  12296. get: function () {
  12297. return this._lineSpacing.toString(this._host);
  12298. },
  12299. /**
  12300. * Gets or sets line spacing value
  12301. */
  12302. set: function (value) {
  12303. if (this._lineSpacing.fromString(value)) {
  12304. this._markAsDirty();
  12305. }
  12306. },
  12307. enumerable: false,
  12308. configurable: true
  12309. });
  12310. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  12311. /**
  12312. * Gets or sets outlineWidth of the text to display
  12313. */
  12314. get: function () {
  12315. return this._outlineWidth;
  12316. },
  12317. /**
  12318. * Gets or sets outlineWidth of the text to display
  12319. */
  12320. set: function (value) {
  12321. if (this._outlineWidth === value) {
  12322. return;
  12323. }
  12324. this._outlineWidth = value;
  12325. this._markAsDirty();
  12326. },
  12327. enumerable: false,
  12328. configurable: true
  12329. });
  12330. Object.defineProperty(TextBlock.prototype, "underline", {
  12331. /**
  12332. * Gets or sets a boolean indicating that text must have underline
  12333. */
  12334. get: function () {
  12335. return this._underline;
  12336. },
  12337. /**
  12338. * Gets or sets a boolean indicating that text must have underline
  12339. */
  12340. set: function (value) {
  12341. if (this._underline === value) {
  12342. return;
  12343. }
  12344. this._underline = value;
  12345. this._markAsDirty();
  12346. },
  12347. enumerable: false,
  12348. configurable: true
  12349. });
  12350. Object.defineProperty(TextBlock.prototype, "lineThrough", {
  12351. /**
  12352. * Gets or sets an boolean indicating that text must be crossed out
  12353. */
  12354. get: function () {
  12355. return this._lineThrough;
  12356. },
  12357. /**
  12358. * Gets or sets an boolean indicating that text must be crossed out
  12359. */
  12360. set: function (value) {
  12361. if (this._lineThrough === value) {
  12362. return;
  12363. }
  12364. this._lineThrough = value;
  12365. this._markAsDirty();
  12366. },
  12367. enumerable: false,
  12368. configurable: true
  12369. });
  12370. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  12371. /**
  12372. * Gets or sets outlineColor of the text to display
  12373. */
  12374. get: function () {
  12375. return this._outlineColor;
  12376. },
  12377. /**
  12378. * Gets or sets outlineColor of the text to display
  12379. */
  12380. set: function (value) {
  12381. if (this._outlineColor === value) {
  12382. return;
  12383. }
  12384. this._outlineColor = value;
  12385. this._markAsDirty();
  12386. },
  12387. enumerable: false,
  12388. configurable: true
  12389. });
  12390. TextBlock.prototype._getTypeName = function () {
  12391. return "TextBlock";
  12392. };
  12393. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  12394. if (!this._fontOffset) {
  12395. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  12396. }
  12397. _super.prototype._processMeasures.call(this, parentMeasure, context);
  12398. // Prepare lines
  12399. this._lines = this._breakLines(this._currentMeasure.width, context);
  12400. this.onLinesReadyObservable.notifyObservers(this);
  12401. var maxLineWidth = 0;
  12402. for (var i = 0; i < this._lines.length; i++) {
  12403. var line = this._lines[i];
  12404. if (line.width > maxLineWidth) {
  12405. maxLineWidth = line.width;
  12406. }
  12407. }
  12408. if (this._resizeToFit) {
  12409. if (this._textWrapping === TextWrapping.Clip) {
  12410. var newWidth = (this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth) | 0;
  12411. if (newWidth !== this._width.internalValue) {
  12412. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12413. this._rebuildLayout = true;
  12414. }
  12415. }
  12416. var newHeight = (this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length) | 0;
  12417. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12418. var lineSpacing = 0;
  12419. if (this._lineSpacing.isPixel) {
  12420. lineSpacing = this._lineSpacing.getValue(this._host);
  12421. }
  12422. else {
  12423. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12424. }
  12425. newHeight += (this._lines.length - 1) * lineSpacing;
  12426. }
  12427. if (newHeight !== this._height.internalValue) {
  12428. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  12429. this._rebuildLayout = true;
  12430. }
  12431. }
  12432. };
  12433. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  12434. var width = this._currentMeasure.width;
  12435. var x = 0;
  12436. switch (this._textHorizontalAlignment) {
  12437. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  12438. x = 0;
  12439. break;
  12440. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  12441. x = width - textWidth;
  12442. break;
  12443. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  12444. x = (width - textWidth) / 2;
  12445. break;
  12446. }
  12447. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  12448. context.shadowColor = this.shadowColor;
  12449. context.shadowBlur = this.shadowBlur;
  12450. context.shadowOffsetX = this.shadowOffsetX;
  12451. context.shadowOffsetY = this.shadowOffsetY;
  12452. }
  12453. if (this.outlineWidth) {
  12454. context.strokeText(text, this._currentMeasure.left + x, y);
  12455. }
  12456. context.fillText(text, this._currentMeasure.left + x, y);
  12457. if (this._underline) {
  12458. context.beginPath();
  12459. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  12460. context.moveTo(this._currentMeasure.left + x, y + 3);
  12461. context.lineTo(this._currentMeasure.left + x + textWidth, y + 3);
  12462. context.stroke();
  12463. context.closePath();
  12464. }
  12465. if (this._lineThrough) {
  12466. context.beginPath();
  12467. context.lineWidth = Math.round(this.fontSizeInPixels * 0.05);
  12468. context.moveTo(this._currentMeasure.left + x, y - this.fontSizeInPixels / 3);
  12469. context.lineTo(this._currentMeasure.left + x + textWidth, y - this.fontSizeInPixels / 3);
  12470. context.stroke();
  12471. context.closePath();
  12472. }
  12473. };
  12474. /** @hidden */
  12475. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  12476. context.save();
  12477. this._applyStates(context);
  12478. // Render lines
  12479. this._renderLines(context);
  12480. context.restore();
  12481. };
  12482. TextBlock.prototype._applyStates = function (context) {
  12483. _super.prototype._applyStates.call(this, context);
  12484. if (this.outlineWidth) {
  12485. context.lineWidth = this.outlineWidth;
  12486. context.strokeStyle = this.outlineColor;
  12487. context.lineJoin = 'miter';
  12488. context.miterLimit = 2;
  12489. }
  12490. };
  12491. TextBlock.prototype._breakLines = function (refWidth, context) {
  12492. var lines = [];
  12493. var _lines = this.text.split("\n");
  12494. if (this._textWrapping === TextWrapping.Ellipsis) {
  12495. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  12496. var _line = _lines_1[_i];
  12497. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  12498. }
  12499. }
  12500. else if (this._textWrapping === TextWrapping.WordWrap) {
  12501. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  12502. var _line = _lines_2[_a];
  12503. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  12504. }
  12505. }
  12506. else {
  12507. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  12508. var _line = _lines_3[_b];
  12509. lines.push(this._parseLine(_line, context));
  12510. }
  12511. }
  12512. return lines;
  12513. };
  12514. TextBlock.prototype._parseLine = function (line, context) {
  12515. if (line === void 0) { line = ""; }
  12516. return { text: line, width: context.measureText(line).width };
  12517. };
  12518. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  12519. if (line === void 0) { line = ""; }
  12520. var lineWidth = context.measureText(line).width;
  12521. if (lineWidth > width) {
  12522. line += "…";
  12523. }
  12524. // unicode support. split('') does not work with unicode!
  12525. // make sure Array.from is available
  12526. var characters = Array.from && Array.from(line);
  12527. if (!characters) {
  12528. // no array.from, use the old method
  12529. while (line.length > 2 && lineWidth > width) {
  12530. line = line.slice(0, -2) + "…";
  12531. lineWidth = context.measureText(line).width;
  12532. }
  12533. }
  12534. else {
  12535. while (characters.length && lineWidth > width) {
  12536. characters.pop();
  12537. line = characters.join("") + "...";
  12538. lineWidth = context.measureText(line).width;
  12539. }
  12540. }
  12541. return { text: line, width: lineWidth };
  12542. };
  12543. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  12544. if (line === void 0) { line = ""; }
  12545. var lines = [];
  12546. var words = this.wordSplittingFunction ? this.wordSplittingFunction(line) : line.split(" ");
  12547. var lineWidth = 0;
  12548. for (var n = 0; n < words.length; n++) {
  12549. var testLine = n > 0 ? line + " " + words[n] : words[0];
  12550. var metrics = context.measureText(testLine);
  12551. var testWidth = metrics.width;
  12552. if (testWidth > width && n > 0) {
  12553. lines.push({ text: line, width: lineWidth });
  12554. line = words[n];
  12555. lineWidth = context.measureText(line).width;
  12556. }
  12557. else {
  12558. lineWidth = testWidth;
  12559. line = testLine;
  12560. }
  12561. }
  12562. lines.push({ text: line, width: lineWidth });
  12563. return lines;
  12564. };
  12565. TextBlock.prototype._renderLines = function (context) {
  12566. var height = this._currentMeasure.height;
  12567. var rootY = 0;
  12568. switch (this._textVerticalAlignment) {
  12569. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  12570. rootY = this._fontOffset.ascent;
  12571. break;
  12572. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  12573. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  12574. break;
  12575. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  12576. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  12577. break;
  12578. }
  12579. rootY += this._currentMeasure.top;
  12580. for (var i = 0; i < this._lines.length; i++) {
  12581. var line = this._lines[i];
  12582. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  12583. if (this._lineSpacing.isPixel) {
  12584. rootY += this._lineSpacing.getValue(this._host);
  12585. }
  12586. else {
  12587. rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12588. }
  12589. }
  12590. this._drawText(line.text, line.width, rootY, context);
  12591. rootY += this._fontOffset.height;
  12592. }
  12593. };
  12594. /**
  12595. * Given a width constraint applied on the text block, find the expected height
  12596. * @returns expected height
  12597. */
  12598. TextBlock.prototype.computeExpectedHeight = function () {
  12599. if (this.text && this.widthInPixels) {
  12600. var context_1 = document.createElement("canvas").getContext("2d");
  12601. if (context_1) {
  12602. this._applyStates(context_1);
  12603. if (!this._fontOffset) {
  12604. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  12605. }
  12606. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  12607. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  12608. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  12609. var lineSpacing = 0;
  12610. if (this._lineSpacing.isPixel) {
  12611. lineSpacing = this._lineSpacing.getValue(this._host);
  12612. }
  12613. else {
  12614. lineSpacing = this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  12615. }
  12616. newHeight += (lines.length - 1) * lineSpacing;
  12617. }
  12618. return newHeight;
  12619. }
  12620. }
  12621. return 0;
  12622. };
  12623. TextBlock.prototype.dispose = function () {
  12624. _super.prototype.dispose.call(this);
  12625. this.onTextChangedObservable.clear();
  12626. };
  12627. return TextBlock;
  12628. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  12629. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  12630. /***/ }),
  12631. /***/ "./2D/controls/virtualKeyboard.ts":
  12632. /*!****************************************!*\
  12633. !*** ./2D/controls/virtualKeyboard.ts ***!
  12634. \****************************************/
  12635. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  12636. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12637. "use strict";
  12638. __webpack_require__.r(__webpack_exports__);
  12639. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  12640. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  12641. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12642. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  12643. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  12644. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  12645. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  12646. /**
  12647. * Class used to store key control properties
  12648. */
  12649. var KeyPropertySet = /** @class */ (function () {
  12650. function KeyPropertySet() {
  12651. }
  12652. return KeyPropertySet;
  12653. }());
  12654. /**
  12655. * Class used to create virtual keyboard
  12656. */
  12657. var VirtualKeyboard = /** @class */ (function (_super) {
  12658. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  12659. function VirtualKeyboard() {
  12660. var _this = _super !== null && _super.apply(this, arguments) || this;
  12661. /** Observable raised when a key is pressed */
  12662. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  12663. /** Gets or sets default key button width */
  12664. _this.defaultButtonWidth = "40px";
  12665. /** Gets or sets default key button height */
  12666. _this.defaultButtonHeight = "40px";
  12667. /** Gets or sets default key button left padding */
  12668. _this.defaultButtonPaddingLeft = "2px";
  12669. /** Gets or sets default key button right padding */
  12670. _this.defaultButtonPaddingRight = "2px";
  12671. /** Gets or sets default key button top padding */
  12672. _this.defaultButtonPaddingTop = "2px";
  12673. /** Gets or sets default key button bottom padding */
  12674. _this.defaultButtonPaddingBottom = "2px";
  12675. /** Gets or sets default key button foreground color */
  12676. _this.defaultButtonColor = "#DDD";
  12677. /** Gets or sets default key button background color */
  12678. _this.defaultButtonBackground = "#070707";
  12679. /** Gets or sets shift button foreground color */
  12680. _this.shiftButtonColor = "#7799FF";
  12681. /** Gets or sets shift button thickness*/
  12682. _this.selectedShiftThickness = 1;
  12683. /** Gets shift key state */
  12684. _this.shiftState = 0;
  12685. _this._currentlyConnectedInputText = null;
  12686. _this._connectedInputTexts = [];
  12687. _this._onKeyPressObserver = null;
  12688. return _this;
  12689. }
  12690. VirtualKeyboard.prototype._getTypeName = function () {
  12691. return "VirtualKeyboard";
  12692. };
  12693. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  12694. var _this = this;
  12695. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  12696. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  12697. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  12698. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  12699. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  12700. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  12701. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  12702. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  12703. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  12704. button.thickness = 0;
  12705. button.isFocusInvisible = true;
  12706. button.shadowColor = this.shadowColor;
  12707. button.shadowBlur = this.shadowBlur;
  12708. button.shadowOffsetX = this.shadowOffsetX;
  12709. button.shadowOffsetY = this.shadowOffsetY;
  12710. button.onPointerUpObservable.add(function () {
  12711. _this.onKeyPressObservable.notifyObservers(key);
  12712. });
  12713. return button;
  12714. };
  12715. /**
  12716. * Adds a new row of keys
  12717. * @param keys defines the list of keys to add
  12718. * @param propertySets defines the associated property sets
  12719. */
  12720. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  12721. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  12722. panel.isVertical = false;
  12723. panel.isFocusInvisible = true;
  12724. var maxKey = null;
  12725. for (var i = 0; i < keys.length; i++) {
  12726. var properties = null;
  12727. if (propertySets && propertySets.length === keys.length) {
  12728. properties = propertySets[i];
  12729. }
  12730. var key = this._createKey(keys[i], properties);
  12731. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  12732. maxKey = key;
  12733. }
  12734. panel.addControl(key);
  12735. }
  12736. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  12737. this.addControl(panel);
  12738. };
  12739. /**
  12740. * Set the shift key to a specific state
  12741. * @param shiftState defines the new shift state
  12742. */
  12743. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  12744. if (!this.children) {
  12745. return;
  12746. }
  12747. for (var i = 0; i < this.children.length; i++) {
  12748. var row = this.children[i];
  12749. if (!row || !row.children) {
  12750. continue;
  12751. }
  12752. var rowContainer = row;
  12753. for (var j = 0; j < rowContainer.children.length; j++) {
  12754. var button = rowContainer.children[j];
  12755. if (!button || !button.children[0]) {
  12756. continue;
  12757. }
  12758. var button_tblock = button.children[0];
  12759. if (button_tblock.text === "\u21E7") {
  12760. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  12761. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  12762. }
  12763. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  12764. }
  12765. }
  12766. };
  12767. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  12768. /** Gets the input text control currently attached to the keyboard */
  12769. get: function () {
  12770. return this._currentlyConnectedInputText;
  12771. },
  12772. enumerable: false,
  12773. configurable: true
  12774. });
  12775. /**
  12776. * Connects the keyboard with an input text control
  12777. *
  12778. * @param input defines the target control
  12779. */
  12780. VirtualKeyboard.prototype.connect = function (input) {
  12781. var _this = this;
  12782. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  12783. if (inputTextAlreadyConnected) {
  12784. return;
  12785. }
  12786. if (this._onKeyPressObserver === null) {
  12787. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  12788. if (!_this._currentlyConnectedInputText) {
  12789. return;
  12790. }
  12791. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  12792. switch (key) {
  12793. case "\u21E7":
  12794. _this.shiftState++;
  12795. if (_this.shiftState > 2) {
  12796. _this.shiftState = 0;
  12797. }
  12798. _this.applyShiftState(_this.shiftState);
  12799. return;
  12800. case "\u2190":
  12801. _this._currentlyConnectedInputText.processKey(8);
  12802. return;
  12803. case "\u21B5":
  12804. _this._currentlyConnectedInputText.processKey(13);
  12805. return;
  12806. }
  12807. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12808. if (_this.shiftState === 1) {
  12809. _this.shiftState = 0;
  12810. _this.applyShiftState(_this.shiftState);
  12811. }
  12812. });
  12813. }
  12814. this.isVisible = false;
  12815. this._currentlyConnectedInputText = input;
  12816. input._connectedVirtualKeyboard = this;
  12817. // Events hooking
  12818. var onFocusObserver = input.onFocusObservable.add(function () {
  12819. _this._currentlyConnectedInputText = input;
  12820. input._connectedVirtualKeyboard = _this;
  12821. _this.isVisible = true;
  12822. });
  12823. var onBlurObserver = input.onBlurObservable.add(function () {
  12824. input._connectedVirtualKeyboard = null;
  12825. _this._currentlyConnectedInputText = null;
  12826. _this.isVisible = false;
  12827. });
  12828. this._connectedInputTexts.push({
  12829. input: input,
  12830. onBlurObserver: onBlurObserver,
  12831. onFocusObserver: onFocusObserver
  12832. });
  12833. };
  12834. /**
  12835. * Disconnects the keyboard from connected InputText controls
  12836. *
  12837. * @param input optionally defines a target control, otherwise all are disconnected
  12838. */
  12839. VirtualKeyboard.prototype.disconnect = function (input) {
  12840. var _this = this;
  12841. if (input) {
  12842. // .find not available on IE
  12843. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12844. if (filtered.length === 1) {
  12845. this._removeConnectedInputObservables(filtered[0]);
  12846. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12847. if (this._currentlyConnectedInputText === input) {
  12848. this._currentlyConnectedInputText = null;
  12849. }
  12850. }
  12851. }
  12852. else {
  12853. this._connectedInputTexts.forEach(function (connectedInputText) {
  12854. _this._removeConnectedInputObservables(connectedInputText);
  12855. });
  12856. this._connectedInputTexts = [];
  12857. }
  12858. if (this._connectedInputTexts.length === 0) {
  12859. this._currentlyConnectedInputText = null;
  12860. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12861. this._onKeyPressObserver = null;
  12862. }
  12863. };
  12864. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12865. connectedInputText.input._connectedVirtualKeyboard = null;
  12866. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12867. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12868. };
  12869. /**
  12870. * Release all resources
  12871. */
  12872. VirtualKeyboard.prototype.dispose = function () {
  12873. _super.prototype.dispose.call(this);
  12874. this.disconnect();
  12875. };
  12876. // Statics
  12877. /**
  12878. * Creates a new keyboard using a default layout
  12879. *
  12880. * @param name defines control name
  12881. * @returns a new VirtualKeyboard
  12882. */
  12883. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12884. var returnValue = new VirtualKeyboard(name);
  12885. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12886. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12887. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12888. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12889. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12890. return returnValue;
  12891. };
  12892. return VirtualKeyboard;
  12893. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12894. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12895. /***/ }),
  12896. /***/ "./2D/index.ts":
  12897. /*!*********************!*\
  12898. !*** ./2D/index.ts ***!
  12899. \*********************/
  12900. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader */
  12901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12902. "use strict";
  12903. __webpack_require__.r(__webpack_exports__);
  12904. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12920. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12922. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12924. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12925. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12926. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12927. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12928. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12929. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12930. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12931. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12932. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12933. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12934. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12935. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12936. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12937. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12938. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12939. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12940. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12941. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12942. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12944. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12946. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12948. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12950. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12951. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12952. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12953. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12954. /***/ }),
  12955. /***/ "./2D/math2D.ts":
  12956. /*!**********************!*\
  12957. !*** ./2D/math2D.ts ***!
  12958. \**********************/
  12959. /*! exports provided: Vector2WithInfo, Matrix2D */
  12960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12961. "use strict";
  12962. __webpack_require__.r(__webpack_exports__);
  12963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12965. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12966. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  12967. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  12968. /**
  12969. * Class used to transport Vector2 information for pointer events
  12970. */
  12971. var Vector2WithInfo = /** @class */ (function (_super) {
  12972. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12973. /**
  12974. * Creates a new Vector2WithInfo
  12975. * @param source defines the vector2 data to transport
  12976. * @param buttonIndex defines the current mouse button index
  12977. */
  12978. function Vector2WithInfo(source,
  12979. /** defines the current mouse button index */
  12980. buttonIndex) {
  12981. if (buttonIndex === void 0) { buttonIndex = 0; }
  12982. var _this = _super.call(this, source.x, source.y) || this;
  12983. _this.buttonIndex = buttonIndex;
  12984. return _this;
  12985. }
  12986. return Vector2WithInfo;
  12987. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12988. /** Class used to provide 2D matrix features */
  12989. var Matrix2D = /** @class */ (function () {
  12990. /**
  12991. * Creates a new matrix
  12992. * @param m00 defines value for (0, 0)
  12993. * @param m01 defines value for (0, 1)
  12994. * @param m10 defines value for (1, 0)
  12995. * @param m11 defines value for (1, 1)
  12996. * @param m20 defines value for (2, 0)
  12997. * @param m21 defines value for (2, 1)
  12998. */
  12999. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  13000. /** Gets the internal array of 6 floats used to store matrix data */
  13001. this.m = new Float32Array(6);
  13002. this.fromValues(m00, m01, m10, m11, m20, m21);
  13003. }
  13004. /**
  13005. * Fills the matrix from direct values
  13006. * @param m00 defines value for (0, 0)
  13007. * @param m01 defines value for (0, 1)
  13008. * @param m10 defines value for (1, 0)
  13009. * @param m11 defines value for (1, 1)
  13010. * @param m20 defines value for (2, 0)
  13011. * @param m21 defines value for (2, 1)
  13012. * @returns the current modified matrix
  13013. */
  13014. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  13015. this.m[0] = m00;
  13016. this.m[1] = m01;
  13017. this.m[2] = m10;
  13018. this.m[3] = m11;
  13019. this.m[4] = m20;
  13020. this.m[5] = m21;
  13021. return this;
  13022. };
  13023. /**
  13024. * Gets matrix determinant
  13025. * @returns the determinant
  13026. */
  13027. Matrix2D.prototype.determinant = function () {
  13028. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  13029. };
  13030. /**
  13031. * Inverses the matrix and stores it in a target matrix
  13032. * @param result defines the target matrix
  13033. * @returns the current matrix
  13034. */
  13035. Matrix2D.prototype.invertToRef = function (result) {
  13036. var l0 = this.m[0];
  13037. var l1 = this.m[1];
  13038. var l2 = this.m[2];
  13039. var l3 = this.m[3];
  13040. var l4 = this.m[4];
  13041. var l5 = this.m[5];
  13042. var det = this.determinant();
  13043. if (det < (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  13044. result.m[0] = 0;
  13045. result.m[1] = 0;
  13046. result.m[2] = 0;
  13047. result.m[3] = 0;
  13048. result.m[4] = 0;
  13049. result.m[5] = 0;
  13050. return this;
  13051. }
  13052. var detDiv = 1 / det;
  13053. var det4 = l2 * l5 - l3 * l4;
  13054. var det5 = l1 * l4 - l0 * l5;
  13055. result.m[0] = l3 * detDiv;
  13056. result.m[1] = -l1 * detDiv;
  13057. result.m[2] = -l2 * detDiv;
  13058. result.m[3] = l0 * detDiv;
  13059. result.m[4] = det4 * detDiv;
  13060. result.m[5] = det5 * detDiv;
  13061. return this;
  13062. };
  13063. /**
  13064. * Multiplies the current matrix with another one
  13065. * @param other defines the second operand
  13066. * @param result defines the target matrix
  13067. * @returns the current matrix
  13068. */
  13069. Matrix2D.prototype.multiplyToRef = function (other, result) {
  13070. var l0 = this.m[0];
  13071. var l1 = this.m[1];
  13072. var l2 = this.m[2];
  13073. var l3 = this.m[3];
  13074. var l4 = this.m[4];
  13075. var l5 = this.m[5];
  13076. var r0 = other.m[0];
  13077. var r1 = other.m[1];
  13078. var r2 = other.m[2];
  13079. var r3 = other.m[3];
  13080. var r4 = other.m[4];
  13081. var r5 = other.m[5];
  13082. result.m[0] = l0 * r0 + l1 * r2;
  13083. result.m[1] = l0 * r1 + l1 * r3;
  13084. result.m[2] = l2 * r0 + l3 * r2;
  13085. result.m[3] = l2 * r1 + l3 * r3;
  13086. result.m[4] = l4 * r0 + l5 * r2 + r4;
  13087. result.m[5] = l4 * r1 + l5 * r3 + r5;
  13088. return this;
  13089. };
  13090. /**
  13091. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  13092. * @param x defines the x coordinate to transform
  13093. * @param y defines the x coordinate to transform
  13094. * @param result defines the target vector2
  13095. * @returns the current matrix
  13096. */
  13097. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  13098. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  13099. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  13100. return this;
  13101. };
  13102. // Statics
  13103. /**
  13104. * Creates an identity matrix
  13105. * @returns a new matrix
  13106. */
  13107. Matrix2D.Identity = function () {
  13108. return new Matrix2D(1, 0, 0, 1, 0, 0);
  13109. };
  13110. /**
  13111. * Creates a translation matrix and stores it in a target matrix
  13112. * @param x defines the x coordinate of the translation
  13113. * @param y defines the y coordinate of the translation
  13114. * @param result defines the target matrix
  13115. */
  13116. Matrix2D.TranslationToRef = function (x, y, result) {
  13117. result.fromValues(1, 0, 0, 1, x, y);
  13118. };
  13119. /**
  13120. * Creates a scaling matrix and stores it in a target matrix
  13121. * @param x defines the x coordinate of the scaling
  13122. * @param y defines the y coordinate of the scaling
  13123. * @param result defines the target matrix
  13124. */
  13125. Matrix2D.ScalingToRef = function (x, y, result) {
  13126. result.fromValues(x, 0, 0, y, 0, 0);
  13127. };
  13128. /**
  13129. * Creates a rotation matrix and stores it in a target matrix
  13130. * @param angle defines the rotation angle
  13131. * @param result defines the target matrix
  13132. */
  13133. Matrix2D.RotationToRef = function (angle, result) {
  13134. var s = Math.sin(angle);
  13135. var c = Math.cos(angle);
  13136. result.fromValues(c, s, -s, c, 0, 0);
  13137. };
  13138. /**
  13139. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  13140. * @param tx defines the x coordinate of the translation
  13141. * @param ty defines the y coordinate of the translation
  13142. * @param angle defines the rotation angle
  13143. * @param scaleX defines the x coordinate of the scaling
  13144. * @param scaleY defines the y coordinate of the scaling
  13145. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  13146. * @param result defines the target matrix
  13147. */
  13148. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  13149. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  13150. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  13151. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  13152. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  13153. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  13154. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  13155. if (parentMatrix) {
  13156. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  13157. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  13158. }
  13159. else {
  13160. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  13161. }
  13162. };
  13163. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  13164. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  13165. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  13166. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  13167. Matrix2D._TempCompose0 = Matrix2D.Identity();
  13168. Matrix2D._TempCompose1 = Matrix2D.Identity();
  13169. Matrix2D._TempCompose2 = Matrix2D.Identity();
  13170. return Matrix2D;
  13171. }());
  13172. /***/ }),
  13173. /***/ "./2D/measure.ts":
  13174. /*!***********************!*\
  13175. !*** ./2D/measure.ts ***!
  13176. \***********************/
  13177. /*! exports provided: Measure */
  13178. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13179. "use strict";
  13180. __webpack_require__.r(__webpack_exports__);
  13181. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  13182. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  13183. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13184. var tmpRect = [
  13185. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13186. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13187. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13188. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13189. ];
  13190. var tmpRect2 = [
  13191. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13192. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13193. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13194. new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0),
  13195. ];
  13196. var tmpV1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13197. var tmpV2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  13198. /**
  13199. * Class used to store 2D control sizes
  13200. */
  13201. var Measure = /** @class */ (function () {
  13202. /**
  13203. * Creates a new measure
  13204. * @param left defines left coordinate
  13205. * @param top defines top coordinate
  13206. * @param width defines width dimension
  13207. * @param height defines height dimension
  13208. */
  13209. function Measure(
  13210. /** defines left coordinate */
  13211. left,
  13212. /** defines top coordinate */
  13213. top,
  13214. /** defines width dimension */
  13215. width,
  13216. /** defines height dimension */
  13217. height) {
  13218. this.left = left;
  13219. this.top = top;
  13220. this.width = width;
  13221. this.height = height;
  13222. }
  13223. /**
  13224. * Copy from another measure
  13225. * @param other defines the other measure to copy from
  13226. */
  13227. Measure.prototype.copyFrom = function (other) {
  13228. this.left = other.left;
  13229. this.top = other.top;
  13230. this.width = other.width;
  13231. this.height = other.height;
  13232. };
  13233. /**
  13234. * Copy from a group of 4 floats
  13235. * @param left defines left coordinate
  13236. * @param top defines top coordinate
  13237. * @param width defines width dimension
  13238. * @param height defines height dimension
  13239. */
  13240. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  13241. this.left = left;
  13242. this.top = top;
  13243. this.width = width;
  13244. this.height = height;
  13245. };
  13246. /**
  13247. * Computes the axis aligned bounding box measure for two given measures
  13248. * @param a Input measure
  13249. * @param b Input measure
  13250. * @param result the resulting bounding measure
  13251. */
  13252. Measure.CombineToRef = function (a, b, result) {
  13253. var left = Math.min(a.left, b.left);
  13254. var top = Math.min(a.top, b.top);
  13255. var right = Math.max(a.left + a.width, b.left + b.width);
  13256. var bottom = Math.max(a.top + a.height, b.top + b.height);
  13257. result.left = left;
  13258. result.top = top;
  13259. result.width = right - left;
  13260. result.height = bottom - top;
  13261. };
  13262. /**
  13263. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13264. * @param transform the matrix to transform the measure before computing the AABB
  13265. * @param addX number to add to left
  13266. * @param addY number to add to top
  13267. * @param addWidth number to add to width
  13268. * @param addHeight number to add to height
  13269. * @param result the resulting AABB
  13270. */
  13271. Measure.prototype.addAndTransformToRef = function (transform, addX, addY, addWidth, addHeight, result) {
  13272. var left = this.left + addX;
  13273. var top = this.top + addY;
  13274. var width = this.width + addWidth;
  13275. var height = this.height + addHeight;
  13276. tmpRect[0].copyFromFloats(left, top);
  13277. tmpRect[1].copyFromFloats(left + width, top);
  13278. tmpRect[2].copyFromFloats(left + width, top + height);
  13279. tmpRect[3].copyFromFloats(left, top + height);
  13280. tmpV1.copyFromFloats(Number.MAX_VALUE, Number.MAX_VALUE);
  13281. tmpV2.copyFromFloats(0, 0);
  13282. for (var i = 0; i < 4; i++) {
  13283. transform.transformCoordinates(tmpRect[i].x, tmpRect[i].y, tmpRect2[i]);
  13284. tmpV1.x = Math.floor(Math.min(tmpV1.x, tmpRect2[i].x));
  13285. tmpV1.y = Math.floor(Math.min(tmpV1.y, tmpRect2[i].y));
  13286. tmpV2.x = Math.ceil(Math.max(tmpV2.x, tmpRect2[i].x));
  13287. tmpV2.y = Math.ceil(Math.max(tmpV2.y, tmpRect2[i].y));
  13288. }
  13289. result.left = tmpV1.x;
  13290. result.top = tmpV1.y;
  13291. result.width = tmpV2.x - tmpV1.x;
  13292. result.height = tmpV2.y - tmpV1.y;
  13293. };
  13294. /**
  13295. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  13296. * @param transform the matrix to transform the measure before computing the AABB
  13297. * @param result the resulting AABB
  13298. */
  13299. Measure.prototype.transformToRef = function (transform, result) {
  13300. this.addAndTransformToRef(transform, 0, 0, 0, 0, result);
  13301. };
  13302. /**
  13303. * Check equality between this measure and another one
  13304. * @param other defines the other measures
  13305. * @returns true if both measures are equals
  13306. */
  13307. Measure.prototype.isEqualsTo = function (other) {
  13308. if (this.left !== other.left) {
  13309. return false;
  13310. }
  13311. if (this.top !== other.top) {
  13312. return false;
  13313. }
  13314. if (this.width !== other.width) {
  13315. return false;
  13316. }
  13317. if (this.height !== other.height) {
  13318. return false;
  13319. }
  13320. return true;
  13321. };
  13322. /**
  13323. * Creates an empty measure
  13324. * @returns a new measure
  13325. */
  13326. Measure.Empty = function () {
  13327. return new Measure(0, 0, 0, 0);
  13328. };
  13329. return Measure;
  13330. }());
  13331. /***/ }),
  13332. /***/ "./2D/multiLinePoint.ts":
  13333. /*!******************************!*\
  13334. !*** ./2D/multiLinePoint.ts ***!
  13335. \******************************/
  13336. /*! exports provided: MultiLinePoint */
  13337. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13338. "use strict";
  13339. __webpack_require__.r(__webpack_exports__);
  13340. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  13341. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  13342. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__);
  13343. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13344. /**
  13345. * Class used to store a point for a MultiLine object.
  13346. * The point can be pure 2D coordinates, a mesh or a control
  13347. */
  13348. var MultiLinePoint = /** @class */ (function () {
  13349. /**
  13350. * Creates a new MultiLinePoint
  13351. * @param multiLine defines the source MultiLine object
  13352. */
  13353. function MultiLinePoint(multiLine) {
  13354. this._multiLine = multiLine;
  13355. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13356. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  13357. this._point = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  13358. }
  13359. Object.defineProperty(MultiLinePoint.prototype, "x", {
  13360. /** Gets or sets x coordinate */
  13361. get: function () {
  13362. return this._x.toString(this._multiLine._host);
  13363. },
  13364. set: function (value) {
  13365. if (this._x.toString(this._multiLine._host) === value) {
  13366. return;
  13367. }
  13368. if (this._x.fromString(value)) {
  13369. this._multiLine._markAsDirty();
  13370. }
  13371. },
  13372. enumerable: false,
  13373. configurable: true
  13374. });
  13375. Object.defineProperty(MultiLinePoint.prototype, "y", {
  13376. /** Gets or sets y coordinate */
  13377. get: function () {
  13378. return this._y.toString(this._multiLine._host);
  13379. },
  13380. set: function (value) {
  13381. if (this._y.toString(this._multiLine._host) === value) {
  13382. return;
  13383. }
  13384. if (this._y.fromString(value)) {
  13385. this._multiLine._markAsDirty();
  13386. }
  13387. },
  13388. enumerable: false,
  13389. configurable: true
  13390. });
  13391. Object.defineProperty(MultiLinePoint.prototype, "control", {
  13392. /** Gets or sets the control associated with this point */
  13393. get: function () {
  13394. return this._control;
  13395. },
  13396. set: function (value) {
  13397. if (this._control === value) {
  13398. return;
  13399. }
  13400. if (this._control && this._controlObserver) {
  13401. this._control.onDirtyObservable.remove(this._controlObserver);
  13402. this._controlObserver = null;
  13403. }
  13404. this._control = value;
  13405. if (this._control) {
  13406. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  13407. }
  13408. this._multiLine._markAsDirty();
  13409. },
  13410. enumerable: false,
  13411. configurable: true
  13412. });
  13413. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  13414. /** Gets or sets the mesh associated with this point */
  13415. get: function () {
  13416. return this._mesh;
  13417. },
  13418. set: function (value) {
  13419. if (this._mesh === value) {
  13420. return;
  13421. }
  13422. if (this._mesh && this._meshObserver) {
  13423. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  13424. }
  13425. this._mesh = value;
  13426. if (this._mesh) {
  13427. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  13428. }
  13429. this._multiLine._markAsDirty();
  13430. },
  13431. enumerable: false,
  13432. configurable: true
  13433. });
  13434. /** Resets links */
  13435. MultiLinePoint.prototype.resetLinks = function () {
  13436. this.control = null;
  13437. this.mesh = null;
  13438. };
  13439. /**
  13440. * Gets a translation vector with Z component
  13441. * @returns the translation vector
  13442. */
  13443. MultiLinePoint.prototype.translate = function () {
  13444. this._point = this._translatePoint();
  13445. return this._point;
  13446. };
  13447. MultiLinePoint.prototype._translatePoint = function () {
  13448. if (this._mesh != null) {
  13449. return this._multiLine._host.getProjectedPositionWithZ(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  13450. }
  13451. else if (this._control != null) {
  13452. 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"]);
  13453. }
  13454. else {
  13455. var host = this._multiLine._host;
  13456. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  13457. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  13458. return new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Vector3"](xValue, yValue, 1. - babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]);
  13459. }
  13460. };
  13461. /** Release associated resources */
  13462. MultiLinePoint.prototype.dispose = function () {
  13463. this.resetLinks();
  13464. };
  13465. return MultiLinePoint;
  13466. }());
  13467. /***/ }),
  13468. /***/ "./2D/style.ts":
  13469. /*!*********************!*\
  13470. !*** ./2D/style.ts ***!
  13471. \*********************/
  13472. /*! exports provided: Style */
  13473. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13474. "use strict";
  13475. __webpack_require__.r(__webpack_exports__);
  13476. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  13477. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  13478. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13479. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  13480. /**
  13481. * Define a style used by control to automatically setup properties based on a template.
  13482. * Only support font related properties so far
  13483. */
  13484. var Style = /** @class */ (function () {
  13485. /**
  13486. * Creates a new style object
  13487. * @param host defines the AdvancedDynamicTexture which hosts this style
  13488. */
  13489. function Style(host) {
  13490. this._fontFamily = "Arial";
  13491. this._fontStyle = "";
  13492. this._fontWeight = "";
  13493. /** @hidden */
  13494. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  13495. /**
  13496. * Observable raised when the style values are changed
  13497. */
  13498. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13499. this._host = host;
  13500. }
  13501. Object.defineProperty(Style.prototype, "fontSize", {
  13502. /**
  13503. * Gets or sets the font size
  13504. */
  13505. get: function () {
  13506. return this._fontSize.toString(this._host);
  13507. },
  13508. set: function (value) {
  13509. if (this._fontSize.toString(this._host) === value) {
  13510. return;
  13511. }
  13512. if (this._fontSize.fromString(value)) {
  13513. this.onChangedObservable.notifyObservers(this);
  13514. }
  13515. },
  13516. enumerable: false,
  13517. configurable: true
  13518. });
  13519. Object.defineProperty(Style.prototype, "fontFamily", {
  13520. /**
  13521. * Gets or sets the font family
  13522. */
  13523. get: function () {
  13524. return this._fontFamily;
  13525. },
  13526. set: function (value) {
  13527. if (this._fontFamily === value) {
  13528. return;
  13529. }
  13530. this._fontFamily = value;
  13531. this.onChangedObservable.notifyObservers(this);
  13532. },
  13533. enumerable: false,
  13534. configurable: true
  13535. });
  13536. Object.defineProperty(Style.prototype, "fontStyle", {
  13537. /**
  13538. * Gets or sets the font style
  13539. */
  13540. get: function () {
  13541. return this._fontStyle;
  13542. },
  13543. set: function (value) {
  13544. if (this._fontStyle === value) {
  13545. return;
  13546. }
  13547. this._fontStyle = value;
  13548. this.onChangedObservable.notifyObservers(this);
  13549. },
  13550. enumerable: false,
  13551. configurable: true
  13552. });
  13553. Object.defineProperty(Style.prototype, "fontWeight", {
  13554. /** Gets or sets font weight */
  13555. get: function () {
  13556. return this._fontWeight;
  13557. },
  13558. set: function (value) {
  13559. if (this._fontWeight === value) {
  13560. return;
  13561. }
  13562. this._fontWeight = value;
  13563. this.onChangedObservable.notifyObservers(this);
  13564. },
  13565. enumerable: false,
  13566. configurable: true
  13567. });
  13568. /** Dispose all associated resources */
  13569. Style.prototype.dispose = function () {
  13570. this.onChangedObservable.clear();
  13571. };
  13572. return Style;
  13573. }());
  13574. /***/ }),
  13575. /***/ "./2D/valueAndUnit.ts":
  13576. /*!****************************!*\
  13577. !*** ./2D/valueAndUnit.ts ***!
  13578. \****************************/
  13579. /*! exports provided: ValueAndUnit */
  13580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13581. "use strict";
  13582. __webpack_require__.r(__webpack_exports__);
  13583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  13584. /**
  13585. * Class used to specific a value and its associated unit
  13586. */
  13587. var ValueAndUnit = /** @class */ (function () {
  13588. /**
  13589. * Creates a new ValueAndUnit
  13590. * @param value defines the value to store
  13591. * @param unit defines the unit to store
  13592. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  13593. */
  13594. function ValueAndUnit(value,
  13595. /** defines the unit to store */
  13596. unit,
  13597. /** defines a boolean indicating if the value can be negative */
  13598. negativeValueAllowed) {
  13599. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13600. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  13601. this.unit = unit;
  13602. this.negativeValueAllowed = negativeValueAllowed;
  13603. this._value = 1;
  13604. /**
  13605. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  13606. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  13607. */
  13608. this.ignoreAdaptiveScaling = false;
  13609. this._value = value;
  13610. this._originalUnit = unit;
  13611. }
  13612. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  13613. /** Gets a boolean indicating if the value is a percentage */
  13614. get: function () {
  13615. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  13616. },
  13617. enumerable: false,
  13618. configurable: true
  13619. });
  13620. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  13621. /** Gets a boolean indicating if the value is store as pixel */
  13622. get: function () {
  13623. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  13624. },
  13625. enumerable: false,
  13626. configurable: true
  13627. });
  13628. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  13629. /** Gets direct internal value */
  13630. get: function () {
  13631. return this._value;
  13632. },
  13633. enumerable: false,
  13634. configurable: true
  13635. });
  13636. /**
  13637. * Gets value as pixel
  13638. * @param host defines the root host
  13639. * @param refValue defines the reference value for percentages
  13640. * @returns the value as pixel
  13641. */
  13642. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  13643. if (this.isPixel) {
  13644. return this.getValue(host);
  13645. }
  13646. return this.getValue(host) * refValue;
  13647. };
  13648. /**
  13649. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  13650. * @param value defines the value to store
  13651. * @param unit defines the unit to store
  13652. * @returns the current ValueAndUnit
  13653. */
  13654. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  13655. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  13656. this._value = value;
  13657. this.unit = unit;
  13658. return this;
  13659. };
  13660. /**
  13661. * Gets the value accordingly to its unit
  13662. * @param host defines the root host
  13663. * @returns the value
  13664. */
  13665. ValueAndUnit.prototype.getValue = function (host) {
  13666. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  13667. var width = 0;
  13668. var height = 0;
  13669. if (host.idealWidth) {
  13670. width = (this._value * host.getSize().width) / host.idealWidth;
  13671. }
  13672. if (host.idealHeight) {
  13673. height = (this._value * host.getSize().height) / host.idealHeight;
  13674. }
  13675. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  13676. return window.innerWidth < window.innerHeight ? width : height;
  13677. }
  13678. if (host.idealWidth) { // horizontal
  13679. return width;
  13680. }
  13681. if (host.idealHeight) { // vertical
  13682. return height;
  13683. }
  13684. }
  13685. return this._value;
  13686. };
  13687. /**
  13688. * Gets a string representation of the value
  13689. * @param host defines the root host
  13690. * @param decimals defines an optional number of decimals to display
  13691. * @returns a string
  13692. */
  13693. ValueAndUnit.prototype.toString = function (host, decimals) {
  13694. switch (this.unit) {
  13695. case ValueAndUnit.UNITMODE_PERCENTAGE:
  13696. var percentage = this.getValue(host) * 100;
  13697. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  13698. case ValueAndUnit.UNITMODE_PIXEL:
  13699. var pixels = this.getValue(host);
  13700. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  13701. }
  13702. return this.unit.toString();
  13703. };
  13704. /**
  13705. * Store a value parsed from a string
  13706. * @param source defines the source string
  13707. * @returns true if the value was successfully parsed
  13708. */
  13709. ValueAndUnit.prototype.fromString = function (source) {
  13710. var match = ValueAndUnit._Regex.exec(source.toString());
  13711. if (!match || match.length === 0) {
  13712. return false;
  13713. }
  13714. var sourceValue = parseFloat(match[1]);
  13715. var sourceUnit = this._originalUnit;
  13716. if (!this.negativeValueAllowed) {
  13717. if (sourceValue < 0) {
  13718. sourceValue = 0;
  13719. }
  13720. }
  13721. if (match.length === 4) {
  13722. switch (match[3]) {
  13723. case "px":
  13724. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  13725. break;
  13726. case "%":
  13727. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  13728. sourceValue /= 100.0;
  13729. break;
  13730. }
  13731. }
  13732. if (sourceValue === this._value && sourceUnit === this.unit) {
  13733. return false;
  13734. }
  13735. this._value = sourceValue;
  13736. this.unit = sourceUnit;
  13737. return true;
  13738. };
  13739. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  13740. /** UNITMODE_PERCENTAGE */
  13741. get: function () {
  13742. return ValueAndUnit._UNITMODE_PERCENTAGE;
  13743. },
  13744. enumerable: false,
  13745. configurable: true
  13746. });
  13747. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  13748. /** UNITMODE_PIXEL */
  13749. get: function () {
  13750. return ValueAndUnit._UNITMODE_PIXEL;
  13751. },
  13752. enumerable: false,
  13753. configurable: true
  13754. });
  13755. // Static
  13756. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  13757. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  13758. ValueAndUnit._UNITMODE_PIXEL = 1;
  13759. return ValueAndUnit;
  13760. }());
  13761. /***/ }),
  13762. /***/ "./2D/xmlLoader.ts":
  13763. /*!*************************!*\
  13764. !*** ./2D/xmlLoader.ts ***!
  13765. \*************************/
  13766. /*! exports provided: XmlLoader */
  13767. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13768. "use strict";
  13769. __webpack_require__.r(__webpack_exports__);
  13770. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  13771. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Misc/observable");
  13772. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  13773. /**
  13774. * Class used to load GUI via XML.
  13775. */
  13776. var XmlLoader = /** @class */ (function () {
  13777. /**
  13778. * Create a new xml loader
  13779. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  13780. */
  13781. function XmlLoader(parentClass) {
  13782. if (parentClass === void 0) { parentClass = null; }
  13783. this._nodes = {};
  13784. this._nodeTypes = {
  13785. element: 1,
  13786. attribute: 2,
  13787. text: 3
  13788. };
  13789. this._isLoaded = false;
  13790. this._objectAttributes = {
  13791. "textHorizontalAlignment": 1,
  13792. "textVerticalAlignment": 2,
  13793. "horizontalAlignment": 3,
  13794. "verticalAlignment": 4,
  13795. "stretch": 5,
  13796. };
  13797. if (parentClass) {
  13798. this._parentClass = parentClass;
  13799. }
  13800. }
  13801. XmlLoader.prototype._getChainElement = function (attributeValue) {
  13802. var element = window;
  13803. if (this._parentClass) {
  13804. element = this._parentClass;
  13805. }
  13806. var value = attributeValue;
  13807. value = value.split(".");
  13808. for (var i = 0; i < value.length; i++) {
  13809. element = element[value[i]];
  13810. }
  13811. return element;
  13812. };
  13813. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  13814. var attribute = attributeName.split(".");
  13815. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  13816. return className[attribute[1]];
  13817. };
  13818. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  13819. if (linkParent === void 0) { linkParent = true; }
  13820. try {
  13821. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  13822. var guiNode = new className();
  13823. if (parent && linkParent) {
  13824. parent.addControl(guiNode);
  13825. }
  13826. for (var i = 0; i < node.attributes.length; i++) {
  13827. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  13828. continue;
  13829. }
  13830. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  13831. var element = this._getChainElement(node.attributes[i].value);
  13832. guiNode[node.attributes[i].name].add(element);
  13833. continue;
  13834. }
  13835. else if (node.attributes[i].name == "linkWithMesh") {
  13836. if (this._parentClass) {
  13837. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13838. }
  13839. else {
  13840. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13841. }
  13842. }
  13843. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13844. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13845. guiNode[node.attributes[i].name] = element;
  13846. }
  13847. else if (!this._objectAttributes[node.attributes[i].name]) {
  13848. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13849. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13850. }
  13851. else {
  13852. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13853. }
  13854. }
  13855. else {
  13856. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13857. }
  13858. }
  13859. if (!node.attributes.getNamedItem("id")) {
  13860. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13861. return guiNode;
  13862. }
  13863. var id = node.attributes.getNamedItem("id").value;
  13864. if (id.startsWith("{{") && id.endsWith("}}")) {
  13865. id = this._getChainElement(id.substring(2, id.length - 2));
  13866. }
  13867. if (!this._nodes[id]) {
  13868. this._nodes[id] = guiNode;
  13869. }
  13870. else {
  13871. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13872. }
  13873. return guiNode;
  13874. }
  13875. catch (e) {
  13876. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13877. }
  13878. };
  13879. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13880. var width;
  13881. var height;
  13882. var columns;
  13883. var rows = node.children;
  13884. var cells;
  13885. var isPixel = false;
  13886. var cellNode;
  13887. var rowNumber = -1;
  13888. var columnNumber = -1;
  13889. var totalColumnsNumber = 0;
  13890. for (var i = 0; i < rows.length; i++) {
  13891. if (rows[i].nodeType != this._nodeTypes.element) {
  13892. continue;
  13893. }
  13894. if (rows[i].nodeName != "Row") {
  13895. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13896. }
  13897. rowNumber += 1;
  13898. columns = rows[i].children;
  13899. if (!rows[i].attributes.getNamedItem("height")) {
  13900. throw "XmlLoader Exception : Height must be defined for grid rows";
  13901. }
  13902. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13903. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13904. guiNode.addRowDefinition(height, isPixel);
  13905. for (var j = 0; j < columns.length; j++) {
  13906. if (columns[j].nodeType != this._nodeTypes.element) {
  13907. continue;
  13908. }
  13909. if (columns[j].nodeName != "Column") {
  13910. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13911. }
  13912. columnNumber += 1;
  13913. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13914. 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.";
  13915. }
  13916. if (rowNumber == 0) {
  13917. if (!columns[j].attributes.getNamedItem("width")) {
  13918. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13919. }
  13920. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13921. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13922. guiNode.addColumnDefinition(width, isPixel);
  13923. }
  13924. cells = columns[j].children;
  13925. for (var k = 0; k < cells.length; k++) {
  13926. if (cells[k].nodeType != this._nodeTypes.element) {
  13927. continue;
  13928. }
  13929. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13930. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13931. if (cells[k].firstChild) {
  13932. this._parseXml(cells[k].firstChild, cellNode);
  13933. }
  13934. }
  13935. }
  13936. if (rowNumber == 0) {
  13937. totalColumnsNumber = columnNumber;
  13938. }
  13939. columnNumber = -1;
  13940. }
  13941. if (node.nextSibling) {
  13942. this._parseXml(node.nextSibling, parent);
  13943. }
  13944. };
  13945. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13946. if (node.firstChild) {
  13947. this._parseXml(node.firstChild, guiNode);
  13948. }
  13949. if (node.nextSibling) {
  13950. this._parseXml(node.nextSibling, parent);
  13951. }
  13952. };
  13953. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13954. if (this._parentClass) {
  13955. this._parentClass[variable] = source[iterator];
  13956. }
  13957. else {
  13958. window[variable] = source[iterator];
  13959. }
  13960. if (node.firstChild) {
  13961. this._parseXml(node.firstChild, guiNode, true);
  13962. }
  13963. };
  13964. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13965. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13966. if (!dataSource.includes(" in ")) {
  13967. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13968. }
  13969. else {
  13970. var isArray = true;
  13971. var splittedSource = dataSource.split(" in ");
  13972. if (splittedSource.length < 2) {
  13973. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13974. }
  13975. var source = splittedSource[1];
  13976. if (source.startsWith("{") && source.endsWith("}")) {
  13977. isArray = false;
  13978. }
  13979. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13980. source = source.substring(1, source.length - 1);
  13981. }
  13982. if (this._parentClass) {
  13983. source = this._parentClass[source];
  13984. }
  13985. else {
  13986. source = window[source];
  13987. }
  13988. if (isArray) {
  13989. for (var i = 0; i < source.length; i++) {
  13990. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13991. }
  13992. }
  13993. else {
  13994. for (var i in source) {
  13995. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13996. }
  13997. }
  13998. if (node.nextSibling) {
  13999. this._parseXml(node.nextSibling, parent);
  14000. }
  14001. }
  14002. };
  14003. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  14004. if (generated === void 0) { generated = false; }
  14005. if (node.nodeType != this._nodeTypes.element) {
  14006. if (node.nextSibling) {
  14007. this._parseXml(node.nextSibling, parent, generated);
  14008. }
  14009. return;
  14010. }
  14011. if (generated) {
  14012. node.setAttribute("id", parent.id + (parent._children.length + 1));
  14013. }
  14014. var guiNode = this._createGuiElement(node, parent);
  14015. if (node.nodeName == "Grid") {
  14016. this._parseGrid(node, guiNode, parent);
  14017. }
  14018. else if (!node.attributes.getNamedItem("dataSource")) {
  14019. this._parseElement(node, guiNode, parent);
  14020. }
  14021. else {
  14022. this._parseElementsFromSource(node, guiNode, parent);
  14023. }
  14024. };
  14025. /**
  14026. * Gets if the loading has finished.
  14027. * @returns whether the loading has finished or not
  14028. */
  14029. XmlLoader.prototype.isLoaded = function () {
  14030. return this._isLoaded;
  14031. };
  14032. /**
  14033. * Gets a loaded node / control by id.
  14034. * @param id the Controls id set in the xml
  14035. * @returns element of type Control
  14036. */
  14037. XmlLoader.prototype.getNodeById = function (id) {
  14038. return this._nodes[id];
  14039. };
  14040. /**
  14041. * Gets all loaded nodes / controls
  14042. * @returns Array of controls
  14043. */
  14044. XmlLoader.prototype.getNodes = function () {
  14045. return this._nodes;
  14046. };
  14047. /**
  14048. * Initiates the xml layout loading
  14049. * @param xmlFile defines the xml layout to load
  14050. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  14051. * @param callback defines the callback called on layout load.
  14052. */
  14053. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  14054. var xhttp = new XMLHttpRequest();
  14055. xhttp.onreadystatechange = function () {
  14056. if (xhttp.readyState == 4 && xhttp.status == 200) {
  14057. if (!xhttp.responseXML) {
  14058. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  14059. }
  14060. var xmlDoc = xhttp.responseXML.documentElement;
  14061. this._parseXml(xmlDoc.firstChild, rootNode);
  14062. this._isLoaded = true;
  14063. if (callback) {
  14064. callback();
  14065. }
  14066. }
  14067. }.bind(this);
  14068. xhttp.open("GET", xmlFile, true);
  14069. xhttp.send();
  14070. };
  14071. return XmlLoader;
  14072. }());
  14073. /***/ }),
  14074. /***/ "./3D/controls/abstractButton3D.ts":
  14075. /*!*****************************************!*\
  14076. !*** ./3D/controls/abstractButton3D.ts ***!
  14077. \*****************************************/
  14078. /*! exports provided: AbstractButton3D */
  14079. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14080. "use strict";
  14081. __webpack_require__.r(__webpack_exports__);
  14082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  14083. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14084. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  14085. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14086. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14087. /**
  14088. * Class used as a root to all buttons
  14089. */
  14090. var AbstractButton3D = /** @class */ (function (_super) {
  14091. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  14092. /**
  14093. * Creates a new button
  14094. * @param name defines the control name
  14095. */
  14096. function AbstractButton3D(name) {
  14097. return _super.call(this, name) || this;
  14098. }
  14099. AbstractButton3D.prototype._getTypeName = function () {
  14100. return "AbstractButton3D";
  14101. };
  14102. // Mesh association
  14103. AbstractButton3D.prototype._createNode = function (scene) {
  14104. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  14105. };
  14106. return AbstractButton3D;
  14107. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14108. /***/ }),
  14109. /***/ "./3D/controls/button3D.ts":
  14110. /*!*********************************!*\
  14111. !*** ./3D/controls/button3D.ts ***!
  14112. \*********************************/
  14113. /*! exports provided: Button3D */
  14114. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14115. "use strict";
  14116. __webpack_require__.r(__webpack_exports__);
  14117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  14118. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14119. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  14120. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  14121. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14122. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14123. /**
  14124. * Class used to create a button in 3D
  14125. */
  14126. var Button3D = /** @class */ (function (_super) {
  14127. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  14128. /**
  14129. * Creates a new button
  14130. * @param name defines the control name
  14131. */
  14132. function Button3D(name) {
  14133. var _this = _super.call(this, name) || this;
  14134. _this._contentResolution = 512;
  14135. _this._contentScaleRatio = 2;
  14136. // Default animations
  14137. _this.pointerEnterAnimation = function () {
  14138. if (!_this.mesh) {
  14139. return;
  14140. }
  14141. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  14142. };
  14143. _this.pointerOutAnimation = function () {
  14144. _this._currentMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14145. };
  14146. _this.pointerDownAnimation = function () {
  14147. if (!_this.mesh) {
  14148. return;
  14149. }
  14150. _this.mesh.scaling.scaleInPlace(0.95);
  14151. };
  14152. _this.pointerUpAnimation = function () {
  14153. if (!_this.mesh) {
  14154. return;
  14155. }
  14156. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14157. };
  14158. return _this;
  14159. }
  14160. Object.defineProperty(Button3D.prototype, "contentResolution", {
  14161. /**
  14162. * Gets or sets the texture resolution used to render content (512 by default)
  14163. */
  14164. get: function () {
  14165. return this._contentResolution;
  14166. },
  14167. set: function (value) {
  14168. if (this._contentResolution === value) {
  14169. return;
  14170. }
  14171. this._contentResolution = value;
  14172. this._resetContent();
  14173. },
  14174. enumerable: false,
  14175. configurable: true
  14176. });
  14177. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  14178. /**
  14179. * Gets or sets the texture scale ratio used to render content (2 by default)
  14180. */
  14181. get: function () {
  14182. return this._contentScaleRatio;
  14183. },
  14184. set: function (value) {
  14185. if (this._contentScaleRatio === value) {
  14186. return;
  14187. }
  14188. this._contentScaleRatio = value;
  14189. this._resetContent();
  14190. },
  14191. enumerable: false,
  14192. configurable: true
  14193. });
  14194. Button3D.prototype._disposeFacadeTexture = function () {
  14195. if (this._facadeTexture) {
  14196. this._facadeTexture.dispose();
  14197. this._facadeTexture = null;
  14198. }
  14199. };
  14200. Button3D.prototype._resetContent = function () {
  14201. this._disposeFacadeTexture();
  14202. this.content = this._content;
  14203. };
  14204. Object.defineProperty(Button3D.prototype, "content", {
  14205. /**
  14206. * Gets or sets the GUI 2D content used to display the button's facade
  14207. */
  14208. get: function () {
  14209. return this._content;
  14210. },
  14211. set: function (value) {
  14212. this._content = value;
  14213. if (!this._host || !this._host.utilityLayer) {
  14214. return;
  14215. }
  14216. if (!this._facadeTexture) {
  14217. 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);
  14218. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  14219. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  14220. this._facadeTexture.premulAlpha = true;
  14221. }
  14222. else {
  14223. this._facadeTexture.rootContainer.clearControls();
  14224. }
  14225. this._facadeTexture.addControl(value);
  14226. this._applyFacade(this._facadeTexture);
  14227. },
  14228. enumerable: false,
  14229. configurable: true
  14230. });
  14231. /**
  14232. * Apply the facade texture (created from the content property).
  14233. * This function can be overloaded by child classes
  14234. * @param facadeTexture defines the AdvancedDynamicTexture to use
  14235. */
  14236. Button3D.prototype._applyFacade = function (facadeTexture) {
  14237. this._currentMaterial.emissiveTexture = facadeTexture;
  14238. };
  14239. Button3D.prototype._getTypeName = function () {
  14240. return "Button3D";
  14241. };
  14242. // Mesh association
  14243. Button3D.prototype._createNode = function (scene) {
  14244. var faceUV = new Array(6);
  14245. for (var i = 0; i < 6; i++) {
  14246. faceUV[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  14247. }
  14248. faceUV[1] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  14249. var mesh = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  14250. width: 1.0,
  14251. height: 1.0,
  14252. depth: 0.08,
  14253. faceUV: faceUV
  14254. }, scene);
  14255. return mesh;
  14256. };
  14257. Button3D.prototype._affectMaterial = function (mesh) {
  14258. var material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  14259. material.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  14260. mesh.material = material;
  14261. this._currentMaterial = material;
  14262. this._resetContent();
  14263. };
  14264. /**
  14265. * Releases all associated resources
  14266. */
  14267. Button3D.prototype.dispose = function () {
  14268. _super.prototype.dispose.call(this);
  14269. this._disposeFacadeTexture();
  14270. if (this._currentMaterial) {
  14271. this._currentMaterial.dispose();
  14272. }
  14273. };
  14274. return Button3D;
  14275. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  14276. /***/ }),
  14277. /***/ "./3D/controls/container3D.ts":
  14278. /*!************************************!*\
  14279. !*** ./3D/controls/container3D.ts ***!
  14280. \************************************/
  14281. /*! exports provided: Container3D */
  14282. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14283. "use strict";
  14284. __webpack_require__.r(__webpack_exports__);
  14285. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  14286. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14287. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Misc/observable");
  14288. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  14289. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14290. /**
  14291. * Class used to create containers for controls
  14292. */
  14293. var Container3D = /** @class */ (function (_super) {
  14294. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  14295. /**
  14296. * Creates a new container
  14297. * @param name defines the container name
  14298. */
  14299. function Container3D(name) {
  14300. var _this = _super.call(this, name) || this;
  14301. _this._blockLayout = false;
  14302. /**
  14303. * Gets the list of child controls
  14304. */
  14305. _this._children = new Array();
  14306. return _this;
  14307. }
  14308. Object.defineProperty(Container3D.prototype, "children", {
  14309. /**
  14310. * Gets the list of child controls
  14311. */
  14312. get: function () {
  14313. return this._children;
  14314. },
  14315. enumerable: false,
  14316. configurable: true
  14317. });
  14318. Object.defineProperty(Container3D.prototype, "blockLayout", {
  14319. /**
  14320. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  14321. * This is helpful to optimize layout operation when adding multiple children in a row
  14322. */
  14323. get: function () {
  14324. return this._blockLayout;
  14325. },
  14326. set: function (value) {
  14327. if (this._blockLayout === value) {
  14328. return;
  14329. }
  14330. this._blockLayout = value;
  14331. if (!this._blockLayout) {
  14332. this._arrangeChildren();
  14333. }
  14334. },
  14335. enumerable: false,
  14336. configurable: true
  14337. });
  14338. /**
  14339. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  14340. * @returns the current container
  14341. */
  14342. Container3D.prototype.updateLayout = function () {
  14343. this._arrangeChildren();
  14344. return this;
  14345. };
  14346. /**
  14347. * Gets a boolean indicating if the given control is in the children of this control
  14348. * @param control defines the control to check
  14349. * @returns true if the control is in the child list
  14350. */
  14351. Container3D.prototype.containsControl = function (control) {
  14352. return this._children.indexOf(control) !== -1;
  14353. };
  14354. /**
  14355. * Adds a control to the children of this control
  14356. * @param control defines the control to add
  14357. * @returns the current container
  14358. */
  14359. Container3D.prototype.addControl = function (control) {
  14360. var index = this._children.indexOf(control);
  14361. if (index !== -1) {
  14362. return this;
  14363. }
  14364. control.parent = this;
  14365. control._host = this._host;
  14366. this._children.push(control);
  14367. if (this._host.utilityLayer) {
  14368. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  14369. if (control.node) {
  14370. control.node.parent = this.node;
  14371. }
  14372. if (!this.blockLayout) {
  14373. this._arrangeChildren();
  14374. }
  14375. }
  14376. return this;
  14377. };
  14378. /**
  14379. * This function will be called everytime a new control is added
  14380. */
  14381. Container3D.prototype._arrangeChildren = function () {
  14382. };
  14383. Container3D.prototype._createNode = function (scene) {
  14384. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  14385. };
  14386. /**
  14387. * Removes a control from the children of this control
  14388. * @param control defines the control to remove
  14389. * @returns the current container
  14390. */
  14391. Container3D.prototype.removeControl = function (control) {
  14392. var index = this._children.indexOf(control);
  14393. if (index !== -1) {
  14394. this._children.splice(index, 1);
  14395. control.parent = null;
  14396. control._disposeNode();
  14397. }
  14398. return this;
  14399. };
  14400. Container3D.prototype._getTypeName = function () {
  14401. return "Container3D";
  14402. };
  14403. /**
  14404. * Releases all associated resources
  14405. */
  14406. Container3D.prototype.dispose = function () {
  14407. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14408. var control = _a[_i];
  14409. control.dispose();
  14410. }
  14411. this._children = [];
  14412. _super.prototype.dispose.call(this);
  14413. };
  14414. /** Control rotation will remain unchanged */
  14415. Container3D.UNSET_ORIENTATION = 0;
  14416. /** Control will rotate to make it look at sphere central axis */
  14417. Container3D.FACEORIGIN_ORIENTATION = 1;
  14418. /** Control will rotate to make it look back at sphere central axis */
  14419. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  14420. /** Control will rotate to look at z axis (0, 0, 1) */
  14421. Container3D.FACEFORWARD_ORIENTATION = 3;
  14422. /** Control will rotate to look at negative z axis (0, 0, -1) */
  14423. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  14424. return Container3D;
  14425. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  14426. /***/ }),
  14427. /***/ "./3D/controls/control3D.ts":
  14428. /*!**********************************!*\
  14429. !*** ./3D/controls/control3D.ts ***!
  14430. \**********************************/
  14431. /*! exports provided: Control3D */
  14432. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14433. "use strict";
  14434. __webpack_require__.r(__webpack_exports__);
  14435. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  14436. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  14437. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  14438. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  14439. /**
  14440. * Class used as base class for controls
  14441. */
  14442. var Control3D = /** @class */ (function () {
  14443. /**
  14444. * Creates a new control
  14445. * @param name defines the control name
  14446. */
  14447. function Control3D(
  14448. /** Defines the control name */
  14449. name) {
  14450. this.name = name;
  14451. this._downCount = 0;
  14452. this._enterCount = -1;
  14453. this._downPointerIds = {};
  14454. this._isVisible = true;
  14455. /**
  14456. * An event triggered when the pointer move over the control
  14457. */
  14458. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14459. /**
  14460. * An event triggered when the pointer move out of the control
  14461. */
  14462. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14463. /**
  14464. * An event triggered when the pointer taps the control
  14465. */
  14466. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14467. /**
  14468. * An event triggered when pointer is up
  14469. */
  14470. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14471. /**
  14472. * An event triggered when a control is clicked on (with a mouse)
  14473. */
  14474. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14475. /**
  14476. * An event triggered when pointer enters the control
  14477. */
  14478. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  14479. // Behaviors
  14480. this._behaviors = new Array();
  14481. }
  14482. Object.defineProperty(Control3D.prototype, "position", {
  14483. /** Gets or sets the control position in world space */
  14484. get: function () {
  14485. if (!this._node) {
  14486. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  14487. }
  14488. return this._node.position;
  14489. },
  14490. set: function (value) {
  14491. if (!this._node) {
  14492. return;
  14493. }
  14494. this._node.position = value;
  14495. },
  14496. enumerable: false,
  14497. configurable: true
  14498. });
  14499. Object.defineProperty(Control3D.prototype, "scaling", {
  14500. /** Gets or sets the control scaling in world space */
  14501. get: function () {
  14502. if (!this._node) {
  14503. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  14504. }
  14505. return this._node.scaling;
  14506. },
  14507. set: function (value) {
  14508. if (!this._node) {
  14509. return;
  14510. }
  14511. this._node.scaling = value;
  14512. },
  14513. enumerable: false,
  14514. configurable: true
  14515. });
  14516. Object.defineProperty(Control3D.prototype, "behaviors", {
  14517. /**
  14518. * Gets the list of attached behaviors
  14519. * @see https://doc.babylonjs.com/features/behaviour
  14520. */
  14521. get: function () {
  14522. return this._behaviors;
  14523. },
  14524. enumerable: false,
  14525. configurable: true
  14526. });
  14527. /**
  14528. * Attach a behavior to the control
  14529. * @see https://doc.babylonjs.com/features/behaviour
  14530. * @param behavior defines the behavior to attach
  14531. * @returns the current control
  14532. */
  14533. Control3D.prototype.addBehavior = function (behavior) {
  14534. var _this = this;
  14535. var index = this._behaviors.indexOf(behavior);
  14536. if (index !== -1) {
  14537. return this;
  14538. }
  14539. behavior.init();
  14540. var scene = this._host.scene;
  14541. if (scene.isLoading) {
  14542. // We defer the attach when the scene will be loaded
  14543. scene.onDataLoadedObservable.addOnce(function () {
  14544. behavior.attach(_this);
  14545. });
  14546. }
  14547. else {
  14548. behavior.attach(this);
  14549. }
  14550. this._behaviors.push(behavior);
  14551. return this;
  14552. };
  14553. /**
  14554. * Remove an attached behavior
  14555. * @see https://doc.babylonjs.com/features/behaviour
  14556. * @param behavior defines the behavior to attach
  14557. * @returns the current control
  14558. */
  14559. Control3D.prototype.removeBehavior = function (behavior) {
  14560. var index = this._behaviors.indexOf(behavior);
  14561. if (index === -1) {
  14562. return this;
  14563. }
  14564. this._behaviors[index].detach();
  14565. this._behaviors.splice(index, 1);
  14566. return this;
  14567. };
  14568. /**
  14569. * Gets an attached behavior by name
  14570. * @param name defines the name of the behavior to look for
  14571. * @see https://doc.babylonjs.com/features/behaviour
  14572. * @returns null if behavior was not found else the requested behavior
  14573. */
  14574. Control3D.prototype.getBehaviorByName = function (name) {
  14575. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14576. var behavior = _a[_i];
  14577. if (behavior.name === name) {
  14578. return behavior;
  14579. }
  14580. }
  14581. return null;
  14582. };
  14583. Object.defineProperty(Control3D.prototype, "isVisible", {
  14584. /** Gets or sets a boolean indicating if the control is visible */
  14585. get: function () {
  14586. return this._isVisible;
  14587. },
  14588. set: function (value) {
  14589. if (this._isVisible === value) {
  14590. return;
  14591. }
  14592. this._isVisible = value;
  14593. var mesh = this.mesh;
  14594. if (mesh) {
  14595. mesh.setEnabled(value);
  14596. }
  14597. },
  14598. enumerable: false,
  14599. configurable: true
  14600. });
  14601. Object.defineProperty(Control3D.prototype, "typeName", {
  14602. /**
  14603. * Gets a string representing the class name
  14604. */
  14605. get: function () {
  14606. return this._getTypeName();
  14607. },
  14608. enumerable: false,
  14609. configurable: true
  14610. });
  14611. /**
  14612. * Get the current class name of the control.
  14613. * @returns current class name
  14614. */
  14615. Control3D.prototype.getClassName = function () {
  14616. return this._getTypeName();
  14617. };
  14618. Control3D.prototype._getTypeName = function () {
  14619. return "Control3D";
  14620. };
  14621. Object.defineProperty(Control3D.prototype, "node", {
  14622. /**
  14623. * Gets the transform node used by this control
  14624. */
  14625. get: function () {
  14626. return this._node;
  14627. },
  14628. enumerable: false,
  14629. configurable: true
  14630. });
  14631. Object.defineProperty(Control3D.prototype, "mesh", {
  14632. /**
  14633. * Gets the mesh used to render this control
  14634. */
  14635. get: function () {
  14636. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  14637. return this._node;
  14638. }
  14639. return null;
  14640. },
  14641. enumerable: false,
  14642. configurable: true
  14643. });
  14644. /**
  14645. * Link the control as child of the given node
  14646. * @param node defines the node to link to. Use null to unlink the control
  14647. * @returns the current control
  14648. */
  14649. Control3D.prototype.linkToTransformNode = function (node) {
  14650. if (this._node) {
  14651. this._node.parent = node;
  14652. }
  14653. return this;
  14654. };
  14655. /** @hidden **/
  14656. Control3D.prototype._prepareNode = function (scene) {
  14657. if (!this._node) {
  14658. this._node = this._createNode(scene);
  14659. if (!this.node) {
  14660. return;
  14661. }
  14662. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  14663. this._node.position = this.position;
  14664. this._node.scaling = this.scaling;
  14665. var mesh = this.mesh;
  14666. if (mesh) {
  14667. mesh.isPickable = true;
  14668. this._affectMaterial(mesh);
  14669. }
  14670. }
  14671. };
  14672. /**
  14673. * Node creation.
  14674. * Can be overriden by children
  14675. * @param scene defines the scene where the node must be attached
  14676. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  14677. */
  14678. Control3D.prototype._createNode = function (scene) {
  14679. // Do nothing by default
  14680. return null;
  14681. };
  14682. /**
  14683. * Affect a material to the given mesh
  14684. * @param mesh defines the mesh which will represent the control
  14685. */
  14686. Control3D.prototype._affectMaterial = function (mesh) {
  14687. mesh.material = null;
  14688. };
  14689. // Pointers
  14690. /** @hidden */
  14691. Control3D.prototype._onPointerMove = function (target, coordinates) {
  14692. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  14693. };
  14694. /** @hidden */
  14695. Control3D.prototype._onPointerEnter = function (target) {
  14696. if (this._enterCount > 0) {
  14697. return false;
  14698. }
  14699. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  14700. this._enterCount = 0;
  14701. }
  14702. this._enterCount++;
  14703. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  14704. if (this.pointerEnterAnimation) {
  14705. this.pointerEnterAnimation();
  14706. }
  14707. return true;
  14708. };
  14709. /** @hidden */
  14710. Control3D.prototype._onPointerOut = function (target) {
  14711. this._enterCount = 0;
  14712. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  14713. if (this.pointerOutAnimation) {
  14714. this.pointerOutAnimation();
  14715. }
  14716. };
  14717. /** @hidden */
  14718. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  14719. if (this._downCount !== 0) {
  14720. this._downCount++;
  14721. return false;
  14722. }
  14723. this._downCount++;
  14724. this._downPointerIds[pointerId] = true;
  14725. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14726. if (this.pointerDownAnimation) {
  14727. this.pointerDownAnimation();
  14728. }
  14729. return true;
  14730. };
  14731. /** @hidden */
  14732. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  14733. this._downCount--;
  14734. delete this._downPointerIds[pointerId];
  14735. if (this._downCount < 0) {
  14736. // Handle if forcePointerUp was called prior to this
  14737. this._downCount = 0;
  14738. return;
  14739. }
  14740. if (this._downCount == 0) {
  14741. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  14742. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14743. }
  14744. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  14745. if (this.pointerUpAnimation) {
  14746. this.pointerUpAnimation();
  14747. }
  14748. }
  14749. };
  14750. /** @hidden */
  14751. Control3D.prototype.forcePointerUp = function (pointerId) {
  14752. if (pointerId === void 0) { pointerId = null; }
  14753. if (pointerId !== null) {
  14754. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  14755. }
  14756. else {
  14757. for (var key in this._downPointerIds) {
  14758. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  14759. }
  14760. if (this._downCount > 0) {
  14761. this._downCount = 1;
  14762. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  14763. }
  14764. }
  14765. };
  14766. /** @hidden */
  14767. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  14768. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  14769. this._onPointerMove(this, pickedPoint);
  14770. var previousControlOver = this._host._lastControlOver[pointerId];
  14771. if (previousControlOver && previousControlOver !== this) {
  14772. previousControlOver._onPointerOut(this);
  14773. }
  14774. if (previousControlOver !== this) {
  14775. this._onPointerEnter(this);
  14776. }
  14777. this._host._lastControlOver[pointerId] = this;
  14778. return true;
  14779. }
  14780. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  14781. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  14782. this._host._lastControlDown[pointerId] = this;
  14783. this._host._lastPickedControl = this;
  14784. return true;
  14785. }
  14786. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP || type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOUBLETAP) {
  14787. if (this._host._lastControlDown[pointerId]) {
  14788. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  14789. }
  14790. delete this._host._lastControlDown[pointerId];
  14791. return true;
  14792. }
  14793. return false;
  14794. };
  14795. /** @hidden */
  14796. Control3D.prototype._disposeNode = function () {
  14797. if (this._node) {
  14798. this._node.dispose();
  14799. this._node = null;
  14800. }
  14801. };
  14802. /**
  14803. * Releases all associated resources
  14804. */
  14805. Control3D.prototype.dispose = function () {
  14806. this.onPointerDownObservable.clear();
  14807. this.onPointerEnterObservable.clear();
  14808. this.onPointerMoveObservable.clear();
  14809. this.onPointerOutObservable.clear();
  14810. this.onPointerUpObservable.clear();
  14811. this.onPointerClickObservable.clear();
  14812. this._disposeNode();
  14813. // Behaviors
  14814. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  14815. var behavior = _a[_i];
  14816. behavior.detach();
  14817. }
  14818. };
  14819. return Control3D;
  14820. }());
  14821. /***/ }),
  14822. /***/ "./3D/controls/cylinderPanel.ts":
  14823. /*!**************************************!*\
  14824. !*** ./3D/controls/cylinderPanel.ts ***!
  14825. \**************************************/
  14826. /*! exports provided: CylinderPanel */
  14827. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14828. "use strict";
  14829. __webpack_require__.r(__webpack_exports__);
  14830. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  14831. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14832. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  14833. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14834. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14835. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14836. /**
  14837. * Class used to create a container panel deployed on the surface of a cylinder
  14838. */
  14839. var CylinderPanel = /** @class */ (function (_super) {
  14840. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14841. function CylinderPanel() {
  14842. var _this = _super !== null && _super.apply(this, arguments) || this;
  14843. _this._radius = 5.0;
  14844. return _this;
  14845. }
  14846. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14847. /**
  14848. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14849. */
  14850. get: function () {
  14851. return this._radius;
  14852. },
  14853. set: function (value) {
  14854. var _this = this;
  14855. if (this._radius === value) {
  14856. return;
  14857. }
  14858. this._radius = value;
  14859. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14860. _this._arrangeChildren();
  14861. });
  14862. },
  14863. enumerable: false,
  14864. configurable: true
  14865. });
  14866. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14867. var mesh = control.mesh;
  14868. if (!mesh) {
  14869. return;
  14870. }
  14871. var newPos = this._cylindricalMapping(nodePosition);
  14872. control.position = newPos;
  14873. switch (this.orientation) {
  14874. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14875. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14876. break;
  14877. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14878. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14879. break;
  14880. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14881. break;
  14882. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14883. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14884. break;
  14885. }
  14886. };
  14887. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14888. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14889. var yAngle = (source.x / this._radius);
  14890. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14891. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14892. };
  14893. return CylinderPanel;
  14894. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14895. /***/ }),
  14896. /***/ "./3D/controls/holographicButton.ts":
  14897. /*!******************************************!*\
  14898. !*** ./3D/controls/holographicButton.ts ***!
  14899. \******************************************/
  14900. /*! exports provided: HolographicButton */
  14901. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14902. "use strict";
  14903. __webpack_require__.r(__webpack_exports__);
  14904. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14905. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14906. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14907. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Misc/observable");
  14908. /* harmony import */ var babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__);
  14909. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14910. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14911. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14912. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14913. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14914. /**
  14915. * Class used to create a holographic button in 3D
  14916. */
  14917. var HolographicButton = /** @class */ (function (_super) {
  14918. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14919. /**
  14920. * Creates a new button
  14921. * @param name defines the control name
  14922. */
  14923. function HolographicButton(name, shareMaterials) {
  14924. if (shareMaterials === void 0) { shareMaterials = true; }
  14925. var _this = _super.call(this, name) || this;
  14926. _this._shareMaterials = true;
  14927. _this._shareMaterials = shareMaterials;
  14928. // Default animations
  14929. _this.pointerEnterAnimation = function () {
  14930. if (!_this.mesh) {
  14931. return;
  14932. }
  14933. _this._frontPlate.setEnabled(true);
  14934. };
  14935. _this.pointerOutAnimation = function () {
  14936. if (!_this.mesh) {
  14937. return;
  14938. }
  14939. _this._frontPlate.setEnabled(false);
  14940. };
  14941. return _this;
  14942. }
  14943. HolographicButton.prototype._disposeTooltip = function () {
  14944. this._tooltipFade = null;
  14945. if (this._tooltipTextBlock) {
  14946. this._tooltipTextBlock.dispose();
  14947. }
  14948. if (this._tooltipTexture) {
  14949. this._tooltipTexture.dispose();
  14950. }
  14951. if (this._tooltipMesh) {
  14952. this._tooltipMesh.dispose();
  14953. }
  14954. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14955. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14956. };
  14957. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14958. get: function () {
  14959. return this._backPlate.renderingGroupId;
  14960. },
  14961. /**
  14962. * Rendering ground id of all the mesh in the button
  14963. */
  14964. set: function (id) {
  14965. this._backPlate.renderingGroupId = id;
  14966. this._textPlate.renderingGroupId = id;
  14967. this._frontPlate.renderingGroupId = id;
  14968. if (this._tooltipMesh) {
  14969. this._tooltipMesh.renderingGroupId = id;
  14970. }
  14971. },
  14972. enumerable: false,
  14973. configurable: true
  14974. });
  14975. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14976. get: function () {
  14977. if (this._tooltipTextBlock) {
  14978. return this._tooltipTextBlock.text;
  14979. }
  14980. return null;
  14981. },
  14982. /**
  14983. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14984. */
  14985. set: function (text) {
  14986. var _this = this;
  14987. if (!text) {
  14988. this._disposeTooltip();
  14989. return;
  14990. }
  14991. if (!this._tooltipFade) {
  14992. // Create tooltip with mesh and text
  14993. this._tooltipMesh = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14994. 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);
  14995. var mat = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14996. mat.diffuseColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14997. tooltipBackground.material = mat;
  14998. tooltipBackground.isPickable = false;
  14999. this._tooltipMesh.addChild(tooltipBackground);
  15000. tooltipBackground.position.z = 0.05;
  15001. this._tooltipMesh.scaling.y = 1 / 3;
  15002. this._tooltipMesh.position.y = 0.7;
  15003. this._tooltipMesh.position.z = -0.15;
  15004. this._tooltipMesh.isPickable = false;
  15005. this._tooltipMesh.parent = this._backPlate;
  15006. // Create text texture for the tooltip
  15007. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  15008. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  15009. this._tooltipTextBlock.scaleY = 3;
  15010. this._tooltipTextBlock.color = "white";
  15011. this._tooltipTextBlock.fontSize = 130;
  15012. this._tooltipTexture.addControl(this._tooltipTextBlock);
  15013. // Add hover action to tooltip
  15014. this._tooltipFade = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  15015. this._tooltipFade.delay = 500;
  15016. this._tooltipMesh.addBehavior(this._tooltipFade);
  15017. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  15018. if (_this._tooltipFade) {
  15019. _this._tooltipFade.fadeIn(true);
  15020. }
  15021. });
  15022. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  15023. if (_this._tooltipFade) {
  15024. _this._tooltipFade.fadeIn(false);
  15025. }
  15026. });
  15027. }
  15028. if (this._tooltipTextBlock) {
  15029. this._tooltipTextBlock.text = text;
  15030. }
  15031. },
  15032. enumerable: false,
  15033. configurable: true
  15034. });
  15035. Object.defineProperty(HolographicButton.prototype, "text", {
  15036. /**
  15037. * Gets or sets text for the button
  15038. */
  15039. get: function () {
  15040. return this._text;
  15041. },
  15042. set: function (value) {
  15043. if (this._text === value) {
  15044. return;
  15045. }
  15046. this._text = value;
  15047. this._rebuildContent();
  15048. },
  15049. enumerable: false,
  15050. configurable: true
  15051. });
  15052. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  15053. /**
  15054. * Gets or sets the image url for the button
  15055. */
  15056. get: function () {
  15057. return this._imageUrl;
  15058. },
  15059. set: function (value) {
  15060. if (this._imageUrl === value) {
  15061. return;
  15062. }
  15063. this._imageUrl = value;
  15064. this._rebuildContent();
  15065. },
  15066. enumerable: false,
  15067. configurable: true
  15068. });
  15069. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  15070. /**
  15071. * Gets the back material used by this button
  15072. */
  15073. get: function () {
  15074. return this._backMaterial;
  15075. },
  15076. enumerable: false,
  15077. configurable: true
  15078. });
  15079. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  15080. /**
  15081. * Gets the front material used by this button
  15082. */
  15083. get: function () {
  15084. return this._frontMaterial;
  15085. },
  15086. enumerable: false,
  15087. configurable: true
  15088. });
  15089. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  15090. /**
  15091. * Gets the plate material used by this button
  15092. */
  15093. get: function () {
  15094. return this._plateMaterial;
  15095. },
  15096. enumerable: false,
  15097. configurable: true
  15098. });
  15099. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  15100. /**
  15101. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  15102. */
  15103. get: function () {
  15104. return this._shareMaterials;
  15105. },
  15106. enumerable: false,
  15107. configurable: true
  15108. });
  15109. HolographicButton.prototype._getTypeName = function () {
  15110. return "HolographicButton";
  15111. };
  15112. HolographicButton.prototype._rebuildContent = function () {
  15113. this._disposeFacadeTexture();
  15114. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  15115. panel.isVertical = true;
  15116. if (this._imageUrl) {
  15117. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  15118. image.source = this._imageUrl;
  15119. image.paddingTop = "40px";
  15120. image.height = "180px";
  15121. image.width = "100px";
  15122. image.paddingBottom = "40px";
  15123. panel.addControl(image);
  15124. }
  15125. if (this._text) {
  15126. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  15127. text.text = this._text;
  15128. text.color = "white";
  15129. text.height = "30px";
  15130. text.fontSize = 24;
  15131. panel.addControl(text);
  15132. }
  15133. if (this._frontPlate) {
  15134. this.content = panel;
  15135. }
  15136. };
  15137. // Mesh association
  15138. HolographicButton.prototype._createNode = function (scene) {
  15139. this._backPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  15140. width: 1.0,
  15141. height: 1.0,
  15142. depth: 0.08
  15143. }, scene);
  15144. this._frontPlate = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  15145. width: 1.0,
  15146. height: 1.0,
  15147. depth: 0.08
  15148. }, scene);
  15149. this._frontPlate.parent = this._backPlate;
  15150. this._frontPlate.position.z = -0.08;
  15151. this._frontPlate.isPickable = false;
  15152. this._frontPlate.setEnabled(false);
  15153. this._textPlate = _super.prototype._createNode.call(this, scene);
  15154. this._textPlate.parent = this._backPlate;
  15155. this._textPlate.position.z = -0.08;
  15156. this._textPlate.isPickable = false;
  15157. return this._backPlate;
  15158. };
  15159. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  15160. this._plateMaterial.emissiveTexture = facadeTexture;
  15161. this._plateMaterial.opacityTexture = facadeTexture;
  15162. };
  15163. HolographicButton.prototype._createBackMaterial = function (mesh) {
  15164. var _this = this;
  15165. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  15166. this._backMaterial.renderHoverLight = true;
  15167. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  15168. if (pickedPoint) {
  15169. _this._backMaterial.hoverPosition = pickedPoint;
  15170. _this._backMaterial.hoverColor.a = 1.0;
  15171. }
  15172. else {
  15173. _this._backMaterial.hoverColor.a = 0;
  15174. }
  15175. });
  15176. };
  15177. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  15178. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  15179. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  15180. this._frontMaterial.alpha = 0.5; // Additive
  15181. this._frontMaterial.renderBorders = true;
  15182. };
  15183. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  15184. this._plateMaterial = new babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  15185. this._plateMaterial.specularColor = babylonjs_Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  15186. };
  15187. HolographicButton.prototype._affectMaterial = function (mesh) {
  15188. // Back
  15189. if (this._shareMaterials) {
  15190. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  15191. this._createBackMaterial(mesh);
  15192. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  15193. }
  15194. else {
  15195. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  15196. }
  15197. // Front
  15198. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  15199. this._createFrontMaterial(mesh);
  15200. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  15201. }
  15202. else {
  15203. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  15204. }
  15205. }
  15206. else {
  15207. this._createBackMaterial(mesh);
  15208. this._createFrontMaterial(mesh);
  15209. }
  15210. this._createPlateMaterial(mesh);
  15211. this._backPlate.material = this._backMaterial;
  15212. this._frontPlate.material = this._frontMaterial;
  15213. this._textPlate.material = this._plateMaterial;
  15214. this._rebuildContent();
  15215. };
  15216. /**
  15217. * Releases all associated resources
  15218. */
  15219. HolographicButton.prototype.dispose = function () {
  15220. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  15221. this._disposeTooltip();
  15222. if (!this.shareMaterials) {
  15223. this._backMaterial.dispose();
  15224. this._frontMaterial.dispose();
  15225. this._plateMaterial.dispose();
  15226. if (this._pickedPointObserver) {
  15227. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  15228. this._pickedPointObserver = null;
  15229. }
  15230. }
  15231. };
  15232. return HolographicButton;
  15233. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15234. /***/ }),
  15235. /***/ "./3D/controls/index.ts":
  15236. /*!******************************!*\
  15237. !*** ./3D/controls/index.ts ***!
  15238. \******************************/
  15239. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  15240. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15241. "use strict";
  15242. __webpack_require__.r(__webpack_exports__);
  15243. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  15244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15245. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15247. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  15249. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  15250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  15251. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  15252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  15253. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  15254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  15255. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  15256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  15257. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  15258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  15259. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  15260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  15261. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  15262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  15263. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  15264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  15265. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  15267. /***/ }),
  15268. /***/ "./3D/controls/meshButton3D.ts":
  15269. /*!*************************************!*\
  15270. !*** ./3D/controls/meshButton3D.ts ***!
  15271. \*************************************/
  15272. /*! exports provided: MeshButton3D */
  15273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15274. "use strict";
  15275. __webpack_require__.r(__webpack_exports__);
  15276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  15277. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15278. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  15279. /**
  15280. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  15281. */
  15282. var MeshButton3D = /** @class */ (function (_super) {
  15283. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  15284. /**
  15285. * Creates a new 3D button based on a mesh
  15286. * @param mesh mesh to become a 3D button
  15287. * @param name defines the control name
  15288. */
  15289. function MeshButton3D(mesh, name) {
  15290. var _this = _super.call(this, name) || this;
  15291. _this._currentMesh = mesh;
  15292. /**
  15293. * Provides a default behavior on hover/out & up/down
  15294. * Override those function to create your own desired behavior specific to your mesh
  15295. */
  15296. _this.pointerEnterAnimation = function () {
  15297. if (!_this.mesh) {
  15298. return;
  15299. }
  15300. _this.mesh.scaling.scaleInPlace(1.1);
  15301. };
  15302. _this.pointerOutAnimation = function () {
  15303. if (!_this.mesh) {
  15304. return;
  15305. }
  15306. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  15307. };
  15308. _this.pointerDownAnimation = function () {
  15309. if (!_this.mesh) {
  15310. return;
  15311. }
  15312. _this.mesh.scaling.scaleInPlace(0.95);
  15313. };
  15314. _this.pointerUpAnimation = function () {
  15315. if (!_this.mesh) {
  15316. return;
  15317. }
  15318. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  15319. };
  15320. return _this;
  15321. }
  15322. MeshButton3D.prototype._getTypeName = function () {
  15323. return "MeshButton3D";
  15324. };
  15325. // Mesh association
  15326. MeshButton3D.prototype._createNode = function (scene) {
  15327. var _this = this;
  15328. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  15329. mesh.metadata = _this;
  15330. });
  15331. return this._currentMesh;
  15332. };
  15333. MeshButton3D.prototype._affectMaterial = function (mesh) {
  15334. };
  15335. return MeshButton3D;
  15336. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  15337. /***/ }),
  15338. /***/ "./3D/controls/planePanel.ts":
  15339. /*!***********************************!*\
  15340. !*** ./3D/controls/planePanel.ts ***!
  15341. \***********************************/
  15342. /*! exports provided: PlanePanel */
  15343. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15344. "use strict";
  15345. __webpack_require__.r(__webpack_exports__);
  15346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  15347. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15348. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  15349. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  15350. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15351. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15352. /**
  15353. * Class used to create a container panel deployed on the surface of a plane
  15354. */
  15355. var PlanePanel = /** @class */ (function (_super) {
  15356. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  15357. function PlanePanel() {
  15358. return _super !== null && _super.apply(this, arguments) || this;
  15359. }
  15360. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  15361. var mesh = control.mesh;
  15362. if (!mesh) {
  15363. return;
  15364. }
  15365. control.position = nodePosition.clone();
  15366. var target = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15367. target.copyFrom(nodePosition);
  15368. switch (this.orientation) {
  15369. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  15370. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  15371. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15372. mesh.lookAt(target);
  15373. break;
  15374. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15375. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15376. target.addInPlace(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15377. mesh.lookAt(target);
  15378. break;
  15379. }
  15380. };
  15381. return PlanePanel;
  15382. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  15383. /***/ }),
  15384. /***/ "./3D/controls/scatterPanel.ts":
  15385. /*!*************************************!*\
  15386. !*** ./3D/controls/scatterPanel.ts ***!
  15387. \*************************************/
  15388. /*! exports provided: ScatterPanel */
  15389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15390. "use strict";
  15391. __webpack_require__.r(__webpack_exports__);
  15392. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  15393. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15394. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15395. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15396. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15397. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15398. /**
  15399. * Class used to create a container panel where items get randomized planar mapping
  15400. */
  15401. var ScatterPanel = /** @class */ (function (_super) {
  15402. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  15403. function ScatterPanel() {
  15404. var _this = _super !== null && _super.apply(this, arguments) || this;
  15405. _this._iteration = 100.0;
  15406. return _this;
  15407. }
  15408. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  15409. /**
  15410. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  15411. */
  15412. get: function () {
  15413. return this._iteration;
  15414. },
  15415. set: function (value) {
  15416. var _this = this;
  15417. if (this._iteration === value) {
  15418. return;
  15419. }
  15420. this._iteration = value;
  15421. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15422. _this._arrangeChildren();
  15423. });
  15424. },
  15425. enumerable: false,
  15426. configurable: true
  15427. });
  15428. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  15429. var mesh = control.mesh;
  15430. var newPos = this._scatterMapping(nodePosition);
  15431. if (!mesh) {
  15432. return;
  15433. }
  15434. switch (this.orientation) {
  15435. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15436. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15437. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  15438. break;
  15439. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15440. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15441. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  15442. break;
  15443. }
  15444. control.position = newPos;
  15445. };
  15446. ScatterPanel.prototype._scatterMapping = function (source) {
  15447. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  15448. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  15449. return source;
  15450. };
  15451. ScatterPanel.prototype._finalProcessing = function () {
  15452. var meshes = [];
  15453. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15454. var child = _a[_i];
  15455. if (!child.mesh) {
  15456. continue;
  15457. }
  15458. meshes.push(child.mesh);
  15459. }
  15460. for (var count = 0; count < this._iteration; count++) {
  15461. meshes.sort(function (a, b) {
  15462. var distance1 = a.position.lengthSquared();
  15463. var distance2 = b.position.lengthSquared();
  15464. if (distance1 < distance2) {
  15465. return 1;
  15466. }
  15467. else if (distance1 > distance2) {
  15468. return -1;
  15469. }
  15470. return 0;
  15471. });
  15472. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  15473. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  15474. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  15475. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15476. for (var i = 0; i < meshes.length - 1; i++) {
  15477. for (var j = i + 1; j < meshes.length; j++) {
  15478. if (i != j) {
  15479. meshes[j].position.subtractToRef(meshes[i].position, difference);
  15480. // Ignore Z axis
  15481. difference2D.x = difference.x;
  15482. difference2D.y = difference.y;
  15483. var combinedRadius = cellSize;
  15484. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  15485. var minSeparation = Math.min(distance, radiusPaddingSquared);
  15486. distance -= minSeparation;
  15487. if (distance < (Math.pow(combinedRadius, 2.0))) {
  15488. difference2D.normalize();
  15489. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  15490. meshes[j].position.addInPlace(difference);
  15491. meshes[i].position.subtractInPlace(difference);
  15492. }
  15493. }
  15494. }
  15495. }
  15496. }
  15497. };
  15498. return ScatterPanel;
  15499. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15500. /***/ }),
  15501. /***/ "./3D/controls/spherePanel.ts":
  15502. /*!************************************!*\
  15503. !*** ./3D/controls/spherePanel.ts ***!
  15504. \************************************/
  15505. /*! exports provided: SpherePanel */
  15506. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15507. "use strict";
  15508. __webpack_require__.r(__webpack_exports__);
  15509. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  15510. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15511. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15512. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15513. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  15514. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15515. /**
  15516. * Class used to create a container panel deployed on the surface of a sphere
  15517. */
  15518. var SpherePanel = /** @class */ (function (_super) {
  15519. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  15520. function SpherePanel() {
  15521. var _this = _super !== null && _super.apply(this, arguments) || this;
  15522. _this._radius = 5.0;
  15523. return _this;
  15524. }
  15525. Object.defineProperty(SpherePanel.prototype, "radius", {
  15526. /**
  15527. * Gets or sets the radius of the sphere where to project controls (5 by default)
  15528. */
  15529. get: function () {
  15530. return this._radius;
  15531. },
  15532. set: function (value) {
  15533. var _this = this;
  15534. if (this._radius === value) {
  15535. return;
  15536. }
  15537. this._radius = value;
  15538. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15539. _this._arrangeChildren();
  15540. });
  15541. },
  15542. enumerable: false,
  15543. configurable: true
  15544. });
  15545. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  15546. var mesh = control.mesh;
  15547. if (!mesh) {
  15548. return;
  15549. }
  15550. var newPos = this._sphericalMapping(nodePosition);
  15551. control.position = newPos;
  15552. switch (this.orientation) {
  15553. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  15554. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  15555. break;
  15556. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  15557. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  15558. break;
  15559. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  15560. break;
  15561. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  15562. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  15563. break;
  15564. }
  15565. };
  15566. SpherePanel.prototype._sphericalMapping = function (source) {
  15567. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  15568. var xAngle = (source.y / this._radius);
  15569. var yAngle = -(source.x / this._radius);
  15570. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15571. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15572. };
  15573. return SpherePanel;
  15574. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  15575. /***/ }),
  15576. /***/ "./3D/controls/stackPanel3D.ts":
  15577. /*!*************************************!*\
  15578. !*** ./3D/controls/stackPanel3D.ts ***!
  15579. \*************************************/
  15580. /*! exports provided: StackPanel3D */
  15581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15582. "use strict";
  15583. __webpack_require__.r(__webpack_exports__);
  15584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  15585. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15586. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15587. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15588. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15589. /**
  15590. * Class used to create a stack panel in 3D on XY plane
  15591. */
  15592. var StackPanel3D = /** @class */ (function (_super) {
  15593. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  15594. /**
  15595. * Creates new StackPanel
  15596. * @param isVertical
  15597. */
  15598. function StackPanel3D(isVertical) {
  15599. if (isVertical === void 0) { isVertical = false; }
  15600. var _this = _super.call(this) || this;
  15601. _this._isVertical = false;
  15602. /**
  15603. * Gets or sets the distance between elements
  15604. */
  15605. _this.margin = 0.1;
  15606. _this._isVertical = isVertical;
  15607. return _this;
  15608. }
  15609. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  15610. /**
  15611. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  15612. */
  15613. get: function () {
  15614. return this._isVertical;
  15615. },
  15616. set: function (value) {
  15617. var _this = this;
  15618. if (this._isVertical === value) {
  15619. return;
  15620. }
  15621. this._isVertical = value;
  15622. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15623. _this._arrangeChildren();
  15624. });
  15625. },
  15626. enumerable: false,
  15627. configurable: true
  15628. });
  15629. StackPanel3D.prototype._arrangeChildren = function () {
  15630. var width = 0;
  15631. var height = 0;
  15632. var controlCount = 0;
  15633. var extendSizes = [];
  15634. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15635. // Measure
  15636. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15637. var child = _a[_i];
  15638. if (!child.mesh) {
  15639. continue;
  15640. }
  15641. controlCount++;
  15642. child.mesh.computeWorldMatrix(true);
  15643. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15644. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  15645. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  15646. extendSizes.push(extendSize);
  15647. if (this._isVertical) {
  15648. height += extendSize.y;
  15649. }
  15650. else {
  15651. width += extendSize.x;
  15652. }
  15653. }
  15654. if (this._isVertical) {
  15655. height += (controlCount - 1) * this.margin / 2;
  15656. }
  15657. else {
  15658. width += (controlCount - 1) * this.margin / 2;
  15659. }
  15660. // Arrange
  15661. var offset;
  15662. if (this._isVertical) {
  15663. offset = -height;
  15664. }
  15665. else {
  15666. offset = -width;
  15667. }
  15668. var index = 0;
  15669. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15670. var child = _c[_b];
  15671. if (!child.mesh) {
  15672. continue;
  15673. }
  15674. controlCount--;
  15675. var extendSize = extendSizes[index++];
  15676. if (this._isVertical) {
  15677. child.position.y = offset + extendSize.y;
  15678. child.position.x = 0;
  15679. offset += extendSize.y * 2;
  15680. }
  15681. else {
  15682. child.position.x = offset + extendSize.x;
  15683. child.position.y = 0;
  15684. offset += extendSize.x * 2;
  15685. }
  15686. offset += (controlCount > 0 ? this.margin : 0);
  15687. }
  15688. };
  15689. return StackPanel3D;
  15690. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15691. /***/ }),
  15692. /***/ "./3D/controls/volumeBasedPanel.ts":
  15693. /*!*****************************************!*\
  15694. !*** ./3D/controls/volumeBasedPanel.ts ***!
  15695. \*****************************************/
  15696. /*! exports provided: VolumeBasedPanel */
  15697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15698. "use strict";
  15699. __webpack_require__.r(__webpack_exports__);
  15700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  15701. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15702. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable");
  15703. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  15704. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  15705. /**
  15706. * Abstract class used to create a container panel deployed on the surface of a volume
  15707. */
  15708. var VolumeBasedPanel = /** @class */ (function (_super) {
  15709. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  15710. /**
  15711. * Creates new VolumeBasedPanel
  15712. */
  15713. function VolumeBasedPanel() {
  15714. var _this = _super.call(this) || this;
  15715. _this._columns = 10;
  15716. _this._rows = 0;
  15717. _this._rowThenColum = true;
  15718. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  15719. /**
  15720. * Gets or sets the distance between elements
  15721. */
  15722. _this.margin = 0;
  15723. return _this;
  15724. }
  15725. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  15726. /**
  15727. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  15728. * | Value | Type | Description |
  15729. * | ----- | ----------------------------------- | ----------- |
  15730. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  15731. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  15732. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  15733. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  15734. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  15735. */
  15736. get: function () {
  15737. return this._orientation;
  15738. },
  15739. set: function (value) {
  15740. var _this = this;
  15741. if (this._orientation === value) {
  15742. return;
  15743. }
  15744. this._orientation = value;
  15745. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15746. _this._arrangeChildren();
  15747. });
  15748. },
  15749. enumerable: false,
  15750. configurable: true
  15751. });
  15752. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  15753. /**
  15754. * Gets or sets the number of columns requested (10 by default).
  15755. * The panel will automatically compute the number of rows based on number of child controls.
  15756. */
  15757. get: function () {
  15758. return this._columns;
  15759. },
  15760. set: function (value) {
  15761. var _this = this;
  15762. if (this._columns === value) {
  15763. return;
  15764. }
  15765. this._columns = value;
  15766. this._rowThenColum = true;
  15767. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15768. _this._arrangeChildren();
  15769. });
  15770. },
  15771. enumerable: false,
  15772. configurable: true
  15773. });
  15774. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  15775. /**
  15776. * Gets or sets a the number of rows requested.
  15777. * The panel will automatically compute the number of columns based on number of child controls.
  15778. */
  15779. get: function () {
  15780. return this._rows;
  15781. },
  15782. set: function (value) {
  15783. var _this = this;
  15784. if (this._rows === value) {
  15785. return;
  15786. }
  15787. this._rows = value;
  15788. this._rowThenColum = false;
  15789. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  15790. _this._arrangeChildren();
  15791. });
  15792. },
  15793. enumerable: false,
  15794. configurable: true
  15795. });
  15796. VolumeBasedPanel.prototype._arrangeChildren = function () {
  15797. this._cellWidth = 0;
  15798. this._cellHeight = 0;
  15799. var rows = 0;
  15800. var columns = 0;
  15801. var controlCount = 0;
  15802. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  15803. // Measure
  15804. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  15805. var child = _a[_i];
  15806. if (!child.mesh) {
  15807. continue;
  15808. }
  15809. controlCount++;
  15810. child.mesh.computeWorldMatrix(true);
  15811. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  15812. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  15813. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  15814. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  15815. boundingBox.max.subtractToRef(boundingBox.min, diff);
  15816. diff.scaleInPlace(0.5);
  15817. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  15818. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  15819. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  15820. }
  15821. this._cellWidth += this.margin * 2;
  15822. this._cellHeight += this.margin * 2;
  15823. // Arrange
  15824. if (this._rowThenColum) {
  15825. columns = this._columns;
  15826. rows = Math.ceil(controlCount / this._columns);
  15827. }
  15828. else {
  15829. rows = this._rows;
  15830. columns = Math.ceil(controlCount / this._rows);
  15831. }
  15832. var startOffsetX = (columns * 0.5) * this._cellWidth;
  15833. var startOffsetY = (rows * 0.5) * this._cellHeight;
  15834. var nodeGrid = [];
  15835. var cellCounter = 0;
  15836. if (this._rowThenColum) {
  15837. for (var r = 0; r < rows; r++) {
  15838. for (var c = 0; c < columns; c++) {
  15839. 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));
  15840. cellCounter++;
  15841. if (cellCounter > controlCount) {
  15842. break;
  15843. }
  15844. }
  15845. }
  15846. }
  15847. else {
  15848. for (var c = 0; c < columns; c++) {
  15849. for (var r = 0; r < rows; r++) {
  15850. 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));
  15851. cellCounter++;
  15852. if (cellCounter > controlCount) {
  15853. break;
  15854. }
  15855. }
  15856. }
  15857. }
  15858. cellCounter = 0;
  15859. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15860. var child = _c[_b];
  15861. if (!child.mesh) {
  15862. continue;
  15863. }
  15864. this._mapGridNode(child, nodeGrid[cellCounter]);
  15865. cellCounter++;
  15866. }
  15867. this._finalProcessing();
  15868. };
  15869. /** Child classes can implement this function to provide additional processing */
  15870. VolumeBasedPanel.prototype._finalProcessing = function () {
  15871. };
  15872. return VolumeBasedPanel;
  15873. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15874. /***/ }),
  15875. /***/ "./3D/gui3DManager.ts":
  15876. /*!****************************!*\
  15877. !*** ./3D/gui3DManager.ts ***!
  15878. \****************************/
  15879. /*! exports provided: GUI3DManager */
  15880. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15881. "use strict";
  15882. __webpack_require__.r(__webpack_exports__);
  15883. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15884. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Misc/observable");
  15885. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15886. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15887. /**
  15888. * Class used to manage 3D user interface
  15889. * @see https://doc.babylonjs.com/how_to/gui3d
  15890. */
  15891. var GUI3DManager = /** @class */ (function () {
  15892. /**
  15893. * Creates a new GUI3DManager
  15894. * @param scene
  15895. */
  15896. function GUI3DManager(scene) {
  15897. var _this = this;
  15898. /** @hidden */
  15899. this._lastControlOver = {};
  15900. /** @hidden */
  15901. this._lastControlDown = {};
  15902. /**
  15903. * Observable raised when the point picked by the pointer events changed
  15904. */
  15905. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15906. // Shared resources
  15907. /** @hidden */
  15908. this._sharedMaterials = {};
  15909. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15910. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15911. _this._sceneDisposeObserver = null;
  15912. _this._utilityLayer = null;
  15913. _this.dispose();
  15914. });
  15915. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15916. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15917. this._utilityLayer.pickUtilitySceneFirst = false;
  15918. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15919. return mesh && mesh.metadata && mesh.metadata._node;
  15920. };
  15921. // Root
  15922. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15923. this._rootContainer._host = this;
  15924. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15925. // Events
  15926. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15927. _this._handlePointerOut(pointerId, true);
  15928. });
  15929. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15930. _this._doPicking(pi);
  15931. });
  15932. // Scene
  15933. this._utilityLayer.utilityLayerScene.autoClear = false;
  15934. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15935. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15936. }
  15937. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15938. /** Gets the hosting scene */
  15939. get: function () {
  15940. return this._scene;
  15941. },
  15942. enumerable: false,
  15943. configurable: true
  15944. });
  15945. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15946. /** Gets associated utility layer */
  15947. get: function () {
  15948. return this._utilityLayer;
  15949. },
  15950. enumerable: false,
  15951. configurable: true
  15952. });
  15953. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15954. var previousControlOver = this._lastControlOver[pointerId];
  15955. if (previousControlOver) {
  15956. previousControlOver._onPointerOut(previousControlOver);
  15957. delete this._lastControlOver[pointerId];
  15958. }
  15959. if (isPointerUp) {
  15960. if (this._lastControlDown[pointerId]) {
  15961. this._lastControlDown[pointerId].forcePointerUp();
  15962. delete this._lastControlDown[pointerId];
  15963. }
  15964. }
  15965. this.onPickedPointChangedObservable.notifyObservers(null);
  15966. };
  15967. GUI3DManager.prototype._doPicking = function (pi) {
  15968. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15969. return false;
  15970. }
  15971. var pointerEvent = (pi.event);
  15972. var pointerId = pointerEvent.pointerId || 0;
  15973. var buttonIndex = pointerEvent.button;
  15974. var pickingInfo = pi.pickInfo;
  15975. if (!pickingInfo || !pickingInfo.hit) {
  15976. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15977. return false;
  15978. }
  15979. var control = (pickingInfo.pickedMesh.metadata);
  15980. if (pickingInfo.pickedPoint) {
  15981. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15982. }
  15983. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15984. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15985. if (this._lastControlOver[pointerId]) {
  15986. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15987. }
  15988. delete this._lastControlOver[pointerId];
  15989. }
  15990. }
  15991. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15992. if (this._lastControlDown[pointerEvent.pointerId]) {
  15993. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15994. delete this._lastControlDown[pointerEvent.pointerId];
  15995. }
  15996. if (pointerEvent.pointerType === "touch") {
  15997. this._handlePointerOut(pointerId, false);
  15998. }
  15999. }
  16000. return true;
  16001. };
  16002. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  16003. /**
  16004. * Gets the root container
  16005. */
  16006. get: function () {
  16007. return this._rootContainer;
  16008. },
  16009. enumerable: false,
  16010. configurable: true
  16011. });
  16012. /**
  16013. * Gets a boolean indicating if the given control is in the root child list
  16014. * @param control defines the control to check
  16015. * @returns true if the control is in the root child list
  16016. */
  16017. GUI3DManager.prototype.containsControl = function (control) {
  16018. return this._rootContainer.containsControl(control);
  16019. };
  16020. /**
  16021. * Adds a control to the root child list
  16022. * @param control defines the control to add
  16023. * @returns the current manager
  16024. */
  16025. GUI3DManager.prototype.addControl = function (control) {
  16026. this._rootContainer.addControl(control);
  16027. return this;
  16028. };
  16029. /**
  16030. * Removes a control from the root child list
  16031. * @param control defines the control to remove
  16032. * @returns the current container
  16033. */
  16034. GUI3DManager.prototype.removeControl = function (control) {
  16035. this._rootContainer.removeControl(control);
  16036. return this;
  16037. };
  16038. /**
  16039. * Releases all associated resources
  16040. */
  16041. GUI3DManager.prototype.dispose = function () {
  16042. this._rootContainer.dispose();
  16043. for (var materialName in this._sharedMaterials) {
  16044. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  16045. continue;
  16046. }
  16047. this._sharedMaterials[materialName].dispose();
  16048. }
  16049. this._sharedMaterials = {};
  16050. if (this._pointerOutObserver && this._utilityLayer) {
  16051. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  16052. this._pointerOutObserver = null;
  16053. }
  16054. this.onPickedPointChangedObservable.clear();
  16055. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  16056. if (utilityLayerScene) {
  16057. if (this._pointerObserver) {
  16058. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  16059. this._pointerObserver = null;
  16060. }
  16061. }
  16062. if (this._scene) {
  16063. if (this._sceneDisposeObserver) {
  16064. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  16065. this._sceneDisposeObserver = null;
  16066. }
  16067. }
  16068. if (this._utilityLayer) {
  16069. this._utilityLayer.dispose();
  16070. }
  16071. };
  16072. return GUI3DManager;
  16073. }());
  16074. /***/ }),
  16075. /***/ "./3D/index.ts":
  16076. /*!*********************!*\
  16077. !*** ./3D/index.ts ***!
  16078. \*********************/
  16079. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16080. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16081. "use strict";
  16082. __webpack_require__.r(__webpack_exports__);
  16083. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  16084. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16085. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16086. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16087. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16088. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16089. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16090. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16091. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16092. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16093. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16094. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16095. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16096. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  16097. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16099. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  16100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  16101. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  16102. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  16103. /***/ }),
  16104. /***/ "./3D/materials/fluentMaterial.ts":
  16105. /*!****************************************!*\
  16106. !*** ./3D/materials/fluentMaterial.ts ***!
  16107. \****************************************/
  16108. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16110. "use strict";
  16111. __webpack_require__.r(__webpack_exports__);
  16112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  16113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  16114. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16115. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Misc/observable");
  16116. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  16117. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  16118. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  16119. /** @hidden */
  16120. var FluentMaterialDefines = /** @class */ (function (_super) {
  16121. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  16122. function FluentMaterialDefines() {
  16123. var _this = _super.call(this) || this;
  16124. _this.INNERGLOW = false;
  16125. _this.BORDER = false;
  16126. _this.HOVERLIGHT = false;
  16127. _this.TEXTURE = false;
  16128. _this.rebuild();
  16129. return _this;
  16130. }
  16131. return FluentMaterialDefines;
  16132. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  16133. /**
  16134. * Class used to render controls with fluent desgin
  16135. */
  16136. var FluentMaterial = /** @class */ (function (_super) {
  16137. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  16138. /**
  16139. * Creates a new Fluent material
  16140. * @param name defines the name of the material
  16141. * @param scene defines the hosting scene
  16142. */
  16143. function FluentMaterial(name, scene) {
  16144. var _this = _super.call(this, name, scene) || this;
  16145. /**
  16146. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  16147. */
  16148. _this.innerGlowColorIntensity = 0.5;
  16149. /**
  16150. * Gets or sets the inner glow color (white by default)
  16151. */
  16152. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  16153. /**
  16154. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  16155. */
  16156. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  16157. /**
  16158. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  16159. */
  16160. _this.renderBorders = false;
  16161. /**
  16162. * Gets or sets border width (default is 0.5)
  16163. */
  16164. _this.borderWidth = 0.5;
  16165. /**
  16166. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  16167. */
  16168. _this.edgeSmoothingValue = 0.02;
  16169. /**
  16170. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  16171. */
  16172. _this.borderMinValue = 0.1;
  16173. /**
  16174. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  16175. */
  16176. _this.renderHoverLight = false;
  16177. /**
  16178. * Gets or sets the radius used to render the hover light (default is 1.0)
  16179. */
  16180. _this.hoverRadius = 1.0;
  16181. /**
  16182. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  16183. */
  16184. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  16185. /**
  16186. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  16187. */
  16188. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  16189. return _this;
  16190. }
  16191. FluentMaterial.prototype.needAlphaBlending = function () {
  16192. return this.alpha !== 1.0;
  16193. };
  16194. FluentMaterial.prototype.needAlphaTesting = function () {
  16195. return false;
  16196. };
  16197. FluentMaterial.prototype.getAlphaTestTexture = function () {
  16198. return null;
  16199. };
  16200. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  16201. if (this.isFrozen) {
  16202. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  16203. return true;
  16204. }
  16205. }
  16206. if (!subMesh._materialDefines) {
  16207. subMesh._materialDefines = new FluentMaterialDefines();
  16208. }
  16209. var scene = this.getScene();
  16210. var defines = subMesh._materialDefines;
  16211. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  16212. if (defines._renderId === scene.getRenderId()) {
  16213. return true;
  16214. }
  16215. }
  16216. if (defines._areTexturesDirty) {
  16217. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  16218. defines.BORDER = this.renderBorders;
  16219. defines.HOVERLIGHT = this.renderHoverLight;
  16220. if (this._albedoTexture) {
  16221. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  16222. return false;
  16223. }
  16224. else {
  16225. defines.TEXTURE = true;
  16226. }
  16227. }
  16228. else {
  16229. defines.TEXTURE = false;
  16230. }
  16231. }
  16232. var engine = scene.getEngine();
  16233. // Get correct effect
  16234. if (defines.isDirty) {
  16235. defines.markAsProcessed();
  16236. scene.resetCachedMaterial();
  16237. //Attributes
  16238. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  16239. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  16240. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  16241. var shaderName = "fluent";
  16242. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  16243. "hoverColor", "hoverPosition", "hoverRadius"
  16244. ];
  16245. var samplers = ["albedoSampler"];
  16246. var uniformBuffers = new Array();
  16247. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  16248. uniformsNames: uniforms,
  16249. uniformBuffersNames: uniformBuffers,
  16250. samplers: samplers,
  16251. defines: defines,
  16252. maxSimultaneousLights: 4
  16253. });
  16254. var join = defines.toString();
  16255. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  16256. attributes: attribs,
  16257. uniformsNames: uniforms,
  16258. uniformBuffersNames: uniformBuffers,
  16259. samplers: samplers,
  16260. defines: join,
  16261. fallbacks: null,
  16262. onCompiled: this.onCompiled,
  16263. onError: this.onError,
  16264. indexParameters: { maxSimultaneousLights: 4 }
  16265. }, engine));
  16266. }
  16267. if (!subMesh.effect || !subMesh.effect.isReady()) {
  16268. return false;
  16269. }
  16270. defines._renderId = scene.getRenderId();
  16271. subMesh.effect._wasPreviouslyReady = true;
  16272. return true;
  16273. };
  16274. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  16275. var scene = this.getScene();
  16276. var defines = subMesh._materialDefines;
  16277. if (!defines) {
  16278. return;
  16279. }
  16280. var effect = subMesh.effect;
  16281. if (!effect) {
  16282. return;
  16283. }
  16284. this._activeEffect = effect;
  16285. // Matrices
  16286. this.bindOnlyWorldMatrix(world);
  16287. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  16288. if (this._mustRebind(scene, effect)) {
  16289. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  16290. if (defines.INNERGLOW) {
  16291. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  16292. }
  16293. if (defines.BORDER) {
  16294. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  16295. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  16296. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  16297. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16298. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  16299. }
  16300. if (defines.HOVERLIGHT) {
  16301. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  16302. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  16303. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  16304. }
  16305. if (defines.TEXTURE) {
  16306. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  16307. }
  16308. }
  16309. this._afterBind(mesh, this._activeEffect);
  16310. };
  16311. FluentMaterial.prototype.getActiveTextures = function () {
  16312. var activeTextures = _super.prototype.getActiveTextures.call(this);
  16313. return activeTextures;
  16314. };
  16315. FluentMaterial.prototype.hasTexture = function (texture) {
  16316. if (_super.prototype.hasTexture.call(this, texture)) {
  16317. return true;
  16318. }
  16319. return false;
  16320. };
  16321. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  16322. _super.prototype.dispose.call(this, forceDisposeEffect);
  16323. };
  16324. FluentMaterial.prototype.clone = function (name) {
  16325. var _this = this;
  16326. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  16327. };
  16328. FluentMaterial.prototype.serialize = function () {
  16329. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  16330. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  16331. return serializationObject;
  16332. };
  16333. FluentMaterial.prototype.getClassName = function () {
  16334. return "FluentMaterial";
  16335. };
  16336. // Statics
  16337. FluentMaterial.Parse = function (source, scene, rootUrl) {
  16338. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  16339. };
  16340. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16341. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16342. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16343. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  16344. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16345. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16346. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  16347. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16348. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  16349. ], FluentMaterial.prototype, "albedoColor", void 0);
  16350. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16351. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16352. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16353. ], FluentMaterial.prototype, "renderBorders", void 0);
  16354. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16355. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16356. ], FluentMaterial.prototype, "borderWidth", void 0);
  16357. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16358. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16359. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  16360. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16361. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16362. ], FluentMaterial.prototype, "borderMinValue", void 0);
  16363. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16364. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  16365. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  16366. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  16367. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16368. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  16369. ], FluentMaterial.prototype, "hoverRadius", void 0);
  16370. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16371. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  16372. ], FluentMaterial.prototype, "hoverColor", void 0);
  16373. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16374. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  16375. ], FluentMaterial.prototype, "hoverPosition", void 0);
  16376. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16377. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  16378. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  16379. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  16380. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  16381. ], FluentMaterial.prototype, "albedoTexture", void 0);
  16382. return FluentMaterial;
  16383. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  16384. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  16385. /***/ }),
  16386. /***/ "./3D/materials/index.ts":
  16387. /*!*******************************!*\
  16388. !*** ./3D/materials/index.ts ***!
  16389. \*******************************/
  16390. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  16391. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16392. "use strict";
  16393. __webpack_require__.r(__webpack_exports__);
  16394. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  16395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16397. /***/ }),
  16398. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  16399. /*!*************************************************!*\
  16400. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  16401. \*************************************************/
  16402. /*! exports provided: fluentPixelShader */
  16403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16404. "use strict";
  16405. __webpack_require__.r(__webpack_exports__);
  16406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  16407. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  16408. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16409. var name = 'fluentPixelShader';
  16410. 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}";
  16411. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16412. /** @hidden */
  16413. var fluentPixelShader = { name: name, shader: shader };
  16414. /***/ }),
  16415. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  16416. /*!***********************************************!*\
  16417. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  16418. \***********************************************/
  16419. /*! exports provided: fluentVertexShader */
  16420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16421. "use strict";
  16422. __webpack_require__.r(__webpack_exports__);
  16423. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  16424. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Misc/observable");
  16425. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  16426. var name = 'fluentVertexShader';
  16427. 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";
  16428. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  16429. /** @hidden */
  16430. var fluentVertexShader = { name: name, shader: shader };
  16431. /***/ }),
  16432. /***/ "./3D/vector3WithInfo.ts":
  16433. /*!*******************************!*\
  16434. !*** ./3D/vector3WithInfo.ts ***!
  16435. \*******************************/
  16436. /*! exports provided: Vector3WithInfo */
  16437. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16438. "use strict";
  16439. __webpack_require__.r(__webpack_exports__);
  16440. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  16441. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  16442. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable");
  16443. /* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__);
  16444. /**
  16445. * Class used to transport Vector3 information for pointer events
  16446. */
  16447. var Vector3WithInfo = /** @class */ (function (_super) {
  16448. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  16449. /**
  16450. * Creates a new Vector3WithInfo
  16451. * @param source defines the vector3 data to transport
  16452. * @param buttonIndex defines the current mouse button index
  16453. */
  16454. function Vector3WithInfo(source,
  16455. /** defines the current mouse button index */
  16456. buttonIndex) {
  16457. if (buttonIndex === void 0) { buttonIndex = 0; }
  16458. var _this = _super.call(this, source.x, source.y, source.z) || this;
  16459. _this.buttonIndex = buttonIndex;
  16460. return _this;
  16461. }
  16462. return Vector3WithInfo;
  16463. }(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  16464. /***/ }),
  16465. /***/ "./index.ts":
  16466. /*!******************!*\
  16467. !*** ./index.ts ***!
  16468. \******************/
  16469. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16471. "use strict";
  16472. __webpack_require__.r(__webpack_exports__);
  16473. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  16474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16515. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  16516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  16517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  16518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  16519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  16520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  16521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  16522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  16523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  16524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  16525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  16526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  16527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  16528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  16529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  16530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  16531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  16532. /***/ }),
  16533. /***/ "./legacy/legacy.ts":
  16534. /*!**************************!*\
  16535. !*** ./legacy/legacy.ts ***!
  16536. \**************************/
  16537. /*! exports provided: Button, Checkbox, ColorPicker, Container, Control, Ellipse, Grid, Image, InputText, InputPassword, Line, MultiLine, RadioButton, StackPanel, SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel, ScrollViewer, TextWrapping, TextBlock, KeyPropertySet, VirtualKeyboard, Rectangle, DisplayGrid, BaseSlider, Slider, ImageBasedSlider, ScrollBar, ImageScrollBar, name, AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial, GUI3DManager, Vector3WithInfo */
  16538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  16539. "use strict";
  16540. __webpack_require__.r(__webpack_exports__);
  16541. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  16542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  16543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  16544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  16545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  16546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  16547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  16548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  16549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  16550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  16551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  16552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  16553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  16554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  16555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  16556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  16557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  16558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  16559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  16560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  16561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  16562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  16563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  16564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  16565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  16566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  16567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  16568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  16569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  16570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  16571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  16572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  16573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  16574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  16575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  16576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  16577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  16578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  16579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  16580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  16581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  16582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  16583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  16584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  16585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  16586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  16587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  16588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  16589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  16590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  16591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  16592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  16593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  16594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  16595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  16596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  16597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  16598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  16599. /**
  16600. * Legacy support, defining window.BABYLON.GUI (global variable).
  16601. *
  16602. * This is the entry point for the UMD module.
  16603. * The entry point for a future ESM package should be index.ts
  16604. */
  16605. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  16606. if (typeof globalObject !== "undefined") {
  16607. globalObject.BABYLON = globalObject.BABYLON || {};
  16608. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  16609. }
  16610. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  16611. /***/ }),
  16612. /***/ "babylonjs/Misc/observable":
  16613. /*!****************************************************************************************************!*\
  16614. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  16615. \****************************************************************************************************/
  16616. /*! no static exports found */
  16617. /***/ (function(module, exports) {
  16618. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;
  16619. /***/ })
  16620. /******/ });
  16621. });
  16622. //# sourceMappingURL=babylon.gui.js.map