babylon.gui.js 724 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647
  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_Maths_math__) {
  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. !*** E:/Repos/Babylon.js/node_modules/tslib/tslib.es6.js ***!
  101. \***********************************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __spreadArrays, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  126. /*! *****************************************************************************
  127. Copyright (c) Microsoft Corporation. All rights reserved.
  128. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  129. this file except in compliance with the License. You may obtain a copy of the
  130. License at http://www.apache.org/licenses/LICENSE-2.0
  131. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  132. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  133. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  134. MERCHANTABLITY OR NON-INFRINGEMENT.
  135. See the Apache Version 2.0 License for specific language governing permissions
  136. and limitations under the License.
  137. ***************************************************************************** */
  138. /* global Reflect, Promise */
  139. var extendStatics = function(d, b) {
  140. extendStatics = Object.setPrototypeOf ||
  141. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  142. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  143. return extendStatics(d, b);
  144. };
  145. function __extends(d, b) {
  146. extendStatics(d, b);
  147. function __() { this.constructor = d; }
  148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  149. }
  150. var __assign = function() {
  151. __assign = Object.assign || function __assign(t) {
  152. for (var s, i = 1, n = arguments.length; i < n; i++) {
  153. s = arguments[i];
  154. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  155. }
  156. return t;
  157. }
  158. return __assign.apply(this, arguments);
  159. }
  160. function __rest(s, e) {
  161. var t = {};
  162. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  163. t[p] = s[p];
  164. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  165. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  166. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  167. t[p[i]] = s[p[i]];
  168. }
  169. return t;
  170. }
  171. function __decorate(decorators, target, key, desc) {
  172. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  173. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  174. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  175. return c > 3 && r && Object.defineProperty(target, key, r), r;
  176. }
  177. function __param(paramIndex, decorator) {
  178. return function (target, key) { decorator(target, key, paramIndex); }
  179. }
  180. function __metadata(metadataKey, metadataValue) {
  181. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  182. }
  183. function __awaiter(thisArg, _arguments, P, generator) {
  184. return new (P || (P = Promise))(function (resolve, reject) {
  185. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  186. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  187. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  188. step((generator = generator.apply(thisArg, _arguments || [])).next());
  189. });
  190. }
  191. function __generator(thisArg, body) {
  192. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  193. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  194. function verb(n) { return function (v) { return step([n, v]); }; }
  195. function step(op) {
  196. if (f) throw new TypeError("Generator is already executing.");
  197. while (_) try {
  198. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  199. if (y = 0, t) op = [op[0] & 2, t.value];
  200. switch (op[0]) {
  201. case 0: case 1: t = op; break;
  202. case 4: _.label++; return { value: op[1], done: false };
  203. case 5: _.label++; y = op[1]; op = [0]; continue;
  204. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  205. default:
  206. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  207. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  208. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  209. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  210. if (t[2]) _.ops.pop();
  211. _.trys.pop(); continue;
  212. }
  213. op = body.call(thisArg, _);
  214. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  215. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  216. }
  217. }
  218. function __exportStar(m, exports) {
  219. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  220. }
  221. function __values(o) {
  222. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  223. if (m) return m.call(o);
  224. return {
  225. next: function () {
  226. if (o && i >= o.length) o = void 0;
  227. return { value: o && o[i++], done: !o };
  228. }
  229. };
  230. }
  231. function __read(o, n) {
  232. var m = typeof Symbol === "function" && o[Symbol.iterator];
  233. if (!m) return o;
  234. var i = m.call(o), r, ar = [], e;
  235. try {
  236. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  237. }
  238. catch (error) { e = { error: error }; }
  239. finally {
  240. try {
  241. if (r && !r.done && (m = i["return"])) m.call(i);
  242. }
  243. finally { if (e) throw e.error; }
  244. }
  245. return ar;
  246. }
  247. function __spread() {
  248. for (var ar = [], i = 0; i < arguments.length; i++)
  249. ar = ar.concat(__read(arguments[i]));
  250. return ar;
  251. }
  252. function __spreadArrays() {
  253. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  254. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  255. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  256. r[k] = a[j];
  257. return r;
  258. };
  259. function __await(v) {
  260. return this instanceof __await ? (this.v = v, this) : new __await(v);
  261. }
  262. function __asyncGenerator(thisArg, _arguments, generator) {
  263. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  264. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  265. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  266. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  267. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  268. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  269. function fulfill(value) { resume("next", value); }
  270. function reject(value) { resume("throw", value); }
  271. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  272. }
  273. function __asyncDelegator(o) {
  274. var i, p;
  275. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  276. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  277. }
  278. function __asyncValues(o) {
  279. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  280. var m = o[Symbol.asyncIterator], i;
  281. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  282. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  283. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  284. }
  285. function __makeTemplateObject(cooked, raw) {
  286. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  287. return cooked;
  288. };
  289. function __importStar(mod) {
  290. if (mod && mod.__esModule) return mod;
  291. var result = {};
  292. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  293. result.default = mod;
  294. return result;
  295. }
  296. function __importDefault(mod) {
  297. return (mod && mod.__esModule) ? mod : { default: mod };
  298. }
  299. /***/ }),
  300. /***/ "../../node_modules/webpack/buildin/global.js":
  301. /*!***********************************!*\
  302. !*** (webpack)/buildin/global.js ***!
  303. \***********************************/
  304. /*! no static exports found */
  305. /***/ (function(module, exports) {
  306. var g;
  307. // This works in non-strict mode
  308. g = (function() {
  309. return this;
  310. })();
  311. try {
  312. // This works if eval is allowed (see CSP)
  313. g = g || new Function("return this")();
  314. } catch (e) {
  315. // This works if the window reference is available
  316. if (typeof window === "object") g = window;
  317. }
  318. // g can still be undefined, but nothing to do about it...
  319. // We return undefined, instead of nothing here, so it's
  320. // easier to handle this case. if(!global) { ...}
  321. module.exports = g;
  322. /***/ }),
  323. /***/ "./2D/adtInstrumentation.ts":
  324. /*!**********************************!*\
  325. !*** ./2D/adtInstrumentation.ts ***!
  326. \**********************************/
  327. /*! exports provided: AdvancedDynamicTextureInstrumentation */
  328. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  329. "use strict";
  330. __webpack_require__.r(__webpack_exports__);
  331. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return AdvancedDynamicTextureInstrumentation; });
  332. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/perfCounter */ "babylonjs/Maths/math");
  333. /* harmony import */ var babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__);
  334. /**
  335. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  336. */
  337. var AdvancedDynamicTextureInstrumentation = /** @class */ (function () {
  338. /**
  339. * Instantiates a new advanced dynamic texture instrumentation.
  340. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  341. * @param texture Defines the AdvancedDynamicTexture to instrument
  342. */
  343. function AdvancedDynamicTextureInstrumentation(
  344. /**
  345. * Define the instrumented AdvancedDynamicTexture.
  346. */
  347. texture) {
  348. this.texture = texture;
  349. this._captureRenderTime = false;
  350. this._renderTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  351. this._captureLayoutTime = false;
  352. this._layoutTime = new babylonjs_Misc_perfCounter__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  353. // Observers
  354. this._onBeginRenderObserver = null;
  355. this._onEndRenderObserver = null;
  356. this._onBeginLayoutObserver = null;
  357. this._onEndLayoutObserver = null;
  358. }
  359. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "renderTimeCounter", {
  360. // Properties
  361. /**
  362. * Gets the perf counter used to capture render time
  363. */
  364. get: function () {
  365. return this._renderTime;
  366. },
  367. enumerable: true,
  368. configurable: true
  369. });
  370. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "layoutTimeCounter", {
  371. /**
  372. * Gets the perf counter used to capture layout time
  373. */
  374. get: function () {
  375. return this._layoutTime;
  376. },
  377. enumerable: true,
  378. configurable: true
  379. });
  380. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureRenderTime", {
  381. /**
  382. * Enable or disable the render time capture
  383. */
  384. get: function () {
  385. return this._captureRenderTime;
  386. },
  387. set: function (value) {
  388. var _this = this;
  389. if (value === this._captureRenderTime) {
  390. return;
  391. }
  392. this._captureRenderTime = value;
  393. if (value) {
  394. this._onBeginRenderObserver = this.texture.onBeginRenderObservable.add(function () {
  395. _this._renderTime.beginMonitoring();
  396. });
  397. this._onEndRenderObserver = this.texture.onEndRenderObservable.add(function () {
  398. _this._renderTime.endMonitoring(true);
  399. });
  400. }
  401. else {
  402. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  403. this._onBeginRenderObserver = null;
  404. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  405. this._onEndRenderObserver = null;
  406. }
  407. },
  408. enumerable: true,
  409. configurable: true
  410. });
  411. Object.defineProperty(AdvancedDynamicTextureInstrumentation.prototype, "captureLayoutTime", {
  412. /**
  413. * Enable or disable the layout time capture
  414. */
  415. get: function () {
  416. return this._captureLayoutTime;
  417. },
  418. set: function (value) {
  419. var _this = this;
  420. if (value === this._captureLayoutTime) {
  421. return;
  422. }
  423. this._captureLayoutTime = value;
  424. if (value) {
  425. this._onBeginLayoutObserver = this.texture.onBeginLayoutObservable.add(function () {
  426. _this._layoutTime.beginMonitoring();
  427. });
  428. this._onEndLayoutObserver = this.texture.onEndLayoutObservable.add(function () {
  429. _this._layoutTime.endMonitoring(true);
  430. });
  431. }
  432. else {
  433. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  434. this._onBeginLayoutObserver = null;
  435. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  436. this._onEndLayoutObserver = null;
  437. }
  438. },
  439. enumerable: true,
  440. configurable: true
  441. });
  442. /**
  443. * Dispose and release associated resources.
  444. */
  445. AdvancedDynamicTextureInstrumentation.prototype.dispose = function () {
  446. this.texture.onBeginRenderObservable.remove(this._onBeginRenderObserver);
  447. this._onBeginRenderObserver = null;
  448. this.texture.onEndRenderObservable.remove(this._onEndRenderObserver);
  449. this._onEndRenderObserver = null;
  450. this.texture.onBeginLayoutObservable.remove(this._onBeginLayoutObserver);
  451. this._onBeginLayoutObserver = null;
  452. this.texture.onEndLayoutObservable.remove(this._onEndLayoutObserver);
  453. this._onEndLayoutObserver = null;
  454. this.texture = null;
  455. };
  456. return AdvancedDynamicTextureInstrumentation;
  457. }());
  458. /***/ }),
  459. /***/ "./2D/advancedDynamicTexture.ts":
  460. /*!**************************************!*\
  461. !*** ./2D/advancedDynamicTexture.ts ***!
  462. \**************************************/
  463. /*! exports provided: AdvancedDynamicTexture */
  464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  465. "use strict";
  466. __webpack_require__.r(__webpack_exports__);
  467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return AdvancedDynamicTexture; });
  468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  469. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  470. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  471. /* harmony import */ var _controls_container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./controls/container */ "./2D/controls/container.ts");
  472. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  473. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  474. /**
  475. * Class used to create texture to support 2D GUI elements
  476. * @see http://doc.babylonjs.com/how_to/gui
  477. */
  478. var AdvancedDynamicTexture = /** @class */ (function (_super) {
  479. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AdvancedDynamicTexture, _super);
  480. /**
  481. * Creates a new AdvancedDynamicTexture
  482. * @param name defines the name of the texture
  483. * @param width defines the width of the texture
  484. * @param height defines the height of the texture
  485. * @param scene defines the hosting scene
  486. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  487. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  488. */
  489. function AdvancedDynamicTexture(name, width, height, scene, generateMipMaps, samplingMode) {
  490. if (width === void 0) { width = 0; }
  491. if (height === void 0) { height = 0; }
  492. if (generateMipMaps === void 0) { generateMipMaps = false; }
  493. if (samplingMode === void 0) { samplingMode = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].NEAREST_SAMPLINGMODE; }
  494. var _this = _super.call(this, name, { width: width, height: height }, scene, generateMipMaps, samplingMode, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGBA) || this;
  495. _this._isDirty = false;
  496. /** @hidden */
  497. _this._rootContainer = new _controls_container__WEBPACK_IMPORTED_MODULE_2__["Container"]("root");
  498. /** @hidden */
  499. _this._lastControlOver = {};
  500. /** @hidden */
  501. _this._lastControlDown = {};
  502. /** @hidden */
  503. _this._capturingControl = {};
  504. /** @hidden */
  505. _this._linkedControls = new Array();
  506. _this._isFullscreen = false;
  507. _this._fullscreenViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 1, 1);
  508. _this._idealWidth = 0;
  509. _this._idealHeight = 0;
  510. _this._useSmallestIdeal = false;
  511. _this._renderAtIdealSize = false;
  512. _this._blockNextFocusCheck = false;
  513. _this._renderScale = 1;
  514. _this._cursorChanged = false;
  515. /**
  516. * Define type to string to ensure compatibility across browsers
  517. * Safari doesn't support DataTransfer constructor
  518. */
  519. _this._clipboardData = "";
  520. /**
  521. * Observable event triggered each time an clipboard event is received from the rendering canvas
  522. */
  523. _this.onClipboardObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  524. /**
  525. * Observable event triggered each time a pointer down is intercepted by a control
  526. */
  527. _this.onControlPickedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  528. /**
  529. * Observable event triggered before layout is evaluated
  530. */
  531. _this.onBeginLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  532. /**
  533. * Observable event triggered after the layout was evaluated
  534. */
  535. _this.onEndLayoutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  536. /**
  537. * Observable event triggered before the texture is rendered
  538. */
  539. _this.onBeginRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  540. /**
  541. * Observable event triggered after the texture was rendered
  542. */
  543. _this.onEndRenderObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  544. /**
  545. * Gets or sets a boolean defining if alpha is stored as premultiplied
  546. */
  547. _this.premulAlpha = false;
  548. _this._useInvalidateRectOptimization = true;
  549. // Invalidated rectangle which is the combination of all invalidated controls after they have been rotated into absolute position
  550. _this._invalidatedRectangle = null;
  551. _this._clearMeasure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, 0, 0);
  552. /** @hidden */
  553. _this.onClipboardCopy = function (rawEvt) {
  554. var evt = rawEvt;
  555. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY, evt);
  556. _this.onClipboardObservable.notifyObservers(ev);
  557. evt.preventDefault();
  558. };
  559. /** @hidden */
  560. _this.onClipboardCut = function (rawEvt) {
  561. var evt = rawEvt;
  562. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT, evt);
  563. _this.onClipboardObservable.notifyObservers(ev);
  564. evt.preventDefault();
  565. };
  566. /** @hidden */
  567. _this.onClipboardPaste = function (rawEvt) {
  568. var evt = rawEvt;
  569. var ev = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardInfo"](babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE, evt);
  570. _this.onClipboardObservable.notifyObservers(ev);
  571. evt.preventDefault();
  572. };
  573. scene = _this.getScene();
  574. if (!scene || !_this._texture) {
  575. return _this;
  576. }
  577. _this._rootElement = scene.getEngine().getInputElement();
  578. _this._renderObserver = scene.onBeforeCameraRenderObservable.add(function (camera) { return _this._checkUpdate(camera); });
  579. _this._preKeyboardObserver = scene.onPreKeyboardObservable.add(function (info) {
  580. if (!_this._focusedControl) {
  581. return;
  582. }
  583. if (info.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["KeyboardEventTypes"].KEYDOWN) {
  584. _this._focusedControl.processKeyboard(info.event);
  585. }
  586. info.skipOnPointerObservable = true;
  587. });
  588. _this._rootContainer._link(_this);
  589. _this.hasAlpha = true;
  590. if (!width || !height) {
  591. _this._resizeObserver = scene.getEngine().onResizeObservable.add(function () { return _this._onResize(); });
  592. _this._onResize();
  593. }
  594. _this._texture.isReady = true;
  595. return _this;
  596. }
  597. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderScale", {
  598. /**
  599. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  600. * Useful when you want more antialiasing
  601. */
  602. get: function () {
  603. return this._renderScale;
  604. },
  605. set: function (value) {
  606. if (value === this._renderScale) {
  607. return;
  608. }
  609. this._renderScale = value;
  610. this._onResize();
  611. },
  612. enumerable: true,
  613. configurable: true
  614. });
  615. Object.defineProperty(AdvancedDynamicTexture.prototype, "background", {
  616. /** Gets or sets the background color */
  617. get: function () {
  618. return this._background;
  619. },
  620. set: function (value) {
  621. if (this._background === value) {
  622. return;
  623. }
  624. this._background = value;
  625. this.markAsDirty();
  626. },
  627. enumerable: true,
  628. configurable: true
  629. });
  630. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealWidth", {
  631. /**
  632. * Gets or sets the ideal width used to design controls.
  633. * The GUI will then rescale everything accordingly
  634. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  635. */
  636. get: function () {
  637. return this._idealWidth;
  638. },
  639. set: function (value) {
  640. if (this._idealWidth === value) {
  641. return;
  642. }
  643. this._idealWidth = value;
  644. this.markAsDirty();
  645. this._rootContainer._markAllAsDirty();
  646. },
  647. enumerable: true,
  648. configurable: true
  649. });
  650. Object.defineProperty(AdvancedDynamicTexture.prototype, "idealHeight", {
  651. /**
  652. * Gets or sets the ideal height used to design controls.
  653. * The GUI will then rescale everything accordingly
  654. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  655. */
  656. get: function () {
  657. return this._idealHeight;
  658. },
  659. set: function (value) {
  660. if (this._idealHeight === value) {
  661. return;
  662. }
  663. this._idealHeight = value;
  664. this.markAsDirty();
  665. this._rootContainer._markAllAsDirty();
  666. },
  667. enumerable: true,
  668. configurable: true
  669. });
  670. Object.defineProperty(AdvancedDynamicTexture.prototype, "useSmallestIdeal", {
  671. /**
  672. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  673. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  674. */
  675. get: function () {
  676. return this._useSmallestIdeal;
  677. },
  678. set: function (value) {
  679. if (this._useSmallestIdeal === value) {
  680. return;
  681. }
  682. this._useSmallestIdeal = value;
  683. this.markAsDirty();
  684. this._rootContainer._markAllAsDirty();
  685. },
  686. enumerable: true,
  687. configurable: true
  688. });
  689. Object.defineProperty(AdvancedDynamicTexture.prototype, "renderAtIdealSize", {
  690. /**
  691. * Gets or sets a boolean indicating if adaptive scaling must be used
  692. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  693. */
  694. get: function () {
  695. return this._renderAtIdealSize;
  696. },
  697. set: function (value) {
  698. if (this._renderAtIdealSize === value) {
  699. return;
  700. }
  701. this._renderAtIdealSize = value;
  702. this._onResize();
  703. },
  704. enumerable: true,
  705. configurable: true
  706. });
  707. Object.defineProperty(AdvancedDynamicTexture.prototype, "layer", {
  708. /**
  709. * Gets the underlying layer used to render the texture when in fullscreen mode
  710. */
  711. get: function () {
  712. return this._layerToDispose;
  713. },
  714. enumerable: true,
  715. configurable: true
  716. });
  717. Object.defineProperty(AdvancedDynamicTexture.prototype, "rootContainer", {
  718. /**
  719. * Gets the root container control
  720. */
  721. get: function () {
  722. return this._rootContainer;
  723. },
  724. enumerable: true,
  725. configurable: true
  726. });
  727. /**
  728. * Returns an array containing the root container.
  729. * This is mostly used to let the Inspector introspects the ADT
  730. * @returns an array containing the rootContainer
  731. */
  732. AdvancedDynamicTexture.prototype.getChildren = function () {
  733. return [this._rootContainer];
  734. };
  735. /**
  736. * Will return all controls that are inside this texture
  737. * @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
  738. * @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
  739. * @return all child controls
  740. */
  741. AdvancedDynamicTexture.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  742. return this._rootContainer.getDescendants(directDescendantsOnly, predicate);
  743. };
  744. Object.defineProperty(AdvancedDynamicTexture.prototype, "focusedControl", {
  745. /**
  746. * Gets or sets the current focused control
  747. */
  748. get: function () {
  749. return this._focusedControl;
  750. },
  751. set: function (control) {
  752. if (this._focusedControl == control) {
  753. return;
  754. }
  755. if (this._focusedControl) {
  756. this._focusedControl.onBlur();
  757. }
  758. if (control) {
  759. control.onFocus();
  760. }
  761. this._focusedControl = control;
  762. },
  763. enumerable: true,
  764. configurable: true
  765. });
  766. Object.defineProperty(AdvancedDynamicTexture.prototype, "isForeground", {
  767. /**
  768. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  769. */
  770. get: function () {
  771. if (!this.layer) {
  772. return true;
  773. }
  774. return (!this.layer.isBackground);
  775. },
  776. set: function (value) {
  777. if (!this.layer) {
  778. return;
  779. }
  780. if (this.layer.isBackground === !value) {
  781. return;
  782. }
  783. this.layer.isBackground = !value;
  784. },
  785. enumerable: true,
  786. configurable: true
  787. });
  788. Object.defineProperty(AdvancedDynamicTexture.prototype, "clipboardData", {
  789. /**
  790. * Gets or set information about clipboardData
  791. */
  792. get: function () {
  793. return this._clipboardData;
  794. },
  795. set: function (value) {
  796. this._clipboardData = value;
  797. },
  798. enumerable: true,
  799. configurable: true
  800. });
  801. /**
  802. * Get the current class name of the texture useful for serialization or dynamic coding.
  803. * @returns "AdvancedDynamicTexture"
  804. */
  805. AdvancedDynamicTexture.prototype.getClassName = function () {
  806. return "AdvancedDynamicTexture";
  807. };
  808. /**
  809. * Function used to execute a function on all controls
  810. * @param func defines the function to execute
  811. * @param container defines the container where controls belong. If null the root container will be used
  812. */
  813. AdvancedDynamicTexture.prototype.executeOnAllControls = function (func, container) {
  814. if (!container) {
  815. container = this._rootContainer;
  816. }
  817. func(container);
  818. for (var _i = 0, _a = container.children; _i < _a.length; _i++) {
  819. var child = _a[_i];
  820. if (child.children) {
  821. this.executeOnAllControls(func, child);
  822. continue;
  823. }
  824. func(child);
  825. }
  826. };
  827. Object.defineProperty(AdvancedDynamicTexture.prototype, "useInvalidateRectOptimization", {
  828. /**
  829. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  830. */
  831. get: function () {
  832. return this._useInvalidateRectOptimization;
  833. },
  834. set: function (value) {
  835. this._useInvalidateRectOptimization = value;
  836. },
  837. enumerable: true,
  838. configurable: true
  839. });
  840. /**
  841. * Invalidates a rectangle area on the gui texture
  842. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  843. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  844. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  845. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  846. */
  847. AdvancedDynamicTexture.prototype.invalidateRect = function (invalidMinX, invalidMinY, invalidMaxX, invalidMaxY) {
  848. if (!this._useInvalidateRectOptimization) {
  849. return;
  850. }
  851. if (!this._invalidatedRectangle) {
  852. this._invalidatedRectangle = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](invalidMinX, invalidMinY, invalidMaxX - invalidMinX + 1, invalidMaxY - invalidMinY + 1);
  853. }
  854. else {
  855. // Compute intersection
  856. var maxX = Math.ceil(Math.max(this._invalidatedRectangle.left + this._invalidatedRectangle.width - 1, invalidMaxX));
  857. var maxY = Math.ceil(Math.max(this._invalidatedRectangle.top + this._invalidatedRectangle.height - 1, invalidMaxY));
  858. this._invalidatedRectangle.left = Math.floor(Math.min(this._invalidatedRectangle.left, invalidMinX));
  859. this._invalidatedRectangle.top = Math.floor(Math.min(this._invalidatedRectangle.top, invalidMinY));
  860. this._invalidatedRectangle.width = maxX - this._invalidatedRectangle.left + 1;
  861. this._invalidatedRectangle.height = maxY - this._invalidatedRectangle.top + 1;
  862. }
  863. };
  864. /**
  865. * Marks the texture as dirty forcing a complete update
  866. */
  867. AdvancedDynamicTexture.prototype.markAsDirty = function () {
  868. this._isDirty = true;
  869. };
  870. /**
  871. * Helper function used to create a new style
  872. * @returns a new style
  873. * @see http://doc.babylonjs.com/how_to/gui#styles
  874. */
  875. AdvancedDynamicTexture.prototype.createStyle = function () {
  876. return new _style__WEBPACK_IMPORTED_MODULE_3__["Style"](this);
  877. };
  878. /**
  879. * Adds a new control to the root container
  880. * @param control defines the control to add
  881. * @returns the current texture
  882. */
  883. AdvancedDynamicTexture.prototype.addControl = function (control) {
  884. this._rootContainer.addControl(control);
  885. return this;
  886. };
  887. /**
  888. * Removes a control from the root container
  889. * @param control defines the control to remove
  890. * @returns the current texture
  891. */
  892. AdvancedDynamicTexture.prototype.removeControl = function (control) {
  893. this._rootContainer.removeControl(control);
  894. return this;
  895. };
  896. /**
  897. * Release all resources
  898. */
  899. AdvancedDynamicTexture.prototype.dispose = function () {
  900. var scene = this.getScene();
  901. if (!scene) {
  902. return;
  903. }
  904. this._rootElement = null;
  905. scene.onBeforeCameraRenderObservable.remove(this._renderObserver);
  906. if (this._resizeObserver) {
  907. scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  908. }
  909. if (this._pointerMoveObserver) {
  910. scene.onPrePointerObservable.remove(this._pointerMoveObserver);
  911. }
  912. if (this._pointerObserver) {
  913. scene.onPointerObservable.remove(this._pointerObserver);
  914. }
  915. if (this._preKeyboardObserver) {
  916. scene.onPreKeyboardObservable.remove(this._preKeyboardObserver);
  917. }
  918. if (this._canvasPointerOutObserver) {
  919. scene.getEngine().onCanvasPointerOutObservable.remove(this._canvasPointerOutObserver);
  920. }
  921. if (this._layerToDispose) {
  922. this._layerToDispose.texture = null;
  923. this._layerToDispose.dispose();
  924. this._layerToDispose = null;
  925. }
  926. this._rootContainer.dispose();
  927. this.onClipboardObservable.clear();
  928. this.onControlPickedObservable.clear();
  929. this.onBeginRenderObservable.clear();
  930. this.onEndRenderObservable.clear();
  931. this.onBeginLayoutObservable.clear();
  932. this.onEndLayoutObservable.clear();
  933. _super.prototype.dispose.call(this);
  934. };
  935. AdvancedDynamicTexture.prototype._onResize = function () {
  936. var scene = this.getScene();
  937. if (!scene) {
  938. return;
  939. }
  940. // Check size
  941. var engine = scene.getEngine();
  942. var textureSize = this.getSize();
  943. var renderWidth = engine.getRenderWidth() * this._renderScale;
  944. var renderHeight = engine.getRenderHeight() * this._renderScale;
  945. if (this._renderAtIdealSize) {
  946. if (this._idealWidth) {
  947. renderHeight = (renderHeight * this._idealWidth) / renderWidth;
  948. renderWidth = this._idealWidth;
  949. }
  950. else if (this._idealHeight) {
  951. renderWidth = (renderWidth * this._idealHeight) / renderHeight;
  952. renderHeight = this._idealHeight;
  953. }
  954. }
  955. if (textureSize.width !== renderWidth || textureSize.height !== renderHeight) {
  956. this.scaleTo(renderWidth, renderHeight);
  957. this.markAsDirty();
  958. if (this._idealWidth || this._idealHeight) {
  959. this._rootContainer._markAllAsDirty();
  960. }
  961. }
  962. this.invalidateRect(0, 0, textureSize.width - 1, textureSize.height - 1);
  963. };
  964. /** @hidden */
  965. AdvancedDynamicTexture.prototype._getGlobalViewport = function (scene) {
  966. var engine = scene.getEngine();
  967. return this._fullscreenViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  968. };
  969. /**
  970. * Get screen coordinates for a vector3
  971. * @param position defines the position to project
  972. * @param worldMatrix defines the world matrix to use
  973. * @returns the projected position
  974. */
  975. AdvancedDynamicTexture.prototype.getProjectedPosition = function (position, worldMatrix) {
  976. var scene = this.getScene();
  977. if (!scene) {
  978. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"].Zero();
  979. }
  980. var globalViewport = this._getGlobalViewport(scene);
  981. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, worldMatrix, scene.getTransformMatrix(), globalViewport);
  982. projectedPosition.scaleInPlace(this.renderScale);
  983. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector2"](projectedPosition.x, projectedPosition.y);
  984. };
  985. AdvancedDynamicTexture.prototype._checkUpdate = function (camera) {
  986. if (this._layerToDispose) {
  987. if ((camera.layerMask & this._layerToDispose.layerMask) === 0) {
  988. return;
  989. }
  990. }
  991. if (this._isFullscreen && this._linkedControls.length) {
  992. var scene = this.getScene();
  993. if (!scene) {
  994. return;
  995. }
  996. var globalViewport = this._getGlobalViewport(scene);
  997. for (var _i = 0, _a = this._linkedControls; _i < _a.length; _i++) {
  998. var control = _a[_i];
  999. if (!control.isVisible) {
  1000. continue;
  1001. }
  1002. var mesh = control._linkedMesh;
  1003. if (!mesh || mesh.isDisposed()) {
  1004. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  1005. control.linkWithMesh(null);
  1006. });
  1007. continue;
  1008. }
  1009. var position = mesh.getBoundingInfo ? mesh.getBoundingInfo().boundingSphere.center : babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ZeroReadOnly;
  1010. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, mesh.getWorldMatrix(), scene.getTransformMatrix(), globalViewport);
  1011. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  1012. control.notRenderable = true;
  1013. continue;
  1014. }
  1015. control.notRenderable = false;
  1016. // Account for RenderScale.
  1017. projectedPosition.scaleInPlace(this.renderScale);
  1018. control._moveToProjectedPosition(projectedPosition);
  1019. }
  1020. }
  1021. if (!this._isDirty && !this._rootContainer.isDirty) {
  1022. return;
  1023. }
  1024. this._isDirty = false;
  1025. this._render();
  1026. this.update(true, this.premulAlpha);
  1027. };
  1028. AdvancedDynamicTexture.prototype._render = function () {
  1029. var textureSize = this.getSize();
  1030. var renderWidth = textureSize.width;
  1031. var renderHeight = textureSize.height;
  1032. var context = this.getContext();
  1033. context.font = "18px Arial";
  1034. context.strokeStyle = "white";
  1035. // Layout
  1036. this.onBeginLayoutObservable.notifyObservers(this);
  1037. var measure = new _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"](0, 0, renderWidth, renderHeight);
  1038. this._rootContainer._layout(measure, context);
  1039. this.onEndLayoutObservable.notifyObservers(this);
  1040. this._isDirty = false; // Restoring the dirty state that could have been set by controls during layout processing
  1041. // Clear
  1042. if (this._invalidatedRectangle) {
  1043. this._clearMeasure.copyFrom(this._invalidatedRectangle);
  1044. }
  1045. else {
  1046. this._clearMeasure.copyFromFloats(0, 0, renderWidth, renderHeight);
  1047. }
  1048. context.clearRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1049. if (this._background) {
  1050. context.save();
  1051. context.fillStyle = this._background;
  1052. context.fillRect(this._clearMeasure.left, this._clearMeasure.top, this._clearMeasure.width, this._clearMeasure.height);
  1053. context.restore();
  1054. }
  1055. // Render
  1056. this.onBeginRenderObservable.notifyObservers(this);
  1057. this._rootContainer._render(context, this._invalidatedRectangle);
  1058. this.onEndRenderObservable.notifyObservers(this);
  1059. this._invalidatedRectangle = null;
  1060. };
  1061. /** @hidden */
  1062. AdvancedDynamicTexture.prototype._changeCursor = function (cursor) {
  1063. if (this._rootElement) {
  1064. this._rootElement.style.cursor = cursor;
  1065. this._cursorChanged = true;
  1066. }
  1067. };
  1068. /** @hidden */
  1069. AdvancedDynamicTexture.prototype._registerLastControlDown = function (control, pointerId) {
  1070. this._lastControlDown[pointerId] = control;
  1071. this.onControlPickedObservable.notifyObservers(control);
  1072. };
  1073. AdvancedDynamicTexture.prototype._doPicking = function (x, y, type, pointerId, buttonIndex) {
  1074. var scene = this.getScene();
  1075. if (!scene) {
  1076. return;
  1077. }
  1078. var engine = scene.getEngine();
  1079. var textureSize = this.getSize();
  1080. if (this._isFullscreen) {
  1081. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1082. var viewport = camera.viewport;
  1083. x = x * (textureSize.width / (engine.getRenderWidth() * viewport.width));
  1084. y = y * (textureSize.height / (engine.getRenderHeight() * viewport.height));
  1085. }
  1086. if (this._capturingControl[pointerId]) {
  1087. this._capturingControl[pointerId]._processObservables(type, x, y, pointerId, buttonIndex);
  1088. return;
  1089. }
  1090. this._cursorChanged = false;
  1091. if (!this._rootContainer._processPicking(x, y, type, pointerId, buttonIndex)) {
  1092. this._changeCursor("");
  1093. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1094. if (this._lastControlOver[pointerId]) {
  1095. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  1096. delete this._lastControlOver[pointerId];
  1097. }
  1098. }
  1099. }
  1100. if (!this._cursorChanged) {
  1101. this._changeCursor("");
  1102. }
  1103. this._manageFocus();
  1104. };
  1105. /** @hidden */
  1106. AdvancedDynamicTexture.prototype._cleanControlAfterRemovalFromList = function (list, control) {
  1107. for (var pointerId in list) {
  1108. if (!list.hasOwnProperty(pointerId)) {
  1109. continue;
  1110. }
  1111. var lastControlOver = list[pointerId];
  1112. if (lastControlOver === control) {
  1113. delete list[pointerId];
  1114. }
  1115. }
  1116. };
  1117. /** @hidden */
  1118. AdvancedDynamicTexture.prototype._cleanControlAfterRemoval = function (control) {
  1119. this._cleanControlAfterRemovalFromList(this._lastControlDown, control);
  1120. this._cleanControlAfterRemovalFromList(this._lastControlOver, control);
  1121. };
  1122. /** Attach to all scene events required to support pointer events */
  1123. AdvancedDynamicTexture.prototype.attach = function () {
  1124. var _this = this;
  1125. var scene = this.getScene();
  1126. if (!scene) {
  1127. return;
  1128. }
  1129. var tempViewport = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0, 0);
  1130. this._pointerMoveObserver = scene.onPrePointerObservable.add(function (pi, state) {
  1131. if (scene.isPointerCaptured((pi.event).pointerId)) {
  1132. return;
  1133. }
  1134. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1135. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1136. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1137. return;
  1138. }
  1139. if (!scene) {
  1140. return;
  1141. }
  1142. var camera = scene.cameraToUseForPointers || scene.activeCamera;
  1143. var engine = scene.getEngine();
  1144. if (!camera) {
  1145. tempViewport.x = 0;
  1146. tempViewport.y = 0;
  1147. tempViewport.width = engine.getRenderWidth();
  1148. tempViewport.height = engine.getRenderHeight();
  1149. }
  1150. else {
  1151. camera.viewport.toGlobalToRef(engine.getRenderWidth(), engine.getRenderHeight(), tempViewport);
  1152. }
  1153. var x = scene.pointerX / engine.getHardwareScalingLevel() - tempViewport.x;
  1154. var y = scene.pointerY / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - tempViewport.y - tempViewport.height);
  1155. _this._shouldBlockPointer = false;
  1156. // Do picking modifies _shouldBlockPointer
  1157. _this._doPicking(x, y, pi.type, pi.event.pointerId || 0, pi.event.button);
  1158. // Avoid overwriting a true skipOnPointerObservable to false
  1159. if (_this._shouldBlockPointer) {
  1160. pi.skipOnPointerObservable = _this._shouldBlockPointer;
  1161. }
  1162. });
  1163. this._attachToOnPointerOut(scene);
  1164. };
  1165. /**
  1166. * Register the clipboard Events onto the canvas
  1167. */
  1168. AdvancedDynamicTexture.prototype.registerClipboardEvents = function () {
  1169. self.addEventListener("copy", this.onClipboardCopy, false);
  1170. self.addEventListener("cut", this.onClipboardCut, false);
  1171. self.addEventListener("paste", this.onClipboardPaste, false);
  1172. };
  1173. /**
  1174. * Unregister the clipboard Events from the canvas
  1175. */
  1176. AdvancedDynamicTexture.prototype.unRegisterClipboardEvents = function () {
  1177. self.removeEventListener("copy", this.onClipboardCopy);
  1178. self.removeEventListener("cut", this.onClipboardCut);
  1179. self.removeEventListener("paste", this.onClipboardPaste);
  1180. };
  1181. /**
  1182. * Connect the texture to a hosting mesh to enable interactions
  1183. * @param mesh defines the mesh to attach to
  1184. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  1185. */
  1186. AdvancedDynamicTexture.prototype.attachToMesh = function (mesh, supportPointerMove) {
  1187. var _this = this;
  1188. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1189. var scene = this.getScene();
  1190. if (!scene) {
  1191. return;
  1192. }
  1193. this._pointerObserver = scene.onPointerObservable.add(function (pi, state) {
  1194. if (pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE
  1195. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP
  1196. && pi.type !== babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  1197. return;
  1198. }
  1199. var pointerId = pi.event.pointerId || 0;
  1200. if (pi.pickInfo && pi.pickInfo.hit && pi.pickInfo.pickedMesh === mesh) {
  1201. var uv = pi.pickInfo.getTextureCoordinates();
  1202. if (uv) {
  1203. var size = _this.getSize();
  1204. _this._doPicking(uv.x * size.width, (1.0 - uv.y) * size.height, pi.type, pointerId, pi.event.button);
  1205. }
  1206. }
  1207. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  1208. if (_this._lastControlDown[pointerId]) {
  1209. _this._lastControlDown[pointerId]._forcePointerUp(pointerId);
  1210. }
  1211. delete _this._lastControlDown[pointerId];
  1212. if (_this.focusedControl) {
  1213. var friendlyControls = _this.focusedControl.keepsFocusWith();
  1214. var canMoveFocus = true;
  1215. if (friendlyControls) {
  1216. for (var _i = 0, friendlyControls_1 = friendlyControls; _i < friendlyControls_1.length; _i++) {
  1217. var control = friendlyControls_1[_i];
  1218. // Same host, no need to keep the focus
  1219. if (_this === control._host) {
  1220. continue;
  1221. }
  1222. // Different hosts
  1223. var otherHost = control._host;
  1224. if (otherHost._lastControlOver[pointerId] && otherHost._lastControlOver[pointerId].isAscendant(control)) {
  1225. canMoveFocus = false;
  1226. break;
  1227. }
  1228. }
  1229. }
  1230. if (canMoveFocus) {
  1231. _this.focusedControl = null;
  1232. }
  1233. }
  1234. }
  1235. else if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERMOVE) {
  1236. if (_this._lastControlOver[pointerId]) {
  1237. _this._lastControlOver[pointerId]._onPointerOut(_this._lastControlOver[pointerId], true);
  1238. }
  1239. delete _this._lastControlOver[pointerId];
  1240. }
  1241. });
  1242. mesh.enablePointerMoveEvents = supportPointerMove;
  1243. this._attachToOnPointerOut(scene);
  1244. };
  1245. /**
  1246. * Move the focus to a specific control
  1247. * @param control defines the control which will receive the focus
  1248. */
  1249. AdvancedDynamicTexture.prototype.moveFocusToControl = function (control) {
  1250. this.focusedControl = control;
  1251. this._lastPickedControl = control;
  1252. this._blockNextFocusCheck = true;
  1253. };
  1254. AdvancedDynamicTexture.prototype._manageFocus = function () {
  1255. if (this._blockNextFocusCheck) {
  1256. this._blockNextFocusCheck = false;
  1257. this._lastPickedControl = this._focusedControl;
  1258. return;
  1259. }
  1260. // Focus management
  1261. if (this._focusedControl) {
  1262. if (this._focusedControl !== this._lastPickedControl) {
  1263. if (this._lastPickedControl.isFocusInvisible) {
  1264. return;
  1265. }
  1266. this.focusedControl = null;
  1267. }
  1268. }
  1269. };
  1270. AdvancedDynamicTexture.prototype._attachToOnPointerOut = function (scene) {
  1271. var _this = this;
  1272. this._canvasPointerOutObserver = scene.getEngine().onCanvasPointerOutObservable.add(function (pointerEvent) {
  1273. if (_this._lastControlOver[pointerEvent.pointerId]) {
  1274. _this._lastControlOver[pointerEvent.pointerId]._onPointerOut(_this._lastControlOver[pointerEvent.pointerId]);
  1275. }
  1276. delete _this._lastControlOver[pointerEvent.pointerId];
  1277. if (_this._lastControlDown[pointerEvent.pointerId] && _this._lastControlDown[pointerEvent.pointerId] !== _this._capturingControl[pointerEvent.pointerId]) {
  1278. _this._lastControlDown[pointerEvent.pointerId]._forcePointerUp();
  1279. delete _this._lastControlDown[pointerEvent.pointerId];
  1280. }
  1281. });
  1282. };
  1283. // Statics
  1284. /**
  1285. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  1286. * @param mesh defines the mesh which will receive the texture
  1287. * @param width defines the texture width (1024 by default)
  1288. * @param height defines the texture height (1024 by default)
  1289. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  1290. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  1291. * @returns a new AdvancedDynamicTexture
  1292. */
  1293. AdvancedDynamicTexture.CreateForMesh = function (mesh, width, height, supportPointerMove, onlyAlphaTesting) {
  1294. if (width === void 0) { width = 1024; }
  1295. if (height === void 0) { height = 1024; }
  1296. if (supportPointerMove === void 0) { supportPointerMove = true; }
  1297. if (onlyAlphaTesting === void 0) { onlyAlphaTesting = false; }
  1298. var result = new AdvancedDynamicTexture(mesh.name + " AdvancedDynamicTexture", width, height, mesh.getScene(), true, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  1299. var material = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("AdvancedDynamicTextureMaterial", mesh.getScene());
  1300. material.backFaceCulling = false;
  1301. material.diffuseColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1302. material.specularColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  1303. if (onlyAlphaTesting) {
  1304. material.diffuseTexture = result;
  1305. material.emissiveTexture = result;
  1306. result.hasAlpha = true;
  1307. }
  1308. else {
  1309. material.emissiveTexture = result;
  1310. material.opacityTexture = result;
  1311. }
  1312. mesh.material = material;
  1313. result.attachToMesh(mesh, supportPointerMove);
  1314. return result;
  1315. };
  1316. /**
  1317. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  1318. * In this mode the texture will rely on a layer for its rendering.
  1319. * This allows it to be treated like any other layer.
  1320. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  1321. * LayerMask is set through advancedTexture.layer.layerMask
  1322. * @param name defines name for the texture
  1323. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  1324. * @param scene defines the hsoting scene
  1325. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  1326. * @returns a new AdvancedDynamicTexture
  1327. */
  1328. AdvancedDynamicTexture.CreateFullscreenUI = function (name, foreground, scene, sampling) {
  1329. if (foreground === void 0) { foreground = true; }
  1330. if (scene === void 0) { scene = null; }
  1331. if (sampling === void 0) { sampling = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  1332. var result = new AdvancedDynamicTexture(name, 0, 0, scene, false, sampling);
  1333. // Display
  1334. var layer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Layer"](name + "_layer", null, scene, !foreground);
  1335. layer.texture = result;
  1336. result._layerToDispose = layer;
  1337. result._isFullscreen = true;
  1338. // Attach
  1339. result.attach();
  1340. return result;
  1341. };
  1342. return AdvancedDynamicTexture;
  1343. }(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["DynamicTexture"]));
  1344. /***/ }),
  1345. /***/ "./2D/controls/button.ts":
  1346. /*!*******************************!*\
  1347. !*** ./2D/controls/button.ts ***!
  1348. \*******************************/
  1349. /*! exports provided: Button */
  1350. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1351. "use strict";
  1352. __webpack_require__.r(__webpack_exports__);
  1353. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return Button; });
  1354. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1355. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1356. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1357. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1358. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  1359. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  1360. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__);
  1361. /**
  1362. * Class used to create 2D buttons
  1363. */
  1364. var Button = /** @class */ (function (_super) {
  1365. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button, _super);
  1366. /**
  1367. * Creates a new Button
  1368. * @param name defines the name of the button
  1369. */
  1370. function Button(name) {
  1371. var _this = _super.call(this, name) || this;
  1372. _this.name = name;
  1373. /**
  1374. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  1375. */
  1376. _this.delegatePickingToChildren = false;
  1377. _this.thickness = 1;
  1378. _this.isPointerBlocker = true;
  1379. var alphaStore = null;
  1380. _this.pointerEnterAnimation = function () {
  1381. alphaStore = _this.alpha;
  1382. _this.alpha -= 0.1;
  1383. };
  1384. _this.pointerOutAnimation = function () {
  1385. if (alphaStore !== null) {
  1386. _this.alpha = alphaStore;
  1387. }
  1388. };
  1389. _this.pointerDownAnimation = function () {
  1390. _this.scaleX -= 0.05;
  1391. _this.scaleY -= 0.05;
  1392. };
  1393. _this.pointerUpAnimation = function () {
  1394. _this.scaleX += 0.05;
  1395. _this.scaleY += 0.05;
  1396. };
  1397. return _this;
  1398. }
  1399. Object.defineProperty(Button.prototype, "image", {
  1400. /**
  1401. * Returns the image part of the button (if any)
  1402. */
  1403. get: function () {
  1404. return this._image;
  1405. },
  1406. enumerable: true,
  1407. configurable: true
  1408. });
  1409. Object.defineProperty(Button.prototype, "textBlock", {
  1410. /**
  1411. * Returns the image part of the button (if any)
  1412. */
  1413. get: function () {
  1414. return this._textBlock;
  1415. },
  1416. enumerable: true,
  1417. configurable: true
  1418. });
  1419. Button.prototype._getTypeName = function () {
  1420. return "Button";
  1421. };
  1422. // While being a container, the button behaves like a control.
  1423. /** @hidden */
  1424. Button.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  1425. if (!this._isEnabled || !this.isHitTestVisible || !this.isVisible || this.notRenderable) {
  1426. return false;
  1427. }
  1428. if (!_super.prototype.contains.call(this, x, y)) {
  1429. return false;
  1430. }
  1431. if (this.delegatePickingToChildren) {
  1432. var contains = false;
  1433. for (var index = this._children.length - 1; index >= 0; index--) {
  1434. var child = this._children[index];
  1435. if (child.isEnabled && child.isHitTestVisible && child.isVisible && !child.notRenderable && child.contains(x, y)) {
  1436. contains = true;
  1437. break;
  1438. }
  1439. }
  1440. if (!contains) {
  1441. return false;
  1442. }
  1443. }
  1444. this._processObservables(type, x, y, pointerId, buttonIndex);
  1445. return true;
  1446. };
  1447. /** @hidden */
  1448. Button.prototype._onPointerEnter = function (target) {
  1449. if (!_super.prototype._onPointerEnter.call(this, target)) {
  1450. return false;
  1451. }
  1452. if (this.pointerEnterAnimation) {
  1453. this.pointerEnterAnimation();
  1454. }
  1455. return true;
  1456. };
  1457. /** @hidden */
  1458. Button.prototype._onPointerOut = function (target, force) {
  1459. if (force === void 0) { force = false; }
  1460. if (this.pointerOutAnimation) {
  1461. this.pointerOutAnimation();
  1462. }
  1463. _super.prototype._onPointerOut.call(this, target, force);
  1464. };
  1465. /** @hidden */
  1466. Button.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1467. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1468. return false;
  1469. }
  1470. if (this.pointerDownAnimation) {
  1471. this.pointerDownAnimation();
  1472. }
  1473. return true;
  1474. };
  1475. /** @hidden */
  1476. Button.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  1477. if (this.pointerUpAnimation) {
  1478. this.pointerUpAnimation();
  1479. }
  1480. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  1481. };
  1482. // Statics
  1483. /**
  1484. * Creates a new button made with an image and a text
  1485. * @param name defines the name of the button
  1486. * @param text defines the text of the button
  1487. * @param imageUrl defines the url of the image
  1488. * @returns a new Button
  1489. */
  1490. Button.CreateImageButton = function (name, text, imageUrl) {
  1491. var result = new Button(name);
  1492. // Adding text
  1493. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1494. textBlock.textWrapping = true;
  1495. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1496. textBlock.paddingLeft = "20%";
  1497. result.addControl(textBlock);
  1498. // Adding image
  1499. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1500. iconImage.width = "20%";
  1501. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_UNIFORM;
  1502. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1503. result.addControl(iconImage);
  1504. // Store
  1505. result._image = iconImage;
  1506. result._textBlock = textBlock;
  1507. return result;
  1508. };
  1509. /**
  1510. * Creates a new button made with an image
  1511. * @param name defines the name of the button
  1512. * @param imageUrl defines the url of the image
  1513. * @returns a new Button
  1514. */
  1515. Button.CreateImageOnlyButton = function (name, imageUrl) {
  1516. var result = new Button(name);
  1517. // Adding image
  1518. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1519. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1520. iconImage.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1521. result.addControl(iconImage);
  1522. // Store
  1523. result._image = iconImage;
  1524. return result;
  1525. };
  1526. /**
  1527. * Creates a new button made with a text
  1528. * @param name defines the name of the button
  1529. * @param text defines the text of the button
  1530. * @returns a new Button
  1531. */
  1532. Button.CreateSimpleButton = function (name, text) {
  1533. var result = new Button(name);
  1534. // Adding text
  1535. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1536. textBlock.textWrapping = true;
  1537. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1538. result.addControl(textBlock);
  1539. // Store
  1540. result._textBlock = textBlock;
  1541. return result;
  1542. };
  1543. /**
  1544. * Creates a new button made with an image and a centered text
  1545. * @param name defines the name of the button
  1546. * @param text defines the text of the button
  1547. * @param imageUrl defines the url of the image
  1548. * @returns a new Button
  1549. */
  1550. Button.CreateImageWithCenterTextButton = function (name, text, imageUrl) {
  1551. var result = new Button(name);
  1552. // Adding image
  1553. var iconImage = new _image__WEBPACK_IMPORTED_MODULE_4__["Image"](name + "_icon", imageUrl);
  1554. iconImage.stretch = _image__WEBPACK_IMPORTED_MODULE_4__["Image"].STRETCH_FILL;
  1555. result.addControl(iconImage);
  1556. // Adding text
  1557. var textBlock = new _textBlock__WEBPACK_IMPORTED_MODULE_3__["TextBlock"](name + "_button", text);
  1558. textBlock.textWrapping = true;
  1559. textBlock.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  1560. result.addControl(textBlock);
  1561. // Store
  1562. result._image = iconImage;
  1563. result._textBlock = textBlock;
  1564. return result;
  1565. };
  1566. return Button;
  1567. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  1568. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Button"] = Button;
  1569. /***/ }),
  1570. /***/ "./2D/controls/checkbox.ts":
  1571. /*!*********************************!*\
  1572. !*** ./2D/controls/checkbox.ts ***!
  1573. \*********************************/
  1574. /*! exports provided: Checkbox */
  1575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1576. "use strict";
  1577. __webpack_require__.r(__webpack_exports__);
  1578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return Checkbox; });
  1579. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1580. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  1581. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1582. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1583. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  1584. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  1585. /**
  1586. * Class used to represent a 2D checkbox
  1587. */
  1588. var Checkbox = /** @class */ (function (_super) {
  1589. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Checkbox, _super);
  1590. /**
  1591. * Creates a new CheckBox
  1592. * @param name defines the control name
  1593. */
  1594. function Checkbox(name) {
  1595. var _this = _super.call(this, name) || this;
  1596. _this.name = name;
  1597. _this._isChecked = false;
  1598. _this._background = "black";
  1599. _this._checkSizeRatio = 0.8;
  1600. _this._thickness = 1;
  1601. /**
  1602. * Observable raised when isChecked property changes
  1603. */
  1604. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1605. _this.isPointerBlocker = true;
  1606. return _this;
  1607. }
  1608. Object.defineProperty(Checkbox.prototype, "thickness", {
  1609. /** Gets or sets border thickness */
  1610. get: function () {
  1611. return this._thickness;
  1612. },
  1613. set: function (value) {
  1614. if (this._thickness === value) {
  1615. return;
  1616. }
  1617. this._thickness = value;
  1618. this._markAsDirty();
  1619. },
  1620. enumerable: true,
  1621. configurable: true
  1622. });
  1623. Object.defineProperty(Checkbox.prototype, "checkSizeRatio", {
  1624. /** Gets or sets a value indicating the ratio between overall size and check size */
  1625. get: function () {
  1626. return this._checkSizeRatio;
  1627. },
  1628. set: function (value) {
  1629. value = Math.max(Math.min(1, value), 0);
  1630. if (this._checkSizeRatio === value) {
  1631. return;
  1632. }
  1633. this._checkSizeRatio = value;
  1634. this._markAsDirty();
  1635. },
  1636. enumerable: true,
  1637. configurable: true
  1638. });
  1639. Object.defineProperty(Checkbox.prototype, "background", {
  1640. /** Gets or sets background color */
  1641. get: function () {
  1642. return this._background;
  1643. },
  1644. set: function (value) {
  1645. if (this._background === value) {
  1646. return;
  1647. }
  1648. this._background = value;
  1649. this._markAsDirty();
  1650. },
  1651. enumerable: true,
  1652. configurable: true
  1653. });
  1654. Object.defineProperty(Checkbox.prototype, "isChecked", {
  1655. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  1656. get: function () {
  1657. return this._isChecked;
  1658. },
  1659. set: function (value) {
  1660. if (this._isChecked === value) {
  1661. return;
  1662. }
  1663. this._isChecked = value;
  1664. this._markAsDirty();
  1665. this.onIsCheckedChangedObservable.notifyObservers(value);
  1666. },
  1667. enumerable: true,
  1668. configurable: true
  1669. });
  1670. Checkbox.prototype._getTypeName = function () {
  1671. return "Checkbox";
  1672. };
  1673. /** @hidden */
  1674. Checkbox.prototype._draw = function (context, invalidatedRectangle) {
  1675. context.save();
  1676. this._applyStates(context);
  1677. var actualWidth = this._currentMeasure.width - this._thickness;
  1678. var actualHeight = this._currentMeasure.height - this._thickness;
  1679. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1680. context.shadowColor = this.shadowColor;
  1681. context.shadowBlur = this.shadowBlur;
  1682. context.shadowOffsetX = this.shadowOffsetX;
  1683. context.shadowOffsetY = this.shadowOffsetY;
  1684. }
  1685. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  1686. context.fillRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1687. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1688. context.shadowBlur = 0;
  1689. context.shadowOffsetX = 0;
  1690. context.shadowOffsetY = 0;
  1691. }
  1692. if (this._isChecked) {
  1693. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  1694. var offsetWidth = actualWidth * this._checkSizeRatio;
  1695. var offseHeight = actualHeight * this._checkSizeRatio;
  1696. context.fillRect(this._currentMeasure.left + this._thickness / 2 + (actualWidth - offsetWidth) / 2, this._currentMeasure.top + this._thickness / 2 + (actualHeight - offseHeight) / 2, offsetWidth, offseHeight);
  1697. }
  1698. context.strokeStyle = this.color;
  1699. context.lineWidth = this._thickness;
  1700. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, actualWidth, actualHeight);
  1701. context.restore();
  1702. };
  1703. // Events
  1704. /** @hidden */
  1705. Checkbox.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  1706. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  1707. return false;
  1708. }
  1709. this.isChecked = !this.isChecked;
  1710. return true;
  1711. };
  1712. /**
  1713. * Utility function to easily create a checkbox with a header
  1714. * @param title defines the label to use for the header
  1715. * @param onValueChanged defines the callback to call when value changes
  1716. * @returns a StackPanel containing the checkbox and a textBlock
  1717. */
  1718. Checkbox.AddCheckBoxWithHeader = function (title, onValueChanged) {
  1719. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  1720. panel.isVertical = false;
  1721. panel.height = "30px";
  1722. var checkbox = new Checkbox();
  1723. checkbox.width = "20px";
  1724. checkbox.height = "20px";
  1725. checkbox.isChecked = true;
  1726. checkbox.color = "green";
  1727. checkbox.onIsCheckedChangedObservable.add(onValueChanged);
  1728. panel.addControl(checkbox);
  1729. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  1730. header.text = title;
  1731. header.width = "180px";
  1732. header.paddingLeft = "5px";
  1733. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  1734. header.color = "white";
  1735. panel.addControl(header);
  1736. return panel;
  1737. };
  1738. return Checkbox;
  1739. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  1740. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Checkbox"] = Checkbox;
  1741. /***/ }),
  1742. /***/ "./2D/controls/colorpicker.ts":
  1743. /*!************************************!*\
  1744. !*** ./2D/controls/colorpicker.ts ***!
  1745. \************************************/
  1746. /*! exports provided: ColorPicker */
  1747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1748. "use strict";
  1749. __webpack_require__.r(__webpack_exports__);
  1750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return ColorPicker; });
  1751. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  1752. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  1753. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  1754. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  1755. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  1756. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  1757. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  1758. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  1759. /* harmony import */ var _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../controls/textBlock */ "./2D/controls/textBlock.ts");
  1760. /** Class used to create color pickers */
  1761. var ColorPicker = /** @class */ (function (_super) {
  1762. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ColorPicker, _super);
  1763. /**
  1764. * Creates a new ColorPicker
  1765. * @param name defines the control name
  1766. */
  1767. function ColorPicker(name) {
  1768. var _this = _super.call(this, name) || this;
  1769. _this.name = name;
  1770. _this._value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  1771. _this._tmpColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]();
  1772. _this._pointerStartedOnSquare = false;
  1773. _this._pointerStartedOnWheel = false;
  1774. _this._squareLeft = 0;
  1775. _this._squareTop = 0;
  1776. _this._squareSize = 0;
  1777. _this._h = 360;
  1778. _this._s = 1;
  1779. _this._v = 1;
  1780. _this._lastPointerDownID = -1;
  1781. /**
  1782. * Observable raised when the value changes
  1783. */
  1784. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  1785. // Events
  1786. _this._pointerIsDown = false;
  1787. _this.value = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](.88, .1, .1);
  1788. _this.size = "200px";
  1789. _this.isPointerBlocker = true;
  1790. return _this;
  1791. }
  1792. Object.defineProperty(ColorPicker.prototype, "value", {
  1793. /** Gets or sets the color of the color picker */
  1794. get: function () {
  1795. return this._value;
  1796. },
  1797. set: function (value) {
  1798. if (this._value.equals(value)) {
  1799. return;
  1800. }
  1801. this._value.copyFrom(value);
  1802. this._value.toHSVToRef(this._tmpColor);
  1803. this._h = this._tmpColor.r;
  1804. this._s = Math.max(this._tmpColor.g, 0.00001);
  1805. this._v = Math.max(this._tmpColor.b, 0.00001);
  1806. this._markAsDirty();
  1807. if (this._value.r <= ColorPicker._Epsilon) {
  1808. this._value.r = 0;
  1809. }
  1810. if (this._value.g <= ColorPicker._Epsilon) {
  1811. this._value.g = 0;
  1812. }
  1813. if (this._value.b <= ColorPicker._Epsilon) {
  1814. this._value.b = 0;
  1815. }
  1816. if (this._value.r >= 1.0 - ColorPicker._Epsilon) {
  1817. this._value.r = 1.0;
  1818. }
  1819. if (this._value.g >= 1.0 - ColorPicker._Epsilon) {
  1820. this._value.g = 1.0;
  1821. }
  1822. if (this._value.b >= 1.0 - ColorPicker._Epsilon) {
  1823. this._value.b = 1.0;
  1824. }
  1825. this.onValueChangedObservable.notifyObservers(this._value);
  1826. },
  1827. enumerable: true,
  1828. configurable: true
  1829. });
  1830. Object.defineProperty(ColorPicker.prototype, "width", {
  1831. /**
  1832. * Gets or sets control width
  1833. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1834. */
  1835. get: function () {
  1836. return this._width.toString(this._host);
  1837. },
  1838. set: function (value) {
  1839. if (this._width.toString(this._host) === value) {
  1840. return;
  1841. }
  1842. if (this._width.fromString(value)) {
  1843. this._height.fromString(value);
  1844. this._markAsDirty();
  1845. }
  1846. },
  1847. enumerable: true,
  1848. configurable: true
  1849. });
  1850. Object.defineProperty(ColorPicker.prototype, "height", {
  1851. /**
  1852. * Gets or sets control height
  1853. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  1854. */
  1855. get: function () {
  1856. return this._height.toString(this._host);
  1857. },
  1858. /** Gets or sets control height */
  1859. set: function (value) {
  1860. if (this._height.toString(this._host) === value) {
  1861. return;
  1862. }
  1863. if (this._height.fromString(value)) {
  1864. this._width.fromString(value);
  1865. this._markAsDirty();
  1866. }
  1867. },
  1868. enumerable: true,
  1869. configurable: true
  1870. });
  1871. Object.defineProperty(ColorPicker.prototype, "size", {
  1872. /** Gets or sets control size */
  1873. get: function () {
  1874. return this.width;
  1875. },
  1876. set: function (value) {
  1877. this.width = value;
  1878. },
  1879. enumerable: true,
  1880. configurable: true
  1881. });
  1882. ColorPicker.prototype._getTypeName = function () {
  1883. return "ColorPicker";
  1884. };
  1885. /** @hidden */
  1886. ColorPicker.prototype._preMeasure = function (parentMeasure, context) {
  1887. if (parentMeasure.width < parentMeasure.height) {
  1888. this._currentMeasure.height = parentMeasure.width;
  1889. }
  1890. else {
  1891. this._currentMeasure.width = parentMeasure.height;
  1892. }
  1893. };
  1894. ColorPicker.prototype._updateSquareProps = function () {
  1895. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1896. var wheelThickness = radius * .2;
  1897. var innerDiameter = (radius - wheelThickness) * 2;
  1898. var squareSize = innerDiameter / (Math.sqrt(2));
  1899. var offset = radius - squareSize * .5;
  1900. this._squareLeft = this._currentMeasure.left + offset;
  1901. this._squareTop = this._currentMeasure.top + offset;
  1902. this._squareSize = squareSize;
  1903. };
  1904. ColorPicker.prototype._drawGradientSquare = function (hueValue, left, top, width, height, context) {
  1905. var lgh = context.createLinearGradient(left, top, width + left, top);
  1906. lgh.addColorStop(0, '#fff');
  1907. lgh.addColorStop(1, 'hsl(' + hueValue + ', 100%, 50%)');
  1908. context.fillStyle = lgh;
  1909. context.fillRect(left, top, width, height);
  1910. var lgv = context.createLinearGradient(left, top, left, height + top);
  1911. lgv.addColorStop(0, 'rgba(0,0,0,0)');
  1912. lgv.addColorStop(1, '#000');
  1913. context.fillStyle = lgv;
  1914. context.fillRect(left, top, width, height);
  1915. };
  1916. ColorPicker.prototype._drawCircle = function (centerX, centerY, radius, context) {
  1917. context.beginPath();
  1918. context.arc(centerX, centerY, radius + 1, 0, 2 * Math.PI, false);
  1919. context.lineWidth = 3;
  1920. context.strokeStyle = '#333333';
  1921. context.stroke();
  1922. context.beginPath();
  1923. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  1924. context.lineWidth = 3;
  1925. context.strokeStyle = '#ffffff';
  1926. context.stroke();
  1927. };
  1928. ColorPicker.prototype._createColorWheelCanvas = function (radius, thickness) {
  1929. var canvas = document.createElement("canvas");
  1930. canvas.width = radius * 2;
  1931. canvas.height = radius * 2;
  1932. var context = canvas.getContext("2d");
  1933. var image = context.getImageData(0, 0, radius * 2, radius * 2);
  1934. var data = image.data;
  1935. var color = this._tmpColor;
  1936. var maxDistSq = radius * radius;
  1937. var innerRadius = radius - thickness;
  1938. var minDistSq = innerRadius * innerRadius;
  1939. for (var x = -radius; x < radius; x++) {
  1940. for (var y = -radius; y < radius; y++) {
  1941. var distSq = x * x + y * y;
  1942. if (distSq > maxDistSq || distSq < minDistSq) {
  1943. continue;
  1944. }
  1945. var dist = Math.sqrt(distSq);
  1946. var ang = Math.atan2(y, x);
  1947. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(ang * 180 / Math.PI + 180, dist / radius, 1, color);
  1948. var index = ((x + radius) + ((y + radius) * 2 * radius)) * 4;
  1949. data[index] = color.r * 255;
  1950. data[index + 1] = color.g * 255;
  1951. data[index + 2] = color.b * 255;
  1952. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1953. //apply less alpha to bigger color pickers
  1954. var alphaAmount = .2;
  1955. var maxAlpha = .2;
  1956. var minAlpha = .04;
  1957. var lowerRadius = 50;
  1958. var upperRadius = 150;
  1959. if (radius < lowerRadius) {
  1960. alphaAmount = maxAlpha;
  1961. }
  1962. else if (radius > upperRadius) {
  1963. alphaAmount = minAlpha;
  1964. }
  1965. else {
  1966. alphaAmount = (minAlpha - maxAlpha) * (radius - lowerRadius) / (upperRadius - lowerRadius) + maxAlpha;
  1967. }
  1968. var alphaRatio = (dist - innerRadius) / (radius - innerRadius);
  1969. if (alphaRatio < alphaAmount) {
  1970. data[index + 3] = 255 * (alphaRatio / alphaAmount);
  1971. }
  1972. else if (alphaRatio > 1 - alphaAmount) {
  1973. data[index + 3] = 255 * (1.0 - ((alphaRatio - (1 - alphaAmount)) / alphaAmount));
  1974. }
  1975. else {
  1976. data[index + 3] = 255;
  1977. }
  1978. }
  1979. }
  1980. context.putImageData(image, 0, 0);
  1981. return canvas;
  1982. };
  1983. /** @hidden */
  1984. ColorPicker.prototype._draw = function (context) {
  1985. context.save();
  1986. this._applyStates(context);
  1987. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  1988. var wheelThickness = radius * .2;
  1989. var left = this._currentMeasure.left;
  1990. var top = this._currentMeasure.top;
  1991. if (!this._colorWheelCanvas || this._colorWheelCanvas.width != radius * 2) {
  1992. this._colorWheelCanvas = this._createColorWheelCanvas(radius, wheelThickness);
  1993. }
  1994. this._updateSquareProps();
  1995. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  1996. context.shadowColor = this.shadowColor;
  1997. context.shadowBlur = this.shadowBlur;
  1998. context.shadowOffsetX = this.shadowOffsetX;
  1999. context.shadowOffsetY = this.shadowOffsetY;
  2000. context.fillRect(this._squareLeft, this._squareTop, this._squareSize, this._squareSize);
  2001. }
  2002. context.drawImage(this._colorWheelCanvas, left, top);
  2003. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  2004. context.shadowBlur = 0;
  2005. context.shadowOffsetX = 0;
  2006. context.shadowOffsetY = 0;
  2007. }
  2008. this._drawGradientSquare(this._h, this._squareLeft, this._squareTop, this._squareSize, this._squareSize, context);
  2009. var cx = this._squareLeft + this._squareSize * this._s;
  2010. var cy = this._squareTop + this._squareSize * (1 - this._v);
  2011. this._drawCircle(cx, cy, radius * .04, context);
  2012. var dist = radius - wheelThickness * .5;
  2013. cx = left + radius + Math.cos((this._h - 180) * Math.PI / 180) * dist;
  2014. cy = top + radius + Math.sin((this._h - 180) * Math.PI / 180) * dist;
  2015. this._drawCircle(cx, cy, wheelThickness * .35, context);
  2016. context.restore();
  2017. };
  2018. ColorPicker.prototype._updateValueFromPointer = function (x, y) {
  2019. if (this._pointerStartedOnWheel) {
  2020. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2021. var centerX = radius + this._currentMeasure.left;
  2022. var centerY = radius + this._currentMeasure.top;
  2023. this._h = Math.atan2(y - centerY, x - centerX) * 180 / Math.PI + 180;
  2024. }
  2025. else if (this._pointerStartedOnSquare) {
  2026. this._updateSquareProps();
  2027. this._s = (x - this._squareLeft) / this._squareSize;
  2028. this._v = 1 - (y - this._squareTop) / this._squareSize;
  2029. this._s = Math.min(this._s, 1);
  2030. this._s = Math.max(this._s, ColorPicker._Epsilon);
  2031. this._v = Math.min(this._v, 1);
  2032. this._v = Math.max(this._v, ColorPicker._Epsilon);
  2033. }
  2034. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].HSVtoRGBToRef(this._h, this._s, this._v, this._tmpColor);
  2035. this.value = this._tmpColor;
  2036. };
  2037. ColorPicker.prototype._isPointOnSquare = function (x, y) {
  2038. this._updateSquareProps();
  2039. var left = this._squareLeft;
  2040. var top = this._squareTop;
  2041. var size = this._squareSize;
  2042. if (x >= left && x <= left + size &&
  2043. y >= top && y <= top + size) {
  2044. return true;
  2045. }
  2046. return false;
  2047. };
  2048. ColorPicker.prototype._isPointOnWheel = function (x, y) {
  2049. var radius = Math.min(this._currentMeasure.width, this._currentMeasure.height) * .5;
  2050. var centerX = radius + this._currentMeasure.left;
  2051. var centerY = radius + this._currentMeasure.top;
  2052. var wheelThickness = radius * .2;
  2053. var innerRadius = radius - wheelThickness;
  2054. var radiusSq = radius * radius;
  2055. var innerRadiusSq = innerRadius * innerRadius;
  2056. var dx = x - centerX;
  2057. var dy = y - centerY;
  2058. var distSq = dx * dx + dy * dy;
  2059. if (distSq <= radiusSq && distSq >= innerRadiusSq) {
  2060. return true;
  2061. }
  2062. return false;
  2063. };
  2064. ColorPicker.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  2065. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  2066. return false;
  2067. }
  2068. this._pointerIsDown = true;
  2069. this._pointerStartedOnSquare = false;
  2070. this._pointerStartedOnWheel = false;
  2071. // Invert transform
  2072. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2073. var x = this._transformedPosition.x;
  2074. var y = this._transformedPosition.y;
  2075. if (this._isPointOnSquare(x, y)) {
  2076. this._pointerStartedOnSquare = true;
  2077. }
  2078. else if (this._isPointOnWheel(x, y)) {
  2079. this._pointerStartedOnWheel = true;
  2080. }
  2081. this._updateValueFromPointer(x, y);
  2082. this._host._capturingControl[pointerId] = this;
  2083. this._lastPointerDownID = pointerId;
  2084. return true;
  2085. };
  2086. ColorPicker.prototype._onPointerMove = function (target, coordinates, pointerId) {
  2087. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  2088. if (pointerId != this._lastPointerDownID) {
  2089. return;
  2090. }
  2091. // Invert transform
  2092. this._invertTransformMatrix.transformCoordinates(coordinates.x, coordinates.y, this._transformedPosition);
  2093. var x = this._transformedPosition.x;
  2094. var y = this._transformedPosition.y;
  2095. if (this._pointerIsDown) {
  2096. this._updateValueFromPointer(x, y);
  2097. }
  2098. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  2099. };
  2100. ColorPicker.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  2101. this._pointerIsDown = false;
  2102. delete this._host._capturingControl[pointerId];
  2103. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  2104. };
  2105. /**
  2106. * This function expands the color picker by creating a color picker dialog with manual
  2107. * color value input and the ability to save colors into an array to be used later in
  2108. * subsequent launches of the dialogue.
  2109. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  2110. * @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.
  2111. * @returns picked color as a hex string and the saved colors array as hex strings.
  2112. */
  2113. ColorPicker.ShowPickerDialogAsync = function (advancedTexture, options) {
  2114. return new Promise(function (resolve, reject) {
  2115. // Default options
  2116. options.pickerWidth = options.pickerWidth || "640px";
  2117. options.pickerHeight = options.pickerHeight || "400px";
  2118. options.headerHeight = options.headerHeight || "35px";
  2119. options.lastColor = options.lastColor || "#000000";
  2120. options.swatchLimit = options.swatchLimit || 20;
  2121. options.numSwatchesPerLine = options.numSwatchesPerLine || 10;
  2122. // Window size settings
  2123. var drawerMaxRows = options.swatchLimit / options.numSwatchesPerLine;
  2124. var rawSwatchSize = parseFloat(options.pickerWidth) / options.numSwatchesPerLine;
  2125. var gutterSize = Math.floor(rawSwatchSize * 0.25);
  2126. var colGutters = gutterSize * (options.numSwatchesPerLine + 1);
  2127. var swatchSize = Math.floor((parseFloat(options.pickerWidth) - colGutters) / options.numSwatchesPerLine);
  2128. var drawerMaxSize = (swatchSize * drawerMaxRows) + (gutterSize * (drawerMaxRows + 1));
  2129. var containerSize = (parseInt(options.pickerHeight) + drawerMaxSize + Math.floor(swatchSize * 0.25)).toString() + "px";
  2130. // Button Colors
  2131. var buttonColor = "#c0c0c0";
  2132. var buttonBackgroundColor = "#535353";
  2133. var buttonBackgroundHoverColor = "#414141";
  2134. var buttonBackgroundClickColor = "515151";
  2135. var buttonDisabledColor = "#555555";
  2136. var buttonDisabledBackgroundColor = "#454545";
  2137. var currentSwatchesOutlineColor = "#404040";
  2138. var luminanceLimitColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString("#dddddd");
  2139. var luminanceLimit = luminanceLimitColor.r + luminanceLimitColor.g + luminanceLimitColor.b;
  2140. var iconColorDark = "#aaaaaa";
  2141. var iconColorLight = "#ffffff";
  2142. var closeIconColor;
  2143. // Button settings
  2144. var buttonFontSize;
  2145. var butEdit;
  2146. var buttonWidth;
  2147. var buttonHeight;
  2148. // Input Text Colors
  2149. var inputFieldLabels = ["R", "G", "B"];
  2150. var inputTextBackgroundColor = "#454545";
  2151. var inputTextColor = "#f0f0f0";
  2152. // This is the current color as set by either the picker or by entering a value
  2153. var currentColor;
  2154. // This int is used for naming swatches and serves as the index for calling them from the list
  2155. var swatchNumber;
  2156. // Menu Panel options. We need to know if the swatchDrawer exists so we can create it if needed.
  2157. var swatchDrawer;
  2158. var editSwatchMode = false;
  2159. // Color InputText fields that will be updated upon value change
  2160. var picker;
  2161. var rValInt;
  2162. var gValInt;
  2163. var bValInt;
  2164. var rValDec;
  2165. var gValDec;
  2166. var bValDec;
  2167. var hexVal;
  2168. var newSwatch;
  2169. var lastVal;
  2170. var activeField;
  2171. /**
  2172. * Will update all values for InputText and ColorPicker controls based on the BABYLON.Color3 passed to this function.
  2173. * Each InputText control and the ColorPicker control will be tested to see if they are the activeField and if they
  2174. * are will receive no update. This is to prevent the input from the user being overwritten.
  2175. */
  2176. function updateValues(value, inputField) {
  2177. activeField = inputField;
  2178. var pickedColor = value.toHexString();
  2179. newSwatch.background = pickedColor;
  2180. if (rValInt.name != activeField) {
  2181. rValInt.text = Math.floor(value.r * 255).toString();
  2182. }
  2183. if (gValInt.name != activeField) {
  2184. gValInt.text = Math.floor(value.g * 255).toString();
  2185. }
  2186. if (bValInt.name != activeField) {
  2187. bValInt.text = Math.floor(value.b * 255).toString();
  2188. }
  2189. if (rValDec.name != activeField) {
  2190. rValDec.text = value.r.toString();
  2191. }
  2192. if (gValDec.name != activeField) {
  2193. gValDec.text = value.g.toString();
  2194. }
  2195. if (bValDec.name != activeField) {
  2196. bValDec.text = value.b.toString();
  2197. }
  2198. if (hexVal.name != activeField) {
  2199. var minusPound = pickedColor.split("#");
  2200. hexVal.text = minusPound[1];
  2201. }
  2202. if (picker.name != activeField) {
  2203. picker.value = value;
  2204. }
  2205. }
  2206. // 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.
  2207. function updateInt(field, channel) {
  2208. var newValue = field.text;
  2209. var checkVal = /[^0-9]/g.test(newValue);
  2210. if (checkVal) {
  2211. field.text = lastVal;
  2212. return;
  2213. }
  2214. else {
  2215. if (newValue != "") {
  2216. if (Math.floor(parseInt(newValue)) < 0) {
  2217. newValue = "0";
  2218. }
  2219. else if (Math.floor(parseInt(newValue)) > 255) {
  2220. newValue = "255";
  2221. }
  2222. else if (isNaN(parseInt(newValue))) {
  2223. newValue = "0";
  2224. }
  2225. }
  2226. if (activeField == field.name) {
  2227. lastVal = newValue;
  2228. }
  2229. }
  2230. if (newValue != "") {
  2231. newValue = parseInt(newValue).toString();
  2232. field.text = newValue;
  2233. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2234. if (activeField == field.name) {
  2235. if (channel == "r") {
  2236. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"]((parseInt(newValue)) / 255, newSwatchRGB.g, newSwatchRGB.b), field.name);
  2237. }
  2238. else if (channel == "g") {
  2239. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, (parseInt(newValue)) / 255, newSwatchRGB.b), field.name);
  2240. }
  2241. else {
  2242. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, (parseInt(newValue)) / 255), field.name);
  2243. }
  2244. }
  2245. }
  2246. }
  2247. // 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.
  2248. function updateFloat(field, channel) {
  2249. var newValue = field.text;
  2250. var checkVal = /[^0-9\.]/g.test(newValue);
  2251. if (checkVal) {
  2252. field.text = lastVal;
  2253. return;
  2254. }
  2255. else {
  2256. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2257. if (parseFloat(newValue) < 0.0) {
  2258. newValue = "0.0";
  2259. }
  2260. else if (parseFloat(newValue) > 1.0) {
  2261. newValue = "1.0";
  2262. }
  2263. else if (isNaN(parseFloat(newValue))) {
  2264. newValue = "0.0";
  2265. }
  2266. }
  2267. if (activeField == field.name) {
  2268. lastVal = newValue;
  2269. }
  2270. }
  2271. if (newValue != "" && newValue != "." && parseFloat(newValue) != 0) {
  2272. newValue = parseFloat(newValue).toString();
  2273. field.text = newValue;
  2274. }
  2275. else {
  2276. newValue = "0.0";
  2277. }
  2278. var newSwatchRGB = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newSwatch.background);
  2279. if (activeField == field.name) {
  2280. if (channel == "r") {
  2281. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](parseFloat(newValue), newSwatchRGB.g, newSwatchRGB.b), field.name);
  2282. }
  2283. else if (channel == "g") {
  2284. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, parseFloat(newValue), newSwatchRGB.b), field.name);
  2285. }
  2286. else {
  2287. updateValues(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](newSwatchRGB.r, newSwatchRGB.g, parseFloat(newValue)), field.name);
  2288. }
  2289. }
  2290. }
  2291. // Removes the current index from the savedColors array. Drawer can then be regenerated.
  2292. function deleteSwatch(index) {
  2293. if (options.savedColors) {
  2294. options.savedColors.splice(index, 1);
  2295. }
  2296. if (options.savedColors && options.savedColors.length == 0) {
  2297. setEditButtonVisibility(false);
  2298. editSwatchMode = false;
  2299. }
  2300. }
  2301. // Creates and styles an individual swatch when updateSwatches is called.
  2302. function createSwatch() {
  2303. if (options.savedColors && options.savedColors[swatchNumber]) {
  2304. if (editSwatchMode) {
  2305. var icon = "b";
  2306. }
  2307. else {
  2308. var icon = "";
  2309. }
  2310. var swatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("Swatch_" + swatchNumber, icon);
  2311. swatch.fontFamily = "BabylonJSglyphs";
  2312. var swatchColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[swatchNumber]);
  2313. var swatchLuminence = swatchColor.r + swatchColor.g + swatchColor.b;
  2314. // Set color of outline and textBlock based on luminance of the color swatch so feedback always visible
  2315. if (swatchLuminence > luminanceLimit) {
  2316. swatch.color = iconColorDark;
  2317. }
  2318. else {
  2319. swatch.color = iconColorLight;
  2320. }
  2321. swatch.fontSize = Math.floor(swatchSize * 0.7);
  2322. swatch.textBlock.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2323. swatch.height = swatch.width = (swatchSize).toString() + "px";
  2324. swatch.background = options.savedColors[swatchNumber];
  2325. swatch.thickness = 2;
  2326. var metadata_1 = swatchNumber;
  2327. swatch.pointerDownAnimation = function () {
  2328. swatch.thickness = 4;
  2329. };
  2330. swatch.pointerUpAnimation = function () {
  2331. swatch.thickness = 3;
  2332. };
  2333. swatch.pointerEnterAnimation = function () {
  2334. swatch.thickness = 3;
  2335. };
  2336. swatch.pointerOutAnimation = function () {
  2337. swatch.thickness = 2;
  2338. };
  2339. swatch.onPointerClickObservable.add(function () {
  2340. if (!editSwatchMode) {
  2341. if (options.savedColors) {
  2342. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.savedColors[metadata_1]), swatch.name);
  2343. }
  2344. }
  2345. else {
  2346. deleteSwatch(metadata_1);
  2347. updateSwatches("", butSave);
  2348. }
  2349. });
  2350. return swatch;
  2351. }
  2352. else {
  2353. return null;
  2354. }
  2355. }
  2356. // Mode switch to render button text and close symbols on swatch controls
  2357. function editSwatches(mode) {
  2358. if (mode !== undefined) {
  2359. editSwatchMode = mode;
  2360. }
  2361. if (editSwatchMode) {
  2362. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2363. var thisButton = swatchDrawer.children[i];
  2364. thisButton.textBlock.text = "b";
  2365. }
  2366. if (butEdit !== undefined) {
  2367. butEdit.textBlock.text = "Done";
  2368. }
  2369. }
  2370. else {
  2371. for (var i = 0; i < swatchDrawer.children.length; i++) {
  2372. var thisButton = swatchDrawer.children[i];
  2373. thisButton.textBlock.text = "";
  2374. }
  2375. if (butEdit !== undefined) {
  2376. butEdit.textBlock.text = "Edit";
  2377. }
  2378. }
  2379. }
  2380. /**
  2381. * When Save Color button is pressed this function will first create a swatch drawer if one is not already
  2382. * made. Then all controls are removed from the drawer and we step through the savedColors array and
  2383. * creates one swatch per color. It will also set the height of the drawer control based on how many
  2384. * saved colors there are and how many can be stored per row.
  2385. */
  2386. function updateSwatches(color, button) {
  2387. if (options.savedColors) {
  2388. if (color != "") {
  2389. options.savedColors.push(color);
  2390. }
  2391. swatchNumber = 0;
  2392. swatchDrawer.clearControls();
  2393. var rowCount = Math.ceil(options.savedColors.length / options.numSwatchesPerLine);
  2394. if (rowCount == 0) {
  2395. var gutterCount = 0;
  2396. }
  2397. else {
  2398. var gutterCount = rowCount + 1;
  2399. }
  2400. if (swatchDrawer.rowCount != rowCount + gutterCount) {
  2401. var currentRows = swatchDrawer.rowCount;
  2402. for (var i = 0; i < currentRows; i++) {
  2403. swatchDrawer.removeRowDefinition(0);
  2404. }
  2405. for (var i = 0; i < rowCount + gutterCount; i++) {
  2406. if (i % 2) {
  2407. swatchDrawer.addRowDefinition(swatchSize, true);
  2408. }
  2409. else {
  2410. swatchDrawer.addRowDefinition(gutterSize, true);
  2411. }
  2412. }
  2413. }
  2414. swatchDrawer.height = ((swatchSize * rowCount) + (gutterCount * gutterSize)).toString() + "px";
  2415. for (var y = 1, thisRow = 1; y < rowCount + gutterCount; y += 2, thisRow++) {
  2416. // Determine number of buttons to create per row based on the button limit per row and number of saved colors
  2417. if (options.savedColors.length > thisRow * options.numSwatchesPerLine) {
  2418. var totalButtonsThisRow = options.numSwatchesPerLine;
  2419. }
  2420. else {
  2421. var totalButtonsThisRow = options.savedColors.length - ((thisRow - 1) * options.numSwatchesPerLine);
  2422. }
  2423. var buttonIterations = (Math.min(Math.max(totalButtonsThisRow, 0), options.numSwatchesPerLine));
  2424. for (var x = 0, w = 1; x < buttonIterations; x++) {
  2425. if (x > options.numSwatchesPerLine) {
  2426. continue;
  2427. }
  2428. var swatch = createSwatch();
  2429. if (swatch != null) {
  2430. swatchDrawer.addControl(swatch, y, w);
  2431. w += 2;
  2432. swatchNumber++;
  2433. }
  2434. else {
  2435. continue;
  2436. }
  2437. }
  2438. }
  2439. if (options.savedColors.length >= options.swatchLimit) {
  2440. disableButton(button, true);
  2441. }
  2442. else {
  2443. disableButton(button, false);
  2444. }
  2445. }
  2446. }
  2447. // Shows or hides edit swatches button depending on if there are saved swatches
  2448. function setEditButtonVisibility(enableButton) {
  2449. if (enableButton) {
  2450. butEdit = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butEdit", "Edit");
  2451. butEdit.width = buttonWidth;
  2452. butEdit.height = buttonHeight;
  2453. butEdit.left = (Math.floor(parseInt(buttonWidth) * 0.1)).toString() + "px";
  2454. butEdit.top = (parseFloat(butEdit.left) * -1).toString() + "px";
  2455. butEdit.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_BOTTOM;
  2456. butEdit.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2457. butEdit.thickness = 2;
  2458. butEdit.color = buttonColor;
  2459. butEdit.fontSize = buttonFontSize;
  2460. butEdit.background = buttonBackgroundColor;
  2461. butEdit.onPointerEnterObservable.add(function () {
  2462. butEdit.background = buttonBackgroundHoverColor;
  2463. });
  2464. butEdit.onPointerOutObservable.add(function () {
  2465. butEdit.background = buttonBackgroundColor;
  2466. });
  2467. butEdit.pointerDownAnimation = function () {
  2468. butEdit.background = buttonBackgroundClickColor;
  2469. };
  2470. butEdit.pointerUpAnimation = function () {
  2471. butEdit.background = buttonBackgroundHoverColor;
  2472. };
  2473. butEdit.onPointerClickObservable.add(function () {
  2474. if (editSwatchMode) {
  2475. editSwatchMode = false;
  2476. }
  2477. else {
  2478. editSwatchMode = true;
  2479. }
  2480. editSwatches();
  2481. });
  2482. pickerGrid.addControl(butEdit, 1, 0);
  2483. }
  2484. else {
  2485. pickerGrid.removeControl(butEdit);
  2486. }
  2487. }
  2488. // Called when the user hits the limit of saved colors in the drawer.
  2489. function disableButton(button, disabled) {
  2490. if (disabled) {
  2491. button.color = buttonDisabledColor;
  2492. button.background = buttonDisabledBackgroundColor;
  2493. }
  2494. else {
  2495. button.color = buttonColor;
  2496. button.background = buttonBackgroundColor;
  2497. }
  2498. }
  2499. // Passes last chosen color back to scene and kills dialog by removing from AdvancedDynamicTexture
  2500. function closePicker(color) {
  2501. if (options.savedColors && options.savedColors.length > 0) {
  2502. resolve({
  2503. savedColors: options.savedColors,
  2504. pickedColor: color
  2505. });
  2506. }
  2507. else {
  2508. resolve({
  2509. pickedColor: color
  2510. });
  2511. }
  2512. advancedTexture.removeControl(dialogContainer);
  2513. }
  2514. // Dialogue menu container which will contain both the main dialogue window and the swatch drawer which opens once a color is saved.
  2515. var dialogContainer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2516. dialogContainer.name = "Dialog Container";
  2517. dialogContainer.width = options.pickerWidth;
  2518. if (options.savedColors) {
  2519. dialogContainer.height = containerSize;
  2520. var topRow = parseInt(options.pickerHeight) / parseInt(containerSize);
  2521. dialogContainer.addRowDefinition(topRow, false);
  2522. dialogContainer.addRowDefinition(1.0 - topRow, false);
  2523. }
  2524. else {
  2525. dialogContainer.height = options.pickerHeight;
  2526. dialogContainer.addRowDefinition(1.0, false);
  2527. }
  2528. advancedTexture.addControl(dialogContainer);
  2529. // Swatch drawer which contains all saved color buttons
  2530. if (options.savedColors) {
  2531. swatchDrawer = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2532. swatchDrawer.name = "Swatch Drawer";
  2533. swatchDrawer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  2534. swatchDrawer.background = buttonBackgroundColor;
  2535. swatchDrawer.width = options.pickerWidth;
  2536. var initialRows = options.savedColors.length / options.numSwatchesPerLine;
  2537. if (initialRows == 0) {
  2538. var gutterCount = 0;
  2539. }
  2540. else {
  2541. var gutterCount = initialRows + 1;
  2542. }
  2543. swatchDrawer.height = ((swatchSize * initialRows) + (gutterCount * gutterSize)).toString() + "px";
  2544. swatchDrawer.top = Math.floor(swatchSize * 0.25).toString() + "px";
  2545. for (var i = 0; i < (Math.ceil(options.savedColors.length / options.numSwatchesPerLine) * 2) + 1; i++) {
  2546. if (i % 2 != 0) {
  2547. swatchDrawer.addRowDefinition(swatchSize, true);
  2548. }
  2549. else {
  2550. swatchDrawer.addRowDefinition(gutterSize, true);
  2551. }
  2552. }
  2553. for (var i = 0; i < options.numSwatchesPerLine * 2 + 1; i++) {
  2554. if (i % 2 != 0) {
  2555. swatchDrawer.addColumnDefinition(swatchSize, true);
  2556. }
  2557. else {
  2558. swatchDrawer.addColumnDefinition(gutterSize, true);
  2559. }
  2560. }
  2561. dialogContainer.addControl(swatchDrawer, 1, 0);
  2562. }
  2563. // Picker container
  2564. var pickerPanel = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2565. pickerPanel.name = "Picker Panel";
  2566. pickerPanel.height = options.pickerHeight;
  2567. var panelHead = parseInt(options.headerHeight) / parseInt(options.pickerHeight);
  2568. var pickerPanelRows = [panelHead, 1.0 - panelHead];
  2569. pickerPanel.addRowDefinition(pickerPanelRows[0], false);
  2570. pickerPanel.addRowDefinition(pickerPanelRows[1], false);
  2571. dialogContainer.addControl(pickerPanel, 0, 0);
  2572. // Picker container header
  2573. var header = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2574. header.name = "Dialogue Header Bar";
  2575. header.background = "#cccccc";
  2576. header.thickness = 0;
  2577. pickerPanel.addControl(header, 0, 0);
  2578. // Header close button
  2579. var closeButton = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("closeButton", "a");
  2580. closeButton.fontFamily = "BabylonJSglyphs";
  2581. var headerColor3 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(header.background);
  2582. closeIconColor = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0 - headerColor3.r, 1.0 - headerColor3.g, 1.0 - headerColor3.b);
  2583. closeButton.color = closeIconColor.toHexString();
  2584. closeButton.fontSize = Math.floor(parseInt(options.headerHeight) * 0.6);
  2585. closeButton.textBlock.textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2586. closeButton.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_RIGHT;
  2587. closeButton.height = closeButton.width = options.headerHeight;
  2588. closeButton.background = header.background;
  2589. closeButton.thickness = 0;
  2590. closeButton.pointerDownAnimation = function () {
  2591. };
  2592. closeButton.pointerUpAnimation = function () {
  2593. closeButton.background = header.background;
  2594. };
  2595. closeButton.pointerEnterAnimation = function () {
  2596. closeButton.color = header.background;
  2597. closeButton.background = "red";
  2598. };
  2599. closeButton.pointerOutAnimation = function () {
  2600. closeButton.color = closeIconColor.toHexString();
  2601. closeButton.background = header.background;
  2602. };
  2603. closeButton.onPointerClickObservable.add(function () {
  2604. closePicker(currentSwatch.background);
  2605. });
  2606. pickerPanel.addControl(closeButton, 0, 0);
  2607. // Dialog container body
  2608. var dialogBody = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2609. dialogBody.name = "Dialogue Body";
  2610. dialogBody.background = buttonBackgroundColor;
  2611. var dialogBodyCols = [0.4375, 0.5625];
  2612. dialogBody.addRowDefinition(1.0, false);
  2613. dialogBody.addColumnDefinition(dialogBodyCols[0], false);
  2614. dialogBody.addColumnDefinition(dialogBodyCols[1], false);
  2615. pickerPanel.addControl(dialogBody, 1, 0);
  2616. // Picker grid
  2617. var pickerGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2618. pickerGrid.name = "Picker Grid";
  2619. pickerGrid.addRowDefinition(0.85, false);
  2620. pickerGrid.addRowDefinition(0.15, false);
  2621. dialogBody.addControl(pickerGrid, 0, 0);
  2622. // Picker control
  2623. picker = new ColorPicker();
  2624. picker.name = "GUI Color Picker";
  2625. if (options.pickerHeight < options.pickerWidth) {
  2626. picker.width = 0.89;
  2627. }
  2628. else {
  2629. picker.height = 0.89;
  2630. }
  2631. picker.value = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2632. picker.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  2633. picker.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2634. picker.onPointerDownObservable.add(function () {
  2635. activeField = picker.name;
  2636. lastVal = "";
  2637. editSwatches(false);
  2638. });
  2639. picker.onValueChangedObservable.add(function (value) {
  2640. if (activeField == picker.name) {
  2641. updateValues(value, picker.name);
  2642. }
  2643. });
  2644. pickerGrid.addControl(picker, 0, 0);
  2645. // Picker body right quarant
  2646. var pickerBodyRight = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2647. pickerBodyRight.name = "Dialogue Right Half";
  2648. pickerBodyRight.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  2649. var pickerBodyRightRows = [0.514, 0.486];
  2650. pickerBodyRight.addRowDefinition(pickerBodyRightRows[0], false);
  2651. pickerBodyRight.addRowDefinition(pickerBodyRightRows[1], false);
  2652. dialogBody.addControl(pickerBodyRight, 1, 1);
  2653. // Picker container swatches and buttons
  2654. var pickerSwatchesButtons = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2655. pickerSwatchesButtons.name = "Swatches and Buttons";
  2656. var pickerButtonsCol = [0.417, 0.583];
  2657. pickerSwatchesButtons.addRowDefinition(1.0, false);
  2658. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[0], false);
  2659. pickerSwatchesButtons.addColumnDefinition(pickerButtonsCol[1], false);
  2660. pickerBodyRight.addControl(pickerSwatchesButtons, 0, 0);
  2661. // Picker Swatches quadrant
  2662. var pickerSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2663. pickerSwatches.name = "New and Current Swatches";
  2664. var pickeSwatchesRows = [0.04, 0.16, 0.64, 0.16];
  2665. pickerSwatches.addRowDefinition(pickeSwatchesRows[0], false);
  2666. pickerSwatches.addRowDefinition(pickeSwatchesRows[1], false);
  2667. pickerSwatches.addRowDefinition(pickeSwatchesRows[2], false);
  2668. pickerSwatches.addRowDefinition(pickeSwatchesRows[3], false);
  2669. pickerSwatchesButtons.addControl(pickerSwatches, 0, 0);
  2670. // Active swatches
  2671. var activeSwatches = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2672. activeSwatches.name = "Active Swatches";
  2673. activeSwatches.width = 0.67;
  2674. activeSwatches.addRowDefinition(0.5, false);
  2675. activeSwatches.addRowDefinition(0.5, false);
  2676. pickerSwatches.addControl(activeSwatches, 2, 0);
  2677. var labelWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[0] * 0.11));
  2678. var labelHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * pickeSwatchesRows[1] * 0.5));
  2679. if (options.pickerWidth > options.pickerHeight) {
  2680. var labelTextSize = labelHeight;
  2681. }
  2682. else {
  2683. var labelTextSize = labelWidth;
  2684. }
  2685. // New color swatch and previous color button
  2686. var newText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2687. newText.text = "new";
  2688. newText.name = "New Color Label";
  2689. newText.color = buttonColor;
  2690. newText.fontSize = labelTextSize;
  2691. pickerSwatches.addControl(newText, 1, 0);
  2692. newSwatch = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2693. newSwatch.name = "New Color Swatch";
  2694. newSwatch.background = options.lastColor;
  2695. newSwatch.thickness = 0;
  2696. activeSwatches.addControl(newSwatch, 0, 0);
  2697. var currentSwatch = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("currentSwatch", "");
  2698. currentSwatch.background = options.lastColor;
  2699. currentSwatch.thickness = 0;
  2700. currentSwatch.onPointerClickObservable.add(function () {
  2701. var revertColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(currentSwatch.background);
  2702. updateValues(revertColor, currentSwatch.name);
  2703. editSwatches(false);
  2704. });
  2705. currentSwatch.pointerDownAnimation = function () { };
  2706. currentSwatch.pointerUpAnimation = function () { };
  2707. currentSwatch.pointerEnterAnimation = function () { };
  2708. currentSwatch.pointerOutAnimation = function () { };
  2709. activeSwatches.addControl(currentSwatch, 1, 0);
  2710. var swatchOutline = new _rectangle__WEBPACK_IMPORTED_MODULE_4__["Rectangle"]();
  2711. swatchOutline.name = "Swatch Outline";
  2712. swatchOutline.width = 0.67;
  2713. swatchOutline.thickness = 2;
  2714. swatchOutline.color = currentSwatchesOutlineColor;
  2715. swatchOutline.isHitTestVisible = false;
  2716. pickerSwatches.addControl(swatchOutline, 2, 0);
  2717. var currentText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2718. currentText.name = "Current Color Label";
  2719. currentText.text = "current";
  2720. currentText.color = buttonColor;
  2721. currentText.fontSize = labelTextSize;
  2722. pickerSwatches.addControl(currentText, 3, 0);
  2723. // Buttons grid
  2724. var buttonGrid = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2725. buttonGrid.name = "Button Grid";
  2726. buttonGrid.height = 0.8;
  2727. var buttonGridRows = 1 / 3;
  2728. buttonGrid.addRowDefinition(buttonGridRows, false);
  2729. buttonGrid.addRowDefinition(buttonGridRows, false);
  2730. buttonGrid.addRowDefinition(buttonGridRows, false);
  2731. pickerSwatchesButtons.addControl(buttonGrid, 0, 1);
  2732. // Determine pixel width and height for all buttons from overall panel dimensions
  2733. buttonWidth = (Math.floor(parseInt(options.pickerWidth) * dialogBodyCols[1] * pickerButtonsCol[1] * 0.67)).toString() + "px";
  2734. buttonHeight = (Math.floor(parseInt(options.pickerHeight) * pickerPanelRows[1] * pickerBodyRightRows[0] * (parseFloat(buttonGrid.height.toString()) / 100) * buttonGridRows * 0.7)).toString() + "px";
  2735. // Determine button type size
  2736. if (parseFloat(buttonWidth) > parseFloat(buttonHeight)) {
  2737. buttonFontSize = Math.floor(parseFloat(buttonHeight) * 0.45);
  2738. }
  2739. else {
  2740. buttonFontSize = Math.floor(parseFloat(buttonWidth) * 0.11);
  2741. }
  2742. // Panel Buttons
  2743. var butOK = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butOK", "OK");
  2744. butOK.width = buttonWidth;
  2745. butOK.height = buttonHeight;
  2746. butOK.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2747. butOK.thickness = 2;
  2748. butOK.color = buttonColor;
  2749. butOK.fontSize = buttonFontSize;
  2750. butOK.background = buttonBackgroundColor;
  2751. butOK.onPointerEnterObservable.add(function () { butOK.background = buttonBackgroundHoverColor; });
  2752. butOK.onPointerOutObservable.add(function () { butOK.background = buttonBackgroundColor; });
  2753. butOK.pointerDownAnimation = function () {
  2754. butOK.background = buttonBackgroundClickColor;
  2755. };
  2756. butOK.pointerUpAnimation = function () {
  2757. butOK.background = buttonBackgroundHoverColor;
  2758. };
  2759. butOK.onPointerClickObservable.add(function () {
  2760. editSwatches(false);
  2761. closePicker(newSwatch.background);
  2762. });
  2763. buttonGrid.addControl(butOK, 0, 0);
  2764. var butCancel = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butCancel", "Cancel");
  2765. butCancel.width = buttonWidth;
  2766. butCancel.height = buttonHeight;
  2767. butCancel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2768. butCancel.thickness = 2;
  2769. butCancel.color = buttonColor;
  2770. butCancel.fontSize = buttonFontSize;
  2771. butCancel.background = buttonBackgroundColor;
  2772. butCancel.onPointerEnterObservable.add(function () { butCancel.background = buttonBackgroundHoverColor; });
  2773. butCancel.onPointerOutObservable.add(function () { butCancel.background = buttonBackgroundColor; });
  2774. butCancel.pointerDownAnimation = function () {
  2775. butCancel.background = buttonBackgroundClickColor;
  2776. };
  2777. butCancel.pointerUpAnimation = function () {
  2778. butCancel.background = buttonBackgroundHoverColor;
  2779. };
  2780. butCancel.onPointerClickObservable.add(function () {
  2781. editSwatches(false);
  2782. closePicker(currentSwatch.background);
  2783. });
  2784. buttonGrid.addControl(butCancel, 1, 0);
  2785. if (options.savedColors) {
  2786. var butSave = _button__WEBPACK_IMPORTED_MODULE_5__["Button"].CreateSimpleButton("butSave", "Save");
  2787. butSave.width = buttonWidth;
  2788. butSave.height = buttonHeight;
  2789. butSave.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2790. butSave.thickness = 2;
  2791. butSave.fontSize = buttonFontSize;
  2792. if (options.savedColors.length < options.swatchLimit) {
  2793. butSave.color = buttonColor;
  2794. butSave.background = buttonBackgroundColor;
  2795. }
  2796. else {
  2797. disableButton(butSave, true);
  2798. }
  2799. butSave.onPointerEnterObservable.add(function () {
  2800. if (options.savedColors) {
  2801. if (options.savedColors.length < options.swatchLimit) {
  2802. butSave.background = buttonBackgroundHoverColor;
  2803. }
  2804. }
  2805. });
  2806. butSave.onPointerOutObservable.add(function () {
  2807. if (options.savedColors) {
  2808. if (options.savedColors.length < options.swatchLimit) {
  2809. butSave.background = buttonBackgroundColor;
  2810. }
  2811. }
  2812. });
  2813. butSave.pointerDownAnimation = function () {
  2814. if (options.savedColors) {
  2815. if (options.savedColors.length < options.swatchLimit) {
  2816. butSave.background = buttonBackgroundClickColor;
  2817. }
  2818. }
  2819. };
  2820. butSave.pointerUpAnimation = function () {
  2821. if (options.savedColors) {
  2822. if (options.savedColors.length < options.swatchLimit) {
  2823. butSave.background = buttonBackgroundHoverColor;
  2824. }
  2825. }
  2826. };
  2827. butSave.onPointerClickObservable.add(function () {
  2828. if (options.savedColors) {
  2829. if (options.savedColors.length == 0) {
  2830. setEditButtonVisibility(true);
  2831. }
  2832. if (options.savedColors.length < options.swatchLimit) {
  2833. updateSwatches(newSwatch.background, butSave);
  2834. }
  2835. editSwatches(false);
  2836. }
  2837. });
  2838. if (options.savedColors.length > 0) {
  2839. setEditButtonVisibility(true);
  2840. }
  2841. buttonGrid.addControl(butSave, 2, 0);
  2842. }
  2843. // Picker color values input
  2844. var pickerColorValues = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2845. pickerColorValues.name = "Dialog Lower Right";
  2846. pickerColorValues.addRowDefinition(0.02, false);
  2847. pickerColorValues.addRowDefinition(0.63, false);
  2848. pickerColorValues.addRowDefinition(0.21, false);
  2849. pickerColorValues.addRowDefinition(0.14, false);
  2850. pickerBodyRight.addControl(pickerColorValues, 1, 0);
  2851. // RGB values text boxes
  2852. currentColor = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(options.lastColor);
  2853. var rgbValuesQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  2854. rgbValuesQuadrant.name = "RGB Values";
  2855. rgbValuesQuadrant.width = 0.82;
  2856. rgbValuesQuadrant.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_CENTER;
  2857. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2858. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2859. rgbValuesQuadrant.addRowDefinition(1 / 3, false);
  2860. rgbValuesQuadrant.addColumnDefinition(0.1, false);
  2861. rgbValuesQuadrant.addColumnDefinition(0.2, false);
  2862. rgbValuesQuadrant.addColumnDefinition(0.7, false);
  2863. pickerColorValues.addControl(rgbValuesQuadrant, 1, 0);
  2864. for (var i = 0; i < inputFieldLabels.length; i++) {
  2865. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  2866. labelText.text = inputFieldLabels[i];
  2867. labelText.color = buttonColor;
  2868. labelText.fontSize = buttonFontSize;
  2869. rgbValuesQuadrant.addControl(labelText, i, 0);
  2870. }
  2871. // Input fields for RGB values
  2872. rValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2873. rValInt.width = 0.83;
  2874. rValInt.height = 0.72;
  2875. rValInt.name = "rIntField";
  2876. rValInt.fontSize = buttonFontSize;
  2877. rValInt.text = (currentColor.r * 255).toString();
  2878. rValInt.color = inputTextColor;
  2879. rValInt.background = inputTextBackgroundColor;
  2880. rValInt.onFocusObservable.add(function () {
  2881. activeField = rValInt.name;
  2882. lastVal = rValInt.text;
  2883. editSwatches(false);
  2884. });
  2885. rValInt.onBlurObservable.add(function () {
  2886. if (rValInt.text == "") {
  2887. rValInt.text = "0";
  2888. }
  2889. updateInt(rValInt, "r");
  2890. if (activeField == rValInt.name) {
  2891. activeField = "";
  2892. }
  2893. });
  2894. rValInt.onTextChangedObservable.add(function () {
  2895. if (activeField == rValInt.name) {
  2896. updateInt(rValInt, "r");
  2897. }
  2898. });
  2899. rgbValuesQuadrant.addControl(rValInt, 0, 1);
  2900. gValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2901. gValInt.width = 0.83;
  2902. gValInt.height = 0.72;
  2903. gValInt.name = "gIntField";
  2904. gValInt.fontSize = buttonFontSize;
  2905. gValInt.text = (currentColor.g * 255).toString();
  2906. gValInt.color = inputTextColor;
  2907. gValInt.background = inputTextBackgroundColor;
  2908. gValInt.onFocusObservable.add(function () {
  2909. activeField = gValInt.name;
  2910. lastVal = gValInt.text;
  2911. editSwatches(false);
  2912. });
  2913. gValInt.onBlurObservable.add(function () {
  2914. if (gValInt.text == "") {
  2915. gValInt.text = "0";
  2916. }
  2917. updateInt(gValInt, "g");
  2918. if (activeField == gValInt.name) {
  2919. activeField = "";
  2920. }
  2921. });
  2922. gValInt.onTextChangedObservable.add(function () {
  2923. if (activeField == gValInt.name) {
  2924. updateInt(gValInt, "g");
  2925. }
  2926. });
  2927. rgbValuesQuadrant.addControl(gValInt, 1, 1);
  2928. bValInt = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2929. bValInt.width = 0.83;
  2930. bValInt.height = 0.72;
  2931. bValInt.name = "bIntField";
  2932. bValInt.fontSize = buttonFontSize;
  2933. bValInt.text = (currentColor.b * 255).toString();
  2934. bValInt.color = inputTextColor;
  2935. bValInt.background = inputTextBackgroundColor;
  2936. bValInt.onFocusObservable.add(function () {
  2937. activeField = bValInt.name;
  2938. lastVal = bValInt.text;
  2939. editSwatches(false);
  2940. });
  2941. bValInt.onBlurObservable.add(function () {
  2942. if (bValInt.text == "") {
  2943. bValInt.text = "0";
  2944. }
  2945. updateInt(bValInt, "b");
  2946. if (activeField == bValInt.name) {
  2947. activeField = "";
  2948. }
  2949. });
  2950. bValInt.onTextChangedObservable.add(function () {
  2951. if (activeField == bValInt.name) {
  2952. updateInt(bValInt, "b");
  2953. }
  2954. });
  2955. rgbValuesQuadrant.addControl(bValInt, 2, 1);
  2956. rValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2957. rValDec.width = 0.95;
  2958. rValDec.height = 0.72;
  2959. rValDec.name = "rDecField";
  2960. rValDec.fontSize = buttonFontSize;
  2961. rValDec.text = currentColor.r.toString();
  2962. rValDec.color = inputTextColor;
  2963. rValDec.background = inputTextBackgroundColor;
  2964. rValDec.onFocusObservable.add(function () {
  2965. activeField = rValDec.name;
  2966. lastVal = rValDec.text;
  2967. editSwatches(false);
  2968. });
  2969. rValDec.onBlurObservable.add(function () {
  2970. if (parseFloat(rValDec.text) == 0 || rValDec.text == "") {
  2971. rValDec.text = "0";
  2972. updateFloat(rValDec, "r");
  2973. }
  2974. if (activeField == rValDec.name) {
  2975. activeField = "";
  2976. }
  2977. });
  2978. rValDec.onTextChangedObservable.add(function () {
  2979. if (activeField == rValDec.name) {
  2980. updateFloat(rValDec, "r");
  2981. }
  2982. });
  2983. rgbValuesQuadrant.addControl(rValDec, 0, 2);
  2984. gValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  2985. gValDec.width = 0.95;
  2986. gValDec.height = 0.72;
  2987. gValDec.name = "gDecField";
  2988. gValDec.fontSize = buttonFontSize;
  2989. gValDec.text = currentColor.g.toString();
  2990. gValDec.color = inputTextColor;
  2991. gValDec.background = inputTextBackgroundColor;
  2992. gValDec.onFocusObservable.add(function () {
  2993. activeField = gValDec.name;
  2994. lastVal = gValDec.text;
  2995. editSwatches(false);
  2996. });
  2997. gValDec.onBlurObservable.add(function () {
  2998. if (parseFloat(gValDec.text) == 0 || gValDec.text == "") {
  2999. gValDec.text = "0";
  3000. updateFloat(gValDec, "g");
  3001. }
  3002. if (activeField == gValDec.name) {
  3003. activeField = "";
  3004. }
  3005. });
  3006. gValDec.onTextChangedObservable.add(function () {
  3007. if (activeField == gValDec.name) {
  3008. updateFloat(gValDec, "g");
  3009. }
  3010. });
  3011. rgbValuesQuadrant.addControl(gValDec, 1, 2);
  3012. bValDec = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3013. bValDec.width = 0.95;
  3014. bValDec.height = 0.72;
  3015. bValDec.name = "bDecField";
  3016. bValDec.fontSize = buttonFontSize;
  3017. bValDec.text = currentColor.b.toString();
  3018. bValDec.color = inputTextColor;
  3019. bValDec.background = inputTextBackgroundColor;
  3020. bValDec.onFocusObservable.add(function () {
  3021. activeField = bValDec.name;
  3022. lastVal = bValDec.text;
  3023. editSwatches(false);
  3024. });
  3025. bValDec.onBlurObservable.add(function () {
  3026. if (parseFloat(bValDec.text) == 0 || bValDec.text == "") {
  3027. bValDec.text = "0";
  3028. updateFloat(bValDec, "b");
  3029. }
  3030. if (activeField == bValDec.name) {
  3031. activeField = "";
  3032. }
  3033. });
  3034. bValDec.onTextChangedObservable.add(function () {
  3035. if (activeField == bValDec.name) {
  3036. updateFloat(bValDec, "b");
  3037. }
  3038. });
  3039. rgbValuesQuadrant.addControl(bValDec, 2, 2);
  3040. // Hex value input
  3041. var hexValueQuadrant = new _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]();
  3042. hexValueQuadrant.name = "Hex Value";
  3043. hexValueQuadrant.width = 0.82;
  3044. hexValueQuadrant.addRowDefinition(1.0, false);
  3045. hexValueQuadrant.addColumnDefinition(0.1, false);
  3046. hexValueQuadrant.addColumnDefinition(0.9, false);
  3047. pickerColorValues.addControl(hexValueQuadrant, 2, 0);
  3048. var labelText = new _controls_textBlock__WEBPACK_IMPORTED_MODULE_7__["TextBlock"]();
  3049. labelText.text = "#";
  3050. labelText.color = buttonColor;
  3051. labelText.fontSize = buttonFontSize;
  3052. hexValueQuadrant.addControl(labelText, 0, 0);
  3053. hexVal = new _inputText__WEBPACK_IMPORTED_MODULE_3__["InputText"]();
  3054. hexVal.width = 0.96;
  3055. hexVal.height = 0.72;
  3056. hexVal.name = "hexField";
  3057. hexVal.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  3058. hexVal.fontSize = buttonFontSize;
  3059. var minusPound = options.lastColor.split("#");
  3060. hexVal.text = minusPound[1];
  3061. hexVal.color = inputTextColor;
  3062. hexVal.background = inputTextBackgroundColor;
  3063. hexVal.onFocusObservable.add(function () {
  3064. activeField = hexVal.name;
  3065. lastVal = hexVal.text;
  3066. editSwatches(false);
  3067. });
  3068. hexVal.onBlurObservable.add(function () {
  3069. if (hexVal.text.length == 3) {
  3070. var val = hexVal.text.split("");
  3071. hexVal.text = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3072. }
  3073. if (hexVal.text == "") {
  3074. hexVal.text = "000000";
  3075. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(hexVal.text), "b");
  3076. }
  3077. if (activeField == hexVal.name) {
  3078. activeField = "";
  3079. }
  3080. });
  3081. hexVal.onTextChangedObservable.add(function () {
  3082. var newHexValue = hexVal.text;
  3083. var checkHex = /[^0-9A-F]/i.test(newHexValue);
  3084. if ((hexVal.text.length > 6 || checkHex) && activeField == hexVal.name) {
  3085. hexVal.text = lastVal;
  3086. }
  3087. else {
  3088. if (hexVal.text.length < 6) {
  3089. var leadingZero = 6 - hexVal.text.length;
  3090. for (var i = 0; i < leadingZero; i++) {
  3091. newHexValue = "0" + newHexValue;
  3092. }
  3093. }
  3094. if (hexVal.text.length == 3) {
  3095. var val = hexVal.text.split("");
  3096. newHexValue = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
  3097. }
  3098. newHexValue = "#" + newHexValue;
  3099. if (activeField == hexVal.name) {
  3100. lastVal = hexVal.text;
  3101. updateValues(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromHexString(newHexValue), hexVal.name);
  3102. }
  3103. }
  3104. });
  3105. hexValueQuadrant.addControl(hexVal, 0, 1);
  3106. if (options.savedColors && options.savedColors.length > 0) {
  3107. updateSwatches("", butSave);
  3108. }
  3109. });
  3110. };
  3111. ColorPicker._Epsilon = 0.000001;
  3112. return ColorPicker;
  3113. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3114. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ColorPicker"] = ColorPicker;
  3115. /***/ }),
  3116. /***/ "./2D/controls/container.ts":
  3117. /*!**********************************!*\
  3118. !*** ./2D/controls/container.ts ***!
  3119. \**********************************/
  3120. /*! exports provided: Container */
  3121. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3122. "use strict";
  3123. __webpack_require__.r(__webpack_exports__);
  3124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return Container; });
  3125. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  3126. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Maths/math");
  3127. /* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__);
  3128. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  3129. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3130. /**
  3131. * Root class for 2D containers
  3132. * @see http://doc.babylonjs.com/how_to/gui#containers
  3133. */
  3134. var Container = /** @class */ (function (_super) {
  3135. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container, _super);
  3136. /**
  3137. * Creates a new Container
  3138. * @param name defines the name of the container
  3139. */
  3140. function Container(name) {
  3141. var _this = _super.call(this, name) || this;
  3142. _this.name = name;
  3143. /** @hidden */
  3144. _this._children = new Array();
  3145. /** @hidden */
  3146. _this._measureForChildren = _measure__WEBPACK_IMPORTED_MODULE_3__["Measure"].Empty();
  3147. /** @hidden */
  3148. _this._background = "";
  3149. /** @hidden */
  3150. _this._adaptWidthToChildren = false;
  3151. /** @hidden */
  3152. _this._adaptHeightToChildren = false;
  3153. /**
  3154. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  3155. */
  3156. _this.logLayoutCycleErrors = false;
  3157. /**
  3158. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  3159. */
  3160. _this.maxLayoutCycle = 3;
  3161. return _this;
  3162. }
  3163. Object.defineProperty(Container.prototype, "adaptHeightToChildren", {
  3164. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  3165. get: function () {
  3166. return this._adaptHeightToChildren;
  3167. },
  3168. set: function (value) {
  3169. if (this._adaptHeightToChildren === value) {
  3170. return;
  3171. }
  3172. this._adaptHeightToChildren = value;
  3173. if (value) {
  3174. this.height = "100%";
  3175. }
  3176. this._markAsDirty();
  3177. },
  3178. enumerable: true,
  3179. configurable: true
  3180. });
  3181. Object.defineProperty(Container.prototype, "adaptWidthToChildren", {
  3182. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  3183. get: function () {
  3184. return this._adaptWidthToChildren;
  3185. },
  3186. set: function (value) {
  3187. if (this._adaptWidthToChildren === value) {
  3188. return;
  3189. }
  3190. this._adaptWidthToChildren = value;
  3191. if (value) {
  3192. this.width = "100%";
  3193. }
  3194. this._markAsDirty();
  3195. },
  3196. enumerable: true,
  3197. configurable: true
  3198. });
  3199. Object.defineProperty(Container.prototype, "background", {
  3200. /** Gets or sets background color */
  3201. get: function () {
  3202. return this._background;
  3203. },
  3204. set: function (value) {
  3205. if (this._background === value) {
  3206. return;
  3207. }
  3208. this._background = value;
  3209. this._markAsDirty();
  3210. },
  3211. enumerable: true,
  3212. configurable: true
  3213. });
  3214. Object.defineProperty(Container.prototype, "children", {
  3215. /** Gets the list of children */
  3216. get: function () {
  3217. return this._children;
  3218. },
  3219. enumerable: true,
  3220. configurable: true
  3221. });
  3222. Container.prototype._getTypeName = function () {
  3223. return "Container";
  3224. };
  3225. Container.prototype._flagDescendantsAsMatrixDirty = function () {
  3226. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3227. var child = _a[_i];
  3228. child._markMatrixAsDirty();
  3229. }
  3230. };
  3231. /**
  3232. * Gets a child using its name
  3233. * @param name defines the child name to look for
  3234. * @returns the child control if found
  3235. */
  3236. Container.prototype.getChildByName = function (name) {
  3237. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3238. var child = _a[_i];
  3239. if (child.name === name) {
  3240. return child;
  3241. }
  3242. }
  3243. return null;
  3244. };
  3245. /**
  3246. * Gets a child using its type and its name
  3247. * @param name defines the child name to look for
  3248. * @param type defines the child type to look for
  3249. * @returns the child control if found
  3250. */
  3251. Container.prototype.getChildByType = function (name, type) {
  3252. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  3253. var child = _a[_i];
  3254. if (child.typeName === type) {
  3255. return child;
  3256. }
  3257. }
  3258. return null;
  3259. };
  3260. /**
  3261. * Search for a specific control in children
  3262. * @param control defines the control to look for
  3263. * @returns true if the control is in child list
  3264. */
  3265. Container.prototype.containsControl = function (control) {
  3266. return this.children.indexOf(control) !== -1;
  3267. };
  3268. /**
  3269. * Adds a new control to the current container
  3270. * @param control defines the control to add
  3271. * @returns the current container
  3272. */
  3273. Container.prototype.addControl = function (control) {
  3274. if (!control) {
  3275. return this;
  3276. }
  3277. var index = this._children.indexOf(control);
  3278. if (index !== -1) {
  3279. return this;
  3280. }
  3281. control._link(this._host);
  3282. control._markAllAsDirty();
  3283. this._reOrderControl(control);
  3284. this._markAsDirty();
  3285. return this;
  3286. };
  3287. /**
  3288. * Removes all controls from the current container
  3289. * @returns the current container
  3290. */
  3291. Container.prototype.clearControls = function () {
  3292. var children = this.children.slice();
  3293. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  3294. var child = children_1[_i];
  3295. this.removeControl(child);
  3296. }
  3297. return this;
  3298. };
  3299. /**
  3300. * Removes a control from the current container
  3301. * @param control defines the control to remove
  3302. * @returns the current container
  3303. */
  3304. Container.prototype.removeControl = function (control) {
  3305. var index = this._children.indexOf(control);
  3306. if (index !== -1) {
  3307. this._children.splice(index, 1);
  3308. control.parent = null;
  3309. }
  3310. control.linkWithMesh(null);
  3311. if (this._host) {
  3312. this._host._cleanControlAfterRemoval(control);
  3313. }
  3314. this._markAsDirty();
  3315. return this;
  3316. };
  3317. /** @hidden */
  3318. Container.prototype._reOrderControl = function (control) {
  3319. this.removeControl(control);
  3320. var wasAdded = false;
  3321. for (var index = 0; index < this._children.length; index++) {
  3322. if (this._children[index].zIndex > control.zIndex) {
  3323. this._children.splice(index, 0, control);
  3324. wasAdded = true;
  3325. break;
  3326. }
  3327. }
  3328. if (!wasAdded) {
  3329. this._children.push(control);
  3330. }
  3331. control.parent = this;
  3332. this._markAsDirty();
  3333. };
  3334. /** @hidden */
  3335. Container.prototype._offsetLeft = function (offset) {
  3336. _super.prototype._offsetLeft.call(this, offset);
  3337. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3338. var child = _a[_i];
  3339. child._offsetLeft(offset);
  3340. }
  3341. };
  3342. /** @hidden */
  3343. Container.prototype._offsetTop = function (offset) {
  3344. _super.prototype._offsetTop.call(this, offset);
  3345. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3346. var child = _a[_i];
  3347. child._offsetTop(offset);
  3348. }
  3349. };
  3350. /** @hidden */
  3351. Container.prototype._markAllAsDirty = function () {
  3352. _super.prototype._markAllAsDirty.call(this);
  3353. for (var index = 0; index < this._children.length; index++) {
  3354. this._children[index]._markAllAsDirty();
  3355. }
  3356. };
  3357. /** @hidden */
  3358. Container.prototype._localDraw = function (context) {
  3359. if (this._background) {
  3360. context.save();
  3361. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  3362. context.shadowColor = this.shadowColor;
  3363. context.shadowBlur = this.shadowBlur;
  3364. context.shadowOffsetX = this.shadowOffsetX;
  3365. context.shadowOffsetY = this.shadowOffsetY;
  3366. }
  3367. context.fillStyle = this._background;
  3368. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  3369. context.restore();
  3370. }
  3371. };
  3372. /** @hidden */
  3373. Container.prototype._link = function (host) {
  3374. _super.prototype._link.call(this, host);
  3375. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3376. var child = _a[_i];
  3377. child._link(host);
  3378. }
  3379. };
  3380. /** @hidden */
  3381. Container.prototype._beforeLayout = function () {
  3382. // Do nothing
  3383. };
  3384. /** @hidden */
  3385. Container.prototype._processMeasures = function (parentMeasure, context) {
  3386. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  3387. _super.prototype._processMeasures.call(this, parentMeasure, context);
  3388. this._evaluateClippingState(parentMeasure);
  3389. }
  3390. };
  3391. /** @hidden */
  3392. Container.prototype._layout = function (parentMeasure, context) {
  3393. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  3394. return false;
  3395. }
  3396. if (this._isDirty) {
  3397. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  3398. }
  3399. var rebuildCount = 0;
  3400. context.save();
  3401. this._applyStates(context);
  3402. this._beforeLayout();
  3403. do {
  3404. var computedWidth = -1;
  3405. var computedHeight = -1;
  3406. this._rebuildLayout = false;
  3407. this._processMeasures(parentMeasure, context);
  3408. if (!this._isClipped) {
  3409. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3410. var child = _a[_i];
  3411. child._tempParentMeasure.copyFrom(this._measureForChildren);
  3412. if (child._layout(this._measureForChildren, context)) {
  3413. if (this.adaptWidthToChildren && child._width.isPixel) {
  3414. computedWidth = Math.max(computedWidth, child._currentMeasure.width);
  3415. }
  3416. if (this.adaptHeightToChildren && child._height.isPixel) {
  3417. computedHeight = Math.max(computedHeight, child._currentMeasure.height);
  3418. }
  3419. }
  3420. }
  3421. if (this.adaptWidthToChildren && computedWidth >= 0) {
  3422. if (this.width !== computedWidth + "px") {
  3423. this.width = computedWidth + "px";
  3424. this._rebuildLayout = true;
  3425. }
  3426. }
  3427. if (this.adaptHeightToChildren && computedHeight >= 0) {
  3428. if (this.height !== computedHeight + "px") {
  3429. this.height = computedHeight + "px";
  3430. this._rebuildLayout = true;
  3431. }
  3432. }
  3433. this._postMeasure();
  3434. }
  3435. rebuildCount++;
  3436. } while (this._rebuildLayout && rebuildCount < this.maxLayoutCycle);
  3437. if (rebuildCount >= 3 && this.logLayoutCycleErrors) {
  3438. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Layout cycle detected in GUI (Container name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  3439. }
  3440. context.restore();
  3441. if (this._isDirty) {
  3442. this.invalidateRect();
  3443. this._isDirty = false;
  3444. }
  3445. return true;
  3446. };
  3447. Container.prototype._postMeasure = function () {
  3448. // Do nothing by default
  3449. };
  3450. /** @hidden */
  3451. Container.prototype._draw = function (context, invalidatedRectangle) {
  3452. this._localDraw(context);
  3453. if (this.clipChildren) {
  3454. this._clipForChildren(context);
  3455. }
  3456. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  3457. var child = _a[_i];
  3458. // Only redraw parts of the screen that are invalidated
  3459. if (invalidatedRectangle) {
  3460. if (!child._intersectsRect(invalidatedRectangle)) {
  3461. continue;
  3462. }
  3463. }
  3464. child._render(context, invalidatedRectangle);
  3465. }
  3466. };
  3467. Container.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  3468. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  3469. if (!this.children) {
  3470. return;
  3471. }
  3472. for (var index = 0; index < this.children.length; index++) {
  3473. var item = this.children[index];
  3474. if (!predicate || predicate(item)) {
  3475. results.push(item);
  3476. }
  3477. if (!directDescendantsOnly) {
  3478. item.getDescendantsToRef(results, false, predicate);
  3479. }
  3480. }
  3481. };
  3482. /** @hidden */
  3483. Container.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  3484. if (!this._isEnabled || !this.isVisible || this.notRenderable) {
  3485. return false;
  3486. }
  3487. if (!_super.prototype.contains.call(this, x, y)) {
  3488. return false;
  3489. }
  3490. // Checking backwards to pick closest first
  3491. for (var index = this._children.length - 1; index >= 0; index--) {
  3492. var child = this._children[index];
  3493. if (child._processPicking(x, y, type, pointerId, buttonIndex)) {
  3494. if (child.hoverCursor) {
  3495. this._host._changeCursor(child.hoverCursor);
  3496. }
  3497. return true;
  3498. }
  3499. }
  3500. if (!this.isHitTestVisible) {
  3501. return false;
  3502. }
  3503. return this._processObservables(type, x, y, pointerId, buttonIndex);
  3504. };
  3505. /** @hidden */
  3506. Container.prototype._additionalProcessing = function (parentMeasure, context) {
  3507. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  3508. this._measureForChildren.copyFrom(this._currentMeasure);
  3509. };
  3510. /** Releases associated resources */
  3511. Container.prototype.dispose = function () {
  3512. _super.prototype.dispose.call(this);
  3513. for (var index = this.children.length - 1; index >= 0; index--) {
  3514. this.children[index].dispose();
  3515. }
  3516. };
  3517. return Container;
  3518. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  3519. babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Container"] = Container;
  3520. /***/ }),
  3521. /***/ "./2D/controls/control.ts":
  3522. /*!********************************!*\
  3523. !*** ./2D/controls/control.ts ***!
  3524. \********************************/
  3525. /*! exports provided: Control */
  3526. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3527. "use strict";
  3528. __webpack_require__.r(__webpack_exports__);
  3529. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return Control; });
  3530. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  3531. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  3532. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  3533. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../measure */ "./2D/measure.ts");
  3534. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../math2D */ "./2D/math2D.ts");
  3535. /**
  3536. * Root class used for all 2D controls
  3537. * @see http://doc.babylonjs.com/how_to/gui#controls
  3538. */
  3539. var Control = /** @class */ (function () {
  3540. // Functions
  3541. /**
  3542. * Creates a new control
  3543. * @param name defines the name of the control
  3544. */
  3545. function Control(
  3546. /** defines the name of the control */
  3547. name) {
  3548. this.name = name;
  3549. this._alpha = 1;
  3550. this._alphaSet = false;
  3551. this._zIndex = 0;
  3552. /** @hidden */
  3553. this._currentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3554. this._fontFamily = "Arial";
  3555. this._fontStyle = "";
  3556. this._fontWeight = "";
  3557. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  3558. /** @hidden */
  3559. this._width = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3560. /** @hidden */
  3561. this._height = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  3562. this._color = "";
  3563. this._style = null;
  3564. /** @hidden */
  3565. this._horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_CENTER;
  3566. /** @hidden */
  3567. this._verticalAlignment = Control.VERTICAL_ALIGNMENT_CENTER;
  3568. /** @hidden */
  3569. this._isDirty = true;
  3570. /** @hidden */
  3571. this._wasDirty = false;
  3572. /** @hidden */
  3573. this._tempParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3574. /** @hidden */
  3575. this._prevCurrentMeasureTransformedIntoGlobalSpace = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3576. /** @hidden */
  3577. this._cachedParentMeasure = _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].Empty();
  3578. this._paddingLeft = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3579. this._paddingRight = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3580. this._paddingTop = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3581. this._paddingBottom = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3582. /** @hidden */
  3583. this._left = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3584. /** @hidden */
  3585. this._top = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3586. this._scaleX = 1.0;
  3587. this._scaleY = 1.0;
  3588. this._rotation = 0;
  3589. this._transformCenterX = 0.5;
  3590. this._transformCenterY = 0.5;
  3591. /** @hidden */
  3592. this._transformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3593. /** @hidden */
  3594. this._invertTransformMatrix = _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].Identity();
  3595. /** @hidden */
  3596. this._transformedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3597. this._isMatrixDirty = true;
  3598. this._isVisible = true;
  3599. this._isHighlighted = false;
  3600. this._fontSet = false;
  3601. this._dummyVector2 = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  3602. this._downCount = 0;
  3603. this._enterCount = -1;
  3604. this._doNotRender = false;
  3605. this._downPointerIds = {};
  3606. this._isEnabled = true;
  3607. this._disabledColor = "#9a9a9a";
  3608. /** @hidden */
  3609. this._rebuildLayout = false;
  3610. /** @hidden */
  3611. this._isClipped = false;
  3612. /** @hidden */
  3613. this._automaticSize = false;
  3614. /**
  3615. * Gets or sets an object used to store user defined information for the node
  3616. */
  3617. this.metadata = null;
  3618. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  3619. this.isHitTestVisible = true;
  3620. /** Gets or sets a boolean indicating if the control can block pointer events */
  3621. this.isPointerBlocker = false;
  3622. /** Gets or sets a boolean indicating if the control can be focusable */
  3623. this.isFocusInvisible = false;
  3624. /**
  3625. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  3626. * 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
  3627. */
  3628. this.clipChildren = true;
  3629. /**
  3630. * Gets or sets a boolean indicating that control content must be clipped
  3631. * 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
  3632. */
  3633. this.clipContent = true;
  3634. /**
  3635. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  3636. */
  3637. this.useBitmapCache = false;
  3638. this._shadowOffsetX = 0;
  3639. this._shadowOffsetY = 0;
  3640. this._shadowBlur = 0;
  3641. this._shadowColor = 'black';
  3642. /** Gets or sets the cursor to use when the control is hovered */
  3643. this.hoverCursor = "";
  3644. /** @hidden */
  3645. this._linkOffsetX = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3646. /** @hidden */
  3647. this._linkOffsetY = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  3648. /**
  3649. * An event triggered when the pointer move over the control.
  3650. */
  3651. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3652. /**
  3653. * An event triggered when the pointer move out of the control.
  3654. */
  3655. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3656. /**
  3657. * An event triggered when the pointer taps the control
  3658. */
  3659. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3660. /**
  3661. * An event triggered when pointer up
  3662. */
  3663. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3664. /**
  3665. * An event triggered when a control is clicked on
  3666. */
  3667. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3668. /**
  3669. * An event triggered when pointer enters the control
  3670. */
  3671. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3672. /**
  3673. * An event triggered when the control is marked as dirty
  3674. */
  3675. this.onDirtyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3676. /**
  3677. * An event triggered before drawing the control
  3678. */
  3679. this.onBeforeDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3680. /**
  3681. * An event triggered after the control was drawn
  3682. */
  3683. this.onAfterDrawObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  3684. this._tmpMeasureA = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  3685. }
  3686. Object.defineProperty(Control.prototype, "shadowOffsetX", {
  3687. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  3688. get: function () {
  3689. return this._shadowOffsetX;
  3690. },
  3691. set: function (value) {
  3692. if (this._shadowOffsetX === value) {
  3693. return;
  3694. }
  3695. this._shadowOffsetX = value;
  3696. this._markAsDirty();
  3697. },
  3698. enumerable: true,
  3699. configurable: true
  3700. });
  3701. Object.defineProperty(Control.prototype, "shadowOffsetY", {
  3702. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  3703. get: function () {
  3704. return this._shadowOffsetY;
  3705. },
  3706. set: function (value) {
  3707. if (this._shadowOffsetY === value) {
  3708. return;
  3709. }
  3710. this._shadowOffsetY = value;
  3711. this._markAsDirty();
  3712. },
  3713. enumerable: true,
  3714. configurable: true
  3715. });
  3716. Object.defineProperty(Control.prototype, "shadowBlur", {
  3717. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  3718. get: function () {
  3719. return this._shadowBlur;
  3720. },
  3721. set: function (value) {
  3722. if (this._shadowBlur === value) {
  3723. return;
  3724. }
  3725. this._shadowBlur = value;
  3726. this._markAsDirty();
  3727. },
  3728. enumerable: true,
  3729. configurable: true
  3730. });
  3731. Object.defineProperty(Control.prototype, "shadowColor", {
  3732. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  3733. get: function () {
  3734. return this._shadowColor;
  3735. },
  3736. set: function (value) {
  3737. if (this._shadowColor === value) {
  3738. return;
  3739. }
  3740. this._shadowColor = value;
  3741. this._markAsDirty();
  3742. },
  3743. enumerable: true,
  3744. configurable: true
  3745. });
  3746. Object.defineProperty(Control.prototype, "typeName", {
  3747. // Properties
  3748. /** Gets the control type name */
  3749. get: function () {
  3750. return this._getTypeName();
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. /**
  3756. * Get the current class name of the control.
  3757. * @returns current class name
  3758. */
  3759. Control.prototype.getClassName = function () {
  3760. return this._getTypeName();
  3761. };
  3762. Object.defineProperty(Control.prototype, "host", {
  3763. /**
  3764. * Get the hosting AdvancedDynamicTexture
  3765. */
  3766. get: function () {
  3767. return this._host;
  3768. },
  3769. enumerable: true,
  3770. configurable: true
  3771. });
  3772. Object.defineProperty(Control.prototype, "fontOffset", {
  3773. /** Gets or set information about font offsets (used to render and align text) */
  3774. get: function () {
  3775. return this._fontOffset;
  3776. },
  3777. set: function (offset) {
  3778. this._fontOffset = offset;
  3779. },
  3780. enumerable: true,
  3781. configurable: true
  3782. });
  3783. Object.defineProperty(Control.prototype, "alpha", {
  3784. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  3785. get: function () {
  3786. return this._alpha;
  3787. },
  3788. set: function (value) {
  3789. if (this._alpha === value) {
  3790. return;
  3791. }
  3792. this._alphaSet = true;
  3793. this._alpha = value;
  3794. this._markAsDirty();
  3795. },
  3796. enumerable: true,
  3797. configurable: true
  3798. });
  3799. Object.defineProperty(Control.prototype, "isHighlighted", {
  3800. /**
  3801. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  3802. */
  3803. get: function () {
  3804. return this._isHighlighted;
  3805. },
  3806. set: function (value) {
  3807. if (this._isHighlighted === value) {
  3808. return;
  3809. }
  3810. this._isHighlighted = value;
  3811. this._markAsDirty();
  3812. },
  3813. enumerable: true,
  3814. configurable: true
  3815. });
  3816. Object.defineProperty(Control.prototype, "scaleX", {
  3817. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  3818. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3819. */
  3820. get: function () {
  3821. return this._scaleX;
  3822. },
  3823. set: function (value) {
  3824. if (this._scaleX === value) {
  3825. return;
  3826. }
  3827. this._scaleX = value;
  3828. this._markAsDirty();
  3829. this._markMatrixAsDirty();
  3830. },
  3831. enumerable: true,
  3832. configurable: true
  3833. });
  3834. Object.defineProperty(Control.prototype, "scaleY", {
  3835. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  3836. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3837. */
  3838. get: function () {
  3839. return this._scaleY;
  3840. },
  3841. set: function (value) {
  3842. if (this._scaleY === value) {
  3843. return;
  3844. }
  3845. this._scaleY = value;
  3846. this._markAsDirty();
  3847. this._markMatrixAsDirty();
  3848. },
  3849. enumerable: true,
  3850. configurable: true
  3851. });
  3852. Object.defineProperty(Control.prototype, "rotation", {
  3853. /** Gets or sets the rotation angle (0 by default)
  3854. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3855. */
  3856. get: function () {
  3857. return this._rotation;
  3858. },
  3859. set: function (value) {
  3860. if (this._rotation === value) {
  3861. return;
  3862. }
  3863. this._rotation = value;
  3864. this._markAsDirty();
  3865. this._markMatrixAsDirty();
  3866. },
  3867. enumerable: true,
  3868. configurable: true
  3869. });
  3870. Object.defineProperty(Control.prototype, "transformCenterY", {
  3871. /** Gets or sets the transformation center on Y axis (0 by default)
  3872. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3873. */
  3874. get: function () {
  3875. return this._transformCenterY;
  3876. },
  3877. set: function (value) {
  3878. if (this._transformCenterY === value) {
  3879. return;
  3880. }
  3881. this._transformCenterY = value;
  3882. this._markAsDirty();
  3883. this._markMatrixAsDirty();
  3884. },
  3885. enumerable: true,
  3886. configurable: true
  3887. });
  3888. Object.defineProperty(Control.prototype, "transformCenterX", {
  3889. /** Gets or sets the transformation center on X axis (0 by default)
  3890. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  3891. */
  3892. get: function () {
  3893. return this._transformCenterX;
  3894. },
  3895. set: function (value) {
  3896. if (this._transformCenterX === value) {
  3897. return;
  3898. }
  3899. this._transformCenterX = value;
  3900. this._markAsDirty();
  3901. this._markMatrixAsDirty();
  3902. },
  3903. enumerable: true,
  3904. configurable: true
  3905. });
  3906. Object.defineProperty(Control.prototype, "horizontalAlignment", {
  3907. /**
  3908. * Gets or sets the horizontal alignment
  3909. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3910. */
  3911. get: function () {
  3912. return this._horizontalAlignment;
  3913. },
  3914. set: function (value) {
  3915. if (this._horizontalAlignment === value) {
  3916. return;
  3917. }
  3918. this._horizontalAlignment = value;
  3919. this._markAsDirty();
  3920. },
  3921. enumerable: true,
  3922. configurable: true
  3923. });
  3924. Object.defineProperty(Control.prototype, "verticalAlignment", {
  3925. /**
  3926. * Gets or sets the vertical alignment
  3927. * @see http://doc.babylonjs.com/how_to/gui#alignments
  3928. */
  3929. get: function () {
  3930. return this._verticalAlignment;
  3931. },
  3932. set: function (value) {
  3933. if (this._verticalAlignment === value) {
  3934. return;
  3935. }
  3936. this._verticalAlignment = value;
  3937. this._markAsDirty();
  3938. },
  3939. enumerable: true,
  3940. configurable: true
  3941. });
  3942. Object.defineProperty(Control.prototype, "width", {
  3943. /**
  3944. * Gets or sets control width
  3945. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3946. */
  3947. get: function () {
  3948. return this._width.toString(this._host);
  3949. },
  3950. set: function (value) {
  3951. if (this._width.toString(this._host) === value) {
  3952. return;
  3953. }
  3954. if (this._width.fromString(value)) {
  3955. this._markAsDirty();
  3956. }
  3957. },
  3958. enumerable: true,
  3959. configurable: true
  3960. });
  3961. Object.defineProperty(Control.prototype, "widthInPixels", {
  3962. /**
  3963. * Gets or sets the control width in pixel
  3964. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3965. */
  3966. get: function () {
  3967. return this._width.getValueInPixel(this._host, this._cachedParentMeasure.width);
  3968. },
  3969. set: function (value) {
  3970. if (isNaN(value)) {
  3971. return;
  3972. }
  3973. this.width = value + "px";
  3974. },
  3975. enumerable: true,
  3976. configurable: true
  3977. });
  3978. Object.defineProperty(Control.prototype, "height", {
  3979. /**
  3980. * Gets or sets control height
  3981. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  3982. */
  3983. get: function () {
  3984. return this._height.toString(this._host);
  3985. },
  3986. set: function (value) {
  3987. if (this._height.toString(this._host) === value) {
  3988. return;
  3989. }
  3990. if (this._height.fromString(value)) {
  3991. this._markAsDirty();
  3992. }
  3993. },
  3994. enumerable: true,
  3995. configurable: true
  3996. });
  3997. Object.defineProperty(Control.prototype, "heightInPixels", {
  3998. /**
  3999. * Gets or sets control height in pixel
  4000. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4001. */
  4002. get: function () {
  4003. return this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4004. },
  4005. set: function (value) {
  4006. if (isNaN(value)) {
  4007. return;
  4008. }
  4009. this.height = value + "px";
  4010. },
  4011. enumerable: true,
  4012. configurable: true
  4013. });
  4014. Object.defineProperty(Control.prototype, "fontFamily", {
  4015. /** Gets or set font family */
  4016. get: function () {
  4017. if (!this._fontSet) {
  4018. return "";
  4019. }
  4020. return this._fontFamily;
  4021. },
  4022. set: function (value) {
  4023. if (this._fontFamily === value) {
  4024. return;
  4025. }
  4026. this._fontFamily = value;
  4027. this._resetFontCache();
  4028. },
  4029. enumerable: true,
  4030. configurable: true
  4031. });
  4032. Object.defineProperty(Control.prototype, "fontStyle", {
  4033. /** Gets or sets font style */
  4034. get: function () {
  4035. return this._fontStyle;
  4036. },
  4037. set: function (value) {
  4038. if (this._fontStyle === value) {
  4039. return;
  4040. }
  4041. this._fontStyle = value;
  4042. this._resetFontCache();
  4043. },
  4044. enumerable: true,
  4045. configurable: true
  4046. });
  4047. Object.defineProperty(Control.prototype, "fontWeight", {
  4048. /** Gets or sets font weight */
  4049. get: function () {
  4050. return this._fontWeight;
  4051. },
  4052. set: function (value) {
  4053. if (this._fontWeight === value) {
  4054. return;
  4055. }
  4056. this._fontWeight = value;
  4057. this._resetFontCache();
  4058. },
  4059. enumerable: true,
  4060. configurable: true
  4061. });
  4062. Object.defineProperty(Control.prototype, "style", {
  4063. /**
  4064. * Gets or sets style
  4065. * @see http://doc.babylonjs.com/how_to/gui#styles
  4066. */
  4067. get: function () {
  4068. return this._style;
  4069. },
  4070. set: function (value) {
  4071. var _this = this;
  4072. if (this._style) {
  4073. this._style.onChangedObservable.remove(this._styleObserver);
  4074. this._styleObserver = null;
  4075. }
  4076. this._style = value;
  4077. if (this._style) {
  4078. this._styleObserver = this._style.onChangedObservable.add(function () {
  4079. _this._markAsDirty();
  4080. _this._resetFontCache();
  4081. });
  4082. }
  4083. this._markAsDirty();
  4084. this._resetFontCache();
  4085. },
  4086. enumerable: true,
  4087. configurable: true
  4088. });
  4089. Object.defineProperty(Control.prototype, "_isFontSizeInPercentage", {
  4090. /** @hidden */
  4091. get: function () {
  4092. return this._fontSize.isPercentage;
  4093. },
  4094. enumerable: true,
  4095. configurable: true
  4096. });
  4097. Object.defineProperty(Control.prototype, "fontSizeInPixels", {
  4098. /** Gets or sets font size in pixels */
  4099. get: function () {
  4100. var fontSizeToUse = this._style ? this._style._fontSize : this._fontSize;
  4101. if (fontSizeToUse.isPixel) {
  4102. return fontSizeToUse.getValue(this._host);
  4103. }
  4104. return fontSizeToUse.getValueInPixel(this._host, this._tempParentMeasure.height || this._cachedParentMeasure.height);
  4105. },
  4106. set: function (value) {
  4107. if (isNaN(value)) {
  4108. return;
  4109. }
  4110. this.fontSize = value + "px";
  4111. },
  4112. enumerable: true,
  4113. configurable: true
  4114. });
  4115. Object.defineProperty(Control.prototype, "fontSize", {
  4116. /** Gets or sets font size */
  4117. get: function () {
  4118. return this._fontSize.toString(this._host);
  4119. },
  4120. set: function (value) {
  4121. if (this._fontSize.toString(this._host) === value) {
  4122. return;
  4123. }
  4124. if (this._fontSize.fromString(value)) {
  4125. this._markAsDirty();
  4126. this._resetFontCache();
  4127. }
  4128. },
  4129. enumerable: true,
  4130. configurable: true
  4131. });
  4132. Object.defineProperty(Control.prototype, "color", {
  4133. /** Gets or sets foreground color */
  4134. get: function () {
  4135. return this._color;
  4136. },
  4137. set: function (value) {
  4138. if (this._color === value) {
  4139. return;
  4140. }
  4141. this._color = value;
  4142. this._markAsDirty();
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(Control.prototype, "zIndex", {
  4148. /** Gets or sets z index which is used to reorder controls on the z axis */
  4149. get: function () {
  4150. return this._zIndex;
  4151. },
  4152. set: function (value) {
  4153. if (this.zIndex === value) {
  4154. return;
  4155. }
  4156. this._zIndex = value;
  4157. if (this.parent) {
  4158. this.parent._reOrderControl(this);
  4159. }
  4160. },
  4161. enumerable: true,
  4162. configurable: true
  4163. });
  4164. Object.defineProperty(Control.prototype, "notRenderable", {
  4165. /** Gets or sets a boolean indicating if the control can be rendered */
  4166. get: function () {
  4167. return this._doNotRender;
  4168. },
  4169. set: function (value) {
  4170. if (this._doNotRender === value) {
  4171. return;
  4172. }
  4173. this._doNotRender = value;
  4174. this._markAsDirty();
  4175. },
  4176. enumerable: true,
  4177. configurable: true
  4178. });
  4179. Object.defineProperty(Control.prototype, "isVisible", {
  4180. /** Gets or sets a boolean indicating if the control is visible */
  4181. get: function () {
  4182. return this._isVisible;
  4183. },
  4184. set: function (value) {
  4185. if (this._isVisible === value) {
  4186. return;
  4187. }
  4188. this._isVisible = value;
  4189. this._markAsDirty(true);
  4190. },
  4191. enumerable: true,
  4192. configurable: true
  4193. });
  4194. Object.defineProperty(Control.prototype, "isDirty", {
  4195. /** Gets a boolean indicating that the control needs to update its rendering */
  4196. get: function () {
  4197. return this._isDirty;
  4198. },
  4199. enumerable: true,
  4200. configurable: true
  4201. });
  4202. Object.defineProperty(Control.prototype, "linkedMesh", {
  4203. /**
  4204. * Gets the current linked mesh (or null if none)
  4205. */
  4206. get: function () {
  4207. return this._linkedMesh;
  4208. },
  4209. enumerable: true,
  4210. configurable: true
  4211. });
  4212. Object.defineProperty(Control.prototype, "paddingLeft", {
  4213. /**
  4214. * Gets or sets a value indicating the padding to use on the left of the control
  4215. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4216. */
  4217. get: function () {
  4218. return this._paddingLeft.toString(this._host);
  4219. },
  4220. set: function (value) {
  4221. if (this._paddingLeft.fromString(value)) {
  4222. this._markAsDirty();
  4223. }
  4224. },
  4225. enumerable: true,
  4226. configurable: true
  4227. });
  4228. Object.defineProperty(Control.prototype, "paddingLeftInPixels", {
  4229. /**
  4230. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  4231. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4232. */
  4233. get: function () {
  4234. return this._paddingLeft.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4235. },
  4236. set: function (value) {
  4237. if (isNaN(value)) {
  4238. return;
  4239. }
  4240. this.paddingLeft = value + "px";
  4241. },
  4242. enumerable: true,
  4243. configurable: true
  4244. });
  4245. Object.defineProperty(Control.prototype, "paddingRight", {
  4246. /**
  4247. * Gets or sets a value indicating the padding to use on the right of the control
  4248. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4249. */
  4250. get: function () {
  4251. return this._paddingRight.toString(this._host);
  4252. },
  4253. set: function (value) {
  4254. if (this._paddingRight.fromString(value)) {
  4255. this._markAsDirty();
  4256. }
  4257. },
  4258. enumerable: true,
  4259. configurable: true
  4260. });
  4261. Object.defineProperty(Control.prototype, "paddingRightInPixels", {
  4262. /**
  4263. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  4264. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4265. */
  4266. get: function () {
  4267. return this._paddingRight.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4268. },
  4269. set: function (value) {
  4270. if (isNaN(value)) {
  4271. return;
  4272. }
  4273. this.paddingRight = value + "px";
  4274. },
  4275. enumerable: true,
  4276. configurable: true
  4277. });
  4278. Object.defineProperty(Control.prototype, "paddingTop", {
  4279. /**
  4280. * Gets or sets a value indicating the padding to use on the top of the control
  4281. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4282. */
  4283. get: function () {
  4284. return this._paddingTop.toString(this._host);
  4285. },
  4286. set: function (value) {
  4287. if (this._paddingTop.fromString(value)) {
  4288. this._markAsDirty();
  4289. }
  4290. },
  4291. enumerable: true,
  4292. configurable: true
  4293. });
  4294. Object.defineProperty(Control.prototype, "paddingTopInPixels", {
  4295. /**
  4296. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  4297. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4298. */
  4299. get: function () {
  4300. return this._paddingTop.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4301. },
  4302. set: function (value) {
  4303. if (isNaN(value)) {
  4304. return;
  4305. }
  4306. this.paddingTop = value + "px";
  4307. },
  4308. enumerable: true,
  4309. configurable: true
  4310. });
  4311. Object.defineProperty(Control.prototype, "paddingBottom", {
  4312. /**
  4313. * Gets or sets a value indicating the padding to use on the bottom of the control
  4314. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4315. */
  4316. get: function () {
  4317. return this._paddingBottom.toString(this._host);
  4318. },
  4319. set: function (value) {
  4320. if (this._paddingBottom.fromString(value)) {
  4321. this._markAsDirty();
  4322. }
  4323. },
  4324. enumerable: true,
  4325. configurable: true
  4326. });
  4327. Object.defineProperty(Control.prototype, "paddingBottomInPixels", {
  4328. /**
  4329. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  4330. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4331. */
  4332. get: function () {
  4333. return this._paddingBottom.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4334. },
  4335. set: function (value) {
  4336. if (isNaN(value)) {
  4337. return;
  4338. }
  4339. this.paddingBottom = value + "px";
  4340. },
  4341. enumerable: true,
  4342. configurable: true
  4343. });
  4344. Object.defineProperty(Control.prototype, "left", {
  4345. /**
  4346. * Gets or sets a value indicating the left coordinate of the control
  4347. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4348. */
  4349. get: function () {
  4350. return this._left.toString(this._host);
  4351. },
  4352. set: function (value) {
  4353. if (this._left.fromString(value)) {
  4354. this._markAsDirty();
  4355. }
  4356. },
  4357. enumerable: true,
  4358. configurable: true
  4359. });
  4360. Object.defineProperty(Control.prototype, "leftInPixels", {
  4361. /**
  4362. * Gets or sets a value indicating the left coordinate in pixels of the control
  4363. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4364. */
  4365. get: function () {
  4366. return this._left.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4367. },
  4368. set: function (value) {
  4369. if (isNaN(value)) {
  4370. return;
  4371. }
  4372. this.left = value + "px";
  4373. },
  4374. enumerable: true,
  4375. configurable: true
  4376. });
  4377. Object.defineProperty(Control.prototype, "top", {
  4378. /**
  4379. * Gets or sets a value indicating the top coordinate of the control
  4380. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4381. */
  4382. get: function () {
  4383. return this._top.toString(this._host);
  4384. },
  4385. set: function (value) {
  4386. if (this._top.fromString(value)) {
  4387. this._markAsDirty();
  4388. }
  4389. },
  4390. enumerable: true,
  4391. configurable: true
  4392. });
  4393. Object.defineProperty(Control.prototype, "topInPixels", {
  4394. /**
  4395. * Gets or sets a value indicating the top coordinate in pixels of the control
  4396. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  4397. */
  4398. get: function () {
  4399. return this._top.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4400. },
  4401. set: function (value) {
  4402. if (isNaN(value)) {
  4403. return;
  4404. }
  4405. this.top = value + "px";
  4406. },
  4407. enumerable: true,
  4408. configurable: true
  4409. });
  4410. Object.defineProperty(Control.prototype, "linkOffsetX", {
  4411. /**
  4412. * Gets or sets a value indicating the offset on X axis to the linked mesh
  4413. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4414. */
  4415. get: function () {
  4416. return this._linkOffsetX.toString(this._host);
  4417. },
  4418. set: function (value) {
  4419. if (this._linkOffsetX.fromString(value)) {
  4420. this._markAsDirty();
  4421. }
  4422. },
  4423. enumerable: true,
  4424. configurable: true
  4425. });
  4426. Object.defineProperty(Control.prototype, "linkOffsetXInPixels", {
  4427. /**
  4428. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  4429. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4430. */
  4431. get: function () {
  4432. return this._linkOffsetX.getValueInPixel(this._host, this._cachedParentMeasure.width);
  4433. },
  4434. set: function (value) {
  4435. if (isNaN(value)) {
  4436. return;
  4437. }
  4438. this.linkOffsetX = value + "px";
  4439. },
  4440. enumerable: true,
  4441. configurable: true
  4442. });
  4443. Object.defineProperty(Control.prototype, "linkOffsetY", {
  4444. /**
  4445. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  4446. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4447. */
  4448. get: function () {
  4449. return this._linkOffsetY.toString(this._host);
  4450. },
  4451. set: function (value) {
  4452. if (this._linkOffsetY.fromString(value)) {
  4453. this._markAsDirty();
  4454. }
  4455. },
  4456. enumerable: true,
  4457. configurable: true
  4458. });
  4459. Object.defineProperty(Control.prototype, "linkOffsetYInPixels", {
  4460. /**
  4461. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  4462. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4463. */
  4464. get: function () {
  4465. return this._linkOffsetY.getValueInPixel(this._host, this._cachedParentMeasure.height);
  4466. },
  4467. set: function (value) {
  4468. if (isNaN(value)) {
  4469. return;
  4470. }
  4471. this.linkOffsetY = value + "px";
  4472. },
  4473. enumerable: true,
  4474. configurable: true
  4475. });
  4476. Object.defineProperty(Control.prototype, "centerX", {
  4477. /** Gets the center coordinate on X axis */
  4478. get: function () {
  4479. return this._currentMeasure.left + this._currentMeasure.width / 2;
  4480. },
  4481. enumerable: true,
  4482. configurable: true
  4483. });
  4484. Object.defineProperty(Control.prototype, "centerY", {
  4485. /** Gets the center coordinate on Y axis */
  4486. get: function () {
  4487. return this._currentMeasure.top + this._currentMeasure.height / 2;
  4488. },
  4489. enumerable: true,
  4490. configurable: true
  4491. });
  4492. Object.defineProperty(Control.prototype, "isEnabled", {
  4493. /** Gets or sets if control is Enabled*/
  4494. get: function () {
  4495. return this._isEnabled;
  4496. },
  4497. set: function (value) {
  4498. if (this._isEnabled === value) {
  4499. return;
  4500. }
  4501. this._isEnabled = value;
  4502. this._markAsDirty();
  4503. },
  4504. enumerable: true,
  4505. configurable: true
  4506. });
  4507. Object.defineProperty(Control.prototype, "disabledColor", {
  4508. /** Gets or sets background color of control if it's disabled*/
  4509. get: function () {
  4510. return this._disabledColor;
  4511. },
  4512. set: function (value) {
  4513. if (this._disabledColor === value) {
  4514. return;
  4515. }
  4516. this._disabledColor = value;
  4517. this._markAsDirty();
  4518. },
  4519. enumerable: true,
  4520. configurable: true
  4521. });
  4522. /** @hidden */
  4523. Control.prototype._getTypeName = function () {
  4524. return "Control";
  4525. };
  4526. /**
  4527. * Gets the first ascendant in the hierarchy of the given type
  4528. * @param className defines the required type
  4529. * @returns the ascendant or null if not found
  4530. */
  4531. Control.prototype.getAscendantOfClass = function (className) {
  4532. if (!this.parent) {
  4533. return null;
  4534. }
  4535. if (this.parent.getClassName() === className) {
  4536. return this.parent;
  4537. }
  4538. return this.parent.getAscendantOfClass(className);
  4539. };
  4540. /** @hidden */
  4541. Control.prototype._resetFontCache = function () {
  4542. this._fontSet = true;
  4543. this._markAsDirty();
  4544. };
  4545. /**
  4546. * Determines if a container is an ascendant of the current control
  4547. * @param container defines the container to look for
  4548. * @returns true if the container is one of the ascendant of the control
  4549. */
  4550. Control.prototype.isAscendant = function (container) {
  4551. if (!this.parent) {
  4552. return false;
  4553. }
  4554. if (this.parent === container) {
  4555. return true;
  4556. }
  4557. return this.parent.isAscendant(container);
  4558. };
  4559. /**
  4560. * Gets coordinates in local control space
  4561. * @param globalCoordinates defines the coordinates to transform
  4562. * @returns the new coordinates in local space
  4563. */
  4564. Control.prototype.getLocalCoordinates = function (globalCoordinates) {
  4565. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4566. this.getLocalCoordinatesToRef(globalCoordinates, result);
  4567. return result;
  4568. };
  4569. /**
  4570. * Gets coordinates in local control space
  4571. * @param globalCoordinates defines the coordinates to transform
  4572. * @param result defines the target vector2 where to store the result
  4573. * @returns the current control
  4574. */
  4575. Control.prototype.getLocalCoordinatesToRef = function (globalCoordinates, result) {
  4576. result.x = globalCoordinates.x - this._currentMeasure.left;
  4577. result.y = globalCoordinates.y - this._currentMeasure.top;
  4578. return this;
  4579. };
  4580. /**
  4581. * Gets coordinates in parent local control space
  4582. * @param globalCoordinates defines the coordinates to transform
  4583. * @returns the new coordinates in parent local space
  4584. */
  4585. Control.prototype.getParentLocalCoordinates = function (globalCoordinates) {
  4586. var result = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  4587. result.x = globalCoordinates.x - this._cachedParentMeasure.left;
  4588. result.y = globalCoordinates.y - this._cachedParentMeasure.top;
  4589. return result;
  4590. };
  4591. /**
  4592. * Move the current control to a vector3 position projected onto the screen.
  4593. * @param position defines the target position
  4594. * @param scene defines the hosting scene
  4595. */
  4596. Control.prototype.moveToVector3 = function (position, scene) {
  4597. if (!this._host || this.parent !== this._host._rootContainer) {
  4598. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  4599. return;
  4600. }
  4601. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4602. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4603. var globalViewport = this._host._getGlobalViewport(scene);
  4604. var projectedPosition = babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Project(position, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  4605. this._moveToProjectedPosition(projectedPosition);
  4606. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  4607. this.notRenderable = true;
  4608. return;
  4609. }
  4610. this.notRenderable = false;
  4611. };
  4612. /**
  4613. * Will store all controls that have this control as ascendant in a given array
  4614. * @param results defines the array where to store the descendants
  4615. * @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
  4616. * @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
  4617. */
  4618. Control.prototype.getDescendantsToRef = function (results, directDescendantsOnly, predicate) {
  4619. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  4620. // Do nothing by default
  4621. };
  4622. /**
  4623. * Will return all controls that have this control as ascendant
  4624. * @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
  4625. * @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
  4626. * @return all child controls
  4627. */
  4628. Control.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  4629. var results = new Array();
  4630. this.getDescendantsToRef(results, directDescendantsOnly, predicate);
  4631. return results;
  4632. };
  4633. /**
  4634. * Link current control with a target mesh
  4635. * @param mesh defines the mesh to link with
  4636. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  4637. */
  4638. Control.prototype.linkWithMesh = function (mesh) {
  4639. if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
  4640. if (mesh) {
  4641. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Cannot link a control to a mesh if the control is not at root level");
  4642. }
  4643. return;
  4644. }
  4645. var index = this._host._linkedControls.indexOf(this);
  4646. if (index !== -1) {
  4647. this._linkedMesh = mesh;
  4648. if (!mesh) {
  4649. this._host._linkedControls.splice(index, 1);
  4650. }
  4651. return;
  4652. }
  4653. else if (!mesh) {
  4654. return;
  4655. }
  4656. this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
  4657. this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
  4658. this._linkedMesh = mesh;
  4659. this._host._linkedControls.push(this);
  4660. };
  4661. /** @hidden */
  4662. Control.prototype._moveToProjectedPosition = function (projectedPosition) {
  4663. var oldLeft = this._left.getValue(this._host);
  4664. var oldTop = this._top.getValue(this._host);
  4665. var newLeft = ((projectedPosition.x + this._linkOffsetX.getValue(this._host)) - this._currentMeasure.width / 2);
  4666. var newTop = ((projectedPosition.y + this._linkOffsetY.getValue(this._host)) - this._currentMeasure.height / 2);
  4667. if (this._left.ignoreAdaptiveScaling && this._top.ignoreAdaptiveScaling) {
  4668. if (Math.abs(newLeft - oldLeft) < 0.5) {
  4669. newLeft = oldLeft;
  4670. }
  4671. if (Math.abs(newTop - oldTop) < 0.5) {
  4672. newTop = oldTop;
  4673. }
  4674. }
  4675. this.left = newLeft + "px";
  4676. this.top = newTop + "px";
  4677. this._left.ignoreAdaptiveScaling = true;
  4678. this._top.ignoreAdaptiveScaling = true;
  4679. this._markAsDirty();
  4680. };
  4681. /** @hidden */
  4682. Control.prototype._offsetLeft = function (offset) {
  4683. this._isDirty = true;
  4684. this._currentMeasure.left += offset;
  4685. };
  4686. /** @hidden */
  4687. Control.prototype._offsetTop = function (offset) {
  4688. this._isDirty = true;
  4689. this._currentMeasure.top += offset;
  4690. };
  4691. /** @hidden */
  4692. Control.prototype._markMatrixAsDirty = function () {
  4693. this._isMatrixDirty = true;
  4694. this._flagDescendantsAsMatrixDirty();
  4695. };
  4696. /** @hidden */
  4697. Control.prototype._flagDescendantsAsMatrixDirty = function () {
  4698. // No child
  4699. };
  4700. /** @hidden */
  4701. Control.prototype._intersectsRect = function (rect) {
  4702. // Rotate the control's current measure into local space and check if it intersects the passed in rectangle
  4703. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4704. if (this._tmpMeasureA.left >= rect.left + rect.width) {
  4705. return false;
  4706. }
  4707. if (this._tmpMeasureA.top >= rect.top + rect.height) {
  4708. return false;
  4709. }
  4710. if (this._tmpMeasureA.left + this._tmpMeasureA.width <= rect.left) {
  4711. return false;
  4712. }
  4713. if (this._tmpMeasureA.top + this._tmpMeasureA.height <= rect.top) {
  4714. return false;
  4715. }
  4716. return true;
  4717. };
  4718. /** @hidden */
  4719. Control.prototype.invalidateRect = function () {
  4720. this._transform();
  4721. if (this.host && this.host.useInvalidateRectOptimization) {
  4722. // Rotate by transform to get the measure transformed to global space
  4723. this._currentMeasure.transformToRef(this._transformMatrix, this._tmpMeasureA);
  4724. // get the boudning box of the current measure and last frames measure in global space and invalidate it
  4725. // the previous measure is used to properly clear a control that is scaled down
  4726. _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"].CombineToRef(this._tmpMeasureA, this._prevCurrentMeasureTransformedIntoGlobalSpace, this._tmpMeasureA);
  4727. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  4728. // Expand rect based on shadows
  4729. var shadowOffsetX = this.shadowOffsetX;
  4730. var shadowOffsetY = this.shadowOffsetY;
  4731. var shadowBlur = this.shadowBlur;
  4732. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  4733. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  4734. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  4735. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  4736. 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));
  4737. }
  4738. else {
  4739. 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));
  4740. }
  4741. }
  4742. };
  4743. /** @hidden */
  4744. Control.prototype._markAsDirty = function (force) {
  4745. if (force === void 0) { force = false; }
  4746. if (!this._isVisible && !force) {
  4747. return;
  4748. }
  4749. this._isDirty = true;
  4750. // Redraw only this rectangle
  4751. if (this._host) {
  4752. this._host.markAsDirty();
  4753. }
  4754. };
  4755. /** @hidden */
  4756. Control.prototype._markAllAsDirty = function () {
  4757. this._markAsDirty();
  4758. if (this._font) {
  4759. this._prepareFont();
  4760. }
  4761. };
  4762. /** @hidden */
  4763. Control.prototype._link = function (host) {
  4764. this._host = host;
  4765. if (this._host) {
  4766. this.uniqueId = this._host.getScene().getUniqueId();
  4767. }
  4768. };
  4769. /** @hidden */
  4770. Control.prototype._transform = function (context) {
  4771. if (!this._isMatrixDirty && this._scaleX === 1 && this._scaleY === 1 && this._rotation === 0) {
  4772. return;
  4773. }
  4774. // postTranslate
  4775. var offsetX = this._currentMeasure.width * this._transformCenterX + this._currentMeasure.left;
  4776. var offsetY = this._currentMeasure.height * this._transformCenterY + this._currentMeasure.top;
  4777. if (context) {
  4778. context.translate(offsetX, offsetY);
  4779. // rotate
  4780. context.rotate(this._rotation);
  4781. // scale
  4782. context.scale(this._scaleX, this._scaleY);
  4783. // preTranslate
  4784. context.translate(-offsetX, -offsetY);
  4785. }
  4786. // Need to update matrices?
  4787. if (this._isMatrixDirty || this._cachedOffsetX !== offsetX || this._cachedOffsetY !== offsetY) {
  4788. this._cachedOffsetX = offsetX;
  4789. this._cachedOffsetY = offsetY;
  4790. this._isMatrixDirty = false;
  4791. this._flagDescendantsAsMatrixDirty();
  4792. _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"].ComposeToRef(-offsetX, -offsetY, this._rotation, this._scaleX, this._scaleY, this.parent ? this.parent._transformMatrix : null, this._transformMatrix);
  4793. this._transformMatrix.invertToRef(this._invertTransformMatrix);
  4794. }
  4795. };
  4796. /** @hidden */
  4797. Control.prototype._renderHighlight = function (context) {
  4798. if (!this.isHighlighted) {
  4799. return;
  4800. }
  4801. context.save();
  4802. context.strokeStyle = "#4affff";
  4803. context.lineWidth = 2;
  4804. this._renderHighlightSpecific(context);
  4805. context.restore();
  4806. };
  4807. /** @hidden */
  4808. Control.prototype._renderHighlightSpecific = function (context) {
  4809. context.strokeRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  4810. };
  4811. /** @hidden */
  4812. Control.prototype._applyStates = function (context) {
  4813. if (this._isFontSizeInPercentage) {
  4814. this._fontSet = true;
  4815. }
  4816. if (this._fontSet) {
  4817. this._prepareFont();
  4818. this._fontSet = false;
  4819. }
  4820. if (this._font) {
  4821. context.font = this._font;
  4822. }
  4823. if (this._color) {
  4824. context.fillStyle = this._color;
  4825. }
  4826. if (Control.AllowAlphaInheritance) {
  4827. context.globalAlpha *= this._alpha;
  4828. }
  4829. else if (this._alphaSet) {
  4830. context.globalAlpha = this.parent ? this.parent.alpha * this._alpha : this._alpha;
  4831. }
  4832. };
  4833. /** @hidden */
  4834. Control.prototype._layout = function (parentMeasure, context) {
  4835. if (!this.isDirty && (!this.isVisible || this.notRenderable)) {
  4836. return false;
  4837. }
  4838. if (this._isDirty || !this._cachedParentMeasure.isEqualsTo(parentMeasure)) {
  4839. this._currentMeasure.transformToRef(this._transformMatrix, this._prevCurrentMeasureTransformedIntoGlobalSpace);
  4840. context.save();
  4841. this._applyStates(context);
  4842. var rebuildCount = 0;
  4843. do {
  4844. this._rebuildLayout = false;
  4845. this._processMeasures(parentMeasure, context);
  4846. rebuildCount++;
  4847. } while (this._rebuildLayout && rebuildCount < 3);
  4848. if (rebuildCount >= 3) {
  4849. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Layout cycle detected in GUI (Control name=" + this.name + ", uniqueId=" + this.uniqueId + ")");
  4850. }
  4851. context.restore();
  4852. this.invalidateRect();
  4853. this._evaluateClippingState(parentMeasure);
  4854. }
  4855. this._wasDirty = this._isDirty;
  4856. this._isDirty = false;
  4857. return true;
  4858. };
  4859. /** @hidden */
  4860. Control.prototype._processMeasures = function (parentMeasure, context) {
  4861. this._currentMeasure.copyFrom(parentMeasure);
  4862. // Let children take some pre-measurement actions
  4863. this._preMeasure(parentMeasure, context);
  4864. this._measure();
  4865. this._computeAlignment(parentMeasure, context);
  4866. // Convert to int values
  4867. this._currentMeasure.left = this._currentMeasure.left | 0;
  4868. this._currentMeasure.top = this._currentMeasure.top | 0;
  4869. this._currentMeasure.width = this._currentMeasure.width | 0;
  4870. this._currentMeasure.height = this._currentMeasure.height | 0;
  4871. // Let children add more features
  4872. this._additionalProcessing(parentMeasure, context);
  4873. this._cachedParentMeasure.copyFrom(parentMeasure);
  4874. if (this.onDirtyObservable.hasObservers()) {
  4875. this.onDirtyObservable.notifyObservers(this);
  4876. }
  4877. };
  4878. Control.prototype._evaluateClippingState = function (parentMeasure) {
  4879. if (this.parent && this.parent.clipChildren) {
  4880. // Early clip
  4881. if (this._currentMeasure.left > parentMeasure.left + parentMeasure.width) {
  4882. this._isClipped = true;
  4883. return;
  4884. }
  4885. if (this._currentMeasure.left + this._currentMeasure.width < parentMeasure.left) {
  4886. this._isClipped = true;
  4887. return;
  4888. }
  4889. if (this._currentMeasure.top > parentMeasure.top + parentMeasure.height) {
  4890. this._isClipped = true;
  4891. return;
  4892. }
  4893. if (this._currentMeasure.top + this._currentMeasure.height < parentMeasure.top) {
  4894. this._isClipped = true;
  4895. return;
  4896. }
  4897. }
  4898. this._isClipped = false;
  4899. };
  4900. /** @hidden */
  4901. Control.prototype._measure = function () {
  4902. // Width / Height
  4903. if (this._width.isPixel) {
  4904. this._currentMeasure.width = this._width.getValue(this._host);
  4905. }
  4906. else {
  4907. this._currentMeasure.width *= this._width.getValue(this._host);
  4908. }
  4909. if (this._height.isPixel) {
  4910. this._currentMeasure.height = this._height.getValue(this._host);
  4911. }
  4912. else {
  4913. this._currentMeasure.height *= this._height.getValue(this._host);
  4914. }
  4915. };
  4916. /** @hidden */
  4917. Control.prototype._computeAlignment = function (parentMeasure, context) {
  4918. var width = this._currentMeasure.width;
  4919. var height = this._currentMeasure.height;
  4920. var parentWidth = parentMeasure.width;
  4921. var parentHeight = parentMeasure.height;
  4922. // Left / top
  4923. var x = 0;
  4924. var y = 0;
  4925. switch (this.horizontalAlignment) {
  4926. case Control.HORIZONTAL_ALIGNMENT_LEFT:
  4927. x = 0;
  4928. break;
  4929. case Control.HORIZONTAL_ALIGNMENT_RIGHT:
  4930. x = parentWidth - width;
  4931. break;
  4932. case Control.HORIZONTAL_ALIGNMENT_CENTER:
  4933. x = (parentWidth - width) / 2;
  4934. break;
  4935. }
  4936. switch (this.verticalAlignment) {
  4937. case Control.VERTICAL_ALIGNMENT_TOP:
  4938. y = 0;
  4939. break;
  4940. case Control.VERTICAL_ALIGNMENT_BOTTOM:
  4941. y = parentHeight - height;
  4942. break;
  4943. case Control.VERTICAL_ALIGNMENT_CENTER:
  4944. y = (parentHeight - height) / 2;
  4945. break;
  4946. }
  4947. if (this._paddingLeft.isPixel) {
  4948. this._currentMeasure.left += this._paddingLeft.getValue(this._host);
  4949. this._currentMeasure.width -= this._paddingLeft.getValue(this._host);
  4950. }
  4951. else {
  4952. this._currentMeasure.left += parentWidth * this._paddingLeft.getValue(this._host);
  4953. this._currentMeasure.width -= parentWidth * this._paddingLeft.getValue(this._host);
  4954. }
  4955. if (this._paddingRight.isPixel) {
  4956. this._currentMeasure.width -= this._paddingRight.getValue(this._host);
  4957. }
  4958. else {
  4959. this._currentMeasure.width -= parentWidth * this._paddingRight.getValue(this._host);
  4960. }
  4961. if (this._paddingTop.isPixel) {
  4962. this._currentMeasure.top += this._paddingTop.getValue(this._host);
  4963. this._currentMeasure.height -= this._paddingTop.getValue(this._host);
  4964. }
  4965. else {
  4966. this._currentMeasure.top += parentHeight * this._paddingTop.getValue(this._host);
  4967. this._currentMeasure.height -= parentHeight * this._paddingTop.getValue(this._host);
  4968. }
  4969. if (this._paddingBottom.isPixel) {
  4970. this._currentMeasure.height -= this._paddingBottom.getValue(this._host);
  4971. }
  4972. else {
  4973. this._currentMeasure.height -= parentHeight * this._paddingBottom.getValue(this._host);
  4974. }
  4975. if (this._left.isPixel) {
  4976. this._currentMeasure.left += this._left.getValue(this._host);
  4977. }
  4978. else {
  4979. this._currentMeasure.left += parentWidth * this._left.getValue(this._host);
  4980. }
  4981. if (this._top.isPixel) {
  4982. this._currentMeasure.top += this._top.getValue(this._host);
  4983. }
  4984. else {
  4985. this._currentMeasure.top += parentHeight * this._top.getValue(this._host);
  4986. }
  4987. this._currentMeasure.left += x;
  4988. this._currentMeasure.top += y;
  4989. };
  4990. /** @hidden */
  4991. Control.prototype._preMeasure = function (parentMeasure, context) {
  4992. // Do nothing
  4993. };
  4994. /** @hidden */
  4995. Control.prototype._additionalProcessing = function (parentMeasure, context) {
  4996. // Do nothing
  4997. };
  4998. /** @hidden */
  4999. Control.prototype._clipForChildren = function (context) {
  5000. // DO nothing
  5001. };
  5002. Control.prototype._clip = function (context, invalidatedRectangle) {
  5003. context.beginPath();
  5004. Control._ClipMeasure.copyFrom(this._currentMeasure);
  5005. if (invalidatedRectangle) {
  5006. // Rotate the invalidated rect into the control's space
  5007. invalidatedRectangle.transformToRef(this._invertTransformMatrix, this._tmpMeasureA);
  5008. // Get the intersection of the rect in context space and the current context
  5009. var intersection = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5010. intersection.left = Math.max(this._tmpMeasureA.left, this._currentMeasure.left);
  5011. intersection.top = Math.max(this._tmpMeasureA.top, this._currentMeasure.top);
  5012. intersection.width = Math.min(this._tmpMeasureA.left + this._tmpMeasureA.width, this._currentMeasure.left + this._currentMeasure.width) - intersection.left;
  5013. intersection.height = Math.min(this._tmpMeasureA.top + this._tmpMeasureA.height, this._currentMeasure.top + this._currentMeasure.height) - intersection.top;
  5014. Control._ClipMeasure.copyFrom(intersection);
  5015. }
  5016. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5017. var shadowOffsetX = this.shadowOffsetX;
  5018. var shadowOffsetY = this.shadowOffsetY;
  5019. var shadowBlur = this.shadowBlur;
  5020. var leftShadowOffset = Math.min(Math.min(shadowOffsetX, 0) - shadowBlur * 2, 0);
  5021. var rightShadowOffset = Math.max(Math.max(shadowOffsetX, 0) + shadowBlur * 2, 0);
  5022. var topShadowOffset = Math.min(Math.min(shadowOffsetY, 0) - shadowBlur * 2, 0);
  5023. var bottomShadowOffset = Math.max(Math.max(shadowOffsetY, 0) + shadowBlur * 2, 0);
  5024. context.rect(Control._ClipMeasure.left + leftShadowOffset, Control._ClipMeasure.top + topShadowOffset, Control._ClipMeasure.width + rightShadowOffset - leftShadowOffset, Control._ClipMeasure.height + bottomShadowOffset - topShadowOffset);
  5025. }
  5026. else {
  5027. context.rect(Control._ClipMeasure.left, Control._ClipMeasure.top, Control._ClipMeasure.width, Control._ClipMeasure.height);
  5028. }
  5029. context.clip();
  5030. };
  5031. /** @hidden */
  5032. Control.prototype._render = function (context, invalidatedRectangle) {
  5033. if (!this.isVisible || this.notRenderable || this._isClipped) {
  5034. this._isDirty = false;
  5035. return false;
  5036. }
  5037. context.save();
  5038. this._applyStates(context);
  5039. // Transform
  5040. this._transform(context);
  5041. // Clip
  5042. if (this.clipContent) {
  5043. this._clip(context, invalidatedRectangle);
  5044. }
  5045. if (this.onBeforeDrawObservable.hasObservers()) {
  5046. this.onBeforeDrawObservable.notifyObservers(this);
  5047. }
  5048. if (this.useBitmapCache && !this._wasDirty && this._cacheData) {
  5049. context.putImageData(this._cacheData, this._currentMeasure.left, this._currentMeasure.top);
  5050. }
  5051. else {
  5052. this._draw(context, invalidatedRectangle);
  5053. }
  5054. if (this.useBitmapCache && this._wasDirty) {
  5055. this._cacheData = context.getImageData(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5056. }
  5057. this._renderHighlight(context);
  5058. if (this.onAfterDrawObservable.hasObservers()) {
  5059. this.onAfterDrawObservable.notifyObservers(this);
  5060. }
  5061. context.restore();
  5062. return true;
  5063. };
  5064. /** @hidden */
  5065. Control.prototype._draw = function (context, invalidatedRectangle) {
  5066. // Do nothing
  5067. };
  5068. /**
  5069. * Tests if a given coordinates belong to the current control
  5070. * @param x defines x coordinate to test
  5071. * @param y defines y coordinate to test
  5072. * @returns true if the coordinates are inside the control
  5073. */
  5074. Control.prototype.contains = function (x, y) {
  5075. // Invert transform
  5076. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  5077. x = this._transformedPosition.x;
  5078. y = this._transformedPosition.y;
  5079. // Check
  5080. if (x < this._currentMeasure.left) {
  5081. return false;
  5082. }
  5083. if (x > this._currentMeasure.left + this._currentMeasure.width) {
  5084. return false;
  5085. }
  5086. if (y < this._currentMeasure.top) {
  5087. return false;
  5088. }
  5089. if (y > this._currentMeasure.top + this._currentMeasure.height) {
  5090. return false;
  5091. }
  5092. if (this.isPointerBlocker) {
  5093. this._host._shouldBlockPointer = true;
  5094. }
  5095. return true;
  5096. };
  5097. /** @hidden */
  5098. Control.prototype._processPicking = function (x, y, type, pointerId, buttonIndex) {
  5099. if (!this._isEnabled) {
  5100. return false;
  5101. }
  5102. if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
  5103. return false;
  5104. }
  5105. if (!this.contains(x, y)) {
  5106. return false;
  5107. }
  5108. this._processObservables(type, x, y, pointerId, buttonIndex);
  5109. return true;
  5110. };
  5111. /** @hidden */
  5112. Control.prototype._onPointerMove = function (target, coordinates, pointerId) {
  5113. var canNotify = this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  5114. if (canNotify && this.parent != null) {
  5115. this.parent._onPointerMove(target, coordinates, pointerId);
  5116. }
  5117. };
  5118. /** @hidden */
  5119. Control.prototype._onPointerEnter = function (target) {
  5120. if (!this._isEnabled) {
  5121. return false;
  5122. }
  5123. if (this._enterCount > 0) {
  5124. return false;
  5125. }
  5126. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  5127. this._enterCount = 0;
  5128. }
  5129. this._enterCount++;
  5130. var canNotify = this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  5131. if (canNotify && this.parent != null) {
  5132. this.parent._onPointerEnter(target);
  5133. }
  5134. return true;
  5135. };
  5136. /** @hidden */
  5137. Control.prototype._onPointerOut = function (target, force) {
  5138. if (force === void 0) { force = false; }
  5139. if (!force && (!this._isEnabled || target === this)) {
  5140. return;
  5141. }
  5142. this._enterCount = 0;
  5143. var canNotify = true;
  5144. if (!target.isAscendant(this)) {
  5145. canNotify = this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  5146. }
  5147. if (canNotify && this.parent != null) {
  5148. this.parent._onPointerOut(target, force);
  5149. }
  5150. };
  5151. /** @hidden */
  5152. Control.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  5153. // Prevent pointerout to lose control context.
  5154. // Event redundancy is checked inside the function.
  5155. this._onPointerEnter(this);
  5156. if (this._downCount !== 0) {
  5157. return false;
  5158. }
  5159. this._downCount++;
  5160. this._downPointerIds[pointerId] = true;
  5161. var canNotify = this.onPointerDownObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5162. if (canNotify && this.parent != null) {
  5163. this.parent._onPointerDown(target, coordinates, pointerId, buttonIndex);
  5164. }
  5165. return true;
  5166. };
  5167. /** @hidden */
  5168. Control.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  5169. if (!this._isEnabled) {
  5170. return;
  5171. }
  5172. this._downCount = 0;
  5173. delete this._downPointerIds[pointerId];
  5174. var canNotifyClick = notifyClick;
  5175. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  5176. canNotifyClick = this.onPointerClickObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5177. }
  5178. var canNotify = this.onPointerUpObservable.notifyObservers(new _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"](coordinates, buttonIndex), -1, target, this);
  5179. if (canNotify && this.parent != null) {
  5180. this.parent._onPointerUp(target, coordinates, pointerId, buttonIndex, canNotifyClick);
  5181. }
  5182. };
  5183. /** @hidden */
  5184. Control.prototype._forcePointerUp = function (pointerId) {
  5185. if (pointerId === void 0) { pointerId = null; }
  5186. if (pointerId !== null) {
  5187. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), pointerId, 0, true);
  5188. }
  5189. else {
  5190. for (var key in this._downPointerIds) {
  5191. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero(), +key, 0, true);
  5192. }
  5193. }
  5194. };
  5195. /** @hidden */
  5196. Control.prototype._processObservables = function (type, x, y, pointerId, buttonIndex) {
  5197. if (!this._isEnabled) {
  5198. return false;
  5199. }
  5200. this._dummyVector2.copyFromFloats(x, y);
  5201. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  5202. this._onPointerMove(this, this._dummyVector2, pointerId);
  5203. var previousControlOver = this._host._lastControlOver[pointerId];
  5204. if (previousControlOver && previousControlOver !== this) {
  5205. previousControlOver._onPointerOut(this);
  5206. }
  5207. if (previousControlOver !== this) {
  5208. this._onPointerEnter(this);
  5209. }
  5210. this._host._lastControlOver[pointerId] = this;
  5211. return true;
  5212. }
  5213. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  5214. this._onPointerDown(this, this._dummyVector2, pointerId, buttonIndex);
  5215. this._host._registerLastControlDown(this, pointerId);
  5216. this._host._lastPickedControl = this;
  5217. return true;
  5218. }
  5219. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  5220. if (this._host._lastControlDown[pointerId]) {
  5221. this._host._lastControlDown[pointerId]._onPointerUp(this, this._dummyVector2, pointerId, buttonIndex, true);
  5222. }
  5223. delete this._host._lastControlDown[pointerId];
  5224. return true;
  5225. }
  5226. return false;
  5227. };
  5228. Control.prototype._prepareFont = function () {
  5229. if (!this._font && !this._fontSet) {
  5230. return;
  5231. }
  5232. if (this._style) {
  5233. this._font = this._style.fontStyle + " " + this._style.fontWeight + " " + this.fontSizeInPixels + "px " + this._style.fontFamily;
  5234. }
  5235. else {
  5236. this._font = this._fontStyle + " " + this._fontWeight + " " + this.fontSizeInPixels + "px " + this._fontFamily;
  5237. }
  5238. this._fontOffset = Control._GetFontOffset(this._font);
  5239. };
  5240. /** Releases associated resources */
  5241. Control.prototype.dispose = function () {
  5242. this.onDirtyObservable.clear();
  5243. this.onBeforeDrawObservable.clear();
  5244. this.onAfterDrawObservable.clear();
  5245. this.onPointerDownObservable.clear();
  5246. this.onPointerEnterObservable.clear();
  5247. this.onPointerMoveObservable.clear();
  5248. this.onPointerOutObservable.clear();
  5249. this.onPointerUpObservable.clear();
  5250. this.onPointerClickObservable.clear();
  5251. if (this._styleObserver && this._style) {
  5252. this._style.onChangedObservable.remove(this._styleObserver);
  5253. this._styleObserver = null;
  5254. }
  5255. if (this.parent) {
  5256. this.parent.removeControl(this);
  5257. this.parent = null;
  5258. }
  5259. if (this._host) {
  5260. var index = this._host._linkedControls.indexOf(this);
  5261. if (index > -1) {
  5262. this.linkWithMesh(null);
  5263. }
  5264. }
  5265. };
  5266. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_LEFT", {
  5267. /** HORIZONTAL_ALIGNMENT_LEFT */
  5268. get: function () {
  5269. return Control._HORIZONTAL_ALIGNMENT_LEFT;
  5270. },
  5271. enumerable: true,
  5272. configurable: true
  5273. });
  5274. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_RIGHT", {
  5275. /** HORIZONTAL_ALIGNMENT_RIGHT */
  5276. get: function () {
  5277. return Control._HORIZONTAL_ALIGNMENT_RIGHT;
  5278. },
  5279. enumerable: true,
  5280. configurable: true
  5281. });
  5282. Object.defineProperty(Control, "HORIZONTAL_ALIGNMENT_CENTER", {
  5283. /** HORIZONTAL_ALIGNMENT_CENTER */
  5284. get: function () {
  5285. return Control._HORIZONTAL_ALIGNMENT_CENTER;
  5286. },
  5287. enumerable: true,
  5288. configurable: true
  5289. });
  5290. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_TOP", {
  5291. /** VERTICAL_ALIGNMENT_TOP */
  5292. get: function () {
  5293. return Control._VERTICAL_ALIGNMENT_TOP;
  5294. },
  5295. enumerable: true,
  5296. configurable: true
  5297. });
  5298. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_BOTTOM", {
  5299. /** VERTICAL_ALIGNMENT_BOTTOM */
  5300. get: function () {
  5301. return Control._VERTICAL_ALIGNMENT_BOTTOM;
  5302. },
  5303. enumerable: true,
  5304. configurable: true
  5305. });
  5306. Object.defineProperty(Control, "VERTICAL_ALIGNMENT_CENTER", {
  5307. /** VERTICAL_ALIGNMENT_CENTER */
  5308. get: function () {
  5309. return Control._VERTICAL_ALIGNMENT_CENTER;
  5310. },
  5311. enumerable: true,
  5312. configurable: true
  5313. });
  5314. /** @hidden */
  5315. Control._GetFontOffset = function (font) {
  5316. if (Control._FontHeightSizes[font]) {
  5317. return Control._FontHeightSizes[font];
  5318. }
  5319. var text = document.createElement("span");
  5320. text.innerHTML = "Hg";
  5321. text.style.font = font;
  5322. var block = document.createElement("div");
  5323. block.style.display = "inline-block";
  5324. block.style.width = "1px";
  5325. block.style.height = "0px";
  5326. block.style.verticalAlign = "bottom";
  5327. var div = document.createElement("div");
  5328. div.appendChild(text);
  5329. div.appendChild(block);
  5330. document.body.appendChild(div);
  5331. var fontAscent = 0;
  5332. var fontHeight = 0;
  5333. try {
  5334. fontHeight = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5335. block.style.verticalAlign = "baseline";
  5336. fontAscent = block.getBoundingClientRect().top - text.getBoundingClientRect().top;
  5337. }
  5338. finally {
  5339. document.body.removeChild(div);
  5340. }
  5341. var result = { ascent: fontAscent, height: fontHeight, descent: fontHeight - fontAscent };
  5342. Control._FontHeightSizes[font] = result;
  5343. return result;
  5344. };
  5345. /** @hidden */
  5346. Control.drawEllipse = function (x, y, width, height, context) {
  5347. context.translate(x, y);
  5348. context.scale(width, height);
  5349. context.beginPath();
  5350. context.arc(0, 0, 1, 0, 2 * Math.PI);
  5351. context.closePath();
  5352. context.scale(1 / width, 1 / height);
  5353. context.translate(-x, -y);
  5354. };
  5355. /**
  5356. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  5357. */
  5358. Control.AllowAlphaInheritance = false;
  5359. Control._ClipMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  5360. // Statics
  5361. Control._HORIZONTAL_ALIGNMENT_LEFT = 0;
  5362. Control._HORIZONTAL_ALIGNMENT_RIGHT = 1;
  5363. Control._HORIZONTAL_ALIGNMENT_CENTER = 2;
  5364. Control._VERTICAL_ALIGNMENT_TOP = 0;
  5365. Control._VERTICAL_ALIGNMENT_BOTTOM = 1;
  5366. Control._VERTICAL_ALIGNMENT_CENTER = 2;
  5367. Control._FontHeightSizes = {};
  5368. /**
  5369. * Creates a stack panel that can be used to render headers
  5370. * @param control defines the control to associate with the header
  5371. * @param text defines the text of the header
  5372. * @param size defines the size of the header
  5373. * @param options defines options used to configure the header
  5374. * @returns a new StackPanel
  5375. * @ignore
  5376. * @hidden
  5377. */
  5378. Control.AddHeader = function () { };
  5379. return Control;
  5380. }());
  5381. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Control"] = Control;
  5382. /***/ }),
  5383. /***/ "./2D/controls/displayGrid.ts":
  5384. /*!************************************!*\
  5385. !*** ./2D/controls/displayGrid.ts ***!
  5386. \************************************/
  5387. /*! exports provided: DisplayGrid */
  5388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5389. "use strict";
  5390. __webpack_require__.r(__webpack_exports__);
  5391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return DisplayGrid; });
  5392. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5393. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5394. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  5395. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  5396. /** Class used to render a grid */
  5397. var DisplayGrid = /** @class */ (function (_super) {
  5398. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DisplayGrid, _super);
  5399. /**
  5400. * Creates a new GridDisplayRectangle
  5401. * @param name defines the control name
  5402. */
  5403. function DisplayGrid(name) {
  5404. var _this = _super.call(this, name) || this;
  5405. _this.name = name;
  5406. _this._cellWidth = 20;
  5407. _this._cellHeight = 20;
  5408. _this._minorLineTickness = 1;
  5409. _this._minorLineColor = "DarkGray";
  5410. _this._majorLineTickness = 2;
  5411. _this._majorLineColor = "White";
  5412. _this._majorLineFrequency = 5;
  5413. _this._background = "Black";
  5414. _this._displayMajorLines = true;
  5415. _this._displayMinorLines = true;
  5416. return _this;
  5417. }
  5418. Object.defineProperty(DisplayGrid.prototype, "displayMinorLines", {
  5419. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  5420. get: function () {
  5421. return this._displayMinorLines;
  5422. },
  5423. set: function (value) {
  5424. if (this._displayMinorLines === value) {
  5425. return;
  5426. }
  5427. this._displayMinorLines = value;
  5428. this._markAsDirty();
  5429. },
  5430. enumerable: true,
  5431. configurable: true
  5432. });
  5433. Object.defineProperty(DisplayGrid.prototype, "displayMajorLines", {
  5434. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  5435. get: function () {
  5436. return this._displayMajorLines;
  5437. },
  5438. set: function (value) {
  5439. if (this._displayMajorLines === value) {
  5440. return;
  5441. }
  5442. this._displayMajorLines = value;
  5443. this._markAsDirty();
  5444. },
  5445. enumerable: true,
  5446. configurable: true
  5447. });
  5448. Object.defineProperty(DisplayGrid.prototype, "background", {
  5449. /** Gets or sets background color (Black by default) */
  5450. get: function () {
  5451. return this._background;
  5452. },
  5453. set: function (value) {
  5454. if (this._background === value) {
  5455. return;
  5456. }
  5457. this._background = value;
  5458. this._markAsDirty();
  5459. },
  5460. enumerable: true,
  5461. configurable: true
  5462. });
  5463. Object.defineProperty(DisplayGrid.prototype, "cellWidth", {
  5464. /** Gets or sets the width of each cell (20 by default) */
  5465. get: function () {
  5466. return this._cellWidth;
  5467. },
  5468. set: function (value) {
  5469. this._cellWidth = value;
  5470. this._markAsDirty();
  5471. },
  5472. enumerable: true,
  5473. configurable: true
  5474. });
  5475. Object.defineProperty(DisplayGrid.prototype, "cellHeight", {
  5476. /** Gets or sets the height of each cell (20 by default) */
  5477. get: function () {
  5478. return this._cellHeight;
  5479. },
  5480. set: function (value) {
  5481. this._cellHeight = value;
  5482. this._markAsDirty();
  5483. },
  5484. enumerable: true,
  5485. configurable: true
  5486. });
  5487. Object.defineProperty(DisplayGrid.prototype, "minorLineTickness", {
  5488. /** Gets or sets the tickness of minor lines (1 by default) */
  5489. get: function () {
  5490. return this._minorLineTickness;
  5491. },
  5492. set: function (value) {
  5493. this._minorLineTickness = value;
  5494. this._markAsDirty();
  5495. },
  5496. enumerable: true,
  5497. configurable: true
  5498. });
  5499. Object.defineProperty(DisplayGrid.prototype, "minorLineColor", {
  5500. /** Gets or sets the color of minor lines (DarkGray by default) */
  5501. get: function () {
  5502. return this._minorLineColor;
  5503. },
  5504. set: function (value) {
  5505. this._minorLineColor = value;
  5506. this._markAsDirty();
  5507. },
  5508. enumerable: true,
  5509. configurable: true
  5510. });
  5511. Object.defineProperty(DisplayGrid.prototype, "majorLineTickness", {
  5512. /** Gets or sets the tickness of major lines (2 by default) */
  5513. get: function () {
  5514. return this._majorLineTickness;
  5515. },
  5516. set: function (value) {
  5517. this._majorLineTickness = value;
  5518. this._markAsDirty();
  5519. },
  5520. enumerable: true,
  5521. configurable: true
  5522. });
  5523. Object.defineProperty(DisplayGrid.prototype, "majorLineColor", {
  5524. /** Gets or sets the color of major lines (White by default) */
  5525. get: function () {
  5526. return this._majorLineColor;
  5527. },
  5528. set: function (value) {
  5529. this._majorLineColor = value;
  5530. this._markAsDirty();
  5531. },
  5532. enumerable: true,
  5533. configurable: true
  5534. });
  5535. Object.defineProperty(DisplayGrid.prototype, "majorLineFrequency", {
  5536. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  5537. get: function () {
  5538. return this._majorLineFrequency;
  5539. },
  5540. set: function (value) {
  5541. this._majorLineFrequency = value;
  5542. this._markAsDirty();
  5543. },
  5544. enumerable: true,
  5545. configurable: true
  5546. });
  5547. DisplayGrid.prototype._draw = function (context, invalidatedRectangle) {
  5548. context.save();
  5549. this._applyStates(context);
  5550. if (this._isEnabled) {
  5551. if (this._background) {
  5552. context.fillStyle = this._background;
  5553. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  5554. }
  5555. var cellCountX = this._currentMeasure.width / this._cellWidth;
  5556. var cellCountY = this._currentMeasure.height / this._cellHeight;
  5557. // Minor lines
  5558. var left = this._currentMeasure.left + this._currentMeasure.width / 2;
  5559. var top_1 = this._currentMeasure.top + this._currentMeasure.height / 2;
  5560. if (this._displayMinorLines) {
  5561. context.strokeStyle = this._minorLineColor;
  5562. context.lineWidth = this._minorLineTickness;
  5563. for (var x = -cellCountX / 2; x < cellCountX / 2; x++) {
  5564. var cellX = left + x * this.cellWidth;
  5565. context.beginPath();
  5566. context.moveTo(cellX, this._currentMeasure.top);
  5567. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5568. context.stroke();
  5569. }
  5570. for (var y = -cellCountY / 2; y < cellCountY / 2; y++) {
  5571. var cellY = top_1 + y * this.cellHeight;
  5572. context.beginPath();
  5573. context.moveTo(this._currentMeasure.left, cellY);
  5574. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5575. context.stroke();
  5576. }
  5577. }
  5578. // Major lines
  5579. if (this._displayMajorLines) {
  5580. context.strokeStyle = this._majorLineColor;
  5581. context.lineWidth = this._majorLineTickness;
  5582. for (var x = -cellCountX / 2 + this._majorLineFrequency; x < cellCountX / 2; x += this._majorLineFrequency) {
  5583. var cellX = left + x * this.cellWidth;
  5584. context.beginPath();
  5585. context.moveTo(cellX, this._currentMeasure.top);
  5586. context.lineTo(cellX, this._currentMeasure.top + this._currentMeasure.height);
  5587. context.stroke();
  5588. }
  5589. for (var y = -cellCountY / 2 + this._majorLineFrequency; y < cellCountY / 2; y += this._majorLineFrequency) {
  5590. var cellY = top_1 + y * this.cellHeight;
  5591. context.moveTo(this._currentMeasure.left, cellY);
  5592. context.lineTo(this._currentMeasure.left + this._currentMeasure.width, cellY);
  5593. context.closePath();
  5594. context.stroke();
  5595. }
  5596. }
  5597. }
  5598. context.restore();
  5599. };
  5600. DisplayGrid.prototype._getTypeName = function () {
  5601. return "DisplayGrid";
  5602. };
  5603. return DisplayGrid;
  5604. }(_control__WEBPACK_IMPORTED_MODULE_1__["Control"]));
  5605. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.DisplayGrid"] = DisplayGrid;
  5606. /***/ }),
  5607. /***/ "./2D/controls/ellipse.ts":
  5608. /*!********************************!*\
  5609. !*** ./2D/controls/ellipse.ts ***!
  5610. \********************************/
  5611. /*! exports provided: Ellipse */
  5612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5613. "use strict";
  5614. __webpack_require__.r(__webpack_exports__);
  5615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return Ellipse; });
  5616. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5617. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5618. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5619. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  5620. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  5621. /** Class used to create 2D ellipse containers */
  5622. var Ellipse = /** @class */ (function (_super) {
  5623. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Ellipse, _super);
  5624. /**
  5625. * Creates a new Ellipse
  5626. * @param name defines the control name
  5627. */
  5628. function Ellipse(name) {
  5629. var _this = _super.call(this, name) || this;
  5630. _this.name = name;
  5631. _this._thickness = 1;
  5632. return _this;
  5633. }
  5634. Object.defineProperty(Ellipse.prototype, "thickness", {
  5635. /** Gets or sets border thickness */
  5636. get: function () {
  5637. return this._thickness;
  5638. },
  5639. set: function (value) {
  5640. if (this._thickness === value) {
  5641. return;
  5642. }
  5643. this._thickness = value;
  5644. this._markAsDirty();
  5645. },
  5646. enumerable: true,
  5647. configurable: true
  5648. });
  5649. Ellipse.prototype._getTypeName = function () {
  5650. return "Ellipse";
  5651. };
  5652. Ellipse.prototype._localDraw = function (context) {
  5653. context.save();
  5654. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5655. context.shadowColor = this.shadowColor;
  5656. context.shadowBlur = this.shadowBlur;
  5657. context.shadowOffsetX = this.shadowOffsetX;
  5658. context.shadowOffsetY = this.shadowOffsetY;
  5659. }
  5660. _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);
  5661. if (this._background) {
  5662. context.fillStyle = this._background;
  5663. context.fill();
  5664. }
  5665. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  5666. context.shadowBlur = 0;
  5667. context.shadowOffsetX = 0;
  5668. context.shadowOffsetY = 0;
  5669. }
  5670. if (this._thickness) {
  5671. if (this.color) {
  5672. context.strokeStyle = this.color;
  5673. }
  5674. context.lineWidth = this._thickness;
  5675. context.stroke();
  5676. }
  5677. context.restore();
  5678. };
  5679. Ellipse.prototype._additionalProcessing = function (parentMeasure, context) {
  5680. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  5681. this._measureForChildren.width -= 2 * this._thickness;
  5682. this._measureForChildren.height -= 2 * this._thickness;
  5683. this._measureForChildren.left += this._thickness;
  5684. this._measureForChildren.top += this._thickness;
  5685. };
  5686. Ellipse.prototype._clipForChildren = function (context) {
  5687. _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);
  5688. context.clip();
  5689. };
  5690. return Ellipse;
  5691. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  5692. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Ellipse"] = Ellipse;
  5693. /***/ }),
  5694. /***/ "./2D/controls/grid.ts":
  5695. /*!*****************************!*\
  5696. !*** ./2D/controls/grid.ts ***!
  5697. \*****************************/
  5698. /*! exports provided: Grid */
  5699. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5700. "use strict";
  5701. __webpack_require__.r(__webpack_exports__);
  5702. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return Grid; });
  5703. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  5704. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  5705. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  5706. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  5707. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  5708. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__);
  5709. /**
  5710. * Class used to create a 2D grid container
  5711. */
  5712. var Grid = /** @class */ (function (_super) {
  5713. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Grid, _super);
  5714. /**
  5715. * Creates a new Grid
  5716. * @param name defines control name
  5717. */
  5718. function Grid(name) {
  5719. var _this = _super.call(this, name) || this;
  5720. _this.name = name;
  5721. _this._rowDefinitions = new Array();
  5722. _this._columnDefinitions = new Array();
  5723. _this._cells = {};
  5724. _this._childControls = new Array();
  5725. return _this;
  5726. }
  5727. Object.defineProperty(Grid.prototype, "columnCount", {
  5728. /**
  5729. * Gets the number of columns
  5730. */
  5731. get: function () {
  5732. return this._columnDefinitions.length;
  5733. },
  5734. enumerable: true,
  5735. configurable: true
  5736. });
  5737. Object.defineProperty(Grid.prototype, "rowCount", {
  5738. /**
  5739. * Gets the number of rows
  5740. */
  5741. get: function () {
  5742. return this._rowDefinitions.length;
  5743. },
  5744. enumerable: true,
  5745. configurable: true
  5746. });
  5747. Object.defineProperty(Grid.prototype, "children", {
  5748. /** Gets the list of children */
  5749. get: function () {
  5750. return this._childControls;
  5751. },
  5752. enumerable: true,
  5753. configurable: true
  5754. });
  5755. Object.defineProperty(Grid.prototype, "cells", {
  5756. /** Gets the list of cells (e.g. the containers) */
  5757. get: function () {
  5758. return this._cells;
  5759. },
  5760. enumerable: true,
  5761. configurable: true
  5762. });
  5763. /**
  5764. * Gets the definition of a specific row
  5765. * @param index defines the index of the row
  5766. * @returns the row definition
  5767. */
  5768. Grid.prototype.getRowDefinition = function (index) {
  5769. if (index < 0 || index >= this._rowDefinitions.length) {
  5770. return null;
  5771. }
  5772. return this._rowDefinitions[index];
  5773. };
  5774. /**
  5775. * Gets the definition of a specific column
  5776. * @param index defines the index of the column
  5777. * @returns the column definition
  5778. */
  5779. Grid.prototype.getColumnDefinition = function (index) {
  5780. if (index < 0 || index >= this._columnDefinitions.length) {
  5781. return null;
  5782. }
  5783. return this._columnDefinitions[index];
  5784. };
  5785. /**
  5786. * Adds a new row to the grid
  5787. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5788. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  5789. * @returns the current grid
  5790. */
  5791. Grid.prototype.addRowDefinition = function (height, isPixel) {
  5792. if (isPixel === void 0) { isPixel = false; }
  5793. 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));
  5794. this._markAsDirty();
  5795. return this;
  5796. };
  5797. /**
  5798. * Adds a new column to the grid
  5799. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5800. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5801. * @returns the current grid
  5802. */
  5803. Grid.prototype.addColumnDefinition = function (width, isPixel) {
  5804. if (isPixel === void 0) { isPixel = false; }
  5805. 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));
  5806. this._markAsDirty();
  5807. return this;
  5808. };
  5809. /**
  5810. * Update a row definition
  5811. * @param index defines the index of the row to update
  5812. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  5813. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  5814. * @returns the current grid
  5815. */
  5816. Grid.prototype.setRowDefinition = function (index, height, isPixel) {
  5817. if (isPixel === void 0) { isPixel = false; }
  5818. if (index < 0 || index >= this._rowDefinitions.length) {
  5819. return this;
  5820. }
  5821. var current = this._rowDefinitions[index];
  5822. if (current && current.isPixel === isPixel && current.internalValue === height) {
  5823. return this;
  5824. }
  5825. 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);
  5826. this._markAsDirty();
  5827. return this;
  5828. };
  5829. /**
  5830. * Update a column definition
  5831. * @param index defines the index of the column to update
  5832. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  5833. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  5834. * @returns the current grid
  5835. */
  5836. Grid.prototype.setColumnDefinition = function (index, width, isPixel) {
  5837. if (isPixel === void 0) { isPixel = false; }
  5838. if (index < 0 || index >= this._columnDefinitions.length) {
  5839. return this;
  5840. }
  5841. var current = this._columnDefinitions[index];
  5842. if (current && current.isPixel === isPixel && current.internalValue === width) {
  5843. return this;
  5844. }
  5845. 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);
  5846. this._markAsDirty();
  5847. return this;
  5848. };
  5849. /**
  5850. * Gets the list of children stored in a specific cell
  5851. * @param row defines the row to check
  5852. * @param column defines the column to check
  5853. * @returns the list of controls
  5854. */
  5855. Grid.prototype.getChildrenAt = function (row, column) {
  5856. var cell = this._cells[row + ":" + column];
  5857. if (!cell) {
  5858. return null;
  5859. }
  5860. return cell.children;
  5861. };
  5862. /**
  5863. * Gets a string representing the child cell info (row x column)
  5864. * @param child defines the control to get info from
  5865. * @returns a string containing the child cell info (row x column)
  5866. */
  5867. Grid.prototype.getChildCellInfo = function (child) {
  5868. return child._tag;
  5869. };
  5870. Grid.prototype._removeCell = function (cell, key) {
  5871. if (!cell) {
  5872. return;
  5873. }
  5874. _super.prototype.removeControl.call(this, cell);
  5875. for (var _i = 0, _a = cell.children; _i < _a.length; _i++) {
  5876. var control = _a[_i];
  5877. var childIndex = this._childControls.indexOf(control);
  5878. if (childIndex !== -1) {
  5879. this._childControls.splice(childIndex, 1);
  5880. }
  5881. }
  5882. delete this._cells[key];
  5883. };
  5884. Grid.prototype._offsetCell = function (previousKey, key) {
  5885. if (!this._cells[key]) {
  5886. return;
  5887. }
  5888. this._cells[previousKey] = this._cells[key];
  5889. for (var _i = 0, _a = this._cells[previousKey].children; _i < _a.length; _i++) {
  5890. var control = _a[_i];
  5891. control._tag = previousKey;
  5892. }
  5893. delete this._cells[key];
  5894. };
  5895. /**
  5896. * Remove a column definition at specified index
  5897. * @param index defines the index of the column to remove
  5898. * @returns the current grid
  5899. */
  5900. Grid.prototype.removeColumnDefinition = function (index) {
  5901. if (index < 0 || index >= this._columnDefinitions.length) {
  5902. return this;
  5903. }
  5904. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5905. var key = x + ":" + index;
  5906. var cell = this._cells[key];
  5907. this._removeCell(cell, key);
  5908. }
  5909. for (var x = 0; x < this._rowDefinitions.length; x++) {
  5910. for (var y = index + 1; y < this._columnDefinitions.length; y++) {
  5911. var previousKey = x + ":" + (y - 1);
  5912. var key = x + ":" + y;
  5913. this._offsetCell(previousKey, key);
  5914. }
  5915. }
  5916. this._columnDefinitions.splice(index, 1);
  5917. this._markAsDirty();
  5918. return this;
  5919. };
  5920. /**
  5921. * Remove a row definition at specified index
  5922. * @param index defines the index of the row to remove
  5923. * @returns the current grid
  5924. */
  5925. Grid.prototype.removeRowDefinition = function (index) {
  5926. if (index < 0 || index >= this._rowDefinitions.length) {
  5927. return this;
  5928. }
  5929. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5930. var key = index + ":" + y;
  5931. var cell = this._cells[key];
  5932. this._removeCell(cell, key);
  5933. }
  5934. for (var y = 0; y < this._columnDefinitions.length; y++) {
  5935. for (var x = index + 1; x < this._rowDefinitions.length; x++) {
  5936. var previousKey = x - 1 + ":" + y;
  5937. var key = x + ":" + y;
  5938. this._offsetCell(previousKey, key);
  5939. }
  5940. }
  5941. this._rowDefinitions.splice(index, 1);
  5942. this._markAsDirty();
  5943. return this;
  5944. };
  5945. /**
  5946. * Adds a new control to the current grid
  5947. * @param control defines the control to add
  5948. * @param row defines the row where to add the control (0 by default)
  5949. * @param column defines the column where to add the control (0 by default)
  5950. * @returns the current grid
  5951. */
  5952. Grid.prototype.addControl = function (control, row, column) {
  5953. if (row === void 0) { row = 0; }
  5954. if (column === void 0) { column = 0; }
  5955. if (this._rowDefinitions.length === 0) {
  5956. // Add default row definition
  5957. this.addRowDefinition(1, false);
  5958. }
  5959. if (this._columnDefinitions.length === 0) {
  5960. // Add default column definition
  5961. this.addColumnDefinition(1, false);
  5962. }
  5963. if (this._childControls.indexOf(control) !== -1) {
  5964. 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");
  5965. return this;
  5966. }
  5967. var x = Math.min(row, this._rowDefinitions.length - 1);
  5968. var y = Math.min(column, this._columnDefinitions.length - 1);
  5969. var key = x + ":" + y;
  5970. var goodContainer = this._cells[key];
  5971. if (!goodContainer) {
  5972. goodContainer = new _container__WEBPACK_IMPORTED_MODULE_1__["Container"](key);
  5973. this._cells[key] = goodContainer;
  5974. goodContainer.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  5975. goodContainer.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  5976. _super.prototype.addControl.call(this, goodContainer);
  5977. }
  5978. goodContainer.addControl(control);
  5979. this._childControls.push(control);
  5980. control._tag = key;
  5981. control.parent = this;
  5982. this._markAsDirty();
  5983. return this;
  5984. };
  5985. /**
  5986. * Removes a control from the current container
  5987. * @param control defines the control to remove
  5988. * @returns the current container
  5989. */
  5990. Grid.prototype.removeControl = function (control) {
  5991. var index = this._childControls.indexOf(control);
  5992. if (index !== -1) {
  5993. this._childControls.splice(index, 1);
  5994. }
  5995. var cell = this._cells[control._tag];
  5996. if (cell) {
  5997. cell.removeControl(control);
  5998. control._tag = null;
  5999. }
  6000. this._markAsDirty();
  6001. return this;
  6002. };
  6003. Grid.prototype._getTypeName = function () {
  6004. return "Grid";
  6005. };
  6006. Grid.prototype._getGridDefinitions = function (definitionCallback) {
  6007. var widths = [];
  6008. var heights = [];
  6009. var lefts = [];
  6010. var tops = [];
  6011. var availableWidth = this._currentMeasure.width;
  6012. var globalWidthPercentage = 0;
  6013. var availableHeight = this._currentMeasure.height;
  6014. var globalHeightPercentage = 0;
  6015. // Heights
  6016. var index = 0;
  6017. for (var _i = 0, _a = this._rowDefinitions; _i < _a.length; _i++) {
  6018. var value = _a[_i];
  6019. if (value.isPixel) {
  6020. var height = value.getValue(this._host);
  6021. availableHeight -= height;
  6022. heights[index] = height;
  6023. }
  6024. else {
  6025. globalHeightPercentage += value.internalValue;
  6026. }
  6027. index++;
  6028. }
  6029. var top = 0;
  6030. index = 0;
  6031. for (var _b = 0, _c = this._rowDefinitions; _b < _c.length; _b++) {
  6032. var value = _c[_b];
  6033. tops.push(top);
  6034. if (!value.isPixel) {
  6035. var height = (value.internalValue / globalHeightPercentage) * availableHeight;
  6036. top += height;
  6037. heights[index] = height;
  6038. }
  6039. else {
  6040. top += value.getValue(this._host);
  6041. }
  6042. index++;
  6043. }
  6044. // Widths
  6045. index = 0;
  6046. for (var _d = 0, _e = this._columnDefinitions; _d < _e.length; _d++) {
  6047. var value = _e[_d];
  6048. if (value.isPixel) {
  6049. var width = value.getValue(this._host);
  6050. availableWidth -= width;
  6051. widths[index] = width;
  6052. }
  6053. else {
  6054. globalWidthPercentage += value.internalValue;
  6055. }
  6056. index++;
  6057. }
  6058. var left = 0;
  6059. index = 0;
  6060. for (var _f = 0, _g = this._columnDefinitions; _f < _g.length; _f++) {
  6061. var value = _g[_f];
  6062. lefts.push(left);
  6063. if (!value.isPixel) {
  6064. var width = (value.internalValue / globalWidthPercentage) * availableWidth;
  6065. left += width;
  6066. widths[index] = width;
  6067. }
  6068. else {
  6069. left += value.getValue(this._host);
  6070. }
  6071. index++;
  6072. }
  6073. definitionCallback(lefts, tops, widths, heights);
  6074. };
  6075. Grid.prototype._additionalProcessing = function (parentMeasure, context) {
  6076. var _this = this;
  6077. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6078. // Setting child sizes
  6079. for (var key in _this._cells) {
  6080. if (!_this._cells.hasOwnProperty(key)) {
  6081. continue;
  6082. }
  6083. var split = key.split(":");
  6084. var x = parseInt(split[0]);
  6085. var y = parseInt(split[1]);
  6086. var cell = _this._cells[key];
  6087. cell.left = lefts[y] + "px";
  6088. cell.top = tops[x] + "px";
  6089. cell.width = widths[y] + "px";
  6090. cell.height = heights[x] + "px";
  6091. cell._left.ignoreAdaptiveScaling = true;
  6092. cell._top.ignoreAdaptiveScaling = true;
  6093. cell._width.ignoreAdaptiveScaling = true;
  6094. cell._height.ignoreAdaptiveScaling = true;
  6095. }
  6096. });
  6097. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  6098. };
  6099. Grid.prototype._flagDescendantsAsMatrixDirty = function () {
  6100. for (var key in this._cells) {
  6101. if (!this._cells.hasOwnProperty(key)) {
  6102. continue;
  6103. }
  6104. var child = this._cells[key];
  6105. child._markMatrixAsDirty();
  6106. }
  6107. };
  6108. Grid.prototype._renderHighlightSpecific = function (context) {
  6109. var _this = this;
  6110. _super.prototype._renderHighlightSpecific.call(this, context);
  6111. this._getGridDefinitions(function (lefts, tops, widths, heights) {
  6112. // Columns
  6113. for (var index = 0; index < lefts.length; index++) {
  6114. var left = _this._currentMeasure.left + lefts[index] + widths[index];
  6115. context.beginPath();
  6116. context.moveTo(left, _this._currentMeasure.top);
  6117. context.lineTo(left, _this._currentMeasure.top + _this._currentMeasure.height);
  6118. context.stroke();
  6119. }
  6120. // Rows
  6121. for (var index = 0; index < tops.length; index++) {
  6122. var top_1 = _this._currentMeasure.top + tops[index] + heights[index];
  6123. context.beginPath();
  6124. context.moveTo(_this._currentMeasure.left, top_1);
  6125. context.lineTo(_this._currentMeasure.left + _this._currentMeasure.width, top_1);
  6126. context.stroke();
  6127. }
  6128. });
  6129. context.restore();
  6130. };
  6131. /** Releases associated resources */
  6132. Grid.prototype.dispose = function () {
  6133. _super.prototype.dispose.call(this);
  6134. for (var _i = 0, _a = this._childControls; _i < _a.length; _i++) {
  6135. var control = _a[_i];
  6136. control.dispose();
  6137. }
  6138. this._childControls = [];
  6139. };
  6140. return Grid;
  6141. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  6142. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Grid"] = Grid;
  6143. /***/ }),
  6144. /***/ "./2D/controls/image.ts":
  6145. /*!******************************!*\
  6146. !*** ./2D/controls/image.ts ***!
  6147. \******************************/
  6148. /*! exports provided: Image */
  6149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6150. "use strict";
  6151. __webpack_require__.r(__webpack_exports__);
  6152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return Image; });
  6153. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6154. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6155. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6156. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6157. /**
  6158. * Class used to create 2D images
  6159. */
  6160. var Image = /** @class */ (function (_super) {
  6161. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Image, _super);
  6162. /**
  6163. * Creates a new Image
  6164. * @param name defines the control name
  6165. * @param url defines the image url
  6166. */
  6167. function Image(name, url) {
  6168. if (url === void 0) { url = null; }
  6169. var _this = _super.call(this, name) || this;
  6170. _this.name = name;
  6171. _this._workingCanvas = null;
  6172. _this._loaded = false;
  6173. _this._stretch = Image.STRETCH_FILL;
  6174. _this._autoScale = false;
  6175. _this._sourceLeft = 0;
  6176. _this._sourceTop = 0;
  6177. _this._sourceWidth = 0;
  6178. _this._sourceHeight = 0;
  6179. _this._cellWidth = 0;
  6180. _this._cellHeight = 0;
  6181. _this._cellId = -1;
  6182. _this._populateNinePatchSlicesFromImage = false;
  6183. /**
  6184. * Observable notified when the content is loaded
  6185. */
  6186. _this.onImageLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6187. /**
  6188. * Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  6189. */
  6190. _this.onSVGAttributesComputedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6191. _this.source = url;
  6192. return _this;
  6193. }
  6194. Object.defineProperty(Image.prototype, "isLoaded", {
  6195. /**
  6196. * Gets a boolean indicating that the content is loaded
  6197. */
  6198. get: function () {
  6199. return this._loaded;
  6200. },
  6201. enumerable: true,
  6202. configurable: true
  6203. });
  6204. Object.defineProperty(Image.prototype, "populateNinePatchSlicesFromImage", {
  6205. /**
  6206. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  6207. */
  6208. get: function () {
  6209. return this._populateNinePatchSlicesFromImage;
  6210. },
  6211. set: function (value) {
  6212. if (this._populateNinePatchSlicesFromImage === value) {
  6213. return;
  6214. }
  6215. this._populateNinePatchSlicesFromImage = value;
  6216. if (this._populateNinePatchSlicesFromImage && this._loaded) {
  6217. this._extractNinePatchSliceDataFromImage();
  6218. }
  6219. },
  6220. enumerable: true,
  6221. configurable: true
  6222. });
  6223. Object.defineProperty(Image.prototype, "detectPointerOnOpaqueOnly", {
  6224. /**
  6225. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  6226. * Beware using this as this will comsume more memory as the image has to be stored twice
  6227. */
  6228. get: function () {
  6229. return this._detectPointerOnOpaqueOnly;
  6230. },
  6231. set: function (value) {
  6232. if (this._detectPointerOnOpaqueOnly === value) {
  6233. return;
  6234. }
  6235. this._detectPointerOnOpaqueOnly = value;
  6236. },
  6237. enumerable: true,
  6238. configurable: true
  6239. });
  6240. Object.defineProperty(Image.prototype, "sliceLeft", {
  6241. /**
  6242. * Gets or sets the left value for slicing (9-patch)
  6243. */
  6244. get: function () {
  6245. return this._sliceLeft;
  6246. },
  6247. set: function (value) {
  6248. if (this._sliceLeft === value) {
  6249. return;
  6250. }
  6251. this._sliceLeft = value;
  6252. this._markAsDirty();
  6253. },
  6254. enumerable: true,
  6255. configurable: true
  6256. });
  6257. Object.defineProperty(Image.prototype, "sliceRight", {
  6258. /**
  6259. * Gets or sets the right value for slicing (9-patch)
  6260. */
  6261. get: function () {
  6262. return this._sliceRight;
  6263. },
  6264. set: function (value) {
  6265. if (this._sliceRight === value) {
  6266. return;
  6267. }
  6268. this._sliceRight = value;
  6269. this._markAsDirty();
  6270. },
  6271. enumerable: true,
  6272. configurable: true
  6273. });
  6274. Object.defineProperty(Image.prototype, "sliceTop", {
  6275. /**
  6276. * Gets or sets the top value for slicing (9-patch)
  6277. */
  6278. get: function () {
  6279. return this._sliceTop;
  6280. },
  6281. set: function (value) {
  6282. if (this._sliceTop === value) {
  6283. return;
  6284. }
  6285. this._sliceTop = value;
  6286. this._markAsDirty();
  6287. },
  6288. enumerable: true,
  6289. configurable: true
  6290. });
  6291. Object.defineProperty(Image.prototype, "sliceBottom", {
  6292. /**
  6293. * Gets or sets the bottom value for slicing (9-patch)
  6294. */
  6295. get: function () {
  6296. return this._sliceBottom;
  6297. },
  6298. set: function (value) {
  6299. if (this._sliceBottom === value) {
  6300. return;
  6301. }
  6302. this._sliceBottom = value;
  6303. this._markAsDirty();
  6304. },
  6305. enumerable: true,
  6306. configurable: true
  6307. });
  6308. Object.defineProperty(Image.prototype, "sourceLeft", {
  6309. /**
  6310. * Gets or sets the left coordinate in the source image
  6311. */
  6312. get: function () {
  6313. return this._sourceLeft;
  6314. },
  6315. set: function (value) {
  6316. if (this._sourceLeft === value) {
  6317. return;
  6318. }
  6319. this._sourceLeft = value;
  6320. this._markAsDirty();
  6321. },
  6322. enumerable: true,
  6323. configurable: true
  6324. });
  6325. Object.defineProperty(Image.prototype, "sourceTop", {
  6326. /**
  6327. * Gets or sets the top coordinate in the source image
  6328. */
  6329. get: function () {
  6330. return this._sourceTop;
  6331. },
  6332. set: function (value) {
  6333. if (this._sourceTop === value) {
  6334. return;
  6335. }
  6336. this._sourceTop = value;
  6337. this._markAsDirty();
  6338. },
  6339. enumerable: true,
  6340. configurable: true
  6341. });
  6342. Object.defineProperty(Image.prototype, "sourceWidth", {
  6343. /**
  6344. * Gets or sets the width to capture in the source image
  6345. */
  6346. get: function () {
  6347. return this._sourceWidth;
  6348. },
  6349. set: function (value) {
  6350. if (this._sourceWidth === value) {
  6351. return;
  6352. }
  6353. this._sourceWidth = value;
  6354. this._markAsDirty();
  6355. },
  6356. enumerable: true,
  6357. configurable: true
  6358. });
  6359. Object.defineProperty(Image.prototype, "sourceHeight", {
  6360. /**
  6361. * Gets or sets the height to capture in the source image
  6362. */
  6363. get: function () {
  6364. return this._sourceHeight;
  6365. },
  6366. set: function (value) {
  6367. if (this._sourceHeight === value) {
  6368. return;
  6369. }
  6370. this._sourceHeight = value;
  6371. this._markAsDirty();
  6372. },
  6373. enumerable: true,
  6374. configurable: true
  6375. });
  6376. Object.defineProperty(Image.prototype, "autoScale", {
  6377. /**
  6378. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  6379. * @see http://doc.babylonjs.com/how_to/gui#image
  6380. */
  6381. get: function () {
  6382. return this._autoScale;
  6383. },
  6384. set: function (value) {
  6385. if (this._autoScale === value) {
  6386. return;
  6387. }
  6388. this._autoScale = value;
  6389. if (value && this._loaded) {
  6390. this.synchronizeSizeWithContent();
  6391. }
  6392. },
  6393. enumerable: true,
  6394. configurable: true
  6395. });
  6396. Object.defineProperty(Image.prototype, "stretch", {
  6397. /** Gets or sets the streching mode used by the image */
  6398. get: function () {
  6399. return this._stretch;
  6400. },
  6401. set: function (value) {
  6402. if (this._stretch === value) {
  6403. return;
  6404. }
  6405. this._stretch = value;
  6406. this._markAsDirty();
  6407. },
  6408. enumerable: true,
  6409. configurable: true
  6410. });
  6411. /** @hidden */
  6412. Image.prototype._rotate90 = function (n) {
  6413. var canvas = document.createElement('canvas');
  6414. var context = canvas.getContext('2d');
  6415. var width = this._domImage.width;
  6416. var height = this._domImage.height;
  6417. canvas.width = height;
  6418. canvas.height = width;
  6419. context.translate(canvas.width / 2, canvas.height / 2);
  6420. context.rotate(n * Math.PI / 2);
  6421. context.drawImage(this._domImage, 0, 0, width, height, -width / 2, -height / 2, width, height);
  6422. var dataUrl = canvas.toDataURL("image/jpg");
  6423. var rotatedImage = new Image(this.name + "rotated", dataUrl);
  6424. return rotatedImage;
  6425. };
  6426. Object.defineProperty(Image.prototype, "domImage", {
  6427. get: function () {
  6428. return this._domImage;
  6429. },
  6430. /**
  6431. * Gets or sets the internal DOM image used to render the control
  6432. */
  6433. set: function (value) {
  6434. var _this = this;
  6435. this._domImage = value;
  6436. this._loaded = false;
  6437. if (this._domImage.width) {
  6438. this._onImageLoaded();
  6439. }
  6440. else {
  6441. this._domImage.onload = function () {
  6442. _this._onImageLoaded();
  6443. };
  6444. }
  6445. },
  6446. enumerable: true,
  6447. configurable: true
  6448. });
  6449. Image.prototype._onImageLoaded = function () {
  6450. this._imageWidth = this._domImage.width;
  6451. this._imageHeight = this._domImage.height;
  6452. this._loaded = true;
  6453. if (this._populateNinePatchSlicesFromImage) {
  6454. this._extractNinePatchSliceDataFromImage();
  6455. }
  6456. if (this._autoScale) {
  6457. this.synchronizeSizeWithContent();
  6458. }
  6459. this.onImageLoadedObservable.notifyObservers(this);
  6460. this._markAsDirty();
  6461. };
  6462. Image.prototype._extractNinePatchSliceDataFromImage = function () {
  6463. if (!this._workingCanvas) {
  6464. this._workingCanvas = document.createElement('canvas');
  6465. }
  6466. var canvas = this._workingCanvas;
  6467. var context = canvas.getContext('2d');
  6468. var width = this._domImage.width;
  6469. var height = this._domImage.height;
  6470. canvas.width = width;
  6471. canvas.height = height;
  6472. context.drawImage(this._domImage, 0, 0, width, height);
  6473. var imageData = context.getImageData(0, 0, width, height);
  6474. // Left and right
  6475. this._sliceLeft = -1;
  6476. this._sliceRight = -1;
  6477. for (var x = 0; x < width; x++) {
  6478. var alpha = imageData.data[x * 4 + 3];
  6479. if (alpha > 127 && this._sliceLeft === -1) {
  6480. this._sliceLeft = x;
  6481. continue;
  6482. }
  6483. if (alpha < 127 && this._sliceLeft > -1) {
  6484. this._sliceRight = x;
  6485. break;
  6486. }
  6487. }
  6488. // top and bottom
  6489. this._sliceTop = -1;
  6490. this._sliceBottom = -1;
  6491. for (var y = 0; y < height; y++) {
  6492. var alpha = imageData.data[y * width * 4 + 3];
  6493. if (alpha > 127 && this._sliceTop === -1) {
  6494. this._sliceTop = y;
  6495. continue;
  6496. }
  6497. if (alpha < 127 && this._sliceTop > -1) {
  6498. this._sliceBottom = y;
  6499. break;
  6500. }
  6501. }
  6502. };
  6503. Object.defineProperty(Image.prototype, "source", {
  6504. /**
  6505. * Gets or sets image source url
  6506. */
  6507. set: function (value) {
  6508. var _this = this;
  6509. if (this._source === value) {
  6510. return;
  6511. }
  6512. this._loaded = false;
  6513. this._source = value;
  6514. if (value) {
  6515. value = this._svgCheck(value);
  6516. }
  6517. this._domImage = document.createElement("img");
  6518. this._domImage.onload = function () {
  6519. _this._onImageLoaded();
  6520. };
  6521. if (value) {
  6522. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetCorsBehavior(value, this._domImage);
  6523. this._domImage.src = value;
  6524. }
  6525. },
  6526. enumerable: true,
  6527. configurable: true
  6528. });
  6529. /**
  6530. * Checks for svg document with icon id present
  6531. */
  6532. Image.prototype._svgCheck = function (value) {
  6533. var _this = this;
  6534. if (window.SVGSVGElement && (value.search(/.svg#/gi) !== -1) && (value.indexOf("#") === value.lastIndexOf("#"))) {
  6535. var svgsrc = value.split('#')[0];
  6536. var elemid = value.split('#')[1];
  6537. // check if object alr exist in document
  6538. var svgExist = document.body.querySelector('object[data="' + svgsrc + '"]');
  6539. if (svgExist) {
  6540. var svgDoc = svgExist.contentDocument;
  6541. // get viewbox width and height, get svg document width and height in px
  6542. if (svgDoc && svgDoc.documentElement) {
  6543. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6544. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6545. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6546. if (vb && docwidth && docheight) {
  6547. this._getSVGAttribs(svgExist, elemid);
  6548. return value;
  6549. }
  6550. }
  6551. // wait for object to load
  6552. svgExist.addEventListener("load", function () {
  6553. _this._getSVGAttribs(svgExist, elemid);
  6554. });
  6555. }
  6556. else {
  6557. // create document object
  6558. var svgImage = document.createElement("object");
  6559. svgImage.data = svgsrc;
  6560. svgImage.type = "image/svg+xml";
  6561. svgImage.width = "0%";
  6562. svgImage.height = "0%";
  6563. document.body.appendChild(svgImage);
  6564. // when the object has loaded, get the element attribs
  6565. svgImage.onload = function () {
  6566. var svgobj = document.body.querySelector('object[data="' + svgsrc + '"]');
  6567. if (svgobj) {
  6568. _this._getSVGAttribs(svgobj, elemid);
  6569. }
  6570. };
  6571. }
  6572. return svgsrc;
  6573. }
  6574. else {
  6575. return value;
  6576. }
  6577. };
  6578. /**
  6579. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  6580. * given external svg file and icon id
  6581. */
  6582. Image.prototype._getSVGAttribs = function (svgsrc, elemid) {
  6583. var svgDoc = svgsrc.contentDocument;
  6584. // get viewbox width and height, get svg document width and height in px
  6585. if (svgDoc && svgDoc.documentElement) {
  6586. var vb = svgDoc.documentElement.getAttribute("viewBox");
  6587. var docwidth = Number(svgDoc.documentElement.getAttribute("width"));
  6588. var docheight = Number(svgDoc.documentElement.getAttribute("height"));
  6589. // get element bbox and matrix transform
  6590. var elem = svgDoc.getElementById(elemid);
  6591. if (vb && docwidth && docheight) {
  6592. var vb_width = Number(vb.split(" ")[2]);
  6593. var vb_height = Number(vb.split(" ")[3]);
  6594. var elem_bbox = elem.getBBox();
  6595. var elem_matrix_a = 1;
  6596. var elem_matrix_d = 1;
  6597. var elem_matrix_e = 0;
  6598. var elem_matrix_f = 0;
  6599. if (elem.transform && elem.transform.baseVal.consolidate()) {
  6600. elem_matrix_a = elem.transform.baseVal.consolidate().matrix.a;
  6601. elem_matrix_d = elem.transform.baseVal.consolidate().matrix.d;
  6602. elem_matrix_e = elem.transform.baseVal.consolidate().matrix.e;
  6603. elem_matrix_f = elem.transform.baseVal.consolidate().matrix.f;
  6604. }
  6605. // compute source coordinates and dimensions
  6606. this.sourceLeft = ((elem_matrix_a * elem_bbox.x + elem_matrix_e) * docwidth) / vb_width;
  6607. this.sourceTop = ((elem_matrix_d * elem_bbox.y + elem_matrix_f) * docheight) / vb_height;
  6608. this.sourceWidth = (elem_bbox.width * elem_matrix_a) * (docwidth / vb_width);
  6609. this.sourceHeight = (elem_bbox.height * elem_matrix_d) * (docheight / vb_height);
  6610. this.onSVGAttributesComputedObservable.notifyObservers(this);
  6611. }
  6612. }
  6613. };
  6614. Object.defineProperty(Image.prototype, "cellWidth", {
  6615. /**
  6616. * Gets or sets the cell width to use when animation sheet is enabled
  6617. * @see http://doc.babylonjs.com/how_to/gui#image
  6618. */
  6619. get: function () {
  6620. return this._cellWidth;
  6621. },
  6622. set: function (value) {
  6623. if (this._cellWidth === value) {
  6624. return;
  6625. }
  6626. this._cellWidth = value;
  6627. this._markAsDirty();
  6628. },
  6629. enumerable: true,
  6630. configurable: true
  6631. });
  6632. Object.defineProperty(Image.prototype, "cellHeight", {
  6633. /**
  6634. * Gets or sets the cell height to use when animation sheet is enabled
  6635. * @see http://doc.babylonjs.com/how_to/gui#image
  6636. */
  6637. get: function () {
  6638. return this._cellHeight;
  6639. },
  6640. set: function (value) {
  6641. if (this._cellHeight === value) {
  6642. return;
  6643. }
  6644. this._cellHeight = value;
  6645. this._markAsDirty();
  6646. },
  6647. enumerable: true,
  6648. configurable: true
  6649. });
  6650. Object.defineProperty(Image.prototype, "cellId", {
  6651. /**
  6652. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  6653. * @see http://doc.babylonjs.com/how_to/gui#image
  6654. */
  6655. get: function () {
  6656. return this._cellId;
  6657. },
  6658. set: function (value) {
  6659. if (this._cellId === value) {
  6660. return;
  6661. }
  6662. this._cellId = value;
  6663. this._markAsDirty();
  6664. },
  6665. enumerable: true,
  6666. configurable: true
  6667. });
  6668. /**
  6669. * Tests if a given coordinates belong to the current control
  6670. * @param x defines x coordinate to test
  6671. * @param y defines y coordinate to test
  6672. * @returns true if the coordinates are inside the control
  6673. */
  6674. Image.prototype.contains = function (x, y) {
  6675. if (!_super.prototype.contains.call(this, x, y)) {
  6676. return false;
  6677. }
  6678. if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
  6679. return true;
  6680. }
  6681. var canvas = this._workingCanvas;
  6682. var context = canvas.getContext("2d");
  6683. var width = this._currentMeasure.width | 0;
  6684. var height = this._currentMeasure.height | 0;
  6685. var imageData = context.getImageData(0, 0, width, height).data;
  6686. x = (x - this._currentMeasure.left) | 0;
  6687. y = (y - this._currentMeasure.top) | 0;
  6688. var pickedPixel = imageData[(x + y * this._currentMeasure.width) * 4 + 3];
  6689. return pickedPixel > 0;
  6690. };
  6691. Image.prototype._getTypeName = function () {
  6692. return "Image";
  6693. };
  6694. /** Force the control to synchronize with its content */
  6695. Image.prototype.synchronizeSizeWithContent = function () {
  6696. if (!this._loaded) {
  6697. return;
  6698. }
  6699. this.width = this._domImage.width + "px";
  6700. this.height = this._domImage.height + "px";
  6701. };
  6702. Image.prototype._processMeasures = function (parentMeasure, context) {
  6703. if (this._loaded) {
  6704. switch (this._stretch) {
  6705. case Image.STRETCH_NONE:
  6706. break;
  6707. case Image.STRETCH_FILL:
  6708. break;
  6709. case Image.STRETCH_UNIFORM:
  6710. break;
  6711. case Image.STRETCH_NINE_PATCH:
  6712. break;
  6713. case Image.STRETCH_EXTEND:
  6714. if (this._autoScale) {
  6715. this.synchronizeSizeWithContent();
  6716. }
  6717. if (this.parent && this.parent.parent) { // Will update root size if root is not the top root
  6718. this.parent.adaptWidthToChildren = true;
  6719. this.parent.adaptHeightToChildren = true;
  6720. }
  6721. break;
  6722. }
  6723. }
  6724. _super.prototype._processMeasures.call(this, parentMeasure, context);
  6725. };
  6726. Image.prototype._prepareWorkingCanvasForOpaqueDetection = function () {
  6727. if (!this._detectPointerOnOpaqueOnly) {
  6728. return;
  6729. }
  6730. if (!this._workingCanvas) {
  6731. this._workingCanvas = document.createElement('canvas');
  6732. }
  6733. var canvas = this._workingCanvas;
  6734. var width = this._currentMeasure.width;
  6735. var height = this._currentMeasure.height;
  6736. var context = canvas.getContext("2d");
  6737. canvas.width = width;
  6738. canvas.height = height;
  6739. context.clearRect(0, 0, width, height);
  6740. };
  6741. Image.prototype._drawImage = function (context, sx, sy, sw, sh, tx, ty, tw, th) {
  6742. context.drawImage(this._domImage, sx, sy, sw, sh, tx, ty, tw, th);
  6743. if (!this._detectPointerOnOpaqueOnly) {
  6744. return;
  6745. }
  6746. var canvas = this._workingCanvas;
  6747. context = canvas.getContext("2d");
  6748. context.drawImage(this._domImage, sx, sy, sw, sh, tx - this._currentMeasure.left, ty - this._currentMeasure.top, tw, th);
  6749. };
  6750. Image.prototype._draw = function (context) {
  6751. context.save();
  6752. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  6753. context.shadowColor = this.shadowColor;
  6754. context.shadowBlur = this.shadowBlur;
  6755. context.shadowOffsetX = this.shadowOffsetX;
  6756. context.shadowOffsetY = this.shadowOffsetY;
  6757. }
  6758. var x, y, width, height;
  6759. if (this.cellId == -1) {
  6760. x = this._sourceLeft;
  6761. y = this._sourceTop;
  6762. width = this._sourceWidth ? this._sourceWidth : this._imageWidth;
  6763. height = this._sourceHeight ? this._sourceHeight : this._imageHeight;
  6764. }
  6765. else {
  6766. var rowCount = this._domImage.naturalWidth / this.cellWidth;
  6767. var column = (this.cellId / rowCount) >> 0;
  6768. var row = this.cellId % rowCount;
  6769. x = this.cellWidth * row;
  6770. y = this.cellHeight * column;
  6771. width = this.cellWidth;
  6772. height = this.cellHeight;
  6773. }
  6774. this._prepareWorkingCanvasForOpaqueDetection();
  6775. this._applyStates(context);
  6776. if (this._loaded) {
  6777. switch (this._stretch) {
  6778. case Image.STRETCH_NONE:
  6779. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6780. break;
  6781. case Image.STRETCH_FILL:
  6782. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6783. break;
  6784. case Image.STRETCH_UNIFORM:
  6785. var hRatio = this._currentMeasure.width / width;
  6786. var vRatio = this._currentMeasure.height / height;
  6787. var ratio = Math.min(hRatio, vRatio);
  6788. var centerX = (this._currentMeasure.width - width * ratio) / 2;
  6789. var centerY = (this._currentMeasure.height - height * ratio) / 2;
  6790. this._drawImage(context, x, y, width, height, this._currentMeasure.left + centerX, this._currentMeasure.top + centerY, width * ratio, height * ratio);
  6791. break;
  6792. case Image.STRETCH_EXTEND:
  6793. this._drawImage(context, x, y, width, height, this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  6794. break;
  6795. case Image.STRETCH_NINE_PATCH:
  6796. this._renderNinePatch(context);
  6797. break;
  6798. }
  6799. }
  6800. context.restore();
  6801. };
  6802. Image.prototype._renderCornerPatch = function (context, x, y, width, height, targetX, targetY) {
  6803. this._drawImage(context, x, y, width, height, this._currentMeasure.left + targetX, this._currentMeasure.top + targetY, width, height);
  6804. };
  6805. Image.prototype._renderNinePatch = function (context) {
  6806. var height = this._imageHeight;
  6807. var leftWidth = this._sliceLeft;
  6808. var topHeight = this._sliceTop;
  6809. var bottomHeight = this._imageHeight - this._sliceBottom;
  6810. var rightWidth = this._imageWidth - this._sliceRight;
  6811. var left = 0;
  6812. var top = 0;
  6813. if (this._populateNinePatchSlicesFromImage) {
  6814. left = 1;
  6815. top = 1;
  6816. height -= 2;
  6817. leftWidth -= 1;
  6818. topHeight -= 1;
  6819. bottomHeight -= 1;
  6820. rightWidth -= 1;
  6821. }
  6822. var centerWidth = this._sliceRight - this._sliceLeft + 1;
  6823. var targetCenterWidth = this._currentMeasure.width - rightWidth - this.sliceLeft + 1;
  6824. var targetTopHeight = this._currentMeasure.height - height + this._sliceBottom;
  6825. // Corners
  6826. this._renderCornerPatch(context, left, top, leftWidth, topHeight, 0, 0);
  6827. this._renderCornerPatch(context, left, this._sliceBottom, leftWidth, height - this._sliceBottom, 0, targetTopHeight);
  6828. this._renderCornerPatch(context, this._sliceRight, top, rightWidth, topHeight, this._currentMeasure.width - rightWidth, 0);
  6829. this._renderCornerPatch(context, this._sliceRight, this._sliceBottom, rightWidth, height - this._sliceBottom, this._currentMeasure.width - rightWidth, targetTopHeight);
  6830. // Center
  6831. this._drawImage(context, this._sliceLeft, this._sliceTop, centerWidth, this._sliceBottom - this._sliceTop + 1, this._currentMeasure.left + leftWidth, this._currentMeasure.top + topHeight, targetCenterWidth, targetTopHeight - topHeight + 1);
  6832. // Borders
  6833. this._drawImage(context, left, this._sliceTop, leftWidth, this._sliceBottom - this._sliceTop, this._currentMeasure.left, this._currentMeasure.top + topHeight, leftWidth, targetTopHeight - topHeight);
  6834. 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);
  6835. this._drawImage(context, this._sliceLeft, top, centerWidth, topHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top, targetCenterWidth, topHeight);
  6836. this._drawImage(context, this._sliceLeft, this._sliceBottom, centerWidth, bottomHeight, this._currentMeasure.left + leftWidth, this._currentMeasure.top + targetTopHeight, targetCenterWidth, bottomHeight);
  6837. };
  6838. Image.prototype.dispose = function () {
  6839. _super.prototype.dispose.call(this);
  6840. this.onImageLoadedObservable.clear();
  6841. this.onSVGAttributesComputedObservable.clear();
  6842. };
  6843. // Static
  6844. /** STRETCH_NONE */
  6845. Image.STRETCH_NONE = 0;
  6846. /** STRETCH_FILL */
  6847. Image.STRETCH_FILL = 1;
  6848. /** STRETCH_UNIFORM */
  6849. Image.STRETCH_UNIFORM = 2;
  6850. /** STRETCH_EXTEND */
  6851. Image.STRETCH_EXTEND = 3;
  6852. /** NINE_PATCH */
  6853. Image.STRETCH_NINE_PATCH = 4;
  6854. return Image;
  6855. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  6856. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Image"] = Image;
  6857. /***/ }),
  6858. /***/ "./2D/controls/index.ts":
  6859. /*!******************************!*\
  6860. !*** ./2D/controls/index.ts ***!
  6861. \******************************/
  6862. /*! 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 */
  6863. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6864. "use strict";
  6865. __webpack_require__.r(__webpack_exports__);
  6866. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  6867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _button__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  6868. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  6869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _checkbox__WEBPACK_IMPORTED_MODULE_1__["Checkbox"]; });
  6870. /* harmony import */ var _colorpicker__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./colorpicker */ "./2D/controls/colorpicker.ts");
  6871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _colorpicker__WEBPACK_IMPORTED_MODULE_2__["ColorPicker"]; });
  6872. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  6873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _container__WEBPACK_IMPORTED_MODULE_3__["Container"]; });
  6874. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _control__WEBPACK_IMPORTED_MODULE_4__["Control"]; });
  6876. /* harmony import */ var _ellipse__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ellipse */ "./2D/controls/ellipse.ts");
  6877. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _ellipse__WEBPACK_IMPORTED_MODULE_5__["Ellipse"]; });
  6878. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./grid */ "./2D/controls/grid.ts");
  6879. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_6__["Grid"]; });
  6880. /* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./image */ "./2D/controls/image.ts");
  6881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_7__["Image"]; });
  6882. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _inputText__WEBPACK_IMPORTED_MODULE_8__["InputText"]; });
  6884. /* harmony import */ var _inputPassword__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./inputPassword */ "./2D/controls/inputPassword.ts");
  6885. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _inputPassword__WEBPACK_IMPORTED_MODULE_9__["InputPassword"]; });
  6886. /* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./line */ "./2D/controls/line.ts");
  6887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_10__["Line"]; });
  6888. /* harmony import */ var _multiLine__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./multiLine */ "./2D/controls/multiLine.ts");
  6889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _multiLine__WEBPACK_IMPORTED_MODULE_11__["MultiLine"]; });
  6890. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  6891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _radioButton__WEBPACK_IMPORTED_MODULE_12__["RadioButton"]; });
  6892. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  6893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _stackPanel__WEBPACK_IMPORTED_MODULE_13__["StackPanel"]; });
  6894. /* harmony import */ var _selector__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./selector */ "./2D/controls/selector.ts");
  6895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectorGroup"]; });
  6896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["CheckboxGroup"]; });
  6897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["RadioGroup"]; });
  6898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SliderGroup"]; });
  6899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _selector__WEBPACK_IMPORTED_MODULE_14__["SelectionPanel"]; });
  6900. /* harmony import */ var _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./scrollViewers/scrollViewer */ "./2D/controls/scrollViewers/scrollViewer.ts");
  6901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _scrollViewers_scrollViewer__WEBPACK_IMPORTED_MODULE_15__["ScrollViewer"]; });
  6902. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  6903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextWrapping"]; });
  6904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _textBlock__WEBPACK_IMPORTED_MODULE_16__["TextBlock"]; });
  6905. /* harmony import */ var _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./virtualKeyboard */ "./2D/controls/virtualKeyboard.ts");
  6906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["KeyPropertySet"]; });
  6907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _virtualKeyboard__WEBPACK_IMPORTED_MODULE_17__["VirtualKeyboard"]; });
  6908. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  6909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _rectangle__WEBPACK_IMPORTED_MODULE_18__["Rectangle"]; });
  6910. /* harmony import */ var _displayGrid__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./displayGrid */ "./2D/controls/displayGrid.ts");
  6911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _displayGrid__WEBPACK_IMPORTED_MODULE_19__["DisplayGrid"]; });
  6912. /* harmony import */ var _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sliders/baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  6913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _sliders_baseSlider__WEBPACK_IMPORTED_MODULE_20__["BaseSlider"]; });
  6914. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  6915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _sliders_slider__WEBPACK_IMPORTED_MODULE_21__["Slider"]; });
  6916. /* harmony import */ var _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./sliders/imageBasedSlider */ "./2D/controls/sliders/imageBasedSlider.ts");
  6917. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _sliders_imageBasedSlider__WEBPACK_IMPORTED_MODULE_22__["ImageBasedSlider"]; });
  6918. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  6919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_23__["ScrollBar"]; });
  6920. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  6921. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_24__["ImageScrollBar"]; });
  6922. /* harmony import */ var _statics__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./statics */ "./2D/controls/statics.ts");
  6923. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _statics__WEBPACK_IMPORTED_MODULE_25__["name"]; });
  6924. /***/ }),
  6925. /***/ "./2D/controls/inputPassword.ts":
  6926. /*!**************************************!*\
  6927. !*** ./2D/controls/inputPassword.ts ***!
  6928. \**************************************/
  6929. /*! exports provided: InputPassword */
  6930. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6931. "use strict";
  6932. __webpack_require__.r(__webpack_exports__);
  6933. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return InputPassword; });
  6934. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6935. /* harmony import */ var _inputText__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./inputText */ "./2D/controls/inputText.ts");
  6936. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  6937. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  6938. /**
  6939. * Class used to create a password control
  6940. */
  6941. var InputPassword = /** @class */ (function (_super) {
  6942. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputPassword, _super);
  6943. function InputPassword() {
  6944. return _super !== null && _super.apply(this, arguments) || this;
  6945. }
  6946. InputPassword.prototype._beforeRenderText = function (text) {
  6947. var txt = "";
  6948. for (var i = 0; i < text.length; i++) {
  6949. txt += "\u2022";
  6950. }
  6951. return txt;
  6952. };
  6953. return InputPassword;
  6954. }(_inputText__WEBPACK_IMPORTED_MODULE_1__["InputText"]));
  6955. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputPassword"] = InputPassword;
  6956. /***/ }),
  6957. /***/ "./2D/controls/inputText.ts":
  6958. /*!**********************************!*\
  6959. !*** ./2D/controls/inputText.ts ***!
  6960. \**********************************/
  6961. /*! exports provided: InputText */
  6962. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6963. "use strict";
  6964. __webpack_require__.r(__webpack_exports__);
  6965. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return InputText; });
  6966. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  6967. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  6968. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  6969. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  6970. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  6971. /**
  6972. * Class used to create input text control
  6973. */
  6974. var InputText = /** @class */ (function (_super) {
  6975. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(InputText, _super);
  6976. /**
  6977. * Creates a new InputText
  6978. * @param name defines the control name
  6979. * @param text defines the text of the control
  6980. */
  6981. function InputText(name, text) {
  6982. if (text === void 0) { text = ""; }
  6983. var _this = _super.call(this, name) || this;
  6984. _this.name = name;
  6985. _this._text = "";
  6986. _this._placeholderText = "";
  6987. _this._background = "#222222";
  6988. _this._focusedBackground = "#000000";
  6989. _this._focusedColor = "white";
  6990. _this._placeholderColor = "gray";
  6991. _this._thickness = 1;
  6992. _this._margin = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](10, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL);
  6993. _this._autoStretchWidth = true;
  6994. _this._maxWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](1, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PERCENTAGE, false);
  6995. _this._isFocused = false;
  6996. _this._blinkIsEven = false;
  6997. _this._cursorOffset = 0;
  6998. _this._deadKey = false;
  6999. _this._addKey = true;
  7000. _this._currentKey = "";
  7001. _this._isTextHighlightOn = false;
  7002. _this._textHighlightColor = "#d5e0ff";
  7003. _this._highligherOpacity = 0.4;
  7004. _this._highlightedText = "";
  7005. _this._startHighlightIndex = 0;
  7006. _this._endHighlightIndex = 0;
  7007. _this._cursorIndex = -1;
  7008. _this._onFocusSelectAll = false;
  7009. _this._isPointerDown = false;
  7010. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  7011. _this.promptMessage = "Please enter text:";
  7012. /** Force disable prompt on mobile device */
  7013. _this.disableMobilePrompt = false;
  7014. /** Observable raised when the text changes */
  7015. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7016. /** Observable raised just before an entered character is to be added */
  7017. _this.onBeforeKeyAddObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7018. /** Observable raised when the control gets the focus */
  7019. _this.onFocusObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7020. /** Observable raised when the control loses the focus */
  7021. _this.onBlurObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7022. /**Observable raised when the text is highlighted */
  7023. _this.onTextHighlightObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7024. /**Observable raised when copy event is triggered */
  7025. _this.onTextCopyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7026. /** Observable raised when cut event is triggered */
  7027. _this.onTextCutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7028. /** Observable raised when paste event is triggered */
  7029. _this.onTextPasteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7030. /** Observable raised when a key event was processed */
  7031. _this.onKeyboardEventProcessedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  7032. _this.text = text;
  7033. _this.isPointerBlocker = true;
  7034. return _this;
  7035. }
  7036. Object.defineProperty(InputText.prototype, "maxWidth", {
  7037. /** Gets or sets the maximum width allowed by the control */
  7038. get: function () {
  7039. return this._maxWidth.toString(this._host);
  7040. },
  7041. set: function (value) {
  7042. if (this._maxWidth.toString(this._host) === value) {
  7043. return;
  7044. }
  7045. if (this._maxWidth.fromString(value)) {
  7046. this._markAsDirty();
  7047. }
  7048. },
  7049. enumerable: true,
  7050. configurable: true
  7051. });
  7052. Object.defineProperty(InputText.prototype, "maxWidthInPixels", {
  7053. /** Gets the maximum width allowed by the control in pixels */
  7054. get: function () {
  7055. return this._maxWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7056. },
  7057. enumerable: true,
  7058. configurable: true
  7059. });
  7060. Object.defineProperty(InputText.prototype, "highligherOpacity", {
  7061. /** Gets or sets the text highlighter transparency; default: 0.4 */
  7062. get: function () {
  7063. return this._highligherOpacity;
  7064. },
  7065. set: function (value) {
  7066. if (this._highligherOpacity === value) {
  7067. return;
  7068. }
  7069. this._highligherOpacity = value;
  7070. this._markAsDirty();
  7071. },
  7072. enumerable: true,
  7073. configurable: true
  7074. });
  7075. Object.defineProperty(InputText.prototype, "onFocusSelectAll", {
  7076. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  7077. get: function () {
  7078. return this._onFocusSelectAll;
  7079. },
  7080. set: function (value) {
  7081. if (this._onFocusSelectAll === value) {
  7082. return;
  7083. }
  7084. this._onFocusSelectAll = value;
  7085. this._markAsDirty();
  7086. },
  7087. enumerable: true,
  7088. configurable: true
  7089. });
  7090. Object.defineProperty(InputText.prototype, "textHighlightColor", {
  7091. /** Gets or sets the text hightlight color */
  7092. get: function () {
  7093. return this._textHighlightColor;
  7094. },
  7095. set: function (value) {
  7096. if (this._textHighlightColor === value) {
  7097. return;
  7098. }
  7099. this._textHighlightColor = value;
  7100. this._markAsDirty();
  7101. },
  7102. enumerable: true,
  7103. configurable: true
  7104. });
  7105. Object.defineProperty(InputText.prototype, "margin", {
  7106. /** Gets or sets control margin */
  7107. get: function () {
  7108. return this._margin.toString(this._host);
  7109. },
  7110. set: function (value) {
  7111. if (this._margin.toString(this._host) === value) {
  7112. return;
  7113. }
  7114. if (this._margin.fromString(value)) {
  7115. this._markAsDirty();
  7116. }
  7117. },
  7118. enumerable: true,
  7119. configurable: true
  7120. });
  7121. Object.defineProperty(InputText.prototype, "marginInPixels", {
  7122. /** Gets control margin in pixels */
  7123. get: function () {
  7124. return this._margin.getValueInPixel(this._host, this._cachedParentMeasure.width);
  7125. },
  7126. enumerable: true,
  7127. configurable: true
  7128. });
  7129. Object.defineProperty(InputText.prototype, "autoStretchWidth", {
  7130. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  7131. get: function () {
  7132. return this._autoStretchWidth;
  7133. },
  7134. set: function (value) {
  7135. if (this._autoStretchWidth === value) {
  7136. return;
  7137. }
  7138. this._autoStretchWidth = value;
  7139. this._markAsDirty();
  7140. },
  7141. enumerable: true,
  7142. configurable: true
  7143. });
  7144. Object.defineProperty(InputText.prototype, "thickness", {
  7145. /** Gets or sets border thickness */
  7146. get: function () {
  7147. return this._thickness;
  7148. },
  7149. set: function (value) {
  7150. if (this._thickness === value) {
  7151. return;
  7152. }
  7153. this._thickness = value;
  7154. this._markAsDirty();
  7155. },
  7156. enumerable: true,
  7157. configurable: true
  7158. });
  7159. Object.defineProperty(InputText.prototype, "focusedBackground", {
  7160. /** Gets or sets the background color when focused */
  7161. get: function () {
  7162. return this._focusedBackground;
  7163. },
  7164. set: function (value) {
  7165. if (this._focusedBackground === value) {
  7166. return;
  7167. }
  7168. this._focusedBackground = value;
  7169. this._markAsDirty();
  7170. },
  7171. enumerable: true,
  7172. configurable: true
  7173. });
  7174. Object.defineProperty(InputText.prototype, "focusedColor", {
  7175. /** Gets or sets the background color when focused */
  7176. get: function () {
  7177. return this._focusedColor;
  7178. },
  7179. set: function (value) {
  7180. if (this._focusedColor === value) {
  7181. return;
  7182. }
  7183. this._focusedColor = value;
  7184. this._markAsDirty();
  7185. },
  7186. enumerable: true,
  7187. configurable: true
  7188. });
  7189. Object.defineProperty(InputText.prototype, "background", {
  7190. /** Gets or sets the background color */
  7191. get: function () {
  7192. return this._background;
  7193. },
  7194. set: function (value) {
  7195. if (this._background === value) {
  7196. return;
  7197. }
  7198. this._background = value;
  7199. this._markAsDirty();
  7200. },
  7201. enumerable: true,
  7202. configurable: true
  7203. });
  7204. Object.defineProperty(InputText.prototype, "placeholderColor", {
  7205. /** Gets or sets the placeholder color */
  7206. get: function () {
  7207. return this._placeholderColor;
  7208. },
  7209. set: function (value) {
  7210. if (this._placeholderColor === value) {
  7211. return;
  7212. }
  7213. this._placeholderColor = value;
  7214. this._markAsDirty();
  7215. },
  7216. enumerable: true,
  7217. configurable: true
  7218. });
  7219. Object.defineProperty(InputText.prototype, "placeholderText", {
  7220. /** Gets or sets the text displayed when the control is empty */
  7221. get: function () {
  7222. return this._placeholderText;
  7223. },
  7224. set: function (value) {
  7225. if (this._placeholderText === value) {
  7226. return;
  7227. }
  7228. this._placeholderText = value;
  7229. this._markAsDirty();
  7230. },
  7231. enumerable: true,
  7232. configurable: true
  7233. });
  7234. Object.defineProperty(InputText.prototype, "deadKey", {
  7235. /** Gets or sets the dead key flag */
  7236. get: function () {
  7237. return this._deadKey;
  7238. },
  7239. set: function (flag) {
  7240. this._deadKey = flag;
  7241. },
  7242. enumerable: true,
  7243. configurable: true
  7244. });
  7245. Object.defineProperty(InputText.prototype, "highlightedText", {
  7246. /** Gets or sets the highlight text */
  7247. get: function () {
  7248. return this._highlightedText;
  7249. },
  7250. set: function (text) {
  7251. if (this._highlightedText === text) {
  7252. return;
  7253. }
  7254. this._highlightedText = text;
  7255. this._markAsDirty();
  7256. },
  7257. enumerable: true,
  7258. configurable: true
  7259. });
  7260. Object.defineProperty(InputText.prototype, "addKey", {
  7261. /** Gets or sets if the current key should be added */
  7262. get: function () {
  7263. return this._addKey;
  7264. },
  7265. set: function (flag) {
  7266. this._addKey = flag;
  7267. },
  7268. enumerable: true,
  7269. configurable: true
  7270. });
  7271. Object.defineProperty(InputText.prototype, "currentKey", {
  7272. /** Gets or sets the value of the current key being entered */
  7273. get: function () {
  7274. return this._currentKey;
  7275. },
  7276. set: function (key) {
  7277. this._currentKey = key;
  7278. },
  7279. enumerable: true,
  7280. configurable: true
  7281. });
  7282. Object.defineProperty(InputText.prototype, "text", {
  7283. /** Gets or sets the text displayed in the control */
  7284. get: function () {
  7285. return this._text;
  7286. },
  7287. set: function (value) {
  7288. var valueAsString = value.toString(); // Forcing convertion
  7289. if (this._text === valueAsString) {
  7290. return;
  7291. }
  7292. this._text = valueAsString;
  7293. this._markAsDirty();
  7294. this.onTextChangedObservable.notifyObservers(this);
  7295. },
  7296. enumerable: true,
  7297. configurable: true
  7298. });
  7299. Object.defineProperty(InputText.prototype, "width", {
  7300. /** Gets or sets control width */
  7301. get: function () {
  7302. return this._width.toString(this._host);
  7303. },
  7304. set: function (value) {
  7305. if (this._width.toString(this._host) === value) {
  7306. return;
  7307. }
  7308. if (this._width.fromString(value)) {
  7309. this._markAsDirty();
  7310. }
  7311. this.autoStretchWidth = false;
  7312. },
  7313. enumerable: true,
  7314. configurable: true
  7315. });
  7316. /** @hidden */
  7317. InputText.prototype.onBlur = function () {
  7318. this._isFocused = false;
  7319. this._scrollLeft = null;
  7320. this._cursorOffset = 0;
  7321. clearTimeout(this._blinkTimeout);
  7322. this._markAsDirty();
  7323. this.onBlurObservable.notifyObservers(this);
  7324. this._host.unRegisterClipboardEvents();
  7325. if (this._onClipboardObserver) {
  7326. this._host.onClipboardObservable.remove(this._onClipboardObserver);
  7327. }
  7328. var scene = this._host.getScene();
  7329. if (this._onPointerDblTapObserver && scene) {
  7330. scene.onPointerObservable.remove(this._onPointerDblTapObserver);
  7331. }
  7332. };
  7333. /** @hidden */
  7334. InputText.prototype.onFocus = function () {
  7335. var _this = this;
  7336. if (!this._isEnabled) {
  7337. return;
  7338. }
  7339. this._scrollLeft = null;
  7340. this._isFocused = true;
  7341. this._blinkIsEven = false;
  7342. this._cursorOffset = 0;
  7343. this._markAsDirty();
  7344. this.onFocusObservable.notifyObservers(this);
  7345. if (navigator.userAgent.indexOf("Mobile") !== -1 && !this.disableMobilePrompt) {
  7346. var value = prompt(this.promptMessage);
  7347. if (value !== null) {
  7348. this.text = value;
  7349. }
  7350. this._host.focusedControl = null;
  7351. return;
  7352. }
  7353. this._host.registerClipboardEvents();
  7354. this._onClipboardObserver = this._host.onClipboardObservable.add(function (clipboardInfo) {
  7355. // process clipboard event, can be configured.
  7356. switch (clipboardInfo.type) {
  7357. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].COPY:
  7358. _this._onCopyText(clipboardInfo.event);
  7359. _this.onTextCopyObservable.notifyObservers(_this);
  7360. break;
  7361. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].CUT:
  7362. _this._onCutText(clipboardInfo.event);
  7363. _this.onTextCutObservable.notifyObservers(_this);
  7364. break;
  7365. case babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["ClipboardEventTypes"].PASTE:
  7366. _this._onPasteText(clipboardInfo.event);
  7367. _this.onTextPasteObservable.notifyObservers(_this);
  7368. break;
  7369. default: return;
  7370. }
  7371. });
  7372. var scene = this._host.getScene();
  7373. if (scene) {
  7374. //register the pointer double tap event
  7375. this._onPointerDblTapObserver = scene.onPointerObservable.add(function (pointerInfo) {
  7376. if (!_this._isFocused) {
  7377. return;
  7378. }
  7379. if (pointerInfo.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOUBLETAP) {
  7380. _this._processDblClick(pointerInfo);
  7381. }
  7382. });
  7383. }
  7384. if (this._onFocusSelectAll) {
  7385. this._selectAllText();
  7386. }
  7387. };
  7388. InputText.prototype._getTypeName = function () {
  7389. return "InputText";
  7390. };
  7391. /**
  7392. * Function called to get the list of controls that should not steal the focus from this control
  7393. * @returns an array of controls
  7394. */
  7395. InputText.prototype.keepsFocusWith = function () {
  7396. if (!this._connectedVirtualKeyboard) {
  7397. return null;
  7398. }
  7399. return [this._connectedVirtualKeyboard];
  7400. };
  7401. /** @hidden */
  7402. InputText.prototype.processKey = function (keyCode, key, evt) {
  7403. //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
  7404. if (evt && (evt.ctrlKey || evt.metaKey) && (keyCode === 67 || keyCode === 86 || keyCode === 88)) {
  7405. return;
  7406. }
  7407. //select all
  7408. if (evt && (evt.ctrlKey || evt.metaKey) && keyCode === 65) {
  7409. this._selectAllText();
  7410. evt.preventDefault();
  7411. return;
  7412. }
  7413. // Specific cases
  7414. switch (keyCode) {
  7415. case 32: //SPACE
  7416. key = " "; //ie11 key for space is "Spacebar"
  7417. break;
  7418. case 191: //SLASH
  7419. if (evt) {
  7420. evt.preventDefault();
  7421. }
  7422. break;
  7423. case 8: // BACKSPACE
  7424. if (this._text && this._text.length > 0) {
  7425. //delete the highlighted text
  7426. if (this._isTextHighlightOn) {
  7427. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7428. this._isTextHighlightOn = false;
  7429. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7430. this._blinkIsEven = false;
  7431. if (evt) {
  7432. evt.preventDefault();
  7433. }
  7434. return;
  7435. }
  7436. //delete single character
  7437. if (this._cursorOffset === 0) {
  7438. this.text = this._text.substr(0, this._text.length - 1);
  7439. }
  7440. else {
  7441. var deletePosition = this._text.length - this._cursorOffset;
  7442. if (deletePosition > 0) {
  7443. this.text = this._text.slice(0, deletePosition - 1) + this._text.slice(deletePosition);
  7444. }
  7445. }
  7446. }
  7447. if (evt) {
  7448. evt.preventDefault();
  7449. }
  7450. return;
  7451. case 46: // DELETE
  7452. if (this._isTextHighlightOn) {
  7453. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7454. var decrementor = (this._endHighlightIndex - this._startHighlightIndex);
  7455. while (decrementor > 0 && this._cursorOffset > 0) {
  7456. this._cursorOffset--;
  7457. }
  7458. this._isTextHighlightOn = false;
  7459. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7460. if (evt) {
  7461. evt.preventDefault();
  7462. }
  7463. return;
  7464. }
  7465. if (this._text && this._text.length > 0 && this._cursorOffset > 0) {
  7466. var deletePosition = this._text.length - this._cursorOffset;
  7467. this.text = this._text.slice(0, deletePosition) + this._text.slice(deletePosition + 1);
  7468. this._cursorOffset--;
  7469. }
  7470. if (evt) {
  7471. evt.preventDefault();
  7472. }
  7473. return;
  7474. case 13: // RETURN
  7475. this._host.focusedControl = null;
  7476. this._isTextHighlightOn = false;
  7477. return;
  7478. case 35: // END
  7479. this._cursorOffset = 0;
  7480. this._blinkIsEven = false;
  7481. this._isTextHighlightOn = false;
  7482. this._markAsDirty();
  7483. return;
  7484. case 36: // HOME
  7485. this._cursorOffset = this._text.length;
  7486. this._blinkIsEven = false;
  7487. this._isTextHighlightOn = false;
  7488. this._markAsDirty();
  7489. return;
  7490. case 37: // LEFT
  7491. this._cursorOffset++;
  7492. if (this._cursorOffset > this._text.length) {
  7493. this._cursorOffset = this._text.length;
  7494. }
  7495. if (evt && evt.shiftKey) {
  7496. // update the cursor
  7497. this._blinkIsEven = false;
  7498. // shift + ctrl/cmd + <-
  7499. if (evt.ctrlKey || evt.metaKey) {
  7500. if (!this._isTextHighlightOn) {
  7501. if (this._text.length === this._cursorOffset) {
  7502. return;
  7503. }
  7504. else {
  7505. this._endHighlightIndex = this._text.length - this._cursorOffset + 1;
  7506. }
  7507. }
  7508. this._startHighlightIndex = 0;
  7509. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7510. this._cursorOffset = this._text.length;
  7511. this._isTextHighlightOn = true;
  7512. this._markAsDirty();
  7513. return;
  7514. }
  7515. //store the starting point
  7516. if (!this._isTextHighlightOn) {
  7517. this._isTextHighlightOn = true;
  7518. this._cursorIndex = (this._cursorOffset >= this._text.length) ? this._text.length : this._cursorOffset - 1;
  7519. }
  7520. //if text is already highlighted
  7521. else if (this._cursorIndex === -1) {
  7522. this._cursorIndex = this._text.length - this._endHighlightIndex;
  7523. this._cursorOffset = (this._startHighlightIndex === 0) ? this._text.length : this._text.length - this._startHighlightIndex + 1;
  7524. }
  7525. //set the highlight indexes
  7526. if (this._cursorIndex < this._cursorOffset) {
  7527. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7528. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7529. }
  7530. else if (this._cursorIndex > this._cursorOffset) {
  7531. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7532. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7533. }
  7534. else {
  7535. this._isTextHighlightOn = false;
  7536. }
  7537. this._markAsDirty();
  7538. return;
  7539. }
  7540. if (this._isTextHighlightOn) {
  7541. this._cursorOffset = this._text.length - this._startHighlightIndex;
  7542. this._isTextHighlightOn = false;
  7543. }
  7544. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7545. this._cursorOffset = this.text.length;
  7546. evt.preventDefault();
  7547. }
  7548. this._blinkIsEven = false;
  7549. this._isTextHighlightOn = false;
  7550. this._cursorIndex = -1;
  7551. this._markAsDirty();
  7552. return;
  7553. case 39: // RIGHT
  7554. this._cursorOffset--;
  7555. if (this._cursorOffset < 0) {
  7556. this._cursorOffset = 0;
  7557. }
  7558. if (evt && evt.shiftKey) {
  7559. //update the cursor
  7560. this._blinkIsEven = false;
  7561. //shift + ctrl/cmd + ->
  7562. if (evt.ctrlKey || evt.metaKey) {
  7563. if (!this._isTextHighlightOn) {
  7564. if (this._cursorOffset === 0) {
  7565. return;
  7566. }
  7567. else {
  7568. this._startHighlightIndex = this._text.length - this._cursorOffset - 1;
  7569. }
  7570. }
  7571. this._endHighlightIndex = this._text.length;
  7572. this._isTextHighlightOn = true;
  7573. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7574. this._cursorOffset = 0;
  7575. this._markAsDirty();
  7576. return;
  7577. }
  7578. if (!this._isTextHighlightOn) {
  7579. this._isTextHighlightOn = true;
  7580. this._cursorIndex = (this._cursorOffset <= 0) ? 0 : this._cursorOffset + 1;
  7581. }
  7582. //if text is already highlighted
  7583. else if (this._cursorIndex === -1) {
  7584. this._cursorIndex = this._text.length - this._startHighlightIndex;
  7585. this._cursorOffset = (this._text.length === this._endHighlightIndex) ? 0 : this._text.length - this._endHighlightIndex - 1;
  7586. }
  7587. //set the highlight indexes
  7588. if (this._cursorIndex < this._cursorOffset) {
  7589. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7590. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7591. }
  7592. else if (this._cursorIndex > this._cursorOffset) {
  7593. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7594. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7595. }
  7596. else {
  7597. this._isTextHighlightOn = false;
  7598. }
  7599. this._markAsDirty();
  7600. return;
  7601. }
  7602. if (this._isTextHighlightOn) {
  7603. this._cursorOffset = this._text.length - this._endHighlightIndex;
  7604. this._isTextHighlightOn = false;
  7605. }
  7606. //ctr + ->
  7607. if (evt && (evt.ctrlKey || evt.metaKey)) {
  7608. this._cursorOffset = 0;
  7609. evt.preventDefault();
  7610. }
  7611. this._blinkIsEven = false;
  7612. this._isTextHighlightOn = false;
  7613. this._cursorIndex = -1;
  7614. this._markAsDirty();
  7615. return;
  7616. case 222: // Dead
  7617. if (evt) {
  7618. evt.preventDefault();
  7619. }
  7620. this._cursorIndex = -1;
  7621. this.deadKey = true;
  7622. break;
  7623. }
  7624. // Printable characters
  7625. if (key &&
  7626. ((keyCode === -1) || // Direct access
  7627. (keyCode === 32) || // Space
  7628. (keyCode > 47 && keyCode < 64) || // Numbers
  7629. (keyCode > 64 && keyCode < 91) || // Letters
  7630. (keyCode > 159 && keyCode < 193) || // Special characters
  7631. (keyCode > 218 && keyCode < 223) || // Special characters
  7632. (keyCode > 95 && keyCode < 112))) { // Numpad
  7633. this._currentKey = key;
  7634. this.onBeforeKeyAddObservable.notifyObservers(this);
  7635. key = this._currentKey;
  7636. if (this._addKey) {
  7637. if (this._isTextHighlightOn) {
  7638. this.text = this._text.slice(0, this._startHighlightIndex) + key + this._text.slice(this._endHighlightIndex);
  7639. this._cursorOffset = this.text.length - (this._startHighlightIndex + 1);
  7640. this._isTextHighlightOn = false;
  7641. this._blinkIsEven = false;
  7642. this._markAsDirty();
  7643. }
  7644. else if (this._cursorOffset === 0) {
  7645. this.text += key;
  7646. }
  7647. else {
  7648. var insertPosition = this._text.length - this._cursorOffset;
  7649. this.text = this._text.slice(0, insertPosition) + key + this._text.slice(insertPosition);
  7650. }
  7651. }
  7652. }
  7653. };
  7654. /** @hidden */
  7655. InputText.prototype._updateValueFromCursorIndex = function (offset) {
  7656. //update the cursor
  7657. this._blinkIsEven = false;
  7658. if (this._cursorIndex === -1) {
  7659. this._cursorIndex = offset;
  7660. }
  7661. else {
  7662. if (this._cursorIndex < this._cursorOffset) {
  7663. this._endHighlightIndex = this._text.length - this._cursorIndex;
  7664. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7665. }
  7666. else if (this._cursorIndex > this._cursorOffset) {
  7667. this._endHighlightIndex = this._text.length - this._cursorOffset;
  7668. this._startHighlightIndex = this._text.length - this._cursorIndex;
  7669. }
  7670. else {
  7671. this._isTextHighlightOn = false;
  7672. this._markAsDirty();
  7673. return;
  7674. }
  7675. }
  7676. this._isTextHighlightOn = true;
  7677. this._markAsDirty();
  7678. };
  7679. /** @hidden */
  7680. InputText.prototype._processDblClick = function (evt) {
  7681. //pre-find the start and end index of the word under cursor, speeds up the rendering
  7682. this._startHighlightIndex = this._text.length - this._cursorOffset;
  7683. this._endHighlightIndex = this._startHighlightIndex;
  7684. var rWord = /\w+/g, moveLeft, moveRight;
  7685. do {
  7686. moveRight = this._endHighlightIndex < this._text.length && (this._text[this._endHighlightIndex].search(rWord) !== -1) ? ++this._endHighlightIndex : 0;
  7687. moveLeft = this._startHighlightIndex > 0 && (this._text[this._startHighlightIndex - 1].search(rWord) !== -1) ? --this._startHighlightIndex : 0;
  7688. } while (moveLeft || moveRight);
  7689. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7690. this.onTextHighlightObservable.notifyObservers(this);
  7691. this._isTextHighlightOn = true;
  7692. this._clickedCoordinate = null;
  7693. this._blinkIsEven = true;
  7694. this._cursorIndex = -1;
  7695. this._markAsDirty();
  7696. };
  7697. /** @hidden */
  7698. InputText.prototype._selectAllText = function () {
  7699. this._blinkIsEven = true;
  7700. this._isTextHighlightOn = true;
  7701. this._startHighlightIndex = 0;
  7702. this._endHighlightIndex = this._text.length;
  7703. this._cursorOffset = this._text.length;
  7704. this._cursorIndex = -1;
  7705. this._markAsDirty();
  7706. };
  7707. /**
  7708. * Handles the keyboard event
  7709. * @param evt Defines the KeyboardEvent
  7710. */
  7711. InputText.prototype.processKeyboard = function (evt) {
  7712. // process pressed key
  7713. this.processKey(evt.keyCode, evt.key, evt);
  7714. this.onKeyboardEventProcessedObservable.notifyObservers(evt);
  7715. };
  7716. /** @hidden */
  7717. InputText.prototype._onCopyText = function (ev) {
  7718. this._isTextHighlightOn = false;
  7719. //when write permission to clipbaord data is denied
  7720. try {
  7721. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7722. }
  7723. catch (_a) { } //pass
  7724. this._host.clipboardData = this._highlightedText;
  7725. };
  7726. /** @hidden */
  7727. InputText.prototype._onCutText = function (ev) {
  7728. if (!this._highlightedText) {
  7729. return;
  7730. }
  7731. this.text = this._text.slice(0, this._startHighlightIndex) + this._text.slice(this._endHighlightIndex);
  7732. this._isTextHighlightOn = false;
  7733. this._cursorOffset = this.text.length - this._startHighlightIndex;
  7734. //when write permission to clipbaord data is denied
  7735. try {
  7736. ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
  7737. }
  7738. catch (_a) { } //pass
  7739. this._host.clipboardData = this._highlightedText;
  7740. this._highlightedText = "";
  7741. };
  7742. /** @hidden */
  7743. InputText.prototype._onPasteText = function (ev) {
  7744. var data = "";
  7745. if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
  7746. data = ev.clipboardData.getData("text/plain");
  7747. }
  7748. else {
  7749. //get the cached data; returns blank string by default
  7750. data = this._host.clipboardData;
  7751. }
  7752. var insertPosition = this._text.length - this._cursorOffset;
  7753. this.text = this._text.slice(0, insertPosition) + data + this._text.slice(insertPosition);
  7754. };
  7755. InputText.prototype._draw = function (context, invalidatedRectangle) {
  7756. var _this = this;
  7757. context.save();
  7758. this._applyStates(context);
  7759. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7760. context.shadowColor = this.shadowColor;
  7761. context.shadowBlur = this.shadowBlur;
  7762. context.shadowOffsetX = this.shadowOffsetX;
  7763. context.shadowOffsetY = this.shadowOffsetY;
  7764. }
  7765. // Background
  7766. if (this._isFocused) {
  7767. if (this._focusedBackground) {
  7768. context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
  7769. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7770. }
  7771. }
  7772. else if (this._background) {
  7773. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  7774. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  7775. }
  7776. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  7777. context.shadowBlur = 0;
  7778. context.shadowOffsetX = 0;
  7779. context.shadowOffsetY = 0;
  7780. }
  7781. if (!this._fontOffset) {
  7782. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_2__["Control"]._GetFontOffset(context.font);
  7783. }
  7784. // Text
  7785. var clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, this._tempParentMeasure.width);
  7786. if (this.color) {
  7787. context.fillStyle = this.color;
  7788. }
  7789. var text = this._beforeRenderText(this._text);
  7790. if (!this._isFocused && !this._text && this._placeholderText) {
  7791. text = this._placeholderText;
  7792. if (this._placeholderColor) {
  7793. context.fillStyle = this._placeholderColor;
  7794. }
  7795. }
  7796. this._textWidth = context.measureText(text).width;
  7797. var marginWidth = this._margin.getValueInPixel(this._host, this._tempParentMeasure.width) * 2;
  7798. if (this._autoStretchWidth) {
  7799. this.width = Math.min(this._maxWidth.getValueInPixel(this._host, this._tempParentMeasure.width), this._textWidth + marginWidth) + "px";
  7800. }
  7801. var rootY = this._fontOffset.ascent + (this._currentMeasure.height - this._fontOffset.height) / 2;
  7802. var availableWidth = this._width.getValueInPixel(this._host, this._tempParentMeasure.width) - marginWidth;
  7803. context.save();
  7804. context.beginPath();
  7805. context.rect(clipTextLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, availableWidth + 2, this._currentMeasure.height);
  7806. context.clip();
  7807. if (this._isFocused && this._textWidth > availableWidth) {
  7808. var textLeft = clipTextLeft - this._textWidth + availableWidth;
  7809. if (!this._scrollLeft) {
  7810. this._scrollLeft = textLeft;
  7811. }
  7812. }
  7813. else {
  7814. this._scrollLeft = clipTextLeft;
  7815. }
  7816. context.fillText(text, this._scrollLeft, this._currentMeasure.top + rootY);
  7817. // Cursor
  7818. if (this._isFocused) {
  7819. // Need to move cursor
  7820. if (this._clickedCoordinate) {
  7821. var rightPosition = this._scrollLeft + this._textWidth;
  7822. var absoluteCursorPosition = rightPosition - this._clickedCoordinate;
  7823. var currentSize = 0;
  7824. this._cursorOffset = 0;
  7825. var previousDist = 0;
  7826. do {
  7827. if (this._cursorOffset) {
  7828. previousDist = Math.abs(absoluteCursorPosition - currentSize);
  7829. }
  7830. this._cursorOffset++;
  7831. currentSize = context.measureText(text.substr(text.length - this._cursorOffset, this._cursorOffset)).width;
  7832. } while (currentSize < absoluteCursorPosition && (text.length >= this._cursorOffset));
  7833. // Find closest move
  7834. if (Math.abs(absoluteCursorPosition - currentSize) > previousDist) {
  7835. this._cursorOffset--;
  7836. }
  7837. this._blinkIsEven = false;
  7838. this._clickedCoordinate = null;
  7839. }
  7840. // Render cursor
  7841. if (!this._blinkIsEven) {
  7842. var cursorOffsetText = this.text.substr(this._text.length - this._cursorOffset);
  7843. var cursorOffsetWidth = context.measureText(cursorOffsetText).width;
  7844. var cursorLeft = this._scrollLeft + this._textWidth - cursorOffsetWidth;
  7845. if (cursorLeft < clipTextLeft) {
  7846. this._scrollLeft += (clipTextLeft - cursorLeft);
  7847. cursorLeft = clipTextLeft;
  7848. this._markAsDirty();
  7849. }
  7850. else if (cursorLeft > clipTextLeft + availableWidth) {
  7851. this._scrollLeft += (clipTextLeft + availableWidth - cursorLeft);
  7852. cursorLeft = clipTextLeft + availableWidth;
  7853. this._markAsDirty();
  7854. }
  7855. if (!this._isTextHighlightOn) {
  7856. context.fillRect(cursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, 2, this._fontOffset.height);
  7857. }
  7858. }
  7859. clearTimeout(this._blinkTimeout);
  7860. this._blinkTimeout = setTimeout(function () {
  7861. _this._blinkIsEven = !_this._blinkIsEven;
  7862. _this._markAsDirty();
  7863. }, 500);
  7864. //show the highlighted text
  7865. if (this._isTextHighlightOn) {
  7866. clearTimeout(this._blinkTimeout);
  7867. var highlightCursorOffsetWidth = context.measureText(this.text.substring(this._startHighlightIndex)).width;
  7868. var highlightCursorLeft = this._scrollLeft + this._textWidth - highlightCursorOffsetWidth;
  7869. this._highlightedText = this.text.substring(this._startHighlightIndex, this._endHighlightIndex);
  7870. var width = context.measureText(this.text.substring(this._startHighlightIndex, this._endHighlightIndex)).width;
  7871. if (highlightCursorLeft < clipTextLeft) {
  7872. width = width - (clipTextLeft - highlightCursorLeft);
  7873. if (!width) {
  7874. // when using left arrow on text.length > availableWidth;
  7875. // assigns the width of the first letter after clipTextLeft
  7876. width = context.measureText(this.text.charAt(this.text.length - this._cursorOffset)).width;
  7877. }
  7878. highlightCursorLeft = clipTextLeft;
  7879. }
  7880. //for transparancy
  7881. context.globalAlpha = this._highligherOpacity;
  7882. context.fillStyle = this._textHighlightColor;
  7883. context.fillRect(highlightCursorLeft, this._currentMeasure.top + (this._currentMeasure.height - this._fontOffset.height) / 2, width, this._fontOffset.height);
  7884. context.globalAlpha = 1.0;
  7885. }
  7886. }
  7887. context.restore();
  7888. // Border
  7889. if (this._thickness) {
  7890. if (this._isFocused) {
  7891. if (this.focusedColor) {
  7892. context.strokeStyle = this.focusedColor;
  7893. }
  7894. }
  7895. else {
  7896. if (this.color) {
  7897. context.strokeStyle = this.color;
  7898. }
  7899. }
  7900. context.lineWidth = this._thickness;
  7901. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  7902. }
  7903. context.restore();
  7904. };
  7905. InputText.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  7906. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  7907. return false;
  7908. }
  7909. this._clickedCoordinate = coordinates.x;
  7910. this._isTextHighlightOn = false;
  7911. this._highlightedText = "";
  7912. this._cursorIndex = -1;
  7913. this._isPointerDown = true;
  7914. this._host._capturingControl[pointerId] = this;
  7915. if (this._host.focusedControl === this) {
  7916. // Move cursor
  7917. clearTimeout(this._blinkTimeout);
  7918. this._markAsDirty();
  7919. return true;
  7920. }
  7921. if (!this._isEnabled) {
  7922. return false;
  7923. }
  7924. this._host.focusedControl = this;
  7925. return true;
  7926. };
  7927. InputText.prototype._onPointerMove = function (target, coordinates, pointerId) {
  7928. if (this._host.focusedControl === this && this._isPointerDown) {
  7929. this._clickedCoordinate = coordinates.x;
  7930. this._markAsDirty();
  7931. this._updateValueFromCursorIndex(this._cursorOffset);
  7932. }
  7933. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  7934. };
  7935. InputText.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  7936. this._isPointerDown = false;
  7937. delete this._host._capturingControl[pointerId];
  7938. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  7939. };
  7940. InputText.prototype._beforeRenderText = function (text) {
  7941. return text;
  7942. };
  7943. InputText.prototype.dispose = function () {
  7944. _super.prototype.dispose.call(this);
  7945. this.onBlurObservable.clear();
  7946. this.onFocusObservable.clear();
  7947. this.onTextChangedObservable.clear();
  7948. this.onTextCopyObservable.clear();
  7949. this.onTextCutObservable.clear();
  7950. this.onTextPasteObservable.clear();
  7951. this.onTextHighlightObservable.clear();
  7952. this.onKeyboardEventProcessedObservable.clear();
  7953. };
  7954. return InputText;
  7955. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  7956. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.InputText"] = InputText;
  7957. /***/ }),
  7958. /***/ "./2D/controls/line.ts":
  7959. /*!*****************************!*\
  7960. !*** ./2D/controls/line.ts ***!
  7961. \*****************************/
  7962. /*! exports provided: Line */
  7963. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7964. "use strict";
  7965. __webpack_require__.r(__webpack_exports__);
  7966. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return Line; });
  7967. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  7968. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  7969. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  7970. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  7971. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  7972. /** Class used to render 2D lines */
  7973. var Line = /** @class */ (function (_super) {
  7974. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super);
  7975. /**
  7976. * Creates a new Line
  7977. * @param name defines the control name
  7978. */
  7979. function Line(name) {
  7980. var _this = _super.call(this, name) || this;
  7981. _this.name = name;
  7982. _this._lineWidth = 1;
  7983. _this._x1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7984. _this._y1 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7985. _this._x2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7986. _this._y2 = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](0);
  7987. _this._dash = new Array();
  7988. _this._automaticSize = true;
  7989. _this.isHitTestVisible = false;
  7990. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  7991. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  7992. return _this;
  7993. }
  7994. Object.defineProperty(Line.prototype, "dash", {
  7995. /** Gets or sets the dash pattern */
  7996. get: function () {
  7997. return this._dash;
  7998. },
  7999. set: function (value) {
  8000. if (this._dash === value) {
  8001. return;
  8002. }
  8003. this._dash = value;
  8004. this._markAsDirty();
  8005. },
  8006. enumerable: true,
  8007. configurable: true
  8008. });
  8009. Object.defineProperty(Line.prototype, "connectedControl", {
  8010. /** Gets or sets the control connected with the line end */
  8011. get: function () {
  8012. return this._connectedControl;
  8013. },
  8014. set: function (value) {
  8015. var _this = this;
  8016. if (this._connectedControl === value) {
  8017. return;
  8018. }
  8019. if (this._connectedControlDirtyObserver && this._connectedControl) {
  8020. this._connectedControl.onDirtyObservable.remove(this._connectedControlDirtyObserver);
  8021. this._connectedControlDirtyObserver = null;
  8022. }
  8023. if (value) {
  8024. this._connectedControlDirtyObserver = value.onDirtyObservable.add(function () { return _this._markAsDirty(); });
  8025. }
  8026. this._connectedControl = value;
  8027. this._markAsDirty();
  8028. },
  8029. enumerable: true,
  8030. configurable: true
  8031. });
  8032. Object.defineProperty(Line.prototype, "x1", {
  8033. /** Gets or sets start coordinates on X axis */
  8034. get: function () {
  8035. return this._x1.toString(this._host);
  8036. },
  8037. set: function (value) {
  8038. if (this._x1.toString(this._host) === value) {
  8039. return;
  8040. }
  8041. if (this._x1.fromString(value)) {
  8042. this._markAsDirty();
  8043. }
  8044. },
  8045. enumerable: true,
  8046. configurable: true
  8047. });
  8048. Object.defineProperty(Line.prototype, "y1", {
  8049. /** Gets or sets start coordinates on Y axis */
  8050. get: function () {
  8051. return this._y1.toString(this._host);
  8052. },
  8053. set: function (value) {
  8054. if (this._y1.toString(this._host) === value) {
  8055. return;
  8056. }
  8057. if (this._y1.fromString(value)) {
  8058. this._markAsDirty();
  8059. }
  8060. },
  8061. enumerable: true,
  8062. configurable: true
  8063. });
  8064. Object.defineProperty(Line.prototype, "x2", {
  8065. /** Gets or sets end coordinates on X axis */
  8066. get: function () {
  8067. return this._x2.toString(this._host);
  8068. },
  8069. set: function (value) {
  8070. if (this._x2.toString(this._host) === value) {
  8071. return;
  8072. }
  8073. if (this._x2.fromString(value)) {
  8074. this._markAsDirty();
  8075. }
  8076. },
  8077. enumerable: true,
  8078. configurable: true
  8079. });
  8080. Object.defineProperty(Line.prototype, "y2", {
  8081. /** Gets or sets end coordinates on Y axis */
  8082. get: function () {
  8083. return this._y2.toString(this._host);
  8084. },
  8085. set: function (value) {
  8086. if (this._y2.toString(this._host) === value) {
  8087. return;
  8088. }
  8089. if (this._y2.fromString(value)) {
  8090. this._markAsDirty();
  8091. }
  8092. },
  8093. enumerable: true,
  8094. configurable: true
  8095. });
  8096. Object.defineProperty(Line.prototype, "lineWidth", {
  8097. /** Gets or sets line width */
  8098. get: function () {
  8099. return this._lineWidth;
  8100. },
  8101. set: function (value) {
  8102. if (this._lineWidth === value) {
  8103. return;
  8104. }
  8105. this._lineWidth = value;
  8106. this._markAsDirty();
  8107. },
  8108. enumerable: true,
  8109. configurable: true
  8110. });
  8111. Object.defineProperty(Line.prototype, "horizontalAlignment", {
  8112. /** Gets or sets horizontal alignment */
  8113. set: function (value) {
  8114. return;
  8115. },
  8116. enumerable: true,
  8117. configurable: true
  8118. });
  8119. Object.defineProperty(Line.prototype, "verticalAlignment", {
  8120. /** Gets or sets vertical alignment */
  8121. set: function (value) {
  8122. return;
  8123. },
  8124. enumerable: true,
  8125. configurable: true
  8126. });
  8127. Object.defineProperty(Line.prototype, "_effectiveX2", {
  8128. get: function () {
  8129. return (this._connectedControl ? this._connectedControl.centerX : 0) + this._x2.getValue(this._host);
  8130. },
  8131. enumerable: true,
  8132. configurable: true
  8133. });
  8134. Object.defineProperty(Line.prototype, "_effectiveY2", {
  8135. get: function () {
  8136. return (this._connectedControl ? this._connectedControl.centerY : 0) + this._y2.getValue(this._host);
  8137. },
  8138. enumerable: true,
  8139. configurable: true
  8140. });
  8141. Line.prototype._getTypeName = function () {
  8142. return "Line";
  8143. };
  8144. Line.prototype._draw = function (context) {
  8145. context.save();
  8146. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8147. context.shadowColor = this.shadowColor;
  8148. context.shadowBlur = this.shadowBlur;
  8149. context.shadowOffsetX = this.shadowOffsetX;
  8150. context.shadowOffsetY = this.shadowOffsetY;
  8151. }
  8152. this._applyStates(context);
  8153. context.strokeStyle = this.color;
  8154. context.lineWidth = this._lineWidth;
  8155. context.setLineDash(this._dash);
  8156. context.beginPath();
  8157. context.moveTo(this._cachedParentMeasure.left + this._x1.getValue(this._host), this._cachedParentMeasure.top + this._y1.getValue(this._host));
  8158. context.lineTo(this._cachedParentMeasure.left + this._effectiveX2, this._cachedParentMeasure.top + this._effectiveY2);
  8159. context.stroke();
  8160. context.restore();
  8161. };
  8162. Line.prototype._measure = function () {
  8163. // Width / Height
  8164. this._currentMeasure.width = Math.abs(this._x1.getValue(this._host) - this._effectiveX2) + this._lineWidth;
  8165. this._currentMeasure.height = Math.abs(this._y1.getValue(this._host) - this._effectiveY2) + this._lineWidth;
  8166. };
  8167. Line.prototype._computeAlignment = function (parentMeasure, context) {
  8168. this._currentMeasure.left = parentMeasure.left + Math.min(this._x1.getValue(this._host), this._effectiveX2) - this._lineWidth / 2;
  8169. this._currentMeasure.top = parentMeasure.top + Math.min(this._y1.getValue(this._host), this._effectiveY2) - this._lineWidth / 2;
  8170. };
  8171. /**
  8172. * Move one end of the line given 3D cartesian coordinates.
  8173. * @param position Targeted world position
  8174. * @param scene Scene
  8175. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8176. */
  8177. Line.prototype.moveToVector3 = function (position, scene, end) {
  8178. if (end === void 0) { end = false; }
  8179. if (!this._host || this.parent !== this._host._rootContainer) {
  8180. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tools"].Error("Cannot move a control to a vector3 if the control is not at root level");
  8181. return;
  8182. }
  8183. var globalViewport = this._host._getGlobalViewport(scene);
  8184. var projectedPosition = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), scene.getTransformMatrix(), globalViewport);
  8185. this._moveToProjectedPosition(projectedPosition, end);
  8186. if (projectedPosition.z < 0 || projectedPosition.z > 1) {
  8187. this.notRenderable = true;
  8188. return;
  8189. }
  8190. this.notRenderable = false;
  8191. };
  8192. /**
  8193. * Move one end of the line to a position in screen absolute space.
  8194. * @param projectedPosition Position in screen absolute space (X, Y)
  8195. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  8196. */
  8197. Line.prototype._moveToProjectedPosition = function (projectedPosition, end) {
  8198. if (end === void 0) { end = false; }
  8199. var x = (projectedPosition.x + this._linkOffsetX.getValue(this._host)) + "px";
  8200. var y = (projectedPosition.y + this._linkOffsetY.getValue(this._host)) + "px";
  8201. if (end) {
  8202. this.x2 = x;
  8203. this.y2 = y;
  8204. this._x2.ignoreAdaptiveScaling = true;
  8205. this._y2.ignoreAdaptiveScaling = true;
  8206. }
  8207. else {
  8208. this.x1 = x;
  8209. this.y1 = y;
  8210. this._x1.ignoreAdaptiveScaling = true;
  8211. this._y1.ignoreAdaptiveScaling = true;
  8212. }
  8213. };
  8214. return Line;
  8215. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8216. babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Line"] = Line;
  8217. /***/ }),
  8218. /***/ "./2D/controls/multiLine.ts":
  8219. /*!**********************************!*\
  8220. !*** ./2D/controls/multiLine.ts ***!
  8221. \**********************************/
  8222. /*! exports provided: MultiLine */
  8223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8224. "use strict";
  8225. __webpack_require__.r(__webpack_exports__);
  8226. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return MultiLine; });
  8227. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8228. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/abstractMesh */ "babylonjs/Maths/math");
  8229. /* harmony import */ var babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__);
  8230. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8231. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../multiLinePoint */ "./2D/multiLinePoint.ts");
  8232. /**
  8233. * Class used to create multi line control
  8234. */
  8235. var MultiLine = /** @class */ (function (_super) {
  8236. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MultiLine, _super);
  8237. /**
  8238. * Creates a new MultiLine
  8239. * @param name defines the control name
  8240. */
  8241. function MultiLine(name) {
  8242. var _this = _super.call(this, name) || this;
  8243. _this.name = name;
  8244. _this._lineWidth = 1;
  8245. /** Function called when a point is updated */
  8246. _this.onPointUpdate = function () {
  8247. _this._markAsDirty();
  8248. };
  8249. _this._automaticSize = true;
  8250. _this.isHitTestVisible = false;
  8251. _this._horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8252. _this._verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].VERTICAL_ALIGNMENT_TOP;
  8253. _this._dash = [];
  8254. _this._points = [];
  8255. return _this;
  8256. }
  8257. Object.defineProperty(MultiLine.prototype, "dash", {
  8258. /** Gets or sets dash pattern */
  8259. get: function () {
  8260. return this._dash;
  8261. },
  8262. set: function (value) {
  8263. if (this._dash === value) {
  8264. return;
  8265. }
  8266. this._dash = value;
  8267. this._markAsDirty();
  8268. },
  8269. enumerable: true,
  8270. configurable: true
  8271. });
  8272. /**
  8273. * Gets point stored at specified index
  8274. * @param index defines the index to look for
  8275. * @returns the requested point if found
  8276. */
  8277. MultiLine.prototype.getAt = function (index) {
  8278. if (!this._points[index]) {
  8279. this._points[index] = new _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"](this);
  8280. }
  8281. return this._points[index];
  8282. };
  8283. /**
  8284. * Adds new points to the point collection
  8285. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  8286. * @returns the list of created MultiLinePoint
  8287. */
  8288. MultiLine.prototype.add = function () {
  8289. var _this = this;
  8290. var items = [];
  8291. for (var _i = 0; _i < arguments.length; _i++) {
  8292. items[_i] = arguments[_i];
  8293. }
  8294. return items.map(function (item) { return _this.push(item); });
  8295. };
  8296. /**
  8297. * Adds a new point to the point collection
  8298. * @param item defines the item (mesh, control or 2d coordiantes) to add
  8299. * @returns the created MultiLinePoint
  8300. */
  8301. MultiLine.prototype.push = function (item) {
  8302. var point = this.getAt(this._points.length);
  8303. if (item == null) {
  8304. return point;
  8305. }
  8306. if (item instanceof babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  8307. point.mesh = item;
  8308. }
  8309. else if (item instanceof _control__WEBPACK_IMPORTED_MODULE_2__["Control"]) {
  8310. point.control = item;
  8311. }
  8312. else if (item.x != null && item.y != null) {
  8313. point.x = item.x;
  8314. point.y = item.y;
  8315. }
  8316. return point;
  8317. };
  8318. /**
  8319. * Remove a specific value or point from the active point collection
  8320. * @param value defines the value or point to remove
  8321. */
  8322. MultiLine.prototype.remove = function (value) {
  8323. var index;
  8324. if (value instanceof _multiLinePoint__WEBPACK_IMPORTED_MODULE_3__["MultiLinePoint"]) {
  8325. index = this._points.indexOf(value);
  8326. if (index === -1) {
  8327. return;
  8328. }
  8329. }
  8330. else {
  8331. index = value;
  8332. }
  8333. var point = this._points[index];
  8334. if (!point) {
  8335. return;
  8336. }
  8337. point.dispose();
  8338. this._points.splice(index, 1);
  8339. };
  8340. /**
  8341. * Resets this object to initial state (no point)
  8342. */
  8343. MultiLine.prototype.reset = function () {
  8344. while (this._points.length > 0) {
  8345. this.remove(this._points.length - 1);
  8346. }
  8347. };
  8348. /**
  8349. * Resets all links
  8350. */
  8351. MultiLine.prototype.resetLinks = function () {
  8352. this._points.forEach(function (point) {
  8353. if (point != null) {
  8354. point.resetLinks();
  8355. }
  8356. });
  8357. };
  8358. Object.defineProperty(MultiLine.prototype, "lineWidth", {
  8359. /** Gets or sets line width */
  8360. get: function () {
  8361. return this._lineWidth;
  8362. },
  8363. set: function (value) {
  8364. if (this._lineWidth === value) {
  8365. return;
  8366. }
  8367. this._lineWidth = value;
  8368. this._markAsDirty();
  8369. },
  8370. enumerable: true,
  8371. configurable: true
  8372. });
  8373. Object.defineProperty(MultiLine.prototype, "horizontalAlignment", {
  8374. set: function (value) {
  8375. return;
  8376. },
  8377. enumerable: true,
  8378. configurable: true
  8379. });
  8380. Object.defineProperty(MultiLine.prototype, "verticalAlignment", {
  8381. set: function (value) {
  8382. return;
  8383. },
  8384. enumerable: true,
  8385. configurable: true
  8386. });
  8387. MultiLine.prototype._getTypeName = function () {
  8388. return "MultiLine";
  8389. };
  8390. MultiLine.prototype._draw = function (context, invalidatedRectangle) {
  8391. context.save();
  8392. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8393. context.shadowColor = this.shadowColor;
  8394. context.shadowBlur = this.shadowBlur;
  8395. context.shadowOffsetX = this.shadowOffsetX;
  8396. context.shadowOffsetY = this.shadowOffsetY;
  8397. }
  8398. this._applyStates(context);
  8399. context.strokeStyle = this.color;
  8400. context.lineWidth = this._lineWidth;
  8401. context.setLineDash(this._dash);
  8402. context.beginPath();
  8403. var first = true; //first index is not necessarily 0
  8404. this._points.forEach(function (point) {
  8405. if (!point) {
  8406. return;
  8407. }
  8408. if (first) {
  8409. context.moveTo(point._point.x, point._point.y);
  8410. first = false;
  8411. }
  8412. else {
  8413. context.lineTo(point._point.x, point._point.y);
  8414. }
  8415. });
  8416. context.stroke();
  8417. context.restore();
  8418. };
  8419. MultiLine.prototype._additionalProcessing = function (parentMeasure, context) {
  8420. var _this = this;
  8421. this._minX = null;
  8422. this._minY = null;
  8423. this._maxX = null;
  8424. this._maxY = null;
  8425. this._points.forEach(function (point, index) {
  8426. if (!point) {
  8427. return;
  8428. }
  8429. point.translate();
  8430. if (_this._minX == null || point._point.x < _this._minX) {
  8431. _this._minX = point._point.x;
  8432. }
  8433. if (_this._minY == null || point._point.y < _this._minY) {
  8434. _this._minY = point._point.y;
  8435. }
  8436. if (_this._maxX == null || point._point.x > _this._maxX) {
  8437. _this._maxX = point._point.x;
  8438. }
  8439. if (_this._maxY == null || point._point.y > _this._maxY) {
  8440. _this._maxY = point._point.y;
  8441. }
  8442. });
  8443. if (this._minX == null) {
  8444. this._minX = 0;
  8445. }
  8446. if (this._minY == null) {
  8447. this._minY = 0;
  8448. }
  8449. if (this._maxX == null) {
  8450. this._maxX = 0;
  8451. }
  8452. if (this._maxY == null) {
  8453. this._maxY = 0;
  8454. }
  8455. };
  8456. MultiLine.prototype._measure = function () {
  8457. if (this._minX == null || this._maxX == null || this._minY == null || this._maxY == null) {
  8458. return;
  8459. }
  8460. this._currentMeasure.width = Math.abs(this._maxX - this._minX) + this._lineWidth;
  8461. this._currentMeasure.height = Math.abs(this._maxY - this._minY) + this._lineWidth;
  8462. };
  8463. MultiLine.prototype._computeAlignment = function (parentMeasure, context) {
  8464. if (this._minX == null || this._minY == null) {
  8465. return;
  8466. }
  8467. this._currentMeasure.left = this._minX - this._lineWidth / 2;
  8468. this._currentMeasure.top = this._minY - this._lineWidth / 2;
  8469. };
  8470. MultiLine.prototype.dispose = function () {
  8471. this.reset();
  8472. _super.prototype.dispose.call(this);
  8473. };
  8474. return MultiLine;
  8475. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8476. babylonjs_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.MultiLine"] = MultiLine;
  8477. /***/ }),
  8478. /***/ "./2D/controls/radioButton.ts":
  8479. /*!************************************!*\
  8480. !*** ./2D/controls/radioButton.ts ***!
  8481. \************************************/
  8482. /*! exports provided: RadioButton */
  8483. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8484. "use strict";
  8485. __webpack_require__.r(__webpack_exports__);
  8486. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return RadioButton; });
  8487. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8488. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  8489. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  8490. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  8491. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  8492. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  8493. /**
  8494. * Class used to create radio button controls
  8495. */
  8496. var RadioButton = /** @class */ (function (_super) {
  8497. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioButton, _super);
  8498. /**
  8499. * Creates a new RadioButton
  8500. * @param name defines the control name
  8501. */
  8502. function RadioButton(name) {
  8503. var _this = _super.call(this, name) || this;
  8504. _this.name = name;
  8505. _this._isChecked = false;
  8506. _this._background = "black";
  8507. _this._checkSizeRatio = 0.8;
  8508. _this._thickness = 1;
  8509. /** Gets or sets group name */
  8510. _this.group = "";
  8511. /** Observable raised when isChecked is changed */
  8512. _this.onIsCheckedChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  8513. _this.isPointerBlocker = true;
  8514. return _this;
  8515. }
  8516. Object.defineProperty(RadioButton.prototype, "thickness", {
  8517. /** Gets or sets border thickness */
  8518. get: function () {
  8519. return this._thickness;
  8520. },
  8521. set: function (value) {
  8522. if (this._thickness === value) {
  8523. return;
  8524. }
  8525. this._thickness = value;
  8526. this._markAsDirty();
  8527. },
  8528. enumerable: true,
  8529. configurable: true
  8530. });
  8531. Object.defineProperty(RadioButton.prototype, "checkSizeRatio", {
  8532. /** Gets or sets a value indicating the ratio between overall size and check size */
  8533. get: function () {
  8534. return this._checkSizeRatio;
  8535. },
  8536. set: function (value) {
  8537. value = Math.max(Math.min(1, value), 0);
  8538. if (this._checkSizeRatio === value) {
  8539. return;
  8540. }
  8541. this._checkSizeRatio = value;
  8542. this._markAsDirty();
  8543. },
  8544. enumerable: true,
  8545. configurable: true
  8546. });
  8547. Object.defineProperty(RadioButton.prototype, "background", {
  8548. /** Gets or sets background color */
  8549. get: function () {
  8550. return this._background;
  8551. },
  8552. set: function (value) {
  8553. if (this._background === value) {
  8554. return;
  8555. }
  8556. this._background = value;
  8557. this._markAsDirty();
  8558. },
  8559. enumerable: true,
  8560. configurable: true
  8561. });
  8562. Object.defineProperty(RadioButton.prototype, "isChecked", {
  8563. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  8564. get: function () {
  8565. return this._isChecked;
  8566. },
  8567. set: function (value) {
  8568. var _this = this;
  8569. if (this._isChecked === value) {
  8570. return;
  8571. }
  8572. this._isChecked = value;
  8573. this._markAsDirty();
  8574. this.onIsCheckedChangedObservable.notifyObservers(value);
  8575. if (this._isChecked && this._host) {
  8576. // Update all controls from same group
  8577. this._host.executeOnAllControls(function (control) {
  8578. if (control === _this) {
  8579. return;
  8580. }
  8581. if (control.group === undefined) {
  8582. return;
  8583. }
  8584. var childRadio = control;
  8585. if (childRadio.group === _this.group) {
  8586. childRadio.isChecked = false;
  8587. }
  8588. });
  8589. }
  8590. },
  8591. enumerable: true,
  8592. configurable: true
  8593. });
  8594. RadioButton.prototype._getTypeName = function () {
  8595. return "RadioButton";
  8596. };
  8597. RadioButton.prototype._draw = function (context) {
  8598. context.save();
  8599. this._applyStates(context);
  8600. var actualWidth = this._currentMeasure.width - this._thickness;
  8601. var actualHeight = this._currentMeasure.height - this._thickness;
  8602. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8603. context.shadowColor = this.shadowColor;
  8604. context.shadowBlur = this.shadowBlur;
  8605. context.shadowOffsetX = this.shadowOffsetX;
  8606. context.shadowOffsetY = this.shadowOffsetY;
  8607. }
  8608. // Outer
  8609. _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);
  8610. context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
  8611. context.fill();
  8612. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8613. context.shadowBlur = 0;
  8614. context.shadowOffsetX = 0;
  8615. context.shadowOffsetY = 0;
  8616. }
  8617. context.strokeStyle = this.color;
  8618. context.lineWidth = this._thickness;
  8619. context.stroke();
  8620. // Inner
  8621. if (this._isChecked) {
  8622. context.fillStyle = this._isEnabled ? this.color : this._disabledColor;
  8623. var offsetWidth = actualWidth * this._checkSizeRatio;
  8624. var offseHeight = actualHeight * this._checkSizeRatio;
  8625. _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);
  8626. context.fill();
  8627. }
  8628. context.restore();
  8629. };
  8630. // Events
  8631. RadioButton.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  8632. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  8633. return false;
  8634. }
  8635. if (!this.isChecked) {
  8636. this.isChecked = true;
  8637. }
  8638. return true;
  8639. };
  8640. /**
  8641. * Utility function to easily create a radio button with a header
  8642. * @param title defines the label to use for the header
  8643. * @param group defines the group to use for the radio button
  8644. * @param isChecked defines the initial state of the radio button
  8645. * @param onValueChanged defines the callback to call when value changes
  8646. * @returns a StackPanel containing the radio button and a textBlock
  8647. */
  8648. RadioButton.AddRadioButtonWithHeader = function (title, group, isChecked, onValueChanged) {
  8649. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_3__["StackPanel"]();
  8650. panel.isVertical = false;
  8651. panel.height = "30px";
  8652. var radio = new RadioButton();
  8653. radio.width = "20px";
  8654. radio.height = "20px";
  8655. radio.isChecked = isChecked;
  8656. radio.color = "green";
  8657. radio.group = group;
  8658. radio.onIsCheckedChangedObservable.add(function (value) { return onValueChanged(radio, value); });
  8659. panel.addControl(radio);
  8660. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]();
  8661. header.text = title;
  8662. header.width = "180px";
  8663. header.paddingLeft = "5px";
  8664. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_2__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8665. header.color = "white";
  8666. panel.addControl(header);
  8667. return panel;
  8668. };
  8669. return RadioButton;
  8670. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  8671. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.RadioButton"] = RadioButton;
  8672. /***/ }),
  8673. /***/ "./2D/controls/rectangle.ts":
  8674. /*!**********************************!*\
  8675. !*** ./2D/controls/rectangle.ts ***!
  8676. \**********************************/
  8677. /*! exports provided: Rectangle */
  8678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8679. "use strict";
  8680. __webpack_require__.r(__webpack_exports__);
  8681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return Rectangle; });
  8682. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8683. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  8684. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  8685. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  8686. /** Class used to create rectangle container */
  8687. var Rectangle = /** @class */ (function (_super) {
  8688. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Rectangle, _super);
  8689. /**
  8690. * Creates a new Rectangle
  8691. * @param name defines the control name
  8692. */
  8693. function Rectangle(name) {
  8694. var _this = _super.call(this, name) || this;
  8695. _this.name = name;
  8696. _this._thickness = 1;
  8697. _this._cornerRadius = 0;
  8698. return _this;
  8699. }
  8700. Object.defineProperty(Rectangle.prototype, "thickness", {
  8701. /** Gets or sets border thickness */
  8702. get: function () {
  8703. return this._thickness;
  8704. },
  8705. set: function (value) {
  8706. if (this._thickness === value) {
  8707. return;
  8708. }
  8709. this._thickness = value;
  8710. this._markAsDirty();
  8711. },
  8712. enumerable: true,
  8713. configurable: true
  8714. });
  8715. Object.defineProperty(Rectangle.prototype, "cornerRadius", {
  8716. /** Gets or sets the corner radius angle */
  8717. get: function () {
  8718. return this._cornerRadius;
  8719. },
  8720. set: function (value) {
  8721. if (value < 0) {
  8722. value = 0;
  8723. }
  8724. if (this._cornerRadius === value) {
  8725. return;
  8726. }
  8727. this._cornerRadius = value;
  8728. this._markAsDirty();
  8729. },
  8730. enumerable: true,
  8731. configurable: true
  8732. });
  8733. Rectangle.prototype._getTypeName = function () {
  8734. return "Rectangle";
  8735. };
  8736. Rectangle.prototype._localDraw = function (context) {
  8737. context.save();
  8738. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8739. context.shadowColor = this.shadowColor;
  8740. context.shadowBlur = this.shadowBlur;
  8741. context.shadowOffsetX = this.shadowOffsetX;
  8742. context.shadowOffsetY = this.shadowOffsetY;
  8743. }
  8744. if (this._background) {
  8745. context.fillStyle = this._background;
  8746. if (this._cornerRadius) {
  8747. this._drawRoundedRect(context, this._thickness / 2);
  8748. context.fill();
  8749. }
  8750. else {
  8751. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  8752. }
  8753. }
  8754. if (this._thickness) {
  8755. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  8756. context.shadowBlur = 0;
  8757. context.shadowOffsetX = 0;
  8758. context.shadowOffsetY = 0;
  8759. }
  8760. if (this.color) {
  8761. context.strokeStyle = this.color;
  8762. }
  8763. context.lineWidth = this._thickness;
  8764. if (this._cornerRadius) {
  8765. this._drawRoundedRect(context, this._thickness / 2);
  8766. context.stroke();
  8767. }
  8768. else {
  8769. context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
  8770. }
  8771. }
  8772. context.restore();
  8773. };
  8774. Rectangle.prototype._additionalProcessing = function (parentMeasure, context) {
  8775. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8776. this._measureForChildren.width -= 2 * this._thickness;
  8777. this._measureForChildren.height -= 2 * this._thickness;
  8778. this._measureForChildren.left += this._thickness;
  8779. this._measureForChildren.top += this._thickness;
  8780. };
  8781. Rectangle.prototype._drawRoundedRect = function (context, offset) {
  8782. if (offset === void 0) { offset = 0; }
  8783. var x = this._currentMeasure.left + offset;
  8784. var y = this._currentMeasure.top + offset;
  8785. var width = this._currentMeasure.width - offset * 2;
  8786. var height = this._currentMeasure.height - offset * 2;
  8787. var radius = Math.min(height / 2 - 2, Math.min(width / 2 - 2, this._cornerRadius));
  8788. context.beginPath();
  8789. context.moveTo(x + radius, y);
  8790. context.lineTo(x + width - radius, y);
  8791. context.quadraticCurveTo(x + width, y, x + width, y + radius);
  8792. context.lineTo(x + width, y + height - radius);
  8793. context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
  8794. context.lineTo(x + radius, y + height);
  8795. context.quadraticCurveTo(x, y + height, x, y + height - radius);
  8796. context.lineTo(x, y + radius);
  8797. context.quadraticCurveTo(x, y, x + radius, y);
  8798. context.closePath();
  8799. };
  8800. Rectangle.prototype._clipForChildren = function (context) {
  8801. if (this._cornerRadius) {
  8802. this._drawRoundedRect(context, this._thickness);
  8803. context.clip();
  8804. }
  8805. };
  8806. return Rectangle;
  8807. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  8808. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Rectangle"] = Rectangle;
  8809. /***/ }),
  8810. /***/ "./2D/controls/scrollViewers/scrollViewer.ts":
  8811. /*!***************************************************!*\
  8812. !*** ./2D/controls/scrollViewers/scrollViewer.ts ***!
  8813. \***************************************************/
  8814. /*! exports provided: ScrollViewer */
  8815. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8816. "use strict";
  8817. __webpack_require__.r(__webpack_exports__);
  8818. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return ScrollViewer; });
  8819. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  8820. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Events/pointerEvents */ "babylonjs/Maths/math");
  8821. /* harmony import */ var babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__);
  8822. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../rectangle */ "./2D/controls/rectangle.ts");
  8823. /* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../grid */ "./2D/controls/grid.ts");
  8824. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  8825. /* harmony import */ var _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./scrollViewerWindow */ "./2D/controls/scrollViewers/scrollViewerWindow.ts");
  8826. /* harmony import */ var _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sliders/scrollBar */ "./2D/controls/sliders/scrollBar.ts");
  8827. /* harmony import */ var _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../sliders/imageScrollBar */ "./2D/controls/sliders/imageScrollBar.ts");
  8828. /**
  8829. * Class used to hold a viewer window and sliders in a grid
  8830. */
  8831. var ScrollViewer = /** @class */ (function (_super) {
  8832. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollViewer, _super);
  8833. /**
  8834. * Creates a new ScrollViewer
  8835. * @param name of ScrollViewer
  8836. */
  8837. function ScrollViewer(name, isImageBased) {
  8838. var _this = _super.call(this, name) || this;
  8839. _this._barSize = 20;
  8840. _this._pointerIsOver = false;
  8841. _this._wheelPrecision = 0.05;
  8842. _this._thumbLength = 0.5;
  8843. _this._thumbHeight = 1;
  8844. _this._barImageHeight = 1;
  8845. _this._useImageBar = isImageBased ? isImageBased : false;
  8846. _this.onDirtyObservable.add(function () {
  8847. _this._horizontalBarSpace.color = _this.color;
  8848. _this._verticalBarSpace.color = _this.color;
  8849. _this._dragSpace.color = _this.color;
  8850. });
  8851. _this.onPointerEnterObservable.add(function () {
  8852. _this._pointerIsOver = true;
  8853. });
  8854. _this.onPointerOutObservable.add(function () {
  8855. _this._pointerIsOver = false;
  8856. });
  8857. _this._grid = new _grid__WEBPACK_IMPORTED_MODULE_3__["Grid"]();
  8858. if (_this._useImageBar) {
  8859. _this._horizontalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8860. _this._verticalBar = new _sliders_imageScrollBar__WEBPACK_IMPORTED_MODULE_7__["ImageScrollBar"]();
  8861. }
  8862. else {
  8863. _this._horizontalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8864. _this._verticalBar = new _sliders_scrollBar__WEBPACK_IMPORTED_MODULE_6__["ScrollBar"]();
  8865. }
  8866. _this._window = new _scrollViewerWindow__WEBPACK_IMPORTED_MODULE_5__["_ScrollViewerWindow"]();
  8867. _this._window.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8868. _this._window.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8869. _this._grid.addColumnDefinition(1);
  8870. _this._grid.addColumnDefinition(0, true);
  8871. _this._grid.addRowDefinition(1);
  8872. _this._grid.addRowDefinition(0, true);
  8873. _super.prototype.addControl.call(_this, _this._grid);
  8874. _this._grid.addControl(_this._window, 0, 0);
  8875. _this._verticalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8876. _this._verticalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8877. _this._verticalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8878. _this._verticalBarSpace.thickness = 1;
  8879. _this._grid.addControl(_this._verticalBarSpace, 0, 1);
  8880. _this._addBar(_this._verticalBar, _this._verticalBarSpace, true, Math.PI);
  8881. _this._horizontalBarSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8882. _this._horizontalBarSpace.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  8883. _this._horizontalBarSpace.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_TOP;
  8884. _this._horizontalBarSpace.thickness = 1;
  8885. _this._grid.addControl(_this._horizontalBarSpace, 1, 0);
  8886. _this._addBar(_this._horizontalBar, _this._horizontalBarSpace, false, 0);
  8887. _this._dragSpace = new _rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]();
  8888. _this._dragSpace.thickness = 1;
  8889. _this._grid.addControl(_this._dragSpace, 1, 1);
  8890. // Colors
  8891. if (!_this._useImageBar) {
  8892. _this.barColor = "grey";
  8893. _this.barBackground = "transparent";
  8894. }
  8895. return _this;
  8896. }
  8897. Object.defineProperty(ScrollViewer.prototype, "horizontalBar", {
  8898. /**
  8899. * Gets the horizontal scrollbar
  8900. */
  8901. get: function () {
  8902. return this._horizontalBar;
  8903. },
  8904. enumerable: true,
  8905. configurable: true
  8906. });
  8907. Object.defineProperty(ScrollViewer.prototype, "verticalBar", {
  8908. /**
  8909. * Gets the vertical scrollbar
  8910. */
  8911. get: function () {
  8912. return this._verticalBar;
  8913. },
  8914. enumerable: true,
  8915. configurable: true
  8916. });
  8917. /**
  8918. * Adds a new control to the current container
  8919. * @param control defines the control to add
  8920. * @returns the current container
  8921. */
  8922. ScrollViewer.prototype.addControl = function (control) {
  8923. if (!control) {
  8924. return this;
  8925. }
  8926. this._window.addControl(control);
  8927. return this;
  8928. };
  8929. /**
  8930. * Removes a control from the current container
  8931. * @param control defines the control to remove
  8932. * @returns the current container
  8933. */
  8934. ScrollViewer.prototype.removeControl = function (control) {
  8935. this._window.removeControl(control);
  8936. return this;
  8937. };
  8938. Object.defineProperty(ScrollViewer.prototype, "children", {
  8939. /** Gets the list of children */
  8940. get: function () {
  8941. return this._window.children;
  8942. },
  8943. enumerable: true,
  8944. configurable: true
  8945. });
  8946. ScrollViewer.prototype._flagDescendantsAsMatrixDirty = function () {
  8947. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  8948. var child = _a[_i];
  8949. child._markMatrixAsDirty();
  8950. }
  8951. };
  8952. /** Reset the scroll viewer window to initial size */
  8953. ScrollViewer.prototype.resetWindow = function () {
  8954. this._window.width = "100%";
  8955. this._window.height = "100%";
  8956. };
  8957. ScrollViewer.prototype._getTypeName = function () {
  8958. return "ScrollViewer";
  8959. };
  8960. ScrollViewer.prototype._buildClientSizes = function () {
  8961. this._window.parentClientWidth = this._currentMeasure.width - (this._verticalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8962. this._window.parentClientHeight = this._currentMeasure.height - (this._horizontalBar.isVisible ? this._barSize : 0) - 2 * this.thickness;
  8963. this._clientWidth = this._window.parentClientWidth;
  8964. this._clientHeight = this._window.parentClientHeight;
  8965. };
  8966. ScrollViewer.prototype._additionalProcessing = function (parentMeasure, context) {
  8967. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  8968. this._buildClientSizes();
  8969. };
  8970. ScrollViewer.prototype._postMeasure = function () {
  8971. _super.prototype._postMeasure.call(this);
  8972. this._updateScroller();
  8973. };
  8974. Object.defineProperty(ScrollViewer.prototype, "wheelPrecision", {
  8975. /**
  8976. * Gets or sets the mouse wheel precision
  8977. * from 0 to 1 with a default value of 0.05
  8978. * */
  8979. get: function () {
  8980. return this._wheelPrecision;
  8981. },
  8982. set: function (value) {
  8983. if (this._wheelPrecision === value) {
  8984. return;
  8985. }
  8986. if (value < 0) {
  8987. value = 0;
  8988. }
  8989. if (value > 1) {
  8990. value = 1;
  8991. }
  8992. this._wheelPrecision = value;
  8993. },
  8994. enumerable: true,
  8995. configurable: true
  8996. });
  8997. Object.defineProperty(ScrollViewer.prototype, "scrollBackground", {
  8998. /** Gets or sets the scroll bar container background color */
  8999. get: function () {
  9000. return this._horizontalBarSpace.background;
  9001. },
  9002. set: function (color) {
  9003. if (this._horizontalBarSpace.background === color) {
  9004. return;
  9005. }
  9006. this._horizontalBarSpace.background = color;
  9007. this._verticalBarSpace.background = color;
  9008. },
  9009. enumerable: true,
  9010. configurable: true
  9011. });
  9012. Object.defineProperty(ScrollViewer.prototype, "barColor", {
  9013. /** Gets or sets the bar color */
  9014. get: function () {
  9015. return this._barColor;
  9016. },
  9017. set: function (color) {
  9018. if (this._barColor === color) {
  9019. return;
  9020. }
  9021. this._barColor = color;
  9022. this._horizontalBar.color = color;
  9023. this._verticalBar.color = color;
  9024. },
  9025. enumerable: true,
  9026. configurable: true
  9027. });
  9028. Object.defineProperty(ScrollViewer.prototype, "thumbImage", {
  9029. /** Gets or sets the bar image */
  9030. get: function () {
  9031. return this._barImage;
  9032. },
  9033. set: function (value) {
  9034. if (this._barImage === value) {
  9035. return;
  9036. }
  9037. this._barImage = value;
  9038. var hb = this._horizontalBar;
  9039. var vb = this._verticalBar;
  9040. hb.thumbImage = value;
  9041. vb.thumbImage = value;
  9042. },
  9043. enumerable: true,
  9044. configurable: true
  9045. });
  9046. Object.defineProperty(ScrollViewer.prototype, "barSize", {
  9047. /** Gets or sets the size of the bar */
  9048. get: function () {
  9049. return this._barSize;
  9050. },
  9051. set: function (value) {
  9052. if (this._barSize === value) {
  9053. return;
  9054. }
  9055. this._barSize = value;
  9056. this._markAsDirty();
  9057. if (this._horizontalBar.isVisible) {
  9058. this._grid.setRowDefinition(1, this._barSize, true);
  9059. }
  9060. if (this._verticalBar.isVisible) {
  9061. this._grid.setColumnDefinition(1, this._barSize, true);
  9062. }
  9063. },
  9064. enumerable: true,
  9065. configurable: true
  9066. });
  9067. Object.defineProperty(ScrollViewer.prototype, "thumbLength", {
  9068. /** Gets or sets the length of the thumb */
  9069. get: function () {
  9070. return this._thumbLength;
  9071. },
  9072. set: function (value) {
  9073. if (this._thumbLength === value) {
  9074. return;
  9075. }
  9076. if (value <= 0) {
  9077. value = 0.1;
  9078. }
  9079. if (value > 1) {
  9080. value = 1;
  9081. }
  9082. this._thumbLength = value;
  9083. var hb = this._horizontalBar;
  9084. var vb = this._verticalBar;
  9085. hb.thumbLength = value;
  9086. vb.thumbLength = value;
  9087. this._markAsDirty();
  9088. },
  9089. enumerable: true,
  9090. configurable: true
  9091. });
  9092. Object.defineProperty(ScrollViewer.prototype, "thumbHeight", {
  9093. /** Gets or sets the height of the thumb */
  9094. get: function () {
  9095. return this._thumbHeight;
  9096. },
  9097. set: function (value) {
  9098. if (this._thumbHeight === value) {
  9099. return;
  9100. }
  9101. if (value <= 0) {
  9102. value = 0.1;
  9103. }
  9104. if (value > 1) {
  9105. value = 1;
  9106. }
  9107. this._thumbHeight = value;
  9108. var hb = this._horizontalBar;
  9109. var vb = this._verticalBar;
  9110. hb.thumbHeight = value;
  9111. vb.thumbHeight = value;
  9112. this._markAsDirty();
  9113. },
  9114. enumerable: true,
  9115. configurable: true
  9116. });
  9117. Object.defineProperty(ScrollViewer.prototype, "barImageHeight", {
  9118. /** Gets or sets the height of the bar image */
  9119. get: function () {
  9120. return this._barImageHeight;
  9121. },
  9122. set: function (value) {
  9123. if (this._barImageHeight === value) {
  9124. return;
  9125. }
  9126. if (value <= 0) {
  9127. value = 0.1;
  9128. }
  9129. if (value > 1) {
  9130. value = 1;
  9131. }
  9132. this._barImageHeight = value;
  9133. var hb = this._horizontalBar;
  9134. var vb = this._verticalBar;
  9135. hb.barImageHeight = value;
  9136. vb.barImageHeight = value;
  9137. this._markAsDirty();
  9138. },
  9139. enumerable: true,
  9140. configurable: true
  9141. });
  9142. Object.defineProperty(ScrollViewer.prototype, "barBackground", {
  9143. /** Gets or sets the bar background */
  9144. get: function () {
  9145. return this._barBackground;
  9146. },
  9147. set: function (color) {
  9148. if (this._barBackground === color) {
  9149. return;
  9150. }
  9151. this._barBackground = color;
  9152. var hb = this._horizontalBar;
  9153. var vb = this._verticalBar;
  9154. hb.background = color;
  9155. vb.background = color;
  9156. this._dragSpace.background = color;
  9157. },
  9158. enumerable: true,
  9159. configurable: true
  9160. });
  9161. Object.defineProperty(ScrollViewer.prototype, "barImage", {
  9162. /** Gets or sets the bar background image */
  9163. get: function () {
  9164. return this._barBackgroundImage;
  9165. },
  9166. set: function (value) {
  9167. if (this._barBackgroundImage === value) {
  9168. }
  9169. this._barBackgroundImage = value;
  9170. var hb = this._horizontalBar;
  9171. var vb = this._verticalBar;
  9172. hb.backgroundImage = value;
  9173. vb.backgroundImage = value;
  9174. },
  9175. enumerable: true,
  9176. configurable: true
  9177. });
  9178. /** @hidden */
  9179. ScrollViewer.prototype._updateScroller = function () {
  9180. var windowContentsWidth = this._window._currentMeasure.width;
  9181. var windowContentsHeight = this._window._currentMeasure.height;
  9182. if (this._horizontalBar.isVisible && windowContentsWidth <= this._clientWidth) {
  9183. this._grid.setRowDefinition(1, 0, true);
  9184. this._horizontalBar.isVisible = false;
  9185. this._horizontalBar.value = 0;
  9186. this._rebuildLayout = true;
  9187. }
  9188. else if (!this._horizontalBar.isVisible && windowContentsWidth > this._clientWidth) {
  9189. this._grid.setRowDefinition(1, this._barSize, true);
  9190. this._horizontalBar.isVisible = true;
  9191. this._rebuildLayout = true;
  9192. }
  9193. if (this._verticalBar.isVisible && windowContentsHeight <= this._clientHeight) {
  9194. this._grid.setColumnDefinition(1, 0, true);
  9195. this._verticalBar.isVisible = false;
  9196. this._verticalBar.value = 0;
  9197. this._rebuildLayout = true;
  9198. }
  9199. else if (!this._verticalBar.isVisible && windowContentsHeight > this._clientHeight) {
  9200. this._grid.setColumnDefinition(1, this._barSize, true);
  9201. this._verticalBar.isVisible = true;
  9202. this._rebuildLayout = true;
  9203. }
  9204. this._buildClientSizes();
  9205. this._endLeft = this._clientWidth - windowContentsWidth;
  9206. this._endTop = this._clientHeight - windowContentsHeight;
  9207. var newLeft = this._horizontalBar.value * this._endLeft + "px";
  9208. var newTop = this._verticalBar.value * this._endTop + "px";
  9209. if (newLeft !== this._window.left) {
  9210. this._window.left = newLeft;
  9211. this._rebuildLayout = true;
  9212. }
  9213. if (newTop !== this._window.top) {
  9214. this._window.top = newTop;
  9215. this._rebuildLayout = true;
  9216. }
  9217. this._horizontalBar.thumbWidth = this._thumbLength * 0.9 * this._clientWidth + "px";
  9218. this._verticalBar.thumbWidth = this._thumbLength * 0.9 * this._clientHeight + "px";
  9219. };
  9220. ScrollViewer.prototype._link = function (host) {
  9221. _super.prototype._link.call(this, host);
  9222. this._attachWheel();
  9223. };
  9224. /** @hidden */
  9225. ScrollViewer.prototype._addBar = function (barControl, barContainer, isVertical, rotation) {
  9226. var _this = this;
  9227. barControl.paddingLeft = 0;
  9228. barControl.width = "100%";
  9229. barControl.height = "100%";
  9230. barControl.barOffset = 0;
  9231. barControl.value = 0;
  9232. barControl.maximum = 1;
  9233. barControl.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  9234. barControl.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_4__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9235. barControl.isVertical = isVertical;
  9236. barControl.rotation = rotation;
  9237. barControl.isVisible = false;
  9238. barContainer.addControl(barControl);
  9239. barControl.onValueChangedObservable.add(function (value) {
  9240. if (rotation > 0) {
  9241. _this._window.top = value * _this._endTop + "px";
  9242. }
  9243. else {
  9244. _this._window.left = value * _this._endLeft + "px";
  9245. }
  9246. });
  9247. };
  9248. /** @hidden */
  9249. ScrollViewer.prototype._attachWheel = function () {
  9250. var _this = this;
  9251. if (!this._host || this._onPointerObserver) {
  9252. return;
  9253. }
  9254. var scene = this._host.getScene();
  9255. this._onPointerObserver = scene.onPointerObservable.add(function (pi, state) {
  9256. if (!_this._pointerIsOver || pi.type !== babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERWHEEL) {
  9257. return;
  9258. }
  9259. if (_this._verticalBar.isVisible == true) {
  9260. if (pi.event.deltaY < 0 && _this._verticalBar.value > 0) {
  9261. _this._verticalBar.value -= _this._wheelPrecision;
  9262. }
  9263. else if (pi.event.deltaY > 0 && _this._verticalBar.value < _this._verticalBar.maximum) {
  9264. _this._verticalBar.value += _this._wheelPrecision;
  9265. }
  9266. }
  9267. if (_this._horizontalBar.isVisible == true) {
  9268. if (pi.event.deltaX < 0 && _this._horizontalBar.value < _this._horizontalBar.maximum) {
  9269. _this._horizontalBar.value += _this._wheelPrecision;
  9270. }
  9271. else if (pi.event.deltaX > 0 && _this._horizontalBar.value > 0) {
  9272. _this._horizontalBar.value -= _this._wheelPrecision;
  9273. }
  9274. }
  9275. });
  9276. };
  9277. ScrollViewer.prototype._renderHighlightSpecific = function (context) {
  9278. if (!this.isHighlighted) {
  9279. return;
  9280. }
  9281. _super.prototype._renderHighlightSpecific.call(this, context);
  9282. this._grid._renderHighlightSpecific(context);
  9283. context.restore();
  9284. };
  9285. /** Releases associated resources */
  9286. ScrollViewer.prototype.dispose = function () {
  9287. var scene = this._host.getScene();
  9288. if (scene && this._onPointerObserver) {
  9289. scene.onPointerObservable.remove(this._onPointerObserver);
  9290. this._onPointerObserver = null;
  9291. }
  9292. _super.prototype.dispose.call(this);
  9293. };
  9294. return ScrollViewer;
  9295. }(_rectangle__WEBPACK_IMPORTED_MODULE_2__["Rectangle"]));
  9296. babylonjs_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ScrollViewer"] = ScrollViewer;
  9297. /***/ }),
  9298. /***/ "./2D/controls/scrollViewers/scrollViewerWindow.ts":
  9299. /*!*********************************************************!*\
  9300. !*** ./2D/controls/scrollViewers/scrollViewerWindow.ts ***!
  9301. \*********************************************************/
  9302. /*! exports provided: _ScrollViewerWindow */
  9303. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9304. "use strict";
  9305. __webpack_require__.r(__webpack_exports__);
  9306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ScrollViewerWindow", function() { return _ScrollViewerWindow; });
  9307. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9308. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../container */ "./2D/controls/container.ts");
  9309. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  9310. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  9311. /**
  9312. * Class used to hold a the container for ScrollViewer
  9313. * @hidden
  9314. */
  9315. var _ScrollViewerWindow = /** @class */ (function (_super) {
  9316. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(_ScrollViewerWindow, _super);
  9317. /**
  9318. * Creates a new ScrollViewerWindow
  9319. * @param name of ScrollViewerWindow
  9320. */
  9321. function _ScrollViewerWindow(name) {
  9322. return _super.call(this, name) || this;
  9323. }
  9324. _ScrollViewerWindow.prototype._getTypeName = function () {
  9325. return "ScrollViewerWindow";
  9326. };
  9327. /** @hidden */
  9328. _ScrollViewerWindow.prototype._additionalProcessing = function (parentMeasure, context) {
  9329. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  9330. this._measureForChildren.left = this._currentMeasure.left;
  9331. this._measureForChildren.top = this._currentMeasure.top;
  9332. this._measureForChildren.width = parentMeasure.width;
  9333. this._measureForChildren.height = parentMeasure.height;
  9334. };
  9335. _ScrollViewerWindow.prototype._postMeasure = function () {
  9336. var maxWidth = this.parentClientWidth;
  9337. var maxHeight = this.parentClientHeight;
  9338. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  9339. var child = _a[_i];
  9340. if (!child.isVisible || child.notRenderable) {
  9341. continue;
  9342. }
  9343. if (child.horizontalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER) {
  9344. child._offsetLeft(this._currentMeasure.left - child._currentMeasure.left);
  9345. }
  9346. if (child.verticalAlignment === _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER) {
  9347. child._offsetTop(this._currentMeasure.top - child._currentMeasure.top);
  9348. }
  9349. maxWidth = Math.max(maxWidth, child._currentMeasure.left - this._currentMeasure.left + child._currentMeasure.width);
  9350. maxHeight = Math.max(maxHeight, child._currentMeasure.top - this._currentMeasure.top + child._currentMeasure.height);
  9351. }
  9352. if (this._currentMeasure.width !== maxWidth) {
  9353. this._width.updateInPlace(maxWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9354. this._currentMeasure.width = maxWidth;
  9355. this._rebuildLayout = true;
  9356. this._isDirty = true;
  9357. }
  9358. if (this._currentMeasure.height !== maxHeight) {
  9359. this._height.updateInPlace(maxHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  9360. this._currentMeasure.height = maxHeight;
  9361. this._rebuildLayout = true;
  9362. this._isDirty = true;
  9363. }
  9364. _super.prototype._postMeasure.call(this);
  9365. };
  9366. return _ScrollViewerWindow;
  9367. }(_container__WEBPACK_IMPORTED_MODULE_1__["Container"]));
  9368. /***/ }),
  9369. /***/ "./2D/controls/selector.ts":
  9370. /*!*********************************!*\
  9371. !*** ./2D/controls/selector.ts ***!
  9372. \*********************************/
  9373. /*! exports provided: SelectorGroup, CheckboxGroup, RadioGroup, SliderGroup, SelectionPanel */
  9374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9375. "use strict";
  9376. __webpack_require__.r(__webpack_exports__);
  9377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return SelectorGroup; });
  9378. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return CheckboxGroup; });
  9379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return RadioGroup; });
  9380. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return SliderGroup; });
  9381. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return SelectionPanel; });
  9382. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  9383. /* harmony import */ var _rectangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rectangle */ "./2D/controls/rectangle.ts");
  9384. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  9385. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  9386. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  9387. /* harmony import */ var _checkbox__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./checkbox */ "./2D/controls/checkbox.ts");
  9388. /* harmony import */ var _radioButton__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./radioButton */ "./2D/controls/radioButton.ts");
  9389. /* harmony import */ var _sliders_slider__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./sliders/slider */ "./2D/controls/sliders/slider.ts");
  9390. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  9391. /** Class used to create a RadioGroup
  9392. * which contains groups of radio buttons
  9393. */
  9394. var SelectorGroup = /** @class */ (function () {
  9395. /**
  9396. * Creates a new SelectorGroup
  9397. * @param name of group, used as a group heading
  9398. */
  9399. function SelectorGroup(
  9400. /** name of SelectorGroup */
  9401. name) {
  9402. this.name = name;
  9403. this._groupPanel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9404. this._selectors = new Array();
  9405. this._groupPanel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9406. this._groupPanel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9407. this._groupHeader = this._addGroupHeader(name);
  9408. }
  9409. Object.defineProperty(SelectorGroup.prototype, "groupPanel", {
  9410. /** Gets the groupPanel of the SelectorGroup */
  9411. get: function () {
  9412. return this._groupPanel;
  9413. },
  9414. enumerable: true,
  9415. configurable: true
  9416. });
  9417. Object.defineProperty(SelectorGroup.prototype, "selectors", {
  9418. /** Gets the selectors array */
  9419. get: function () {
  9420. return this._selectors;
  9421. },
  9422. enumerable: true,
  9423. configurable: true
  9424. });
  9425. Object.defineProperty(SelectorGroup.prototype, "header", {
  9426. /** Gets and sets the group header */
  9427. get: function () {
  9428. return this._groupHeader.text;
  9429. },
  9430. set: function (label) {
  9431. if (this._groupHeader.text === "label") {
  9432. return;
  9433. }
  9434. this._groupHeader.text = label;
  9435. },
  9436. enumerable: true,
  9437. configurable: true
  9438. });
  9439. /** @hidden */
  9440. SelectorGroup.prototype._addGroupHeader = function (text) {
  9441. var groupHeading = new _textBlock__WEBPACK_IMPORTED_MODULE_4__["TextBlock"]("groupHead", text);
  9442. groupHeading.width = 0.9;
  9443. groupHeading.height = "30px";
  9444. groupHeading.textWrapping = true;
  9445. groupHeading.color = "black";
  9446. groupHeading.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9447. groupHeading.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9448. groupHeading.left = "2px";
  9449. this._groupPanel.addControl(groupHeading);
  9450. return groupHeading;
  9451. };
  9452. /** @hidden*/
  9453. SelectorGroup.prototype._getSelector = function (selectorNb) {
  9454. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9455. return;
  9456. }
  9457. return this._selectors[selectorNb];
  9458. };
  9459. /** Removes the selector at the given position
  9460. * @param selectorNb the position of the selector within the group
  9461. */
  9462. SelectorGroup.prototype.removeSelector = function (selectorNb) {
  9463. if (selectorNb < 0 || selectorNb >= this._selectors.length) {
  9464. return;
  9465. }
  9466. this._groupPanel.removeControl(this._selectors[selectorNb]);
  9467. this._selectors.splice(selectorNb, 1);
  9468. };
  9469. return SelectorGroup;
  9470. }());
  9471. /** Class used to create a CheckboxGroup
  9472. * which contains groups of checkbox buttons
  9473. */
  9474. var CheckboxGroup = /** @class */ (function (_super) {
  9475. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CheckboxGroup, _super);
  9476. function CheckboxGroup() {
  9477. return _super !== null && _super.apply(this, arguments) || this;
  9478. }
  9479. /** Adds a checkbox as a control
  9480. * @param text is the label for the selector
  9481. * @param func is the function called when the Selector is checked
  9482. * @param checked is true when Selector is checked
  9483. */
  9484. CheckboxGroup.prototype.addCheckbox = function (text, func, checked) {
  9485. if (func === void 0) { func = function (s) { }; }
  9486. if (checked === void 0) { checked = false; }
  9487. var checked = checked || false;
  9488. var button = new _checkbox__WEBPACK_IMPORTED_MODULE_5__["Checkbox"]();
  9489. button.width = "20px";
  9490. button.height = "20px";
  9491. button.color = "#364249";
  9492. button.background = "#CCCCCC";
  9493. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9494. button.onIsCheckedChangedObservable.add(function (state) {
  9495. func(state);
  9496. });
  9497. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, text, "200px", { isHorizontal: true, controlFirst: true });
  9498. _selector.height = "30px";
  9499. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9500. _selector.left = "4px";
  9501. this.groupPanel.addControl(_selector);
  9502. this.selectors.push(_selector);
  9503. button.isChecked = checked;
  9504. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9505. button.color = this.groupPanel.parent.parent.buttonColor;
  9506. button.background = this.groupPanel.parent.parent.buttonBackground;
  9507. }
  9508. };
  9509. /** @hidden */
  9510. CheckboxGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9511. this.selectors[selectorNb].children[1].text = label;
  9512. };
  9513. /** @hidden */
  9514. CheckboxGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9515. this.selectors[selectorNb].children[1].color = color;
  9516. };
  9517. /** @hidden */
  9518. CheckboxGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9519. this.selectors[selectorNb].children[0].color = color;
  9520. };
  9521. /** @hidden */
  9522. CheckboxGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9523. this.selectors[selectorNb].children[0].background = color;
  9524. };
  9525. return CheckboxGroup;
  9526. }(SelectorGroup));
  9527. /** Class used to create a RadioGroup
  9528. * which contains groups of radio buttons
  9529. */
  9530. var RadioGroup = /** @class */ (function (_super) {
  9531. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RadioGroup, _super);
  9532. function RadioGroup() {
  9533. var _this = _super !== null && _super.apply(this, arguments) || this;
  9534. _this._selectNb = 0;
  9535. return _this;
  9536. }
  9537. /** Adds a radio button as a control
  9538. * @param label is the label for the selector
  9539. * @param func is the function called when the Selector is checked
  9540. * @param checked is true when Selector is checked
  9541. */
  9542. RadioGroup.prototype.addRadio = function (label, func, checked) {
  9543. if (func === void 0) { func = function (n) { }; }
  9544. if (checked === void 0) { checked = false; }
  9545. var nb = this._selectNb++;
  9546. var button = new _radioButton__WEBPACK_IMPORTED_MODULE_6__["RadioButton"]();
  9547. button.name = label;
  9548. button.width = "20px";
  9549. button.height = "20px";
  9550. button.color = "#364249";
  9551. button.background = "#CCCCCC";
  9552. button.group = this.name;
  9553. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9554. button.onIsCheckedChangedObservable.add(function (state) {
  9555. if (state) {
  9556. func(nb);
  9557. }
  9558. });
  9559. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label, "200px", { isHorizontal: true, controlFirst: true });
  9560. _selector.height = "30px";
  9561. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9562. _selector.left = "4px";
  9563. this.groupPanel.addControl(_selector);
  9564. this.selectors.push(_selector);
  9565. button.isChecked = checked;
  9566. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9567. button.color = this.groupPanel.parent.parent.buttonColor;
  9568. button.background = this.groupPanel.parent.parent.buttonBackground;
  9569. }
  9570. };
  9571. /** @hidden */
  9572. RadioGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9573. this.selectors[selectorNb].children[1].text = label;
  9574. };
  9575. /** @hidden */
  9576. RadioGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9577. this.selectors[selectorNb].children[1].color = color;
  9578. };
  9579. /** @hidden */
  9580. RadioGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9581. this.selectors[selectorNb].children[0].color = color;
  9582. };
  9583. /** @hidden */
  9584. RadioGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9585. this.selectors[selectorNb].children[0].background = color;
  9586. };
  9587. return RadioGroup;
  9588. }(SelectorGroup));
  9589. /** Class used to create a SliderGroup
  9590. * which contains groups of slider buttons
  9591. */
  9592. var SliderGroup = /** @class */ (function (_super) {
  9593. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SliderGroup, _super);
  9594. function SliderGroup() {
  9595. return _super !== null && _super.apply(this, arguments) || this;
  9596. }
  9597. /**
  9598. * Adds a slider to the SelectorGroup
  9599. * @param label is the label for the SliderBar
  9600. * @param func is the function called when the Slider moves
  9601. * @param unit is a string describing the units used, eg degrees or metres
  9602. * @param min is the minimum value for the Slider
  9603. * @param max is the maximum value for the Slider
  9604. * @param value is the start value for the Slider between min and max
  9605. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  9606. */
  9607. SliderGroup.prototype.addSlider = function (label, func, unit, min, max, value, onValueChange) {
  9608. if (func === void 0) { func = function (v) { }; }
  9609. if (unit === void 0) { unit = "Units"; }
  9610. if (min === void 0) { min = 0; }
  9611. if (max === void 0) { max = 0; }
  9612. if (value === void 0) { value = 0; }
  9613. if (onValueChange === void 0) { onValueChange = function (v) { return v | 0; }; }
  9614. var button = new _sliders_slider__WEBPACK_IMPORTED_MODULE_7__["Slider"]();
  9615. button.name = unit;
  9616. button.value = value;
  9617. button.minimum = min;
  9618. button.maximum = max;
  9619. button.width = 0.9;
  9620. button.height = "20px";
  9621. button.color = "#364249";
  9622. button.background = "#CCCCCC";
  9623. button.borderColor = "black";
  9624. button.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9625. button.left = "4px";
  9626. button.paddingBottom = "4px";
  9627. button.onValueChangedObservable.add(function (value) {
  9628. button.parent.children[0].text = button.parent.children[0].name + ": " + onValueChange(value) + " " + button.name;
  9629. func(value);
  9630. });
  9631. var _selector = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].AddHeader(button, label + ": " + onValueChange(value) + " " + unit, "30px", { isHorizontal: false, controlFirst: false });
  9632. _selector.height = "60px";
  9633. _selector.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9634. _selector.left = "4px";
  9635. _selector.children[0].name = label;
  9636. this.groupPanel.addControl(_selector);
  9637. this.selectors.push(_selector);
  9638. if (this.groupPanel.parent && this.groupPanel.parent.parent) {
  9639. button.color = this.groupPanel.parent.parent.buttonColor;
  9640. button.background = this.groupPanel.parent.parent.buttonBackground;
  9641. }
  9642. };
  9643. /** @hidden */
  9644. SliderGroup.prototype._setSelectorLabel = function (selectorNb, label) {
  9645. this.selectors[selectorNb].children[0].name = label;
  9646. this.selectors[selectorNb].children[0].text = label + ": " + this.selectors[selectorNb].children[1].value + " " + this.selectors[selectorNb].children[1].name;
  9647. };
  9648. /** @hidden */
  9649. SliderGroup.prototype._setSelectorLabelColor = function (selectorNb, color) {
  9650. this.selectors[selectorNb].children[0].color = color;
  9651. };
  9652. /** @hidden */
  9653. SliderGroup.prototype._setSelectorButtonColor = function (selectorNb, color) {
  9654. this.selectors[selectorNb].children[1].color = color;
  9655. };
  9656. /** @hidden */
  9657. SliderGroup.prototype._setSelectorButtonBackground = function (selectorNb, color) {
  9658. this.selectors[selectorNb].children[1].background = color;
  9659. };
  9660. return SliderGroup;
  9661. }(SelectorGroup));
  9662. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  9663. * @see http://doc.babylonjs.com/how_to/selector
  9664. */
  9665. var SelectionPanel = /** @class */ (function (_super) {
  9666. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SelectionPanel, _super);
  9667. /**
  9668. * Creates a new SelectionPanel
  9669. * @param name of SelectionPanel
  9670. * @param groups is an array of SelectionGroups
  9671. */
  9672. function SelectionPanel(
  9673. /** name of SelectionPanel */
  9674. name,
  9675. /** an array of SelectionGroups */
  9676. groups) {
  9677. if (groups === void 0) { groups = []; }
  9678. var _this = _super.call(this, name) || this;
  9679. _this.name = name;
  9680. _this.groups = groups;
  9681. _this._buttonColor = "#364249";
  9682. _this._buttonBackground = "#CCCCCC";
  9683. _this._headerColor = "black";
  9684. _this._barColor = "white";
  9685. _this._barHeight = "2px";
  9686. _this._spacerHeight = "20px";
  9687. _this._bars = new Array();
  9688. _this._groups = groups;
  9689. _this.thickness = 2;
  9690. _this._panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  9691. _this._panel.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  9692. _this._panel.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9693. _this._panel.top = 5;
  9694. _this._panel.left = 5;
  9695. _this._panel.width = 0.95;
  9696. if (groups.length > 0) {
  9697. for (var i = 0; i < groups.length - 1; i++) {
  9698. _this._panel.addControl(groups[i].groupPanel);
  9699. _this._addSpacer();
  9700. }
  9701. _this._panel.addControl(groups[groups.length - 1].groupPanel);
  9702. }
  9703. _this.addControl(_this._panel);
  9704. return _this;
  9705. }
  9706. SelectionPanel.prototype._getTypeName = function () {
  9707. return "SelectionPanel";
  9708. };
  9709. Object.defineProperty(SelectionPanel.prototype, "headerColor", {
  9710. /** Gets or sets the headerColor */
  9711. get: function () {
  9712. return this._headerColor;
  9713. },
  9714. set: function (color) {
  9715. if (this._headerColor === color) {
  9716. return;
  9717. }
  9718. this._headerColor = color;
  9719. this._setHeaderColor();
  9720. },
  9721. enumerable: true,
  9722. configurable: true
  9723. });
  9724. SelectionPanel.prototype._setHeaderColor = function () {
  9725. for (var i = 0; i < this._groups.length; i++) {
  9726. this._groups[i].groupPanel.children[0].color = this._headerColor;
  9727. }
  9728. };
  9729. Object.defineProperty(SelectionPanel.prototype, "buttonColor", {
  9730. /** Gets or sets the button color */
  9731. get: function () {
  9732. return this._buttonColor;
  9733. },
  9734. set: function (color) {
  9735. if (this._buttonColor === color) {
  9736. return;
  9737. }
  9738. this._buttonColor = color;
  9739. this._setbuttonColor();
  9740. },
  9741. enumerable: true,
  9742. configurable: true
  9743. });
  9744. SelectionPanel.prototype._setbuttonColor = function () {
  9745. for (var i = 0; i < this._groups.length; i++) {
  9746. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9747. this._groups[i]._setSelectorButtonColor(j, this._buttonColor);
  9748. }
  9749. }
  9750. };
  9751. Object.defineProperty(SelectionPanel.prototype, "labelColor", {
  9752. /** Gets or sets the label color */
  9753. get: function () {
  9754. return this._labelColor;
  9755. },
  9756. set: function (color) {
  9757. if (this._labelColor === color) {
  9758. return;
  9759. }
  9760. this._labelColor = color;
  9761. this._setLabelColor();
  9762. },
  9763. enumerable: true,
  9764. configurable: true
  9765. });
  9766. SelectionPanel.prototype._setLabelColor = function () {
  9767. for (var i = 0; i < this._groups.length; i++) {
  9768. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9769. this._groups[i]._setSelectorLabelColor(j, this._labelColor);
  9770. }
  9771. }
  9772. };
  9773. Object.defineProperty(SelectionPanel.prototype, "buttonBackground", {
  9774. /** Gets or sets the button background */
  9775. get: function () {
  9776. return this._buttonBackground;
  9777. },
  9778. set: function (color) {
  9779. if (this._buttonBackground === color) {
  9780. return;
  9781. }
  9782. this._buttonBackground = color;
  9783. this._setButtonBackground();
  9784. },
  9785. enumerable: true,
  9786. configurable: true
  9787. });
  9788. SelectionPanel.prototype._setButtonBackground = function () {
  9789. for (var i = 0; i < this._groups.length; i++) {
  9790. for (var j = 0; j < this._groups[i].selectors.length; j++) {
  9791. this._groups[i]._setSelectorButtonBackground(j, this._buttonBackground);
  9792. }
  9793. }
  9794. };
  9795. Object.defineProperty(SelectionPanel.prototype, "barColor", {
  9796. /** Gets or sets the color of separator bar */
  9797. get: function () {
  9798. return this._barColor;
  9799. },
  9800. set: function (color) {
  9801. if (this._barColor === color) {
  9802. return;
  9803. }
  9804. this._barColor = color;
  9805. this._setBarColor();
  9806. },
  9807. enumerable: true,
  9808. configurable: true
  9809. });
  9810. SelectionPanel.prototype._setBarColor = function () {
  9811. for (var i = 0; i < this._bars.length; i++) {
  9812. this._bars[i].children[0].background = this._barColor;
  9813. }
  9814. };
  9815. Object.defineProperty(SelectionPanel.prototype, "barHeight", {
  9816. /** Gets or sets the height of separator bar */
  9817. get: function () {
  9818. return this._barHeight;
  9819. },
  9820. set: function (value) {
  9821. if (this._barHeight === value) {
  9822. return;
  9823. }
  9824. this._barHeight = value;
  9825. this._setBarHeight();
  9826. },
  9827. enumerable: true,
  9828. configurable: true
  9829. });
  9830. SelectionPanel.prototype._setBarHeight = function () {
  9831. for (var i = 0; i < this._bars.length; i++) {
  9832. this._bars[i].children[0].height = this._barHeight;
  9833. }
  9834. };
  9835. Object.defineProperty(SelectionPanel.prototype, "spacerHeight", {
  9836. /** Gets or sets the height of spacers*/
  9837. get: function () {
  9838. return this._spacerHeight;
  9839. },
  9840. set: function (value) {
  9841. if (this._spacerHeight === value) {
  9842. return;
  9843. }
  9844. this._spacerHeight = value;
  9845. this._setSpacerHeight();
  9846. },
  9847. enumerable: true,
  9848. configurable: true
  9849. });
  9850. SelectionPanel.prototype._setSpacerHeight = function () {
  9851. for (var i = 0; i < this._bars.length; i++) {
  9852. this._bars[i].height = this._spacerHeight;
  9853. }
  9854. };
  9855. /** Adds a bar between groups */
  9856. SelectionPanel.prototype._addSpacer = function () {
  9857. var separator = new _container__WEBPACK_IMPORTED_MODULE_8__["Container"]();
  9858. separator.width = 1;
  9859. separator.height = this._spacerHeight;
  9860. separator.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9861. var bar = new _rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]();
  9862. bar.width = 1;
  9863. bar.height = this._barHeight;
  9864. bar.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  9865. bar.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  9866. bar.background = this._barColor;
  9867. bar.color = "transparent";
  9868. separator.addControl(bar);
  9869. this._panel.addControl(separator);
  9870. this._bars.push(separator);
  9871. };
  9872. /** Add a group to the selection panel
  9873. * @param group is the selector group to add
  9874. */
  9875. SelectionPanel.prototype.addGroup = function (group) {
  9876. if (this._groups.length > 0) {
  9877. this._addSpacer();
  9878. }
  9879. this._panel.addControl(group.groupPanel);
  9880. this._groups.push(group);
  9881. group.groupPanel.children[0].color = this._headerColor;
  9882. for (var j = 0; j < group.selectors.length; j++) {
  9883. group._setSelectorButtonColor(j, this._buttonColor);
  9884. group._setSelectorButtonBackground(j, this._buttonBackground);
  9885. }
  9886. };
  9887. /** Remove the group from the given position
  9888. * @param groupNb is the position of the group in the list
  9889. */
  9890. SelectionPanel.prototype.removeGroup = function (groupNb) {
  9891. if (groupNb < 0 || groupNb >= this._groups.length) {
  9892. return;
  9893. }
  9894. var group = this._groups[groupNb];
  9895. this._panel.removeControl(group.groupPanel);
  9896. this._groups.splice(groupNb, 1);
  9897. if (groupNb < this._bars.length) {
  9898. this._panel.removeControl(this._bars[groupNb]);
  9899. this._bars.splice(groupNb, 1);
  9900. }
  9901. };
  9902. /** Change a group header label
  9903. * @param label is the new group header label
  9904. * @param groupNb is the number of the group to relabel
  9905. * */
  9906. SelectionPanel.prototype.setHeaderName = function (label, groupNb) {
  9907. if (groupNb < 0 || groupNb >= this._groups.length) {
  9908. return;
  9909. }
  9910. var group = this._groups[groupNb];
  9911. group.groupPanel.children[0].text = label;
  9912. };
  9913. /** Change selector label to the one given
  9914. * @param label is the new selector label
  9915. * @param groupNb is the number of the groupcontaining the selector
  9916. * @param selectorNb is the number of the selector within a group to relabel
  9917. * */
  9918. SelectionPanel.prototype.relabel = function (label, groupNb, selectorNb) {
  9919. if (groupNb < 0 || groupNb >= this._groups.length) {
  9920. return;
  9921. }
  9922. var group = this._groups[groupNb];
  9923. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9924. return;
  9925. }
  9926. group._setSelectorLabel(selectorNb, label);
  9927. };
  9928. /** For a given group position remove the selector at the given position
  9929. * @param groupNb is the number of the group to remove the selector from
  9930. * @param selectorNb is the number of the selector within the group
  9931. */
  9932. SelectionPanel.prototype.removeFromGroupSelector = function (groupNb, selectorNb) {
  9933. if (groupNb < 0 || groupNb >= this._groups.length) {
  9934. return;
  9935. }
  9936. var group = this._groups[groupNb];
  9937. if (selectorNb < 0 || selectorNb >= group.selectors.length) {
  9938. return;
  9939. }
  9940. group.removeSelector(selectorNb);
  9941. };
  9942. /** For a given group position of correct type add a checkbox button
  9943. * @param groupNb is the number of the group to remove the selector from
  9944. * @param label is the label for the selector
  9945. * @param func is the function called when the Selector is checked
  9946. * @param checked is true when Selector is checked
  9947. */
  9948. SelectionPanel.prototype.addToGroupCheckbox = function (groupNb, label, func, checked) {
  9949. if (func === void 0) { func = function () { }; }
  9950. if (checked === void 0) { checked = false; }
  9951. if (groupNb < 0 || groupNb >= this._groups.length) {
  9952. return;
  9953. }
  9954. var group = this._groups[groupNb];
  9955. group.addCheckbox(label, func, checked);
  9956. };
  9957. /** For a given group position of correct type add a radio button
  9958. * @param groupNb is the number of the group to remove the selector from
  9959. * @param label is the label for the selector
  9960. * @param func is the function called when the Selector is checked
  9961. * @param checked is true when Selector is checked
  9962. */
  9963. SelectionPanel.prototype.addToGroupRadio = function (groupNb, label, func, checked) {
  9964. if (func === void 0) { func = function () { }; }
  9965. if (checked === void 0) { checked = false; }
  9966. if (groupNb < 0 || groupNb >= this._groups.length) {
  9967. return;
  9968. }
  9969. var group = this._groups[groupNb];
  9970. group.addRadio(label, func, checked);
  9971. };
  9972. /**
  9973. * For a given slider group add a slider
  9974. * @param groupNb is the number of the group to add the slider to
  9975. * @param label is the label for the Slider
  9976. * @param func is the function called when the Slider moves
  9977. * @param unit is a string describing the units used, eg degrees or metres
  9978. * @param min is the minimum value for the Slider
  9979. * @param max is the maximum value for the Slider
  9980. * @param value is the start value for the Slider between min and max
  9981. * @param onVal is the function used to format the value displayed, eg radians to degrees
  9982. */
  9983. SelectionPanel.prototype.addToGroupSlider = function (groupNb, label, func, unit, min, max, value, onVal) {
  9984. if (func === void 0) { func = function () { }; }
  9985. if (unit === void 0) { unit = "Units"; }
  9986. if (min === void 0) { min = 0; }
  9987. if (max === void 0) { max = 0; }
  9988. if (value === void 0) { value = 0; }
  9989. if (onVal === void 0) { onVal = function (v) { return v | 0; }; }
  9990. if (groupNb < 0 || groupNb >= this._groups.length) {
  9991. return;
  9992. }
  9993. var group = this._groups[groupNb];
  9994. group.addSlider(label, func, unit, min, max, value, onVal);
  9995. };
  9996. return SelectionPanel;
  9997. }(_rectangle__WEBPACK_IMPORTED_MODULE_1__["Rectangle"]));
  9998. /***/ }),
  9999. /***/ "./2D/controls/sliders/baseSlider.ts":
  10000. /*!*******************************************!*\
  10001. !*** ./2D/controls/sliders/baseSlider.ts ***!
  10002. \*******************************************/
  10003. /*! exports provided: BaseSlider */
  10004. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10005. "use strict";
  10006. __webpack_require__.r(__webpack_exports__);
  10007. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return BaseSlider; });
  10008. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10009. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  10010. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  10011. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../control */ "./2D/controls/control.ts");
  10012. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../valueAndUnit */ "./2D/valueAndUnit.ts");
  10013. /**
  10014. * Class used to create slider controls
  10015. */
  10016. var BaseSlider = /** @class */ (function (_super) {
  10017. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(BaseSlider, _super);
  10018. /**
  10019. * Creates a new BaseSlider
  10020. * @param name defines the control name
  10021. */
  10022. function BaseSlider(name) {
  10023. var _this = _super.call(this, name) || this;
  10024. _this.name = name;
  10025. _this._thumbWidth = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](20, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10026. _this._minimum = 0;
  10027. _this._maximum = 100;
  10028. _this._value = 50;
  10029. _this._isVertical = false;
  10030. _this._barOffset = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"](5, _valueAndUnit__WEBPACK_IMPORTED_MODULE_3__["ValueAndUnit"].UNITMODE_PIXEL, false);
  10031. _this._isThumbClamped = false;
  10032. _this._displayThumb = true;
  10033. _this._step = 0;
  10034. _this._lastPointerDownID = -1;
  10035. // Shared rendering info
  10036. _this._effectiveBarOffset = 0;
  10037. /** Observable raised when the sldier value changes */
  10038. _this.onValueChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  10039. // Events
  10040. _this._pointerIsDown = false;
  10041. _this.isPointerBlocker = true;
  10042. return _this;
  10043. }
  10044. Object.defineProperty(BaseSlider.prototype, "displayThumb", {
  10045. /** Gets or sets a boolean indicating if the thumb must be rendered */
  10046. get: function () {
  10047. return this._displayThumb;
  10048. },
  10049. set: function (value) {
  10050. if (this._displayThumb === value) {
  10051. return;
  10052. }
  10053. this._displayThumb = value;
  10054. this._markAsDirty();
  10055. },
  10056. enumerable: true,
  10057. configurable: true
  10058. });
  10059. Object.defineProperty(BaseSlider.prototype, "step", {
  10060. /** Gets or sets a step to apply to values (0 by default) */
  10061. get: function () {
  10062. return this._step;
  10063. },
  10064. set: function (value) {
  10065. if (this._step === value) {
  10066. return;
  10067. }
  10068. this._step = value;
  10069. this._markAsDirty();
  10070. },
  10071. enumerable: true,
  10072. configurable: true
  10073. });
  10074. Object.defineProperty(BaseSlider.prototype, "barOffset", {
  10075. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  10076. get: function () {
  10077. return this._barOffset.toString(this._host);
  10078. },
  10079. set: function (value) {
  10080. if (this._barOffset.toString(this._host) === value) {
  10081. return;
  10082. }
  10083. if (this._barOffset.fromString(value)) {
  10084. this._markAsDirty();
  10085. }
  10086. },
  10087. enumerable: true,
  10088. configurable: true
  10089. });
  10090. Object.defineProperty(BaseSlider.prototype, "barOffsetInPixels", {
  10091. /** Gets main bar offset in pixels*/
  10092. get: function () {
  10093. return this._barOffset.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10094. },
  10095. enumerable: true,
  10096. configurable: true
  10097. });
  10098. Object.defineProperty(BaseSlider.prototype, "thumbWidth", {
  10099. /** Gets or sets thumb width */
  10100. get: function () {
  10101. return this._thumbWidth.toString(this._host);
  10102. },
  10103. set: function (value) {
  10104. if (this._thumbWidth.toString(this._host) === value) {
  10105. return;
  10106. }
  10107. if (this._thumbWidth.fromString(value)) {
  10108. this._markAsDirty();
  10109. }
  10110. },
  10111. enumerable: true,
  10112. configurable: true
  10113. });
  10114. Object.defineProperty(BaseSlider.prototype, "thumbWidthInPixels", {
  10115. /** Gets thumb width in pixels */
  10116. get: function () {
  10117. return this._thumbWidth.getValueInPixel(this._host, this._cachedParentMeasure.width);
  10118. },
  10119. enumerable: true,
  10120. configurable: true
  10121. });
  10122. Object.defineProperty(BaseSlider.prototype, "minimum", {
  10123. /** Gets or sets minimum value */
  10124. get: function () {
  10125. return this._minimum;
  10126. },
  10127. set: function (value) {
  10128. if (this._minimum === value) {
  10129. return;
  10130. }
  10131. this._minimum = value;
  10132. this._markAsDirty();
  10133. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10134. },
  10135. enumerable: true,
  10136. configurable: true
  10137. });
  10138. Object.defineProperty(BaseSlider.prototype, "maximum", {
  10139. /** Gets or sets maximum value */
  10140. get: function () {
  10141. return this._maximum;
  10142. },
  10143. set: function (value) {
  10144. if (this._maximum === value) {
  10145. return;
  10146. }
  10147. this._maximum = value;
  10148. this._markAsDirty();
  10149. this.value = Math.max(Math.min(this.value, this._maximum), this._minimum);
  10150. },
  10151. enumerable: true,
  10152. configurable: true
  10153. });
  10154. Object.defineProperty(BaseSlider.prototype, "value", {
  10155. /** Gets or sets current value */
  10156. get: function () {
  10157. return this._value;
  10158. },
  10159. set: function (value) {
  10160. value = Math.max(Math.min(value, this._maximum), this._minimum);
  10161. if (this._value === value) {
  10162. return;
  10163. }
  10164. this._value = value;
  10165. this._markAsDirty();
  10166. this.onValueChangedObservable.notifyObservers(this._value);
  10167. },
  10168. enumerable: true,
  10169. configurable: true
  10170. });
  10171. Object.defineProperty(BaseSlider.prototype, "isVertical", {
  10172. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  10173. get: function () {
  10174. return this._isVertical;
  10175. },
  10176. set: function (value) {
  10177. if (this._isVertical === value) {
  10178. return;
  10179. }
  10180. this._isVertical = value;
  10181. this._markAsDirty();
  10182. },
  10183. enumerable: true,
  10184. configurable: true
  10185. });
  10186. Object.defineProperty(BaseSlider.prototype, "isThumbClamped", {
  10187. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  10188. get: function () {
  10189. return this._isThumbClamped;
  10190. },
  10191. set: function (value) {
  10192. if (this._isThumbClamped === value) {
  10193. return;
  10194. }
  10195. this._isThumbClamped = value;
  10196. this._markAsDirty();
  10197. },
  10198. enumerable: true,
  10199. configurable: true
  10200. });
  10201. BaseSlider.prototype._getTypeName = function () {
  10202. return "BaseSlider";
  10203. };
  10204. BaseSlider.prototype._getThumbPosition = function () {
  10205. if (this.isVertical) {
  10206. return ((this.maximum - this.value) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10207. }
  10208. return ((this.value - this.minimum) / (this.maximum - this.minimum)) * this._backgroundBoxLength;
  10209. };
  10210. BaseSlider.prototype._getThumbThickness = function (type) {
  10211. var thumbThickness = 0;
  10212. switch (type) {
  10213. case "circle":
  10214. if (this._thumbWidth.isPixel) {
  10215. thumbThickness = Math.max(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10216. }
  10217. else {
  10218. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10219. }
  10220. break;
  10221. case "rectangle":
  10222. if (this._thumbWidth.isPixel) {
  10223. thumbThickness = Math.min(this._thumbWidth.getValue(this._host), this._backgroundBoxThickness);
  10224. }
  10225. else {
  10226. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10227. }
  10228. }
  10229. return thumbThickness;
  10230. };
  10231. BaseSlider.prototype._prepareRenderingData = function (type) {
  10232. // Main bar
  10233. this._effectiveBarOffset = 0;
  10234. this._renderLeft = this._currentMeasure.left;
  10235. this._renderTop = this._currentMeasure.top;
  10236. this._renderWidth = this._currentMeasure.width;
  10237. this._renderHeight = this._currentMeasure.height;
  10238. this._backgroundBoxLength = Math.max(this._currentMeasure.width, this._currentMeasure.height);
  10239. this._backgroundBoxThickness = Math.min(this._currentMeasure.width, this._currentMeasure.height);
  10240. this._effectiveThumbThickness = this._getThumbThickness(type);
  10241. if (this.displayThumb) {
  10242. this._backgroundBoxLength -= this._effectiveThumbThickness;
  10243. }
  10244. //throw error when height is less than width for vertical slider
  10245. if ((this.isVertical && this._currentMeasure.height < this._currentMeasure.width)) {
  10246. console.error("Height should be greater than width");
  10247. return;
  10248. }
  10249. if (this._barOffset.isPixel) {
  10250. this._effectiveBarOffset = Math.min(this._barOffset.getValue(this._host), this._backgroundBoxThickness);
  10251. }
  10252. else {
  10253. this._effectiveBarOffset = this._backgroundBoxThickness * this._barOffset.getValue(this._host);
  10254. }
  10255. this._backgroundBoxThickness -= (this._effectiveBarOffset * 2);
  10256. if (this.isVertical) {
  10257. this._renderLeft += this._effectiveBarOffset;
  10258. if (!this.isThumbClamped && this.displayThumb) {
  10259. this._renderTop += (this._effectiveThumbThickness / 2);
  10260. }
  10261. this._renderHeight = this._backgroundBoxLength;
  10262. this._renderWidth = this._backgroundBoxThickness;
  10263. }
  10264. else {
  10265. this._renderTop += this._effectiveBarOffset;
  10266. if (!this.isThumbClamped && this.displayThumb) {
  10267. this._renderLeft += (this._effectiveThumbThickness / 2);
  10268. }
  10269. this._renderHeight = this._backgroundBoxThickness;
  10270. this._renderWidth = this._backgroundBoxLength;
  10271. }
  10272. };
  10273. /** @hidden */
  10274. BaseSlider.prototype._updateValueFromPointer = function (x, y) {
  10275. if (this.rotation != 0) {
  10276. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10277. x = this._transformedPosition.x;
  10278. y = this._transformedPosition.y;
  10279. }
  10280. var value;
  10281. if (this._isVertical) {
  10282. value = this._minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this._maximum - this._minimum);
  10283. }
  10284. else {
  10285. value = this._minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this._maximum - this._minimum);
  10286. }
  10287. var mult = (1 / this._step) | 0;
  10288. this.value = this._step ? ((value * mult) | 0) / mult : value;
  10289. };
  10290. BaseSlider.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10291. if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex)) {
  10292. return false;
  10293. }
  10294. this._pointerIsDown = true;
  10295. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10296. this._host._capturingControl[pointerId] = this;
  10297. this._lastPointerDownID = pointerId;
  10298. return true;
  10299. };
  10300. BaseSlider.prototype._onPointerMove = function (target, coordinates, pointerId) {
  10301. // Only listen to pointer move events coming from the last pointer to click on the element (To support dual vr controller interaction)
  10302. if (pointerId != this._lastPointerDownID) {
  10303. return;
  10304. }
  10305. if (this._pointerIsDown) {
  10306. this._updateValueFromPointer(coordinates.x, coordinates.y);
  10307. }
  10308. _super.prototype._onPointerMove.call(this, target, coordinates, pointerId);
  10309. };
  10310. BaseSlider.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  10311. this._pointerIsDown = false;
  10312. delete this._host._capturingControl[pointerId];
  10313. _super.prototype._onPointerUp.call(this, target, coordinates, pointerId, buttonIndex, notifyClick);
  10314. };
  10315. return BaseSlider;
  10316. }(_control__WEBPACK_IMPORTED_MODULE_2__["Control"]));
  10317. /***/ }),
  10318. /***/ "./2D/controls/sliders/imageBasedSlider.ts":
  10319. /*!*************************************************!*\
  10320. !*** ./2D/controls/sliders/imageBasedSlider.ts ***!
  10321. \*************************************************/
  10322. /*! exports provided: ImageBasedSlider */
  10323. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10324. "use strict";
  10325. __webpack_require__.r(__webpack_exports__);
  10326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return ImageBasedSlider; });
  10327. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10328. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10329. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10330. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  10331. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__);
  10332. /**
  10333. * Class used to create slider controls based on images
  10334. */
  10335. var ImageBasedSlider = /** @class */ (function (_super) {
  10336. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageBasedSlider, _super);
  10337. /**
  10338. * Creates a new ImageBasedSlider
  10339. * @param name defines the control name
  10340. */
  10341. function ImageBasedSlider(name) {
  10342. var _this = _super.call(this, name) || this;
  10343. _this.name = name;
  10344. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10345. return _this;
  10346. }
  10347. Object.defineProperty(ImageBasedSlider.prototype, "displayThumb", {
  10348. get: function () {
  10349. return this._displayThumb && this.thumbImage != null;
  10350. },
  10351. set: function (value) {
  10352. if (this._displayThumb === value) {
  10353. return;
  10354. }
  10355. this._displayThumb = value;
  10356. this._markAsDirty();
  10357. },
  10358. enumerable: true,
  10359. configurable: true
  10360. });
  10361. Object.defineProperty(ImageBasedSlider.prototype, "backgroundImage", {
  10362. /**
  10363. * Gets or sets the image used to render the background
  10364. */
  10365. get: function () {
  10366. return this._backgroundImage;
  10367. },
  10368. set: function (value) {
  10369. var _this = this;
  10370. if (this._backgroundImage === value) {
  10371. return;
  10372. }
  10373. this._backgroundImage = value;
  10374. if (value && !value.isLoaded) {
  10375. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10376. }
  10377. this._markAsDirty();
  10378. },
  10379. enumerable: true,
  10380. configurable: true
  10381. });
  10382. Object.defineProperty(ImageBasedSlider.prototype, "valueBarImage", {
  10383. /**
  10384. * Gets or sets the image used to render the value bar
  10385. */
  10386. get: function () {
  10387. return this._valueBarImage;
  10388. },
  10389. set: function (value) {
  10390. var _this = this;
  10391. if (this._valueBarImage === value) {
  10392. return;
  10393. }
  10394. this._valueBarImage = value;
  10395. if (value && !value.isLoaded) {
  10396. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10397. }
  10398. this._markAsDirty();
  10399. },
  10400. enumerable: true,
  10401. configurable: true
  10402. });
  10403. Object.defineProperty(ImageBasedSlider.prototype, "thumbImage", {
  10404. /**
  10405. * Gets or sets the image used to render the thumb
  10406. */
  10407. get: function () {
  10408. return this._thumbImage;
  10409. },
  10410. set: function (value) {
  10411. var _this = this;
  10412. if (this._thumbImage === value) {
  10413. return;
  10414. }
  10415. this._thumbImage = value;
  10416. if (value && !value.isLoaded) {
  10417. value.onImageLoadedObservable.addOnce(function () { return _this._markAsDirty(); });
  10418. }
  10419. this._markAsDirty();
  10420. },
  10421. enumerable: true,
  10422. configurable: true
  10423. });
  10424. ImageBasedSlider.prototype._getTypeName = function () {
  10425. return "ImageBasedSlider";
  10426. };
  10427. ImageBasedSlider.prototype._draw = function (context, invalidatedRectangle) {
  10428. context.save();
  10429. this._applyStates(context);
  10430. this._prepareRenderingData("rectangle");
  10431. var thumbPosition = this._getThumbPosition();
  10432. var left = this._renderLeft;
  10433. var top = this._renderTop;
  10434. var width = this._renderWidth;
  10435. var height = this._renderHeight;
  10436. // Background
  10437. if (this._backgroundImage) {
  10438. this._tempMeasure.copyFromFloats(left, top, width, height);
  10439. if (this.isThumbClamped && this.displayThumb) {
  10440. if (this.isVertical) {
  10441. this._tempMeasure.height += this._effectiveThumbThickness;
  10442. }
  10443. else {
  10444. this._tempMeasure.width += this._effectiveThumbThickness;
  10445. }
  10446. }
  10447. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10448. this._backgroundImage._draw(context);
  10449. }
  10450. // Bar
  10451. if (this._valueBarImage) {
  10452. if (this.isVertical) {
  10453. if (this.isThumbClamped && this.displayThumb) {
  10454. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  10455. }
  10456. else {
  10457. this._tempMeasure.copyFromFloats(left, top + thumbPosition, width, height - thumbPosition);
  10458. }
  10459. }
  10460. else {
  10461. if (this.isThumbClamped && this.displayThumb) {
  10462. this._tempMeasure.copyFromFloats(left, top, thumbPosition + this._effectiveThumbThickness / 2, height);
  10463. }
  10464. else {
  10465. this._tempMeasure.copyFromFloats(left, top, thumbPosition, height);
  10466. }
  10467. }
  10468. this._valueBarImage._currentMeasure.copyFrom(this._tempMeasure);
  10469. this._valueBarImage._draw(context);
  10470. }
  10471. // Thumb
  10472. if (this.displayThumb) {
  10473. if (this.isVertical) {
  10474. this._tempMeasure.copyFromFloats(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  10475. }
  10476. else {
  10477. this._tempMeasure.copyFromFloats(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  10478. }
  10479. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10480. this._thumbImage._draw(context);
  10481. }
  10482. context.restore();
  10483. };
  10484. return ImageBasedSlider;
  10485. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10486. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.GUI.ImageBasedSlider"] = ImageBasedSlider;
  10487. /***/ }),
  10488. /***/ "./2D/controls/sliders/imageScrollBar.ts":
  10489. /*!***********************************************!*\
  10490. !*** ./2D/controls/sliders/imageScrollBar.ts ***!
  10491. \***********************************************/
  10492. /*! exports provided: ImageScrollBar */
  10493. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10494. "use strict";
  10495. __webpack_require__.r(__webpack_exports__);
  10496. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return ImageScrollBar; });
  10497. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10498. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10499. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10500. /**
  10501. * Class used to create slider controls
  10502. */
  10503. var ImageScrollBar = /** @class */ (function (_super) {
  10504. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageScrollBar, _super);
  10505. /**
  10506. * Creates a new ImageScrollBar
  10507. * @param name defines the control name
  10508. */
  10509. function ImageScrollBar(name) {
  10510. var _this = _super.call(this, name) || this;
  10511. _this.name = name;
  10512. _this._thumbLength = 0.5;
  10513. _this._thumbHeight = 1;
  10514. _this._barImageHeight = 1;
  10515. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10516. return _this;
  10517. }
  10518. Object.defineProperty(ImageScrollBar.prototype, "backgroundImage", {
  10519. /**
  10520. * Gets or sets the image used to render the background for horizontal bar
  10521. */
  10522. get: function () {
  10523. return this._backgroundBaseImage;
  10524. },
  10525. set: function (value) {
  10526. var _this = this;
  10527. if (this._backgroundBaseImage === value) {
  10528. return;
  10529. }
  10530. this._backgroundBaseImage = value;
  10531. if (this.isVertical) {
  10532. if (value && !value.isLoaded) {
  10533. value.onImageLoadedObservable.addOnce(function () {
  10534. var rotatedValue = value._rotate90(1);
  10535. _this._backgroundImage = rotatedValue;
  10536. if (!rotatedValue.isLoaded) {
  10537. rotatedValue.onImageLoadedObservable.addOnce(function () {
  10538. _this._markAsDirty();
  10539. });
  10540. }
  10541. _this._markAsDirty();
  10542. });
  10543. }
  10544. this._backgroundImage = value._rotate90(1);
  10545. this._markAsDirty();
  10546. }
  10547. else {
  10548. this._backgroundImage = value;
  10549. if (value && !value.isLoaded) {
  10550. value.onImageLoadedObservable.addOnce(function () {
  10551. _this._markAsDirty();
  10552. });
  10553. }
  10554. this._markAsDirty();
  10555. }
  10556. },
  10557. enumerable: true,
  10558. configurable: true
  10559. });
  10560. Object.defineProperty(ImageScrollBar.prototype, "thumbImage", {
  10561. /**
  10562. * Gets or sets the image used to render the thumb
  10563. */
  10564. get: function () {
  10565. return this._thumbBaseImage;
  10566. },
  10567. set: function (value) {
  10568. var _this = this;
  10569. if (this._thumbBaseImage === value) {
  10570. return;
  10571. }
  10572. this._thumbBaseImage = value;
  10573. if (this.isVertical) {
  10574. if (value && !value.isLoaded) {
  10575. value.onImageLoadedObservable.addOnce(function () {
  10576. var rotatedValue = value._rotate90(-1);
  10577. _this._thumbImage = rotatedValue;
  10578. if (!rotatedValue.isLoaded) {
  10579. rotatedValue.onImageLoadedObservable.addOnce(function () {
  10580. _this._markAsDirty();
  10581. });
  10582. }
  10583. _this._markAsDirty();
  10584. });
  10585. }
  10586. this._thumbImage = value._rotate90(-1);
  10587. this._markAsDirty();
  10588. }
  10589. else {
  10590. this._thumbImage = value;
  10591. if (value && !value.isLoaded) {
  10592. value.onImageLoadedObservable.addOnce(function () {
  10593. _this._markAsDirty();
  10594. });
  10595. }
  10596. this._markAsDirty();
  10597. }
  10598. },
  10599. enumerable: true,
  10600. configurable: true
  10601. });
  10602. Object.defineProperty(ImageScrollBar.prototype, "thumbLength", {
  10603. /**
  10604. * Gets or sets the length of the thumb
  10605. */
  10606. get: function () {
  10607. return this._thumbLength;
  10608. },
  10609. set: function (value) {
  10610. if (this._thumbLength === value) {
  10611. return;
  10612. }
  10613. this._thumbLength = value;
  10614. this._markAsDirty();
  10615. },
  10616. enumerable: true,
  10617. configurable: true
  10618. });
  10619. Object.defineProperty(ImageScrollBar.prototype, "thumbHeight", {
  10620. /**
  10621. * Gets or sets the height of the thumb
  10622. */
  10623. get: function () {
  10624. return this._thumbHeight;
  10625. },
  10626. set: function (value) {
  10627. if (this._thumbLength === value) {
  10628. return;
  10629. }
  10630. this._thumbHeight = value;
  10631. this._markAsDirty();
  10632. },
  10633. enumerable: true,
  10634. configurable: true
  10635. });
  10636. Object.defineProperty(ImageScrollBar.prototype, "barImageHeight", {
  10637. /**
  10638. * Gets or sets the height of the bar image
  10639. */
  10640. get: function () {
  10641. return this._barImageHeight;
  10642. },
  10643. set: function (value) {
  10644. if (this._barImageHeight === value) {
  10645. return;
  10646. }
  10647. this._barImageHeight = value;
  10648. this._markAsDirty();
  10649. },
  10650. enumerable: true,
  10651. configurable: true
  10652. });
  10653. ImageScrollBar.prototype._getTypeName = function () {
  10654. return "ImageScrollBar";
  10655. };
  10656. ImageScrollBar.prototype._getThumbThickness = function () {
  10657. var thumbThickness = 0;
  10658. if (this._thumbWidth.isPixel) {
  10659. thumbThickness = this._thumbWidth.getValue(this._host);
  10660. }
  10661. else {
  10662. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10663. }
  10664. return thumbThickness;
  10665. };
  10666. ImageScrollBar.prototype._draw = function (context) {
  10667. context.save();
  10668. this._applyStates(context);
  10669. this._prepareRenderingData("rectangle");
  10670. var thumbPosition = this._getThumbPosition();
  10671. var left = this._renderLeft;
  10672. var top = this._renderTop;
  10673. var width = this._renderWidth;
  10674. var height = this._renderHeight;
  10675. // Background
  10676. if (this._backgroundImage) {
  10677. this._tempMeasure.copyFromFloats(left, top, width, height);
  10678. if (this.isVertical) {
  10679. this._tempMeasure.copyFromFloats(left + width * (1 - this._barImageHeight) * 0.5, this._currentMeasure.top, width * this._barImageHeight, height);
  10680. this._tempMeasure.height += this._effectiveThumbThickness;
  10681. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10682. }
  10683. else {
  10684. this._tempMeasure.copyFromFloats(this._currentMeasure.left, top + height * (1 - this._barImageHeight) * 0.5, width, height * this._barImageHeight);
  10685. this._tempMeasure.width += this._effectiveThumbThickness;
  10686. this._backgroundImage._currentMeasure.copyFrom(this._tempMeasure);
  10687. }
  10688. this._backgroundImage._draw(context);
  10689. }
  10690. // Thumb
  10691. if (this.isVertical) {
  10692. 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);
  10693. }
  10694. else {
  10695. 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);
  10696. }
  10697. this._thumbImage._currentMeasure.copyFrom(this._tempMeasure);
  10698. this._thumbImage._draw(context);
  10699. context.restore();
  10700. };
  10701. /** @hidden */
  10702. ImageScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10703. if (this.rotation != 0) {
  10704. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10705. x = this._transformedPosition.x;
  10706. y = this._transformedPosition.y;
  10707. }
  10708. if (this._first) {
  10709. this._first = false;
  10710. this._originX = x;
  10711. this._originY = y;
  10712. // Check if move is required
  10713. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  10714. if (this.isVertical) {
  10715. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10716. }
  10717. else {
  10718. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10719. }
  10720. }
  10721. }
  10722. // Delta mode
  10723. var delta = 0;
  10724. if (this.isVertical) {
  10725. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10726. }
  10727. else {
  10728. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10729. }
  10730. this.value += delta * (this.maximum - this.minimum);
  10731. this._originX = x;
  10732. this._originY = y;
  10733. };
  10734. ImageScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10735. this._first = true;
  10736. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10737. };
  10738. return ImageScrollBar;
  10739. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10740. /***/ }),
  10741. /***/ "./2D/controls/sliders/scrollBar.ts":
  10742. /*!******************************************!*\
  10743. !*** ./2D/controls/sliders/scrollBar.ts ***!
  10744. \******************************************/
  10745. /*! exports provided: ScrollBar */
  10746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10747. "use strict";
  10748. __webpack_require__.r(__webpack_exports__);
  10749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return ScrollBar; });
  10750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10751. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10752. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../measure */ "./2D/measure.ts");
  10753. /**
  10754. * Class used to create slider controls
  10755. */
  10756. var ScrollBar = /** @class */ (function (_super) {
  10757. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScrollBar, _super);
  10758. /**
  10759. * Creates a new Slider
  10760. * @param name defines the control name
  10761. */
  10762. function ScrollBar(name) {
  10763. var _this = _super.call(this, name) || this;
  10764. _this.name = name;
  10765. _this._background = "black";
  10766. _this._borderColor = "white";
  10767. _this._tempMeasure = new _measure__WEBPACK_IMPORTED_MODULE_2__["Measure"](0, 0, 0, 0);
  10768. return _this;
  10769. }
  10770. Object.defineProperty(ScrollBar.prototype, "borderColor", {
  10771. /** Gets or sets border color */
  10772. get: function () {
  10773. return this._borderColor;
  10774. },
  10775. set: function (value) {
  10776. if (this._borderColor === value) {
  10777. return;
  10778. }
  10779. this._borderColor = value;
  10780. this._markAsDirty();
  10781. },
  10782. enumerable: true,
  10783. configurable: true
  10784. });
  10785. Object.defineProperty(ScrollBar.prototype, "background", {
  10786. /** Gets or sets background color */
  10787. get: function () {
  10788. return this._background;
  10789. },
  10790. set: function (value) {
  10791. if (this._background === value) {
  10792. return;
  10793. }
  10794. this._background = value;
  10795. this._markAsDirty();
  10796. },
  10797. enumerable: true,
  10798. configurable: true
  10799. });
  10800. ScrollBar.prototype._getTypeName = function () {
  10801. return "Scrollbar";
  10802. };
  10803. ScrollBar.prototype._getThumbThickness = function () {
  10804. var thumbThickness = 0;
  10805. if (this._thumbWidth.isPixel) {
  10806. thumbThickness = this._thumbWidth.getValue(this._host);
  10807. }
  10808. else {
  10809. thumbThickness = this._backgroundBoxThickness * this._thumbWidth.getValue(this._host);
  10810. }
  10811. return thumbThickness;
  10812. };
  10813. ScrollBar.prototype._draw = function (context) {
  10814. context.save();
  10815. this._applyStates(context);
  10816. this._prepareRenderingData("rectangle");
  10817. var left = this._renderLeft;
  10818. var thumbPosition = this._getThumbPosition();
  10819. context.fillStyle = this._background;
  10820. context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
  10821. // Value bar
  10822. context.fillStyle = this.color;
  10823. // Thumb
  10824. if (this.isVertical) {
  10825. this._tempMeasure.left = left - this._effectiveBarOffset;
  10826. this._tempMeasure.top = this._currentMeasure.top + thumbPosition;
  10827. this._tempMeasure.width = this._currentMeasure.width;
  10828. this._tempMeasure.height = this._effectiveThumbThickness;
  10829. }
  10830. else {
  10831. this._tempMeasure.left = this._currentMeasure.left + thumbPosition;
  10832. this._tempMeasure.top = this._currentMeasure.top;
  10833. this._tempMeasure.width = this._effectiveThumbThickness;
  10834. this._tempMeasure.height = this._currentMeasure.height;
  10835. }
  10836. context.fillRect(this._tempMeasure.left, this._tempMeasure.top, this._tempMeasure.width, this._tempMeasure.height);
  10837. context.restore();
  10838. };
  10839. /** @hidden */
  10840. ScrollBar.prototype._updateValueFromPointer = function (x, y) {
  10841. if (this.rotation != 0) {
  10842. this._invertTransformMatrix.transformCoordinates(x, y, this._transformedPosition);
  10843. x = this._transformedPosition.x;
  10844. y = this._transformedPosition.y;
  10845. }
  10846. if (this._first) {
  10847. this._first = false;
  10848. this._originX = x;
  10849. this._originY = y;
  10850. // Check if move is required
  10851. if (x < this._tempMeasure.left || x > this._tempMeasure.left + this._tempMeasure.width || y < this._tempMeasure.top || y > this._tempMeasure.top + this._tempMeasure.height) {
  10852. if (this.isVertical) {
  10853. this.value = this.minimum + (1 - ((y - this._currentMeasure.top) / this._currentMeasure.height)) * (this.maximum - this.minimum);
  10854. }
  10855. else {
  10856. this.value = this.minimum + ((x - this._currentMeasure.left) / this._currentMeasure.width) * (this.maximum - this.minimum);
  10857. }
  10858. }
  10859. }
  10860. // Delta mode
  10861. var delta = 0;
  10862. if (this.isVertical) {
  10863. delta = -((y - this._originY) / (this._currentMeasure.height - this._effectiveThumbThickness));
  10864. }
  10865. else {
  10866. delta = (x - this._originX) / (this._currentMeasure.width - this._effectiveThumbThickness);
  10867. }
  10868. this.value += delta * (this.maximum - this.minimum);
  10869. this._originX = x;
  10870. this._originY = y;
  10871. };
  10872. ScrollBar.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  10873. this._first = true;
  10874. return _super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex);
  10875. };
  10876. return ScrollBar;
  10877. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  10878. /***/ }),
  10879. /***/ "./2D/controls/sliders/slider.ts":
  10880. /*!***************************************!*\
  10881. !*** ./2D/controls/sliders/slider.ts ***!
  10882. \***************************************/
  10883. /*! exports provided: Slider */
  10884. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10885. "use strict";
  10886. __webpack_require__.r(__webpack_exports__);
  10887. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; });
  10888. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  10889. /* harmony import */ var _baseSlider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./baseSlider */ "./2D/controls/sliders/baseSlider.ts");
  10890. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  10891. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__);
  10892. /**
  10893. * Class used to create slider controls
  10894. */
  10895. var Slider = /** @class */ (function (_super) {
  10896. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super);
  10897. /**
  10898. * Creates a new Slider
  10899. * @param name defines the control name
  10900. */
  10901. function Slider(name) {
  10902. var _this = _super.call(this, name) || this;
  10903. _this.name = name;
  10904. _this._background = "black";
  10905. _this._borderColor = "white";
  10906. _this._isThumbCircle = false;
  10907. _this._displayValueBar = true;
  10908. return _this;
  10909. }
  10910. Object.defineProperty(Slider.prototype, "displayValueBar", {
  10911. /** Gets or sets a boolean indicating if the value bar must be rendered */
  10912. get: function () {
  10913. return this._displayValueBar;
  10914. },
  10915. set: function (value) {
  10916. if (this._displayValueBar === value) {
  10917. return;
  10918. }
  10919. this._displayValueBar = value;
  10920. this._markAsDirty();
  10921. },
  10922. enumerable: true,
  10923. configurable: true
  10924. });
  10925. Object.defineProperty(Slider.prototype, "borderColor", {
  10926. /** Gets or sets border color */
  10927. get: function () {
  10928. return this._borderColor;
  10929. },
  10930. set: function (value) {
  10931. if (this._borderColor === value) {
  10932. return;
  10933. }
  10934. this._borderColor = value;
  10935. this._markAsDirty();
  10936. },
  10937. enumerable: true,
  10938. configurable: true
  10939. });
  10940. Object.defineProperty(Slider.prototype, "background", {
  10941. /** Gets or sets background color */
  10942. get: function () {
  10943. return this._background;
  10944. },
  10945. set: function (value) {
  10946. if (this._background === value) {
  10947. return;
  10948. }
  10949. this._background = value;
  10950. this._markAsDirty();
  10951. },
  10952. enumerable: true,
  10953. configurable: true
  10954. });
  10955. Object.defineProperty(Slider.prototype, "isThumbCircle", {
  10956. /** Gets or sets a boolean indicating if the thumb should be round or square */
  10957. get: function () {
  10958. return this._isThumbCircle;
  10959. },
  10960. set: function (value) {
  10961. if (this._isThumbCircle === value) {
  10962. return;
  10963. }
  10964. this._isThumbCircle = value;
  10965. this._markAsDirty();
  10966. },
  10967. enumerable: true,
  10968. configurable: true
  10969. });
  10970. Slider.prototype._getTypeName = function () {
  10971. return "Slider";
  10972. };
  10973. Slider.prototype._draw = function (context, invalidatedRectangle) {
  10974. context.save();
  10975. this._applyStates(context);
  10976. this._prepareRenderingData(this.isThumbCircle ? "circle" : "rectangle");
  10977. var left = this._renderLeft;
  10978. var top = this._renderTop;
  10979. var width = this._renderWidth;
  10980. var height = this._renderHeight;
  10981. var radius = 0;
  10982. if (this.isThumbClamped && this.isThumbCircle) {
  10983. if (this.isVertical) {
  10984. top += (this._effectiveThumbThickness / 2);
  10985. }
  10986. else {
  10987. left += (this._effectiveThumbThickness / 2);
  10988. }
  10989. radius = this._backgroundBoxThickness / 2;
  10990. }
  10991. else {
  10992. radius = (this._effectiveThumbThickness - this._effectiveBarOffset) / 2;
  10993. }
  10994. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  10995. context.shadowColor = this.shadowColor;
  10996. context.shadowBlur = this.shadowBlur;
  10997. context.shadowOffsetX = this.shadowOffsetX;
  10998. context.shadowOffsetY = this.shadowOffsetY;
  10999. }
  11000. var thumbPosition = this._getThumbPosition();
  11001. context.fillStyle = this._background;
  11002. if (this.isVertical) {
  11003. if (this.isThumbClamped) {
  11004. if (this.isThumbCircle) {
  11005. context.beginPath();
  11006. context.arc(left + this._backgroundBoxThickness / 2, top, radius, Math.PI, 2 * Math.PI);
  11007. context.fill();
  11008. context.fillRect(left, top, width, height);
  11009. }
  11010. else {
  11011. context.fillRect(left, top, width, height + this._effectiveThumbThickness);
  11012. }
  11013. }
  11014. else {
  11015. context.fillRect(left, top, width, height);
  11016. }
  11017. }
  11018. else {
  11019. if (this.isThumbClamped) {
  11020. if (this.isThumbCircle) {
  11021. context.beginPath();
  11022. context.arc(left + this._backgroundBoxLength, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11023. context.fill();
  11024. context.fillRect(left, top, width, height);
  11025. }
  11026. else {
  11027. context.fillRect(left, top, width + this._effectiveThumbThickness, height);
  11028. }
  11029. }
  11030. else {
  11031. context.fillRect(left, top, width, height);
  11032. }
  11033. }
  11034. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11035. context.shadowBlur = 0;
  11036. context.shadowOffsetX = 0;
  11037. context.shadowOffsetY = 0;
  11038. }
  11039. // Value bar
  11040. context.fillStyle = this.color;
  11041. if (this._displayValueBar) {
  11042. if (this.isVertical) {
  11043. if (this.isThumbClamped) {
  11044. if (this.isThumbCircle) {
  11045. context.beginPath();
  11046. context.arc(left + this._backgroundBoxThickness / 2, top + this._backgroundBoxLength, radius, 0, 2 * Math.PI);
  11047. context.fill();
  11048. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11049. }
  11050. else {
  11051. context.fillRect(left, top + thumbPosition, width, height - thumbPosition + this._effectiveThumbThickness);
  11052. }
  11053. }
  11054. else {
  11055. context.fillRect(left, top + thumbPosition, width, height - thumbPosition);
  11056. }
  11057. }
  11058. else {
  11059. if (this.isThumbClamped) {
  11060. if (this.isThumbCircle) {
  11061. context.beginPath();
  11062. context.arc(left, top + this._backgroundBoxThickness / 2, radius, 0, 2 * Math.PI);
  11063. context.fill();
  11064. context.fillRect(left, top, thumbPosition, height);
  11065. }
  11066. else {
  11067. context.fillRect(left, top, thumbPosition, height);
  11068. }
  11069. }
  11070. else {
  11071. context.fillRect(left, top, thumbPosition, height);
  11072. }
  11073. }
  11074. }
  11075. // Thumb
  11076. if (this.displayThumb) {
  11077. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11078. context.shadowColor = this.shadowColor;
  11079. context.shadowBlur = this.shadowBlur;
  11080. context.shadowOffsetX = this.shadowOffsetX;
  11081. context.shadowOffsetY = this.shadowOffsetY;
  11082. }
  11083. if (this._isThumbCircle) {
  11084. context.beginPath();
  11085. if (this.isVertical) {
  11086. context.arc(left + this._backgroundBoxThickness / 2, top + thumbPosition, radius, 0, 2 * Math.PI);
  11087. }
  11088. else {
  11089. context.arc(left + thumbPosition, top + (this._backgroundBoxThickness / 2), radius, 0, 2 * Math.PI);
  11090. }
  11091. context.fill();
  11092. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11093. context.shadowBlur = 0;
  11094. context.shadowOffsetX = 0;
  11095. context.shadowOffsetY = 0;
  11096. }
  11097. context.strokeStyle = this._borderColor;
  11098. context.stroke();
  11099. }
  11100. else {
  11101. if (this.isVertical) {
  11102. context.fillRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11103. }
  11104. else {
  11105. context.fillRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11106. }
  11107. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11108. context.shadowBlur = 0;
  11109. context.shadowOffsetX = 0;
  11110. context.shadowOffsetY = 0;
  11111. }
  11112. context.strokeStyle = this._borderColor;
  11113. if (this.isVertical) {
  11114. context.strokeRect(left - this._effectiveBarOffset, this._currentMeasure.top + thumbPosition, this._currentMeasure.width, this._effectiveThumbThickness);
  11115. }
  11116. else {
  11117. context.strokeRect(this._currentMeasure.left + thumbPosition, this._currentMeasure.top, this._effectiveThumbThickness, this._currentMeasure.height);
  11118. }
  11119. }
  11120. }
  11121. context.restore();
  11122. };
  11123. return Slider;
  11124. }(_baseSlider__WEBPACK_IMPORTED_MODULE_1__["BaseSlider"]));
  11125. babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.GUI.Slider"] = Slider;
  11126. /***/ }),
  11127. /***/ "./2D/controls/stackPanel.ts":
  11128. /*!***********************************!*\
  11129. !*** ./2D/controls/stackPanel.ts ***!
  11130. \***********************************/
  11131. /*! exports provided: StackPanel */
  11132. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11133. "use strict";
  11134. __webpack_require__.r(__webpack_exports__);
  11135. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return StackPanel; });
  11136. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11137. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  11138. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  11139. /* harmony import */ var _container__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container */ "./2D/controls/container.ts");
  11140. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11141. /**
  11142. * Class used to create a 2D stack panel container
  11143. */
  11144. var StackPanel = /** @class */ (function (_super) {
  11145. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel, _super);
  11146. /**
  11147. * Creates a new StackPanel
  11148. * @param name defines control name
  11149. */
  11150. function StackPanel(name) {
  11151. var _this = _super.call(this, name) || this;
  11152. _this.name = name;
  11153. _this._isVertical = true;
  11154. _this._manualWidth = false;
  11155. _this._manualHeight = false;
  11156. _this._doNotTrackManualChanges = false;
  11157. /**
  11158. * Gets or sets a boolean indicating that layou warnings should be ignored
  11159. */
  11160. _this.ignoreLayoutWarnings = false;
  11161. return _this;
  11162. }
  11163. Object.defineProperty(StackPanel.prototype, "isVertical", {
  11164. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  11165. get: function () {
  11166. return this._isVertical;
  11167. },
  11168. set: function (value) {
  11169. if (this._isVertical === value) {
  11170. return;
  11171. }
  11172. this._isVertical = value;
  11173. this._markAsDirty();
  11174. },
  11175. enumerable: true,
  11176. configurable: true
  11177. });
  11178. Object.defineProperty(StackPanel.prototype, "width", {
  11179. get: function () {
  11180. return this._width.toString(this._host);
  11181. },
  11182. /**
  11183. * Gets or sets panel width.
  11184. * This value should not be set when in horizontal mode as it will be computed automatically
  11185. */
  11186. set: function (value) {
  11187. if (!this._doNotTrackManualChanges) {
  11188. this._manualWidth = true;
  11189. }
  11190. if (this._width.toString(this._host) === value) {
  11191. return;
  11192. }
  11193. if (this._width.fromString(value)) {
  11194. this._markAsDirty();
  11195. }
  11196. },
  11197. enumerable: true,
  11198. configurable: true
  11199. });
  11200. Object.defineProperty(StackPanel.prototype, "height", {
  11201. get: function () {
  11202. return this._height.toString(this._host);
  11203. },
  11204. /**
  11205. * Gets or sets panel height.
  11206. * This value should not be set when in vertical mode as it will be computed automatically
  11207. */
  11208. set: function (value) {
  11209. if (!this._doNotTrackManualChanges) {
  11210. this._manualHeight = true;
  11211. }
  11212. if (this._height.toString(this._host) === value) {
  11213. return;
  11214. }
  11215. if (this._height.fromString(value)) {
  11216. this._markAsDirty();
  11217. }
  11218. },
  11219. enumerable: true,
  11220. configurable: true
  11221. });
  11222. StackPanel.prototype._getTypeName = function () {
  11223. return "StackPanel";
  11224. };
  11225. /** @hidden */
  11226. StackPanel.prototype._preMeasure = function (parentMeasure, context) {
  11227. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11228. var child = _a[_i];
  11229. if (this._isVertical) {
  11230. child.verticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP;
  11231. }
  11232. else {
  11233. child.horizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11234. }
  11235. }
  11236. _super.prototype._preMeasure.call(this, parentMeasure, context);
  11237. };
  11238. StackPanel.prototype._additionalProcessing = function (parentMeasure, context) {
  11239. _super.prototype._additionalProcessing.call(this, parentMeasure, context);
  11240. this._measureForChildren.copyFrom(parentMeasure);
  11241. this._measureForChildren.left = this._currentMeasure.left;
  11242. this._measureForChildren.top = this._currentMeasure.top;
  11243. if (!this.isVertical || this._manualWidth) {
  11244. this._measureForChildren.width = this._currentMeasure.width;
  11245. }
  11246. if (this.isVertical || this._manualHeight) {
  11247. this._measureForChildren.height = this._currentMeasure.height;
  11248. }
  11249. };
  11250. StackPanel.prototype._postMeasure = function () {
  11251. var stackWidth = 0;
  11252. var stackHeight = 0;
  11253. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  11254. var child = _a[_i];
  11255. if (!child.isVisible || child.notRenderable) {
  11256. continue;
  11257. }
  11258. if (this._isVertical) {
  11259. if (child.top !== stackHeight + "px") {
  11260. child.top = stackHeight + "px";
  11261. this._rebuildLayout = true;
  11262. child._top.ignoreAdaptiveScaling = true;
  11263. }
  11264. if (child._height.isPercentage && !child._automaticSize) {
  11265. if (!this.ignoreLayoutWarnings) {
  11266. 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");
  11267. }
  11268. }
  11269. else {
  11270. stackHeight += child._currentMeasure.height + child.paddingTopInPixels + child.paddingBottomInPixels;
  11271. }
  11272. }
  11273. else {
  11274. if (child.left !== stackWidth + "px") {
  11275. child.left = stackWidth + "px";
  11276. this._rebuildLayout = true;
  11277. child._left.ignoreAdaptiveScaling = true;
  11278. }
  11279. if (child._width.isPercentage && !child._automaticSize) {
  11280. if (!this.ignoreLayoutWarnings) {
  11281. 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");
  11282. }
  11283. }
  11284. else {
  11285. stackWidth += child._currentMeasure.width + child.paddingLeftInPixels + child.paddingRightInPixels;
  11286. }
  11287. }
  11288. }
  11289. this._doNotTrackManualChanges = true;
  11290. // Let stack panel width or height default to stackHeight and stackWidth if dimensions are not specified.
  11291. // User can now define their own height and width for stack panel.
  11292. var panelWidthChanged = false;
  11293. var panelHeightChanged = false;
  11294. if (!this._manualHeight && this._isVertical) { // do not specify height if strictly defined by user
  11295. var previousHeight = this.height;
  11296. this.height = stackHeight + "px";
  11297. panelHeightChanged = previousHeight !== this.height || !this._height.ignoreAdaptiveScaling;
  11298. }
  11299. if (!this._manualWidth && !this._isVertical) { // do not specify width if strictly defined by user
  11300. var previousWidth = this.width;
  11301. this.width = stackWidth + "px";
  11302. panelWidthChanged = previousWidth !== this.width || !this._width.ignoreAdaptiveScaling;
  11303. }
  11304. if (panelHeightChanged) {
  11305. this._height.ignoreAdaptiveScaling = true;
  11306. }
  11307. if (panelWidthChanged) {
  11308. this._width.ignoreAdaptiveScaling = true;
  11309. }
  11310. this._doNotTrackManualChanges = false;
  11311. if (panelWidthChanged || panelHeightChanged) {
  11312. this._rebuildLayout = true;
  11313. }
  11314. _super.prototype._postMeasure.call(this);
  11315. };
  11316. return StackPanel;
  11317. }(_container__WEBPACK_IMPORTED_MODULE_2__["Container"]));
  11318. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.StackPanel"] = StackPanel;
  11319. /***/ }),
  11320. /***/ "./2D/controls/statics.ts":
  11321. /*!********************************!*\
  11322. !*** ./2D/controls/statics.ts ***!
  11323. \********************************/
  11324. /*! exports provided: name */
  11325. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11326. "use strict";
  11327. __webpack_require__.r(__webpack_exports__);
  11328. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "name", function() { return name; });
  11329. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11330. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11331. /* harmony import */ var _textBlock__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./textBlock */ "./2D/controls/textBlock.ts");
  11332. /**
  11333. * Forcing an export so that this code will execute
  11334. * @hidden
  11335. */
  11336. var name = "Statics";
  11337. /**
  11338. * Creates a stack panel that can be used to render headers
  11339. * @param control defines the control to associate with the header
  11340. * @param text defines the text of the header
  11341. * @param size defines the size of the header
  11342. * @param options defines options used to configure the header
  11343. * @returns a new StackPanel
  11344. */
  11345. _control__WEBPACK_IMPORTED_MODULE_0__["Control"].AddHeader = function (control, text, size, options) {
  11346. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_1__["StackPanel"]("panel");
  11347. var isHorizontal = options ? options.isHorizontal : true;
  11348. var controlFirst = options ? options.controlFirst : true;
  11349. panel.isVertical = !isHorizontal;
  11350. var header = new _textBlock__WEBPACK_IMPORTED_MODULE_2__["TextBlock"]("header");
  11351. header.text = text;
  11352. header.textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_0__["Control"].HORIZONTAL_ALIGNMENT_LEFT;
  11353. if (isHorizontal) {
  11354. header.width = size;
  11355. }
  11356. else {
  11357. header.height = size;
  11358. }
  11359. if (controlFirst) {
  11360. panel.addControl(control);
  11361. panel.addControl(header);
  11362. header.paddingLeft = "5px";
  11363. }
  11364. else {
  11365. panel.addControl(header);
  11366. panel.addControl(control);
  11367. header.paddingRight = "5px";
  11368. }
  11369. header.shadowBlur = control.shadowBlur;
  11370. header.shadowColor = control.shadowColor;
  11371. header.shadowOffsetX = control.shadowOffsetX;
  11372. header.shadowOffsetY = control.shadowOffsetY;
  11373. return panel;
  11374. };
  11375. /***/ }),
  11376. /***/ "./2D/controls/textBlock.ts":
  11377. /*!**********************************!*\
  11378. !*** ./2D/controls/textBlock.ts ***!
  11379. \**********************************/
  11380. /*! exports provided: TextWrapping, TextBlock */
  11381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11382. "use strict";
  11383. __webpack_require__.r(__webpack_exports__);
  11384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return TextWrapping; });
  11385. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return TextBlock; });
  11386. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11387. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  11388. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11389. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../valueAndUnit */ "./2D/valueAndUnit.ts");
  11390. /* harmony import */ var _control__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control */ "./2D/controls/control.ts");
  11391. /**
  11392. * Enum that determines the text-wrapping mode to use.
  11393. */
  11394. var TextWrapping;
  11395. (function (TextWrapping) {
  11396. /**
  11397. * Clip the text when it's larger than Control.width; this is the default mode.
  11398. */
  11399. TextWrapping[TextWrapping["Clip"] = 0] = "Clip";
  11400. /**
  11401. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  11402. */
  11403. TextWrapping[TextWrapping["WordWrap"] = 1] = "WordWrap";
  11404. /**
  11405. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  11406. */
  11407. TextWrapping[TextWrapping["Ellipsis"] = 2] = "Ellipsis";
  11408. })(TextWrapping || (TextWrapping = {}));
  11409. /**
  11410. * Class used to create text block control
  11411. */
  11412. var TextBlock = /** @class */ (function (_super) {
  11413. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextBlock, _super);
  11414. /**
  11415. * Creates a new TextBlock object
  11416. * @param name defines the name of the control
  11417. * @param text defines the text to display (emptry string by default)
  11418. */
  11419. function TextBlock(
  11420. /**
  11421. * Defines the name of the control
  11422. */
  11423. name, text) {
  11424. if (text === void 0) { text = ""; }
  11425. var _this = _super.call(this, name) || this;
  11426. _this.name = name;
  11427. _this._text = "";
  11428. _this._textWrapping = TextWrapping.Clip;
  11429. _this._textHorizontalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER;
  11430. _this._textVerticalAlignment = _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER;
  11431. _this._resizeToFit = false;
  11432. _this._lineSpacing = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"](0);
  11433. _this._outlineWidth = 0;
  11434. _this._outlineColor = "white";
  11435. /**
  11436. * An event triggered after the text is changed
  11437. */
  11438. _this.onTextChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11439. /**
  11440. * An event triggered after the text was broken up into lines
  11441. */
  11442. _this.onLinesReadyObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11443. _this.text = text;
  11444. return _this;
  11445. }
  11446. Object.defineProperty(TextBlock.prototype, "lines", {
  11447. /**
  11448. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  11449. */
  11450. get: function () {
  11451. return this._lines;
  11452. },
  11453. enumerable: true,
  11454. configurable: true
  11455. });
  11456. Object.defineProperty(TextBlock.prototype, "resizeToFit", {
  11457. /**
  11458. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11459. */
  11460. get: function () {
  11461. return this._resizeToFit;
  11462. },
  11463. /**
  11464. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  11465. */
  11466. set: function (value) {
  11467. if (this._resizeToFit === value) {
  11468. return;
  11469. }
  11470. this._resizeToFit = value;
  11471. if (this._resizeToFit) {
  11472. this._width.ignoreAdaptiveScaling = true;
  11473. this._height.ignoreAdaptiveScaling = true;
  11474. }
  11475. this._markAsDirty();
  11476. },
  11477. enumerable: true,
  11478. configurable: true
  11479. });
  11480. Object.defineProperty(TextBlock.prototype, "textWrapping", {
  11481. /**
  11482. * Gets or sets a boolean indicating if text must be wrapped
  11483. */
  11484. get: function () {
  11485. return this._textWrapping;
  11486. },
  11487. /**
  11488. * Gets or sets a boolean indicating if text must be wrapped
  11489. */
  11490. set: function (value) {
  11491. if (this._textWrapping === value) {
  11492. return;
  11493. }
  11494. this._textWrapping = +value;
  11495. this._markAsDirty();
  11496. },
  11497. enumerable: true,
  11498. configurable: true
  11499. });
  11500. Object.defineProperty(TextBlock.prototype, "text", {
  11501. /**
  11502. * Gets or sets text to display
  11503. */
  11504. get: function () {
  11505. return this._text;
  11506. },
  11507. /**
  11508. * Gets or sets text to display
  11509. */
  11510. set: function (value) {
  11511. if (this._text === value) {
  11512. return;
  11513. }
  11514. this._text = value;
  11515. this._markAsDirty();
  11516. this.onTextChangedObservable.notifyObservers(this);
  11517. },
  11518. enumerable: true,
  11519. configurable: true
  11520. });
  11521. Object.defineProperty(TextBlock.prototype, "textHorizontalAlignment", {
  11522. /**
  11523. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11524. */
  11525. get: function () {
  11526. return this._textHorizontalAlignment;
  11527. },
  11528. /**
  11529. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  11530. */
  11531. set: function (value) {
  11532. if (this._textHorizontalAlignment === value) {
  11533. return;
  11534. }
  11535. this._textHorizontalAlignment = value;
  11536. this._markAsDirty();
  11537. },
  11538. enumerable: true,
  11539. configurable: true
  11540. });
  11541. Object.defineProperty(TextBlock.prototype, "textVerticalAlignment", {
  11542. /**
  11543. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11544. */
  11545. get: function () {
  11546. return this._textVerticalAlignment;
  11547. },
  11548. /**
  11549. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  11550. */
  11551. set: function (value) {
  11552. if (this._textVerticalAlignment === value) {
  11553. return;
  11554. }
  11555. this._textVerticalAlignment = value;
  11556. this._markAsDirty();
  11557. },
  11558. enumerable: true,
  11559. configurable: true
  11560. });
  11561. Object.defineProperty(TextBlock.prototype, "lineSpacing", {
  11562. /**
  11563. * Gets or sets line spacing value
  11564. */
  11565. get: function () {
  11566. return this._lineSpacing.toString(this._host);
  11567. },
  11568. /**
  11569. * Gets or sets line spacing value
  11570. */
  11571. set: function (value) {
  11572. if (this._lineSpacing.fromString(value)) {
  11573. this._markAsDirty();
  11574. }
  11575. },
  11576. enumerable: true,
  11577. configurable: true
  11578. });
  11579. Object.defineProperty(TextBlock.prototype, "outlineWidth", {
  11580. /**
  11581. * Gets or sets outlineWidth of the text to display
  11582. */
  11583. get: function () {
  11584. return this._outlineWidth;
  11585. },
  11586. /**
  11587. * Gets or sets outlineWidth of the text to display
  11588. */
  11589. set: function (value) {
  11590. if (this._outlineWidth === value) {
  11591. return;
  11592. }
  11593. this._outlineWidth = value;
  11594. this._markAsDirty();
  11595. },
  11596. enumerable: true,
  11597. configurable: true
  11598. });
  11599. Object.defineProperty(TextBlock.prototype, "outlineColor", {
  11600. /**
  11601. * Gets or sets outlineColor of the text to display
  11602. */
  11603. get: function () {
  11604. return this._outlineColor;
  11605. },
  11606. /**
  11607. * Gets or sets outlineColor of the text to display
  11608. */
  11609. set: function (value) {
  11610. if (this._outlineColor === value) {
  11611. return;
  11612. }
  11613. this._outlineColor = value;
  11614. this._markAsDirty();
  11615. },
  11616. enumerable: true,
  11617. configurable: true
  11618. });
  11619. TextBlock.prototype._getTypeName = function () {
  11620. return "TextBlock";
  11621. };
  11622. TextBlock.prototype._processMeasures = function (parentMeasure, context) {
  11623. if (!this._fontOffset) {
  11624. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context.font);
  11625. }
  11626. _super.prototype._processMeasures.call(this, parentMeasure, context);
  11627. // Prepare lines
  11628. this._lines = this._breakLines(this._currentMeasure.width, context);
  11629. this.onLinesReadyObservable.notifyObservers(this);
  11630. var maxLineWidth = 0;
  11631. for (var i = 0; i < this._lines.length; i++) {
  11632. var line = this._lines[i];
  11633. if (line.width > maxLineWidth) {
  11634. maxLineWidth = line.width;
  11635. }
  11636. }
  11637. if (this._resizeToFit) {
  11638. if (this._textWrapping === TextWrapping.Clip) {
  11639. var newWidth = this.paddingLeftInPixels + this.paddingRightInPixels + maxLineWidth;
  11640. if (newWidth !== this._width.internalValue) {
  11641. this._width.updateInPlace(newWidth, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11642. this._rebuildLayout = true;
  11643. }
  11644. }
  11645. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * this._lines.length;
  11646. if (this._lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11647. var lineSpacing = 0;
  11648. if (this._lineSpacing.isPixel) {
  11649. lineSpacing = this._lineSpacing.getValue(this._host);
  11650. }
  11651. else {
  11652. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11653. }
  11654. newHeight += (this._lines.length - 1) * lineSpacing;
  11655. }
  11656. if (newHeight !== this._height.internalValue) {
  11657. this._height.updateInPlace(newHeight, _valueAndUnit__WEBPACK_IMPORTED_MODULE_2__["ValueAndUnit"].UNITMODE_PIXEL);
  11658. this._rebuildLayout = true;
  11659. }
  11660. }
  11661. };
  11662. TextBlock.prototype._drawText = function (text, textWidth, y, context) {
  11663. var width = this._currentMeasure.width;
  11664. var x = 0;
  11665. switch (this._textHorizontalAlignment) {
  11666. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_LEFT:
  11667. x = 0;
  11668. break;
  11669. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_RIGHT:
  11670. x = width - textWidth;
  11671. break;
  11672. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].HORIZONTAL_ALIGNMENT_CENTER:
  11673. x = (width - textWidth) / 2;
  11674. break;
  11675. }
  11676. if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
  11677. context.shadowColor = this.shadowColor;
  11678. context.shadowBlur = this.shadowBlur;
  11679. context.shadowOffsetX = this.shadowOffsetX;
  11680. context.shadowOffsetY = this.shadowOffsetY;
  11681. }
  11682. if (this.outlineWidth) {
  11683. context.strokeText(text, this._currentMeasure.left + x, y);
  11684. }
  11685. context.fillText(text, this._currentMeasure.left + x, y);
  11686. };
  11687. /** @hidden */
  11688. TextBlock.prototype._draw = function (context, invalidatedRectangle) {
  11689. context.save();
  11690. this._applyStates(context);
  11691. // Render lines
  11692. this._renderLines(context);
  11693. context.restore();
  11694. };
  11695. TextBlock.prototype._applyStates = function (context) {
  11696. _super.prototype._applyStates.call(this, context);
  11697. if (this.outlineWidth) {
  11698. context.lineWidth = this.outlineWidth;
  11699. context.strokeStyle = this.outlineColor;
  11700. }
  11701. };
  11702. TextBlock.prototype._breakLines = function (refWidth, context) {
  11703. var lines = [];
  11704. var _lines = this.text.split("\n");
  11705. if (this._textWrapping === TextWrapping.Ellipsis) {
  11706. for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
  11707. var _line = _lines_1[_i];
  11708. lines.push(this._parseLineEllipsis(_line, refWidth, context));
  11709. }
  11710. }
  11711. else if (this._textWrapping === TextWrapping.WordWrap) {
  11712. for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
  11713. var _line = _lines_2[_a];
  11714. lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
  11715. }
  11716. }
  11717. else {
  11718. for (var _b = 0, _lines_3 = _lines; _b < _lines_3.length; _b++) {
  11719. var _line = _lines_3[_b];
  11720. lines.push(this._parseLine(_line, context));
  11721. }
  11722. }
  11723. return lines;
  11724. };
  11725. TextBlock.prototype._parseLine = function (line, context) {
  11726. if (line === void 0) { line = ''; }
  11727. return { text: line, width: context.measureText(line).width };
  11728. };
  11729. TextBlock.prototype._parseLineEllipsis = function (line, width, context) {
  11730. if (line === void 0) { line = ''; }
  11731. var lineWidth = context.measureText(line).width;
  11732. if (lineWidth > width) {
  11733. line += '…';
  11734. }
  11735. while (line.length > 2 && lineWidth > width) {
  11736. line = line.slice(0, -2) + '…';
  11737. lineWidth = context.measureText(line).width;
  11738. }
  11739. return { text: line, width: lineWidth };
  11740. };
  11741. TextBlock.prototype._parseLineWordWrap = function (line, width, context) {
  11742. if (line === void 0) { line = ''; }
  11743. var lines = [];
  11744. var words = line.split(' ');
  11745. var lineWidth = 0;
  11746. for (var n = 0; n < words.length; n++) {
  11747. var testLine = n > 0 ? line + " " + words[n] : words[0];
  11748. var metrics = context.measureText(testLine);
  11749. var testWidth = metrics.width;
  11750. if (testWidth > width && n > 0) {
  11751. lines.push({ text: line, width: lineWidth });
  11752. line = words[n];
  11753. lineWidth = context.measureText(line).width;
  11754. }
  11755. else {
  11756. lineWidth = testWidth;
  11757. line = testLine;
  11758. }
  11759. }
  11760. lines.push({ text: line, width: lineWidth });
  11761. return lines;
  11762. };
  11763. TextBlock.prototype._renderLines = function (context) {
  11764. var height = this._currentMeasure.height;
  11765. var rootY = 0;
  11766. switch (this._textVerticalAlignment) {
  11767. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_TOP:
  11768. rootY = this._fontOffset.ascent;
  11769. break;
  11770. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_BOTTOM:
  11771. rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
  11772. break;
  11773. case _control__WEBPACK_IMPORTED_MODULE_3__["Control"].VERTICAL_ALIGNMENT_CENTER:
  11774. rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
  11775. break;
  11776. }
  11777. rootY += this._currentMeasure.top;
  11778. for (var i = 0; i < this._lines.length; i++) {
  11779. var line = this._lines[i];
  11780. if (i !== 0 && this._lineSpacing.internalValue !== 0) {
  11781. if (this._lineSpacing.isPixel) {
  11782. rootY += this._lineSpacing.getValue(this._host);
  11783. }
  11784. else {
  11785. rootY = rootY + (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11786. }
  11787. }
  11788. this._drawText(line.text, line.width, rootY, context);
  11789. rootY += this._fontOffset.height;
  11790. }
  11791. };
  11792. /**
  11793. * Given a width constraint applied on the text block, find the expected height
  11794. * @returns expected height
  11795. */
  11796. TextBlock.prototype.computeExpectedHeight = function () {
  11797. if (this.text && this.widthInPixels) {
  11798. var context_1 = document.createElement('canvas').getContext('2d');
  11799. if (context_1) {
  11800. this._applyStates(context_1);
  11801. if (!this._fontOffset) {
  11802. this._fontOffset = _control__WEBPACK_IMPORTED_MODULE_3__["Control"]._GetFontOffset(context_1.font);
  11803. }
  11804. var lines = this._lines ? this._lines : this._breakLines(this.widthInPixels - this.paddingLeftInPixels - this.paddingRightInPixels, context_1);
  11805. var newHeight = this.paddingTopInPixels + this.paddingBottomInPixels + this._fontOffset.height * lines.length;
  11806. if (lines.length > 0 && this._lineSpacing.internalValue !== 0) {
  11807. var lineSpacing = 0;
  11808. if (this._lineSpacing.isPixel) {
  11809. lineSpacing = this._lineSpacing.getValue(this._host);
  11810. }
  11811. else {
  11812. lineSpacing = (this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height));
  11813. }
  11814. newHeight += (lines.length - 1) * lineSpacing;
  11815. }
  11816. return newHeight;
  11817. }
  11818. }
  11819. return 0;
  11820. };
  11821. TextBlock.prototype.dispose = function () {
  11822. _super.prototype.dispose.call(this);
  11823. this.onTextChangedObservable.clear();
  11824. };
  11825. return TextBlock;
  11826. }(_control__WEBPACK_IMPORTED_MODULE_3__["Control"]));
  11827. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.TextBlock"] = TextBlock;
  11828. /***/ }),
  11829. /***/ "./2D/controls/virtualKeyboard.ts":
  11830. /*!****************************************!*\
  11831. !*** ./2D/controls/virtualKeyboard.ts ***!
  11832. \****************************************/
  11833. /*! exports provided: KeyPropertySet, VirtualKeyboard */
  11834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11835. "use strict";
  11836. __webpack_require__.r(__webpack_exports__);
  11837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return KeyPropertySet; });
  11838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return VirtualKeyboard; });
  11839. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  11840. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  11841. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__);
  11842. /* harmony import */ var _stackPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stackPanel */ "./2D/controls/stackPanel.ts");
  11843. /* harmony import */ var _button__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./button */ "./2D/controls/button.ts");
  11844. /**
  11845. * Class used to store key control properties
  11846. */
  11847. var KeyPropertySet = /** @class */ (function () {
  11848. function KeyPropertySet() {
  11849. }
  11850. return KeyPropertySet;
  11851. }());
  11852. /**
  11853. * Class used to create virtual keyboard
  11854. */
  11855. var VirtualKeyboard = /** @class */ (function (_super) {
  11856. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VirtualKeyboard, _super);
  11857. function VirtualKeyboard() {
  11858. var _this = _super !== null && _super.apply(this, arguments) || this;
  11859. /** Observable raised when a key is pressed */
  11860. _this.onKeyPressObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11861. /** Gets or sets default key button width */
  11862. _this.defaultButtonWidth = "40px";
  11863. /** Gets or sets default key button height */
  11864. _this.defaultButtonHeight = "40px";
  11865. /** Gets or sets default key button left padding */
  11866. _this.defaultButtonPaddingLeft = "2px";
  11867. /** Gets or sets default key button right padding */
  11868. _this.defaultButtonPaddingRight = "2px";
  11869. /** Gets or sets default key button top padding */
  11870. _this.defaultButtonPaddingTop = "2px";
  11871. /** Gets or sets default key button bottom padding */
  11872. _this.defaultButtonPaddingBottom = "2px";
  11873. /** Gets or sets default key button foreground color */
  11874. _this.defaultButtonColor = "#DDD";
  11875. /** Gets or sets default key button background color */
  11876. _this.defaultButtonBackground = "#070707";
  11877. /** Gets or sets shift button foreground color */
  11878. _this.shiftButtonColor = "#7799FF";
  11879. /** Gets or sets shift button thickness*/
  11880. _this.selectedShiftThickness = 1;
  11881. /** Gets shift key state */
  11882. _this.shiftState = 0;
  11883. _this._currentlyConnectedInputText = null;
  11884. _this._connectedInputTexts = [];
  11885. _this._onKeyPressObserver = null;
  11886. return _this;
  11887. }
  11888. VirtualKeyboard.prototype._getTypeName = function () {
  11889. return "VirtualKeyboard";
  11890. };
  11891. VirtualKeyboard.prototype._createKey = function (key, propertySet) {
  11892. var _this = this;
  11893. var button = _button__WEBPACK_IMPORTED_MODULE_3__["Button"].CreateSimpleButton(key, key);
  11894. button.width = propertySet && propertySet.width ? propertySet.width : this.defaultButtonWidth;
  11895. button.height = propertySet && propertySet.height ? propertySet.height : this.defaultButtonHeight;
  11896. button.color = propertySet && propertySet.color ? propertySet.color : this.defaultButtonColor;
  11897. button.background = propertySet && propertySet.background ? propertySet.background : this.defaultButtonBackground;
  11898. button.paddingLeft = propertySet && propertySet.paddingLeft ? propertySet.paddingLeft : this.defaultButtonPaddingLeft;
  11899. button.paddingRight = propertySet && propertySet.paddingRight ? propertySet.paddingRight : this.defaultButtonPaddingRight;
  11900. button.paddingTop = propertySet && propertySet.paddingTop ? propertySet.paddingTop : this.defaultButtonPaddingTop;
  11901. button.paddingBottom = propertySet && propertySet.paddingBottom ? propertySet.paddingBottom : this.defaultButtonPaddingBottom;
  11902. button.thickness = 0;
  11903. button.isFocusInvisible = true;
  11904. button.shadowColor = this.shadowColor;
  11905. button.shadowBlur = this.shadowBlur;
  11906. button.shadowOffsetX = this.shadowOffsetX;
  11907. button.shadowOffsetY = this.shadowOffsetY;
  11908. button.onPointerUpObservable.add(function () {
  11909. _this.onKeyPressObservable.notifyObservers(key);
  11910. });
  11911. return button;
  11912. };
  11913. /**
  11914. * Adds a new row of keys
  11915. * @param keys defines the list of keys to add
  11916. * @param propertySets defines the associated property sets
  11917. */
  11918. VirtualKeyboard.prototype.addKeysRow = function (keys, propertySets) {
  11919. var panel = new _stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]();
  11920. panel.isVertical = false;
  11921. panel.isFocusInvisible = true;
  11922. var maxKey = null;
  11923. for (var i = 0; i < keys.length; i++) {
  11924. var properties = null;
  11925. if (propertySets && propertySets.length === keys.length) {
  11926. properties = propertySets[i];
  11927. }
  11928. var key = this._createKey(keys[i], properties);
  11929. if (!maxKey || key.heightInPixels > maxKey.heightInPixels) {
  11930. maxKey = key;
  11931. }
  11932. panel.addControl(key);
  11933. }
  11934. panel.height = maxKey ? maxKey.height : this.defaultButtonHeight;
  11935. this.addControl(panel);
  11936. };
  11937. /**
  11938. * Set the shift key to a specific state
  11939. * @param shiftState defines the new shift state
  11940. */
  11941. VirtualKeyboard.prototype.applyShiftState = function (shiftState) {
  11942. if (!this.children) {
  11943. return;
  11944. }
  11945. for (var i = 0; i < this.children.length; i++) {
  11946. var row = this.children[i];
  11947. if (!row || !row.children) {
  11948. continue;
  11949. }
  11950. var rowContainer = row;
  11951. for (var j = 0; j < rowContainer.children.length; j++) {
  11952. var button = rowContainer.children[j];
  11953. if (!button || !button.children[0]) {
  11954. continue;
  11955. }
  11956. var button_tblock = button.children[0];
  11957. if (button_tblock.text === "\u21E7") {
  11958. button.color = (shiftState ? this.shiftButtonColor : this.defaultButtonColor);
  11959. button.thickness = (shiftState > 1 ? this.selectedShiftThickness : 0);
  11960. }
  11961. button_tblock.text = (shiftState > 0 ? button_tblock.text.toUpperCase() : button_tblock.text.toLowerCase());
  11962. }
  11963. }
  11964. };
  11965. Object.defineProperty(VirtualKeyboard.prototype, "connectedInputText", {
  11966. /** Gets the input text control currently attached to the keyboard */
  11967. get: function () {
  11968. return this._currentlyConnectedInputText;
  11969. },
  11970. enumerable: true,
  11971. configurable: true
  11972. });
  11973. /**
  11974. * Connects the keyboard with an input text control
  11975. *
  11976. * @param input defines the target control
  11977. */
  11978. VirtualKeyboard.prototype.connect = function (input) {
  11979. var _this = this;
  11980. var inputTextAlreadyConnected = this._connectedInputTexts.some(function (a) { return a.input === input; });
  11981. if (inputTextAlreadyConnected) {
  11982. return;
  11983. }
  11984. if (this._onKeyPressObserver === null) {
  11985. this._onKeyPressObserver = this.onKeyPressObservable.add(function (key) {
  11986. if (!_this._currentlyConnectedInputText) {
  11987. return;
  11988. }
  11989. _this._currentlyConnectedInputText._host.focusedControl = _this._currentlyConnectedInputText;
  11990. switch (key) {
  11991. case "\u21E7":
  11992. _this.shiftState++;
  11993. if (_this.shiftState > 2) {
  11994. _this.shiftState = 0;
  11995. }
  11996. _this.applyShiftState(_this.shiftState);
  11997. return;
  11998. case "\u2190":
  11999. _this._currentlyConnectedInputText.processKey(8);
  12000. return;
  12001. case "\u21B5":
  12002. _this._currentlyConnectedInputText.processKey(13);
  12003. return;
  12004. }
  12005. _this._currentlyConnectedInputText.processKey(-1, (_this.shiftState ? key.toUpperCase() : key));
  12006. if (_this.shiftState === 1) {
  12007. _this.shiftState = 0;
  12008. _this.applyShiftState(_this.shiftState);
  12009. }
  12010. });
  12011. }
  12012. this.isVisible = false;
  12013. this._currentlyConnectedInputText = input;
  12014. input._connectedVirtualKeyboard = this;
  12015. // Events hooking
  12016. var onFocusObserver = input.onFocusObservable.add(function () {
  12017. _this._currentlyConnectedInputText = input;
  12018. input._connectedVirtualKeyboard = _this;
  12019. _this.isVisible = true;
  12020. });
  12021. var onBlurObserver = input.onBlurObservable.add(function () {
  12022. input._connectedVirtualKeyboard = null;
  12023. _this._currentlyConnectedInputText = null;
  12024. _this.isVisible = false;
  12025. });
  12026. this._connectedInputTexts.push({
  12027. input: input,
  12028. onBlurObserver: onBlurObserver,
  12029. onFocusObserver: onFocusObserver
  12030. });
  12031. };
  12032. /**
  12033. * Disconnects the keyboard from connected InputText controls
  12034. *
  12035. * @param input optionally defines a target control, otherwise all are disconnected
  12036. */
  12037. VirtualKeyboard.prototype.disconnect = function (input) {
  12038. var _this = this;
  12039. if (input) {
  12040. // .find not available on IE
  12041. var filtered = this._connectedInputTexts.filter(function (a) { return a.input === input; });
  12042. if (filtered.length === 1) {
  12043. this._removeConnectedInputObservables(filtered[0]);
  12044. this._connectedInputTexts = this._connectedInputTexts.filter(function (a) { return a.input !== input; });
  12045. if (this._currentlyConnectedInputText === input) {
  12046. this._currentlyConnectedInputText = null;
  12047. }
  12048. }
  12049. }
  12050. else {
  12051. this._connectedInputTexts.forEach(function (connectedInputText) {
  12052. _this._removeConnectedInputObservables(connectedInputText);
  12053. });
  12054. this._connectedInputTexts = [];
  12055. }
  12056. if (this._connectedInputTexts.length === 0) {
  12057. this._currentlyConnectedInputText = null;
  12058. this.onKeyPressObservable.remove(this._onKeyPressObserver);
  12059. this._onKeyPressObserver = null;
  12060. }
  12061. };
  12062. VirtualKeyboard.prototype._removeConnectedInputObservables = function (connectedInputText) {
  12063. connectedInputText.input._connectedVirtualKeyboard = null;
  12064. connectedInputText.input.onFocusObservable.remove(connectedInputText.onFocusObserver);
  12065. connectedInputText.input.onBlurObservable.remove(connectedInputText.onBlurObserver);
  12066. };
  12067. /**
  12068. * Release all resources
  12069. */
  12070. VirtualKeyboard.prototype.dispose = function () {
  12071. _super.prototype.dispose.call(this);
  12072. this.disconnect();
  12073. };
  12074. // Statics
  12075. /**
  12076. * Creates a new keyboard using a default layout
  12077. *
  12078. * @param name defines control name
  12079. * @returns a new VirtualKeyboard
  12080. */
  12081. VirtualKeyboard.CreateDefaultLayout = function (name) {
  12082. var returnValue = new VirtualKeyboard(name);
  12083. returnValue.addKeysRow(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\u2190"]);
  12084. returnValue.addKeysRow(["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"]);
  12085. returnValue.addKeysRow(["a", "s", "d", "f", "g", "h", "j", "k", "l", ";", "'", "\u21B5"]);
  12086. returnValue.addKeysRow(["\u21E7", "z", "x", "c", "v", "b", "n", "m", ",", ".", "/"]);
  12087. returnValue.addKeysRow([" "], [{ width: "200px" }]);
  12088. return returnValue;
  12089. };
  12090. return VirtualKeyboard;
  12091. }(_stackPanel__WEBPACK_IMPORTED_MODULE_2__["StackPanel"]));
  12092. babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.VirtualKeyboard"] = VirtualKeyboard;
  12093. /***/ }),
  12094. /***/ "./2D/index.ts":
  12095. /*!*********************!*\
  12096. !*** ./2D/index.ts ***!
  12097. \*********************/
  12098. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, 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 */
  12099. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12100. "use strict";
  12101. __webpack_require__.r(__webpack_exports__);
  12102. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./2D/controls/index.ts");
  12103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  12104. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  12105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  12106. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  12107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  12108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  12109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  12110. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  12111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  12112. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  12113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  12114. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  12115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  12116. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  12117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  12118. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  12119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  12120. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  12121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  12122. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  12123. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  12124. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  12125. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  12126. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  12127. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  12128. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  12129. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  12130. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  12131. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  12132. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  12133. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  12134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  12135. /* harmony import */ var _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  12136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_1__["AdvancedDynamicTexture"]; });
  12137. /* harmony import */ var _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./adtInstrumentation */ "./2D/adtInstrumentation.ts");
  12138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _adtInstrumentation__WEBPACK_IMPORTED_MODULE_2__["AdvancedDynamicTextureInstrumentation"]; });
  12139. /* harmony import */ var _math2D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./math2D */ "./2D/math2D.ts");
  12140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Vector2WithInfo"]; });
  12141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _math2D__WEBPACK_IMPORTED_MODULE_3__["Matrix2D"]; });
  12142. /* harmony import */ var _measure__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./measure */ "./2D/measure.ts");
  12143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _measure__WEBPACK_IMPORTED_MODULE_4__["Measure"]; });
  12144. /* harmony import */ var _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./multiLinePoint */ "./2D/multiLinePoint.ts");
  12145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _multiLinePoint__WEBPACK_IMPORTED_MODULE_5__["MultiLinePoint"]; });
  12146. /* harmony import */ var _style__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./style */ "./2D/style.ts");
  12147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _style__WEBPACK_IMPORTED_MODULE_6__["Style"]; });
  12148. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _valueAndUnit__WEBPACK_IMPORTED_MODULE_7__["ValueAndUnit"]; });
  12150. /* harmony import */ var _xmlLoader__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./xmlLoader */ "./2D/xmlLoader.ts");
  12151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _xmlLoader__WEBPACK_IMPORTED_MODULE_8__["XmlLoader"]; });
  12152. /***/ }),
  12153. /***/ "./2D/math2D.ts":
  12154. /*!**********************!*\
  12155. !*** ./2D/math2D.ts ***!
  12156. \**********************/
  12157. /*! exports provided: Vector2WithInfo, Matrix2D */
  12158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12159. "use strict";
  12160. __webpack_require__.r(__webpack_exports__);
  12161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return Vector2WithInfo; });
  12162. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return Matrix2D; });
  12163. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  12164. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12165. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  12166. /**
  12167. * Class used to transport Vector2 information for pointer events
  12168. */
  12169. var Vector2WithInfo = /** @class */ (function (_super) {
  12170. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector2WithInfo, _super);
  12171. /**
  12172. * Creates a new Vector2WithInfo
  12173. * @param source defines the vector2 data to transport
  12174. * @param buttonIndex defines the current mouse button index
  12175. */
  12176. function Vector2WithInfo(source,
  12177. /** defines the current mouse button index */
  12178. buttonIndex) {
  12179. if (buttonIndex === void 0) { buttonIndex = 0; }
  12180. var _this = _super.call(this, source.x, source.y) || this;
  12181. _this.buttonIndex = buttonIndex;
  12182. return _this;
  12183. }
  12184. return Vector2WithInfo;
  12185. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]));
  12186. /** Class used to provide 2D matrix features */
  12187. var Matrix2D = /** @class */ (function () {
  12188. /**
  12189. * Creates a new matrix
  12190. * @param m00 defines value for (0, 0)
  12191. * @param m01 defines value for (0, 1)
  12192. * @param m10 defines value for (1, 0)
  12193. * @param m11 defines value for (1, 1)
  12194. * @param m20 defines value for (2, 0)
  12195. * @param m21 defines value for (2, 1)
  12196. */
  12197. function Matrix2D(m00, m01, m10, m11, m20, m21) {
  12198. /** Gets the internal array of 6 floats used to store matrix data */
  12199. this.m = new Float32Array(6);
  12200. this.fromValues(m00, m01, m10, m11, m20, m21);
  12201. }
  12202. /**
  12203. * Fills the matrix from direct values
  12204. * @param m00 defines value for (0, 0)
  12205. * @param m01 defines value for (0, 1)
  12206. * @param m10 defines value for (1, 0)
  12207. * @param m11 defines value for (1, 1)
  12208. * @param m20 defines value for (2, 0)
  12209. * @param m21 defines value for (2, 1)
  12210. * @returns the current modified matrix
  12211. */
  12212. Matrix2D.prototype.fromValues = function (m00, m01, m10, m11, m20, m21) {
  12213. this.m[0] = m00;
  12214. this.m[1] = m01;
  12215. this.m[2] = m10;
  12216. this.m[3] = m11;
  12217. this.m[4] = m20;
  12218. this.m[5] = m21;
  12219. return this;
  12220. };
  12221. /**
  12222. * Gets matrix determinant
  12223. * @returns the determinant
  12224. */
  12225. Matrix2D.prototype.determinant = function () {
  12226. return this.m[0] * this.m[3] - this.m[1] * this.m[2];
  12227. };
  12228. /**
  12229. * Inverses the matrix and stores it in a target matrix
  12230. * @param result defines the target matrix
  12231. * @returns the current matrix
  12232. */
  12233. Matrix2D.prototype.invertToRef = function (result) {
  12234. var l0 = this.m[0];
  12235. var l1 = this.m[1];
  12236. var l2 = this.m[2];
  12237. var l3 = this.m[3];
  12238. var l4 = this.m[4];
  12239. var l5 = this.m[5];
  12240. var det = this.determinant();
  12241. if (det < (babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"] * babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"])) {
  12242. result.m[0] = 0;
  12243. result.m[1] = 0;
  12244. result.m[2] = 0;
  12245. result.m[3] = 0;
  12246. result.m[4] = 0;
  12247. result.m[5] = 0;
  12248. return this;
  12249. }
  12250. var detDiv = 1 / det;
  12251. var det4 = l2 * l5 - l3 * l4;
  12252. var det5 = l1 * l4 - l0 * l5;
  12253. result.m[0] = l3 * detDiv;
  12254. result.m[1] = -l1 * detDiv;
  12255. result.m[2] = -l2 * detDiv;
  12256. result.m[3] = l0 * detDiv;
  12257. result.m[4] = det4 * detDiv;
  12258. result.m[5] = det5 * detDiv;
  12259. return this;
  12260. };
  12261. /**
  12262. * Multiplies the current matrix with another one
  12263. * @param other defines the second operand
  12264. * @param result defines the target matrix
  12265. * @returns the current matrix
  12266. */
  12267. Matrix2D.prototype.multiplyToRef = function (other, result) {
  12268. var l0 = this.m[0];
  12269. var l1 = this.m[1];
  12270. var l2 = this.m[2];
  12271. var l3 = this.m[3];
  12272. var l4 = this.m[4];
  12273. var l5 = this.m[5];
  12274. var r0 = other.m[0];
  12275. var r1 = other.m[1];
  12276. var r2 = other.m[2];
  12277. var r3 = other.m[3];
  12278. var r4 = other.m[4];
  12279. var r5 = other.m[5];
  12280. result.m[0] = l0 * r0 + l1 * r2;
  12281. result.m[1] = l0 * r1 + l1 * r3;
  12282. result.m[2] = l2 * r0 + l3 * r2;
  12283. result.m[3] = l2 * r1 + l3 * r3;
  12284. result.m[4] = l4 * r0 + l5 * r2 + r4;
  12285. result.m[5] = l4 * r1 + l5 * r3 + r5;
  12286. return this;
  12287. };
  12288. /**
  12289. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  12290. * @param x defines the x coordinate to transform
  12291. * @param y defines the x coordinate to transform
  12292. * @param result defines the target vector2
  12293. * @returns the current matrix
  12294. */
  12295. Matrix2D.prototype.transformCoordinates = function (x, y, result) {
  12296. result.x = x * this.m[0] + y * this.m[2] + this.m[4];
  12297. result.y = x * this.m[1] + y * this.m[3] + this.m[5];
  12298. return this;
  12299. };
  12300. // Statics
  12301. /**
  12302. * Creates an identity matrix
  12303. * @returns a new matrix
  12304. */
  12305. Matrix2D.Identity = function () {
  12306. return new Matrix2D(1, 0, 0, 1, 0, 0);
  12307. };
  12308. /**
  12309. * Creates a translation matrix and stores it in a target matrix
  12310. * @param x defines the x coordinate of the translation
  12311. * @param y defines the y coordinate of the translation
  12312. * @param result defines the target matrix
  12313. */
  12314. Matrix2D.TranslationToRef = function (x, y, result) {
  12315. result.fromValues(1, 0, 0, 1, x, y);
  12316. };
  12317. /**
  12318. * Creates a scaling matrix and stores it in a target matrix
  12319. * @param x defines the x coordinate of the scaling
  12320. * @param y defines the y coordinate of the scaling
  12321. * @param result defines the target matrix
  12322. */
  12323. Matrix2D.ScalingToRef = function (x, y, result) {
  12324. result.fromValues(x, 0, 0, y, 0, 0);
  12325. };
  12326. /**
  12327. * Creates a rotation matrix and stores it in a target matrix
  12328. * @param angle defines the rotation angle
  12329. * @param result defines the target matrix
  12330. */
  12331. Matrix2D.RotationToRef = function (angle, result) {
  12332. var s = Math.sin(angle);
  12333. var c = Math.cos(angle);
  12334. result.fromValues(c, s, -s, c, 0, 0);
  12335. };
  12336. /**
  12337. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  12338. * @param tx defines the x coordinate of the translation
  12339. * @param ty defines the y coordinate of the translation
  12340. * @param angle defines the rotation angle
  12341. * @param scaleX defines the x coordinate of the scaling
  12342. * @param scaleY defines the y coordinate of the scaling
  12343. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  12344. * @param result defines the target matrix
  12345. */
  12346. Matrix2D.ComposeToRef = function (tx, ty, angle, scaleX, scaleY, parentMatrix, result) {
  12347. Matrix2D.TranslationToRef(tx, ty, Matrix2D._TempPreTranslationMatrix);
  12348. Matrix2D.ScalingToRef(scaleX, scaleY, Matrix2D._TempScalingMatrix);
  12349. Matrix2D.RotationToRef(angle, Matrix2D._TempRotationMatrix);
  12350. Matrix2D.TranslationToRef(-tx, -ty, Matrix2D._TempPostTranslationMatrix);
  12351. Matrix2D._TempPreTranslationMatrix.multiplyToRef(Matrix2D._TempScalingMatrix, Matrix2D._TempCompose0);
  12352. Matrix2D._TempCompose0.multiplyToRef(Matrix2D._TempRotationMatrix, Matrix2D._TempCompose1);
  12353. if (parentMatrix) {
  12354. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, Matrix2D._TempCompose2);
  12355. Matrix2D._TempCompose2.multiplyToRef(parentMatrix, result);
  12356. }
  12357. else {
  12358. Matrix2D._TempCompose1.multiplyToRef(Matrix2D._TempPostTranslationMatrix, result);
  12359. }
  12360. };
  12361. Matrix2D._TempPreTranslationMatrix = Matrix2D.Identity();
  12362. Matrix2D._TempPostTranslationMatrix = Matrix2D.Identity();
  12363. Matrix2D._TempRotationMatrix = Matrix2D.Identity();
  12364. Matrix2D._TempScalingMatrix = Matrix2D.Identity();
  12365. Matrix2D._TempCompose0 = Matrix2D.Identity();
  12366. Matrix2D._TempCompose1 = Matrix2D.Identity();
  12367. Matrix2D._TempCompose2 = Matrix2D.Identity();
  12368. return Matrix2D;
  12369. }());
  12370. /***/ }),
  12371. /***/ "./2D/measure.ts":
  12372. /*!***********************!*\
  12373. !*** ./2D/measure.ts ***!
  12374. \***********************/
  12375. /*! exports provided: Measure */
  12376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12377. "use strict";
  12378. __webpack_require__.r(__webpack_exports__);
  12379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return Measure; });
  12380. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12381. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12382. /**
  12383. * Class used to store 2D control sizes
  12384. */
  12385. var Measure = /** @class */ (function () {
  12386. /**
  12387. * Creates a new measure
  12388. * @param left defines left coordinate
  12389. * @param top defines top coordinate
  12390. * @param width defines width dimension
  12391. * @param height defines height dimension
  12392. */
  12393. function Measure(
  12394. /** defines left coordinate */
  12395. left,
  12396. /** defines top coordinate */
  12397. top,
  12398. /** defines width dimension */
  12399. width,
  12400. /** defines height dimension */
  12401. height) {
  12402. this.left = left;
  12403. this.top = top;
  12404. this.width = width;
  12405. this.height = height;
  12406. }
  12407. /**
  12408. * Copy from another measure
  12409. * @param other defines the other measure to copy from
  12410. */
  12411. Measure.prototype.copyFrom = function (other) {
  12412. this.left = other.left;
  12413. this.top = other.top;
  12414. this.width = other.width;
  12415. this.height = other.height;
  12416. };
  12417. /**
  12418. * Copy from a group of 4 floats
  12419. * @param left defines left coordinate
  12420. * @param top defines top coordinate
  12421. * @param width defines width dimension
  12422. * @param height defines height dimension
  12423. */
  12424. Measure.prototype.copyFromFloats = function (left, top, width, height) {
  12425. this.left = left;
  12426. this.top = top;
  12427. this.width = width;
  12428. this.height = height;
  12429. };
  12430. /**
  12431. * Computes the axis aligned bounding box measure for two given measures
  12432. * @param a Input measure
  12433. * @param b Input measure
  12434. * @param result the resulting bounding measure
  12435. */
  12436. Measure.CombineToRef = function (a, b, result) {
  12437. var left = Math.min(a.left, b.left);
  12438. var top = Math.min(a.top, b.top);
  12439. var right = Math.max(a.left + a.width, b.left + b.width);
  12440. var bottom = Math.max(a.top + a.height, b.top + b.height);
  12441. result.left = left;
  12442. result.top = top;
  12443. result.width = right - left;
  12444. result.height = bottom - top;
  12445. };
  12446. /**
  12447. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  12448. * @param transform the matrix to transform the measure before computing the AABB
  12449. * @param result the resulting AABB
  12450. */
  12451. Measure.prototype.transformToRef = function (transform, result) {
  12452. var rectanglePoints = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Polygon"].Rectangle(this.left, this.top, this.left + this.width, this.top + this.height);
  12453. var min = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](Number.MAX_VALUE, Number.MAX_VALUE);
  12454. var max = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12455. for (var i = 0; i < 4; i++) {
  12456. transform.transformCoordinates(rectanglePoints[i].x, rectanglePoints[i].y, rectanglePoints[i]);
  12457. min.x = Math.floor(Math.min(min.x, rectanglePoints[i].x));
  12458. min.y = Math.floor(Math.min(min.y, rectanglePoints[i].y));
  12459. max.x = Math.ceil(Math.max(max.x, rectanglePoints[i].x));
  12460. max.y = Math.ceil(Math.max(max.y, rectanglePoints[i].y));
  12461. }
  12462. result.left = min.x;
  12463. result.top = min.y;
  12464. result.width = max.x - min.x;
  12465. result.height = max.y - min.y;
  12466. };
  12467. /**
  12468. * Check equality between this measure and another one
  12469. * @param other defines the other measures
  12470. * @returns true if both measures are equals
  12471. */
  12472. Measure.prototype.isEqualsTo = function (other) {
  12473. if (this.left !== other.left) {
  12474. return false;
  12475. }
  12476. if (this.top !== other.top) {
  12477. return false;
  12478. }
  12479. if (this.width !== other.width) {
  12480. return false;
  12481. }
  12482. if (this.height !== other.height) {
  12483. return false;
  12484. }
  12485. return true;
  12486. };
  12487. /**
  12488. * Creates an empty measure
  12489. * @returns a new measure
  12490. */
  12491. Measure.Empty = function () {
  12492. return new Measure(0, 0, 0, 0);
  12493. };
  12494. return Measure;
  12495. }());
  12496. /***/ }),
  12497. /***/ "./2D/multiLinePoint.ts":
  12498. /*!******************************!*\
  12499. !*** ./2D/multiLinePoint.ts ***!
  12500. \******************************/
  12501. /*! exports provided: MultiLinePoint */
  12502. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12503. "use strict";
  12504. __webpack_require__.r(__webpack_exports__);
  12505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return MultiLinePoint; });
  12506. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  12507. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__);
  12508. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12509. /**
  12510. * Class used to store a point for a MultiLine object.
  12511. * The point can be pure 2D coordinates, a mesh or a control
  12512. */
  12513. var MultiLinePoint = /** @class */ (function () {
  12514. /**
  12515. * Creates a new MultiLinePoint
  12516. * @param multiLine defines the source MultiLine object
  12517. */
  12518. function MultiLinePoint(multiLine) {
  12519. this._multiLine = multiLine;
  12520. this._x = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12521. this._y = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](0);
  12522. this._point = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  12523. }
  12524. Object.defineProperty(MultiLinePoint.prototype, "x", {
  12525. /** Gets or sets x coordinate */
  12526. get: function () {
  12527. return this._x.toString(this._multiLine._host);
  12528. },
  12529. set: function (value) {
  12530. if (this._x.toString(this._multiLine._host) === value) {
  12531. return;
  12532. }
  12533. if (this._x.fromString(value)) {
  12534. this._multiLine._markAsDirty();
  12535. }
  12536. },
  12537. enumerable: true,
  12538. configurable: true
  12539. });
  12540. Object.defineProperty(MultiLinePoint.prototype, "y", {
  12541. /** Gets or sets y coordinate */
  12542. get: function () {
  12543. return this._y.toString(this._multiLine._host);
  12544. },
  12545. set: function (value) {
  12546. if (this._y.toString(this._multiLine._host) === value) {
  12547. return;
  12548. }
  12549. if (this._y.fromString(value)) {
  12550. this._multiLine._markAsDirty();
  12551. }
  12552. },
  12553. enumerable: true,
  12554. configurable: true
  12555. });
  12556. Object.defineProperty(MultiLinePoint.prototype, "control", {
  12557. /** Gets or sets the control associated with this point */
  12558. get: function () {
  12559. return this._control;
  12560. },
  12561. set: function (value) {
  12562. if (this._control === value) {
  12563. return;
  12564. }
  12565. if (this._control && this._controlObserver) {
  12566. this._control.onDirtyObservable.remove(this._controlObserver);
  12567. this._controlObserver = null;
  12568. }
  12569. this._control = value;
  12570. if (this._control) {
  12571. this._controlObserver = this._control.onDirtyObservable.add(this._multiLine.onPointUpdate);
  12572. }
  12573. this._multiLine._markAsDirty();
  12574. },
  12575. enumerable: true,
  12576. configurable: true
  12577. });
  12578. Object.defineProperty(MultiLinePoint.prototype, "mesh", {
  12579. /** Gets or sets the mesh associated with this point */
  12580. get: function () {
  12581. return this._mesh;
  12582. },
  12583. set: function (value) {
  12584. if (this._mesh === value) {
  12585. return;
  12586. }
  12587. if (this._mesh && this._meshObserver) {
  12588. this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
  12589. }
  12590. this._mesh = value;
  12591. if (this._mesh) {
  12592. this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
  12593. }
  12594. this._multiLine._markAsDirty();
  12595. },
  12596. enumerable: true,
  12597. configurable: true
  12598. });
  12599. /** Resets links */
  12600. MultiLinePoint.prototype.resetLinks = function () {
  12601. this.control = null;
  12602. this.mesh = null;
  12603. };
  12604. /**
  12605. * Gets a translation vector
  12606. * @returns the translation vector
  12607. */
  12608. MultiLinePoint.prototype.translate = function () {
  12609. this._point = this._translatePoint();
  12610. return this._point;
  12611. };
  12612. MultiLinePoint.prototype._translatePoint = function () {
  12613. if (this._mesh != null) {
  12614. return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
  12615. }
  12616. else if (this._control != null) {
  12617. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](this._control.centerX, this._control.centerY);
  12618. }
  12619. else {
  12620. var host = this._multiLine._host;
  12621. var xValue = this._x.getValueInPixel(host, Number(host._canvas.width));
  12622. var yValue = this._y.getValueInPixel(host, Number(host._canvas.height));
  12623. return new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](xValue, yValue);
  12624. }
  12625. };
  12626. /** Release associated resources */
  12627. MultiLinePoint.prototype.dispose = function () {
  12628. this.resetLinks();
  12629. };
  12630. return MultiLinePoint;
  12631. }());
  12632. /***/ }),
  12633. /***/ "./2D/style.ts":
  12634. /*!*********************!*\
  12635. !*** ./2D/style.ts ***!
  12636. \*********************/
  12637. /*! exports provided: Style */
  12638. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12639. "use strict";
  12640. __webpack_require__.r(__webpack_exports__);
  12641. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return Style; });
  12642. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  12643. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  12644. /* harmony import */ var _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./valueAndUnit */ "./2D/valueAndUnit.ts");
  12645. /**
  12646. * Define a style used by control to automatically setup properties based on a template.
  12647. * Only support font related properties so far
  12648. */
  12649. var Style = /** @class */ (function () {
  12650. /**
  12651. * Creates a new style object
  12652. * @param host defines the AdvancedDynamicTexture which hosts this style
  12653. */
  12654. function Style(host) {
  12655. this._fontFamily = "Arial";
  12656. this._fontStyle = "";
  12657. this._fontWeight = "";
  12658. /** @hidden */
  12659. this._fontSize = new _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"](18, _valueAndUnit__WEBPACK_IMPORTED_MODULE_1__["ValueAndUnit"].UNITMODE_PIXEL, false);
  12660. /**
  12661. * Observable raised when the style values are changed
  12662. */
  12663. this.onChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  12664. this._host = host;
  12665. }
  12666. Object.defineProperty(Style.prototype, "fontSize", {
  12667. /**
  12668. * Gets or sets the font size
  12669. */
  12670. get: function () {
  12671. return this._fontSize.toString(this._host);
  12672. },
  12673. set: function (value) {
  12674. if (this._fontSize.toString(this._host) === value) {
  12675. return;
  12676. }
  12677. if (this._fontSize.fromString(value)) {
  12678. this.onChangedObservable.notifyObservers(this);
  12679. }
  12680. },
  12681. enumerable: true,
  12682. configurable: true
  12683. });
  12684. Object.defineProperty(Style.prototype, "fontFamily", {
  12685. /**
  12686. * Gets or sets the font family
  12687. */
  12688. get: function () {
  12689. return this._fontFamily;
  12690. },
  12691. set: function (value) {
  12692. if (this._fontFamily === value) {
  12693. return;
  12694. }
  12695. this._fontFamily = value;
  12696. this.onChangedObservable.notifyObservers(this);
  12697. },
  12698. enumerable: true,
  12699. configurable: true
  12700. });
  12701. Object.defineProperty(Style.prototype, "fontStyle", {
  12702. /**
  12703. * Gets or sets the font style
  12704. */
  12705. get: function () {
  12706. return this._fontStyle;
  12707. },
  12708. set: function (value) {
  12709. if (this._fontStyle === value) {
  12710. return;
  12711. }
  12712. this._fontStyle = value;
  12713. this.onChangedObservable.notifyObservers(this);
  12714. },
  12715. enumerable: true,
  12716. configurable: true
  12717. });
  12718. Object.defineProperty(Style.prototype, "fontWeight", {
  12719. /** Gets or sets font weight */
  12720. get: function () {
  12721. return this._fontWeight;
  12722. },
  12723. set: function (value) {
  12724. if (this._fontWeight === value) {
  12725. return;
  12726. }
  12727. this._fontWeight = value;
  12728. this.onChangedObservable.notifyObservers(this);
  12729. },
  12730. enumerable: true,
  12731. configurable: true
  12732. });
  12733. /** Dispose all associated resources */
  12734. Style.prototype.dispose = function () {
  12735. this.onChangedObservable.clear();
  12736. };
  12737. return Style;
  12738. }());
  12739. /***/ }),
  12740. /***/ "./2D/valueAndUnit.ts":
  12741. /*!****************************!*\
  12742. !*** ./2D/valueAndUnit.ts ***!
  12743. \****************************/
  12744. /*! exports provided: ValueAndUnit */
  12745. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12746. "use strict";
  12747. __webpack_require__.r(__webpack_exports__);
  12748. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return ValueAndUnit; });
  12749. /**
  12750. * Class used to specific a value and its associated unit
  12751. */
  12752. var ValueAndUnit = /** @class */ (function () {
  12753. /**
  12754. * Creates a new ValueAndUnit
  12755. * @param value defines the value to store
  12756. * @param unit defines the unit to store
  12757. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  12758. */
  12759. function ValueAndUnit(value,
  12760. /** defines the unit to store */
  12761. unit,
  12762. /** defines a boolean indicating if the value can be negative */
  12763. negativeValueAllowed) {
  12764. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12765. if (negativeValueAllowed === void 0) { negativeValueAllowed = true; }
  12766. this.unit = unit;
  12767. this.negativeValueAllowed = negativeValueAllowed;
  12768. this._value = 1;
  12769. /**
  12770. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  12771. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  12772. */
  12773. this.ignoreAdaptiveScaling = false;
  12774. this._value = value;
  12775. this._originalUnit = unit;
  12776. }
  12777. Object.defineProperty(ValueAndUnit.prototype, "isPercentage", {
  12778. /** Gets a boolean indicating if the value is a percentage */
  12779. get: function () {
  12780. return this.unit === ValueAndUnit.UNITMODE_PERCENTAGE;
  12781. },
  12782. enumerable: true,
  12783. configurable: true
  12784. });
  12785. Object.defineProperty(ValueAndUnit.prototype, "isPixel", {
  12786. /** Gets a boolean indicating if the value is store as pixel */
  12787. get: function () {
  12788. return this.unit === ValueAndUnit.UNITMODE_PIXEL;
  12789. },
  12790. enumerable: true,
  12791. configurable: true
  12792. });
  12793. Object.defineProperty(ValueAndUnit.prototype, "internalValue", {
  12794. /** Gets direct internal value */
  12795. get: function () {
  12796. return this._value;
  12797. },
  12798. enumerable: true,
  12799. configurable: true
  12800. });
  12801. /**
  12802. * Gets value as pixel
  12803. * @param host defines the root host
  12804. * @param refValue defines the reference value for percentages
  12805. * @returns the value as pixel
  12806. */
  12807. ValueAndUnit.prototype.getValueInPixel = function (host, refValue) {
  12808. if (this.isPixel) {
  12809. return this.getValue(host);
  12810. }
  12811. return this.getValue(host) * refValue;
  12812. };
  12813. /**
  12814. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  12815. * @param value defines the value to store
  12816. * @param unit defines the unit to store
  12817. * @returns the current ValueAndUnit
  12818. */
  12819. ValueAndUnit.prototype.updateInPlace = function (value, unit) {
  12820. if (unit === void 0) { unit = ValueAndUnit.UNITMODE_PIXEL; }
  12821. this._value = value;
  12822. this.unit = unit;
  12823. return this;
  12824. };
  12825. /**
  12826. * Gets the value accordingly to its unit
  12827. * @param host defines the root host
  12828. * @returns the value
  12829. */
  12830. ValueAndUnit.prototype.getValue = function (host) {
  12831. if (host && !this.ignoreAdaptiveScaling && this.unit !== ValueAndUnit.UNITMODE_PERCENTAGE) {
  12832. var width = 0;
  12833. var height = 0;
  12834. if (host.idealWidth) {
  12835. width = (this._value * host.getSize().width) / host.idealWidth;
  12836. }
  12837. if (host.idealHeight) {
  12838. height = (this._value * host.getSize().height) / host.idealHeight;
  12839. }
  12840. if (host.useSmallestIdeal && host.idealWidth && host.idealHeight) {
  12841. return window.innerWidth < window.innerHeight ? width : height;
  12842. }
  12843. if (host.idealWidth) { // horizontal
  12844. return width;
  12845. }
  12846. if (host.idealHeight) { // vertical
  12847. return height;
  12848. }
  12849. }
  12850. return this._value;
  12851. };
  12852. /**
  12853. * Gets a string representation of the value
  12854. * @param host defines the root host
  12855. * @param decimals defines an optional number of decimals to display
  12856. * @returns a string
  12857. */
  12858. ValueAndUnit.prototype.toString = function (host, decimals) {
  12859. switch (this.unit) {
  12860. case ValueAndUnit.UNITMODE_PERCENTAGE:
  12861. var percentage = this.getValue(host) * 100;
  12862. return (decimals ? percentage.toFixed(decimals) : percentage) + "%";
  12863. case ValueAndUnit.UNITMODE_PIXEL:
  12864. var pixels = this.getValue(host);
  12865. return (decimals ? pixels.toFixed(decimals) : pixels) + "px";
  12866. }
  12867. return this.unit.toString();
  12868. };
  12869. /**
  12870. * Store a value parsed from a string
  12871. * @param source defines the source string
  12872. * @returns true if the value was successfully parsed
  12873. */
  12874. ValueAndUnit.prototype.fromString = function (source) {
  12875. var match = ValueAndUnit._Regex.exec(source.toString());
  12876. if (!match || match.length === 0) {
  12877. return false;
  12878. }
  12879. var sourceValue = parseFloat(match[1]);
  12880. var sourceUnit = this._originalUnit;
  12881. if (!this.negativeValueAllowed) {
  12882. if (sourceValue < 0) {
  12883. sourceValue = 0;
  12884. }
  12885. }
  12886. if (match.length === 4) {
  12887. switch (match[3]) {
  12888. case "px":
  12889. sourceUnit = ValueAndUnit.UNITMODE_PIXEL;
  12890. break;
  12891. case "%":
  12892. sourceUnit = ValueAndUnit.UNITMODE_PERCENTAGE;
  12893. sourceValue /= 100.0;
  12894. break;
  12895. }
  12896. }
  12897. if (sourceValue === this._value && sourceUnit === this.unit) {
  12898. return false;
  12899. }
  12900. this._value = sourceValue;
  12901. this.unit = sourceUnit;
  12902. return true;
  12903. };
  12904. Object.defineProperty(ValueAndUnit, "UNITMODE_PERCENTAGE", {
  12905. /** UNITMODE_PERCENTAGE */
  12906. get: function () {
  12907. return ValueAndUnit._UNITMODE_PERCENTAGE;
  12908. },
  12909. enumerable: true,
  12910. configurable: true
  12911. });
  12912. Object.defineProperty(ValueAndUnit, "UNITMODE_PIXEL", {
  12913. /** UNITMODE_PIXEL */
  12914. get: function () {
  12915. return ValueAndUnit._UNITMODE_PIXEL;
  12916. },
  12917. enumerable: true,
  12918. configurable: true
  12919. });
  12920. // Static
  12921. ValueAndUnit._Regex = /(^-?\d*(\.\d+)?)(%|px)?/;
  12922. ValueAndUnit._UNITMODE_PERCENTAGE = 0;
  12923. ValueAndUnit._UNITMODE_PIXEL = 1;
  12924. return ValueAndUnit;
  12925. }());
  12926. /***/ }),
  12927. /***/ "./2D/xmlLoader.ts":
  12928. /*!*************************!*\
  12929. !*** ./2D/xmlLoader.ts ***!
  12930. \*************************/
  12931. /*! exports provided: XmlLoader */
  12932. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12933. "use strict";
  12934. __webpack_require__.r(__webpack_exports__);
  12935. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return XmlLoader; });
  12936. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/typeStore */ "babylonjs/Maths/math");
  12937. /* harmony import */ var babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__);
  12938. /**
  12939. * Class used to load GUI via XML.
  12940. */
  12941. var XmlLoader = /** @class */ (function () {
  12942. /**
  12943. * Create a new xml loader
  12944. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  12945. */
  12946. function XmlLoader(parentClass) {
  12947. if (parentClass === void 0) { parentClass = null; }
  12948. this._nodes = {};
  12949. this._nodeTypes = {
  12950. element: 1,
  12951. attribute: 2,
  12952. text: 3
  12953. };
  12954. this._isLoaded = false;
  12955. this._objectAttributes = {
  12956. "textHorizontalAlignment": 1,
  12957. "textVerticalAlignment": 2,
  12958. "horizontalAlignment": 3,
  12959. "verticalAlignment": 4,
  12960. "stretch": 5,
  12961. };
  12962. if (parentClass) {
  12963. this._parentClass = parentClass;
  12964. }
  12965. }
  12966. XmlLoader.prototype._getChainElement = function (attributeValue) {
  12967. var element = window;
  12968. if (this._parentClass) {
  12969. element = this._parentClass;
  12970. }
  12971. var value = attributeValue;
  12972. value = value.split(".");
  12973. for (var i = 0; i < value.length; i++) {
  12974. element = element[value[i]];
  12975. }
  12976. return element;
  12977. };
  12978. XmlLoader.prototype._getClassAttribute = function (attributeName) {
  12979. var attribute = attributeName.split(".");
  12980. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + attribute[0]);
  12981. return className[attribute[1]];
  12982. };
  12983. XmlLoader.prototype._createGuiElement = function (node, parent, linkParent) {
  12984. if (linkParent === void 0) { linkParent = true; }
  12985. try {
  12986. var className = babylonjs_Misc_typeStore__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"].GetClass("BABYLON.GUI." + node.nodeName);
  12987. var guiNode = new className();
  12988. if (parent && linkParent) {
  12989. parent.addControl(guiNode);
  12990. }
  12991. for (var i = 0; i < node.attributes.length; i++) {
  12992. if (node.attributes[i].name.toLowerCase().includes("datasource")) {
  12993. continue;
  12994. }
  12995. if (node.attributes[i].name.toLowerCase().includes("observable")) {
  12996. var element = this._getChainElement(node.attributes[i].value);
  12997. guiNode[node.attributes[i].name].add(element);
  12998. continue;
  12999. }
  13000. else if (node.attributes[i].name == "linkWithMesh") {
  13001. if (this._parentClass) {
  13002. guiNode.linkWithMesh(this._parentClass[node.attributes[i].value]);
  13003. }
  13004. else {
  13005. guiNode.linkWithMesh(window[node.attributes[i].value]);
  13006. }
  13007. }
  13008. else if (node.attributes[i].value.startsWith("{{") && node.attributes[i].value.endsWith("}}")) {
  13009. var element = this._getChainElement(node.attributes[i].value.substring(2, node.attributes[i].value.length - 2));
  13010. guiNode[node.attributes[i].name] = element;
  13011. }
  13012. else if (!this._objectAttributes[node.attributes[i].name]) {
  13013. if (node.attributes[i].value == "true" || node.attributes[i].value == "false") {
  13014. guiNode[node.attributes[i].name] = (node.attributes[i].value == 'true');
  13015. }
  13016. else {
  13017. guiNode[node.attributes[i].name] = !isNaN(Number(node.attributes[i].value)) ? Number(node.attributes[i].value) : node.attributes[i].value;
  13018. }
  13019. }
  13020. else {
  13021. guiNode[node.attributes[i].name] = this._getClassAttribute(node.attributes[i].value);
  13022. }
  13023. }
  13024. if (!node.attributes.getNamedItem("id")) {
  13025. this._nodes[node.nodeName + Object.keys(this._nodes).length + "_gen"] = guiNode;
  13026. return guiNode;
  13027. }
  13028. var id = node.attributes.getNamedItem("id").value;
  13029. if (id.startsWith("{{") && id.endsWith("}}")) {
  13030. id = this._getChainElement(id.substring(2, id.length - 2));
  13031. }
  13032. if (!this._nodes[id]) {
  13033. this._nodes[id] = guiNode;
  13034. }
  13035. else {
  13036. throw "XmlLoader Exception : Duplicate ID, every element should have an unique ID attribute";
  13037. }
  13038. return guiNode;
  13039. }
  13040. catch (e) {
  13041. throw "XmlLoader Exception : Error parsing Control " + node.nodeName + "," + e + ".";
  13042. }
  13043. };
  13044. XmlLoader.prototype._parseGrid = function (node, guiNode, parent) {
  13045. var width;
  13046. var height;
  13047. var columns;
  13048. var rows = node.children;
  13049. var cells;
  13050. var isPixel = false;
  13051. var cellNode;
  13052. var rowNumber = -1;
  13053. var columnNumber = -1;
  13054. var totalColumnsNumber = 0;
  13055. for (var i = 0; i < rows.length; i++) {
  13056. if (rows[i].nodeType != this._nodeTypes.element) {
  13057. continue;
  13058. }
  13059. if (rows[i].nodeName != "Row") {
  13060. throw "XmlLoader Exception : Expecting Row node, received " + rows[i].nodeName;
  13061. }
  13062. rowNumber += 1;
  13063. columns = rows[i].children;
  13064. if (!rows[i].attributes.getNamedItem("height")) {
  13065. throw "XmlLoader Exception : Height must be defined for grid rows";
  13066. }
  13067. height = Number(rows[i].attributes.getNamedItem("height").nodeValue);
  13068. isPixel = rows[i].attributes.getNamedItem("isPixel") ? JSON.parse(rows[i].attributes.getNamedItem("isPixel").nodeValue) : false;
  13069. guiNode.addRowDefinition(height, isPixel);
  13070. for (var j = 0; j < columns.length; j++) {
  13071. if (columns[j].nodeType != this._nodeTypes.element) {
  13072. continue;
  13073. }
  13074. if (columns[j].nodeName != "Column") {
  13075. throw "XmlLoader Exception : Expecting Column node, received " + columns[j].nodeName;
  13076. }
  13077. columnNumber += 1;
  13078. if (rowNumber > 0 && columnNumber > totalColumnsNumber) {
  13079. 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.";
  13080. }
  13081. if (rowNumber == 0) {
  13082. if (!columns[j].attributes.getNamedItem("width")) {
  13083. throw "XmlLoader Exception : Width must be defined for all the grid columns in the first row";
  13084. }
  13085. width = Number(columns[j].attributes.getNamedItem("width").nodeValue);
  13086. isPixel = columns[j].attributes.getNamedItem("isPixel") ? JSON.parse(columns[j].attributes.getNamedItem("isPixel").nodeValue) : false;
  13087. guiNode.addColumnDefinition(width, isPixel);
  13088. }
  13089. cells = columns[j].children;
  13090. for (var k = 0; k < cells.length; k++) {
  13091. if (cells[k].nodeType != this._nodeTypes.element) {
  13092. continue;
  13093. }
  13094. cellNode = this._createGuiElement(cells[k], guiNode, false);
  13095. guiNode.addControl(cellNode, rowNumber, columnNumber);
  13096. if (cells[k].firstChild) {
  13097. this._parseXml(cells[k].firstChild, cellNode);
  13098. }
  13099. }
  13100. }
  13101. if (rowNumber == 0) {
  13102. totalColumnsNumber = columnNumber;
  13103. }
  13104. columnNumber = -1;
  13105. }
  13106. if (node.nextSibling) {
  13107. this._parseXml(node.nextSibling, parent);
  13108. }
  13109. };
  13110. XmlLoader.prototype._parseElement = function (node, guiNode, parent) {
  13111. if (node.firstChild) {
  13112. this._parseXml(node.firstChild, guiNode);
  13113. }
  13114. if (node.nextSibling) {
  13115. this._parseXml(node.nextSibling, parent);
  13116. }
  13117. };
  13118. XmlLoader.prototype._prepareSourceElement = function (node, guiNode, variable, source, iterator) {
  13119. if (this._parentClass) {
  13120. this._parentClass[variable] = source[iterator];
  13121. }
  13122. else {
  13123. window[variable] = source[iterator];
  13124. }
  13125. if (node.firstChild) {
  13126. this._parseXml(node.firstChild, guiNode, true);
  13127. }
  13128. };
  13129. XmlLoader.prototype._parseElementsFromSource = function (node, guiNode, parent) {
  13130. var dataSource = node.attributes.getNamedItem("dataSource").value;
  13131. if (!dataSource.includes(" in ")) {
  13132. throw "XmlLoader Exception : Malformed XML, Data Source must include an in";
  13133. }
  13134. else {
  13135. var isArray = true;
  13136. var splittedSource = dataSource.split(" in ");
  13137. if (splittedSource.length < 2) {
  13138. throw "XmlLoader Exception : Malformed XML, Data Source must an iterator and a source";
  13139. }
  13140. var source = splittedSource[1];
  13141. if (source.startsWith("{") && source.endsWith("}")) {
  13142. isArray = false;
  13143. }
  13144. if (!isArray || (source.startsWith("[") && source.endsWith("]"))) {
  13145. source = source.substring(1, source.length - 1);
  13146. }
  13147. if (this._parentClass) {
  13148. source = this._parentClass[source];
  13149. }
  13150. else {
  13151. source = window[source];
  13152. }
  13153. if (isArray) {
  13154. for (var i = 0; i < source.length; i++) {
  13155. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13156. }
  13157. }
  13158. else {
  13159. for (var i in source) {
  13160. this._prepareSourceElement(node, guiNode, splittedSource[0], source, i);
  13161. }
  13162. }
  13163. if (node.nextSibling) {
  13164. this._parseXml(node.nextSibling, parent);
  13165. }
  13166. }
  13167. };
  13168. XmlLoader.prototype._parseXml = function (node, parent, generated) {
  13169. if (generated === void 0) { generated = false; }
  13170. if (node.nodeType != this._nodeTypes.element) {
  13171. if (node.nextSibling) {
  13172. this._parseXml(node.nextSibling, parent, generated);
  13173. }
  13174. return;
  13175. }
  13176. if (generated) {
  13177. node.setAttribute("id", parent.id + (parent._children.length + 1));
  13178. }
  13179. var guiNode = this._createGuiElement(node, parent);
  13180. if (node.nodeName == "Grid") {
  13181. this._parseGrid(node, guiNode, parent);
  13182. }
  13183. else if (!node.attributes.getNamedItem("dataSource")) {
  13184. this._parseElement(node, guiNode, parent);
  13185. }
  13186. else {
  13187. this._parseElementsFromSource(node, guiNode, parent);
  13188. }
  13189. };
  13190. /**
  13191. * Gets if the loading has finished.
  13192. * @returns whether the loading has finished or not
  13193. */
  13194. XmlLoader.prototype.isLoaded = function () {
  13195. return this._isLoaded;
  13196. };
  13197. /**
  13198. * Gets a loaded node / control by id.
  13199. * @param id the Controls id set in the xml
  13200. * @returns element of type Control
  13201. */
  13202. XmlLoader.prototype.getNodeById = function (id) {
  13203. return this._nodes[id];
  13204. };
  13205. /**
  13206. * Gets all loaded nodes / controls
  13207. * @returns Array of controls
  13208. */
  13209. XmlLoader.prototype.getNodes = function () {
  13210. return this._nodes;
  13211. };
  13212. /**
  13213. * Initiates the xml layout loading
  13214. * @param xmlFile defines the xml layout to load
  13215. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  13216. * @param callback defines the callback called on layout load.
  13217. */
  13218. XmlLoader.prototype.loadLayout = function (xmlFile, rootNode, callback) {
  13219. var xhttp = new XMLHttpRequest();
  13220. xhttp.onreadystatechange = function () {
  13221. if (xhttp.readyState == 4 && xhttp.status == 200) {
  13222. if (!xhttp.responseXML) {
  13223. throw "XmlLoader Exception : XML file is malformed or corrupted.";
  13224. }
  13225. var xmlDoc = xhttp.responseXML.documentElement;
  13226. this._parseXml(xmlDoc.firstChild, rootNode);
  13227. this._isLoaded = true;
  13228. if (callback) {
  13229. callback();
  13230. }
  13231. }
  13232. }.bind(this);
  13233. xhttp.open("GET", xmlFile, true);
  13234. xhttp.send();
  13235. };
  13236. return XmlLoader;
  13237. }());
  13238. /***/ }),
  13239. /***/ "./3D/controls/abstractButton3D.ts":
  13240. /*!*****************************************!*\
  13241. !*** ./3D/controls/abstractButton3D.ts ***!
  13242. \*****************************************/
  13243. /*! exports provided: AbstractButton3D */
  13244. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13245. "use strict";
  13246. __webpack_require__.r(__webpack_exports__);
  13247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return AbstractButton3D; });
  13248. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13249. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  13250. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13251. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13252. /**
  13253. * Class used as a root to all buttons
  13254. */
  13255. var AbstractButton3D = /** @class */ (function (_super) {
  13256. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AbstractButton3D, _super);
  13257. /**
  13258. * Creates a new button
  13259. * @param name defines the control name
  13260. */
  13261. function AbstractButton3D(name) {
  13262. return _super.call(this, name) || this;
  13263. }
  13264. AbstractButton3D.prototype._getTypeName = function () {
  13265. return "AbstractButton3D";
  13266. };
  13267. // Mesh association
  13268. AbstractButton3D.prototype._createNode = function (scene) {
  13269. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("button" + this.name);
  13270. };
  13271. return AbstractButton3D;
  13272. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13273. /***/ }),
  13274. /***/ "./3D/controls/button3D.ts":
  13275. /*!*********************************!*\
  13276. !*** ./3D/controls/button3D.ts ***!
  13277. \*********************************/
  13278. /*! exports provided: Button3D */
  13279. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13280. "use strict";
  13281. __webpack_require__.r(__webpack_exports__);
  13282. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return Button3D; });
  13283. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13284. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  13285. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  13286. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  13287. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  13288. /**
  13289. * Class used to create a button in 3D
  13290. */
  13291. var Button3D = /** @class */ (function (_super) {
  13292. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Button3D, _super);
  13293. /**
  13294. * Creates a new button
  13295. * @param name defines the control name
  13296. */
  13297. function Button3D(name) {
  13298. var _this = _super.call(this, name) || this;
  13299. _this._contentResolution = 512;
  13300. _this._contentScaleRatio = 2;
  13301. // Default animations
  13302. _this.pointerEnterAnimation = function () {
  13303. if (!_this.mesh) {
  13304. return;
  13305. }
  13306. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Red();
  13307. };
  13308. _this.pointerOutAnimation = function () {
  13309. _this._currentMaterial.emissiveColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13310. };
  13311. _this.pointerDownAnimation = function () {
  13312. if (!_this.mesh) {
  13313. return;
  13314. }
  13315. _this.mesh.scaling.scaleInPlace(0.95);
  13316. };
  13317. _this.pointerUpAnimation = function () {
  13318. if (!_this.mesh) {
  13319. return;
  13320. }
  13321. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  13322. };
  13323. return _this;
  13324. }
  13325. Object.defineProperty(Button3D.prototype, "contentResolution", {
  13326. /**
  13327. * Gets or sets the texture resolution used to render content (512 by default)
  13328. */
  13329. get: function () {
  13330. return this._contentResolution;
  13331. },
  13332. set: function (value) {
  13333. if (this._contentResolution === value) {
  13334. return;
  13335. }
  13336. this._contentResolution = value;
  13337. this._resetContent();
  13338. },
  13339. enumerable: true,
  13340. configurable: true
  13341. });
  13342. Object.defineProperty(Button3D.prototype, "contentScaleRatio", {
  13343. /**
  13344. * Gets or sets the texture scale ratio used to render content (2 by default)
  13345. */
  13346. get: function () {
  13347. return this._contentScaleRatio;
  13348. },
  13349. set: function (value) {
  13350. if (this._contentScaleRatio === value) {
  13351. return;
  13352. }
  13353. this._contentScaleRatio = value;
  13354. this._resetContent();
  13355. },
  13356. enumerable: true,
  13357. configurable: true
  13358. });
  13359. Button3D.prototype._disposeFacadeTexture = function () {
  13360. if (this._facadeTexture) {
  13361. this._facadeTexture.dispose();
  13362. this._facadeTexture = null;
  13363. }
  13364. };
  13365. Button3D.prototype._resetContent = function () {
  13366. this._disposeFacadeTexture();
  13367. this.content = this._content;
  13368. };
  13369. Object.defineProperty(Button3D.prototype, "content", {
  13370. /**
  13371. * Gets or sets the GUI 2D content used to display the button's facade
  13372. */
  13373. get: function () {
  13374. return this._content;
  13375. },
  13376. set: function (value) {
  13377. this._content = value;
  13378. if (!this._host || !this._host.utilityLayer) {
  13379. return;
  13380. }
  13381. if (!this._facadeTexture) {
  13382. this._facadeTexture = new _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_3__["AdvancedDynamicTexture"]("Facade", this._contentResolution, this._contentResolution, this._host.utilityLayer.utilityLayerScene, true, babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE);
  13383. this._facadeTexture.rootContainer.scaleX = this._contentScaleRatio;
  13384. this._facadeTexture.rootContainer.scaleY = this._contentScaleRatio;
  13385. this._facadeTexture.premulAlpha = true;
  13386. }
  13387. else {
  13388. this._facadeTexture.rootContainer.clearControls();
  13389. }
  13390. this._facadeTexture.addControl(value);
  13391. this._applyFacade(this._facadeTexture);
  13392. },
  13393. enumerable: true,
  13394. configurable: true
  13395. });
  13396. /**
  13397. * Apply the facade texture (created from the content property).
  13398. * This function can be overloaded by child classes
  13399. * @param facadeTexture defines the AdvancedDynamicTexture to use
  13400. */
  13401. Button3D.prototype._applyFacade = function (facadeTexture) {
  13402. this._currentMaterial.emissiveTexture = facadeTexture;
  13403. };
  13404. Button3D.prototype._getTypeName = function () {
  13405. return "Button3D";
  13406. };
  13407. // Mesh association
  13408. Button3D.prototype._createNode = function (scene) {
  13409. var faceUV = new Array(6);
  13410. for (var i = 0; i < 6; i++) {
  13411. faceUV[i] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 0, 0);
  13412. }
  13413. faceUV[1] = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"](0, 0, 1, 1);
  13414. var mesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["BoxBuilder"].CreateBox(this.name + "_rootMesh", {
  13415. width: 1.0,
  13416. height: 1.0,
  13417. depth: 0.08,
  13418. faceUV: faceUV
  13419. }, scene);
  13420. return mesh;
  13421. };
  13422. Button3D.prototype._affectMaterial = function (mesh) {
  13423. var material = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"](this.name + "Material", mesh.getScene());
  13424. material.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  13425. mesh.material = material;
  13426. this._currentMaterial = material;
  13427. this._resetContent();
  13428. };
  13429. /**
  13430. * Releases all associated resources
  13431. */
  13432. Button3D.prototype.dispose = function () {
  13433. _super.prototype.dispose.call(this);
  13434. this._disposeFacadeTexture();
  13435. if (this._currentMaterial) {
  13436. this._currentMaterial.dispose();
  13437. }
  13438. };
  13439. return Button3D;
  13440. }(_abstractButton3D__WEBPACK_IMPORTED_MODULE_2__["AbstractButton3D"]));
  13441. /***/ }),
  13442. /***/ "./3D/controls/container3D.ts":
  13443. /*!************************************!*\
  13444. !*** ./3D/controls/container3D.ts ***!
  13445. \************************************/
  13446. /*! exports provided: Container3D */
  13447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13448. "use strict";
  13449. __webpack_require__.r(__webpack_exports__);
  13450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return Container3D; });
  13451. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13452. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/transformNode */ "babylonjs/Maths/math");
  13453. /* harmony import */ var babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__);
  13454. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  13455. /**
  13456. * Class used to create containers for controls
  13457. */
  13458. var Container3D = /** @class */ (function (_super) {
  13459. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Container3D, _super);
  13460. /**
  13461. * Creates a new container
  13462. * @param name defines the container name
  13463. */
  13464. function Container3D(name) {
  13465. var _this = _super.call(this, name) || this;
  13466. _this._blockLayout = false;
  13467. /**
  13468. * Gets the list of child controls
  13469. */
  13470. _this._children = new Array();
  13471. return _this;
  13472. }
  13473. Object.defineProperty(Container3D.prototype, "children", {
  13474. /**
  13475. * Gets the list of child controls
  13476. */
  13477. get: function () {
  13478. return this._children;
  13479. },
  13480. enumerable: true,
  13481. configurable: true
  13482. });
  13483. Object.defineProperty(Container3D.prototype, "blockLayout", {
  13484. /**
  13485. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  13486. * This is helpful to optimize layout operation when adding multiple children in a row
  13487. */
  13488. get: function () {
  13489. return this._blockLayout;
  13490. },
  13491. set: function (value) {
  13492. if (this._blockLayout === value) {
  13493. return;
  13494. }
  13495. this._blockLayout = value;
  13496. if (!this._blockLayout) {
  13497. this._arrangeChildren();
  13498. }
  13499. },
  13500. enumerable: true,
  13501. configurable: true
  13502. });
  13503. /**
  13504. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  13505. * @returns the current container
  13506. */
  13507. Container3D.prototype.updateLayout = function () {
  13508. this._arrangeChildren();
  13509. return this;
  13510. };
  13511. /**
  13512. * Gets a boolean indicating if the given control is in the children of this control
  13513. * @param control defines the control to check
  13514. * @returns true if the control is in the child list
  13515. */
  13516. Container3D.prototype.containsControl = function (control) {
  13517. return this._children.indexOf(control) !== -1;
  13518. };
  13519. /**
  13520. * Adds a control to the children of this control
  13521. * @param control defines the control to add
  13522. * @returns the current container
  13523. */
  13524. Container3D.prototype.addControl = function (control) {
  13525. var index = this._children.indexOf(control);
  13526. if (index !== -1) {
  13527. return this;
  13528. }
  13529. control.parent = this;
  13530. control._host = this._host;
  13531. this._children.push(control);
  13532. if (this._host.utilityLayer) {
  13533. control._prepareNode(this._host.utilityLayer.utilityLayerScene);
  13534. if (control.node) {
  13535. control.node.parent = this.node;
  13536. }
  13537. if (!this.blockLayout) {
  13538. this._arrangeChildren();
  13539. }
  13540. }
  13541. return this;
  13542. };
  13543. /**
  13544. * This function will be called everytime a new control is added
  13545. */
  13546. Container3D.prototype._arrangeChildren = function () {
  13547. };
  13548. Container3D.prototype._createNode = function (scene) {
  13549. return new babylonjs_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]("ContainerNode", scene);
  13550. };
  13551. /**
  13552. * Removes a control from the children of this control
  13553. * @param control defines the control to remove
  13554. * @returns the current container
  13555. */
  13556. Container3D.prototype.removeControl = function (control) {
  13557. var index = this._children.indexOf(control);
  13558. if (index !== -1) {
  13559. this._children.splice(index, 1);
  13560. control.parent = null;
  13561. control._disposeNode();
  13562. }
  13563. return this;
  13564. };
  13565. Container3D.prototype._getTypeName = function () {
  13566. return "Container3D";
  13567. };
  13568. /**
  13569. * Releases all associated resources
  13570. */
  13571. Container3D.prototype.dispose = function () {
  13572. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  13573. var control = _a[_i];
  13574. control.dispose();
  13575. }
  13576. this._children = [];
  13577. _super.prototype.dispose.call(this);
  13578. };
  13579. /** Control rotation will remain unchanged */
  13580. Container3D.UNSET_ORIENTATION = 0;
  13581. /** Control will rotate to make it look at sphere central axis */
  13582. Container3D.FACEORIGIN_ORIENTATION = 1;
  13583. /** Control will rotate to make it look back at sphere central axis */
  13584. Container3D.FACEORIGINREVERSED_ORIENTATION = 2;
  13585. /** Control will rotate to look at z axis (0, 0, 1) */
  13586. Container3D.FACEFORWARD_ORIENTATION = 3;
  13587. /** Control will rotate to look at negative z axis (0, 0, -1) */
  13588. Container3D.FACEFORWARDREVERSED_ORIENTATION = 4;
  13589. return Container3D;
  13590. }(_control3D__WEBPACK_IMPORTED_MODULE_2__["Control3D"]));
  13591. /***/ }),
  13592. /***/ "./3D/controls/control3D.ts":
  13593. /*!**********************************!*\
  13594. !*** ./3D/controls/control3D.ts ***!
  13595. \**********************************/
  13596. /*! exports provided: Control3D */
  13597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13598. "use strict";
  13599. __webpack_require__.r(__webpack_exports__);
  13600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return Control3D; });
  13601. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  13602. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  13603. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../vector3WithInfo */ "./3D/vector3WithInfo.ts");
  13604. /**
  13605. * Class used as base class for controls
  13606. */
  13607. var Control3D = /** @class */ (function () {
  13608. /**
  13609. * Creates a new control
  13610. * @param name defines the control name
  13611. */
  13612. function Control3D(
  13613. /** Defines the control name */
  13614. name) {
  13615. this.name = name;
  13616. this._downCount = 0;
  13617. this._enterCount = -1;
  13618. this._downPointerIds = {};
  13619. this._isVisible = true;
  13620. /**
  13621. * An event triggered when the pointer move over the control
  13622. */
  13623. this.onPointerMoveObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13624. /**
  13625. * An event triggered when the pointer move out of the control
  13626. */
  13627. this.onPointerOutObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13628. /**
  13629. * An event triggered when the pointer taps the control
  13630. */
  13631. this.onPointerDownObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13632. /**
  13633. * An event triggered when pointer is up
  13634. */
  13635. this.onPointerUpObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13636. /**
  13637. * An event triggered when a control is clicked on (with a mouse)
  13638. */
  13639. this.onPointerClickObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13640. /**
  13641. * An event triggered when pointer enters the control
  13642. */
  13643. this.onPointerEnterObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  13644. // Behaviors
  13645. this._behaviors = new Array();
  13646. }
  13647. Object.defineProperty(Control3D.prototype, "position", {
  13648. /** Gets or sets the control position in world space */
  13649. get: function () {
  13650. if (!this._node) {
  13651. return babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  13652. }
  13653. return this._node.position;
  13654. },
  13655. set: function (value) {
  13656. if (!this._node) {
  13657. return;
  13658. }
  13659. this._node.position = value;
  13660. },
  13661. enumerable: true,
  13662. configurable: true
  13663. });
  13664. Object.defineProperty(Control3D.prototype, "scaling", {
  13665. /** Gets or sets the control scaling in world space */
  13666. get: function () {
  13667. if (!this._node) {
  13668. return new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 1, 1);
  13669. }
  13670. return this._node.scaling;
  13671. },
  13672. set: function (value) {
  13673. if (!this._node) {
  13674. return;
  13675. }
  13676. this._node.scaling = value;
  13677. },
  13678. enumerable: true,
  13679. configurable: true
  13680. });
  13681. Object.defineProperty(Control3D.prototype, "behaviors", {
  13682. /**
  13683. * Gets the list of attached behaviors
  13684. * @see http://doc.babylonjs.com/features/behaviour
  13685. */
  13686. get: function () {
  13687. return this._behaviors;
  13688. },
  13689. enumerable: true,
  13690. configurable: true
  13691. });
  13692. /**
  13693. * Attach a behavior to the control
  13694. * @see http://doc.babylonjs.com/features/behaviour
  13695. * @param behavior defines the behavior to attach
  13696. * @returns the current control
  13697. */
  13698. Control3D.prototype.addBehavior = function (behavior) {
  13699. var _this = this;
  13700. var index = this._behaviors.indexOf(behavior);
  13701. if (index !== -1) {
  13702. return this;
  13703. }
  13704. behavior.init();
  13705. var scene = this._host.scene;
  13706. if (scene.isLoading) {
  13707. // We defer the attach when the scene will be loaded
  13708. scene.onDataLoadedObservable.addOnce(function () {
  13709. behavior.attach(_this);
  13710. });
  13711. }
  13712. else {
  13713. behavior.attach(this);
  13714. }
  13715. this._behaviors.push(behavior);
  13716. return this;
  13717. };
  13718. /**
  13719. * Remove an attached behavior
  13720. * @see http://doc.babylonjs.com/features/behaviour
  13721. * @param behavior defines the behavior to attach
  13722. * @returns the current control
  13723. */
  13724. Control3D.prototype.removeBehavior = function (behavior) {
  13725. var index = this._behaviors.indexOf(behavior);
  13726. if (index === -1) {
  13727. return this;
  13728. }
  13729. this._behaviors[index].detach();
  13730. this._behaviors.splice(index, 1);
  13731. return this;
  13732. };
  13733. /**
  13734. * Gets an attached behavior by name
  13735. * @param name defines the name of the behavior to look for
  13736. * @see http://doc.babylonjs.com/features/behaviour
  13737. * @returns null if behavior was not found else the requested behavior
  13738. */
  13739. Control3D.prototype.getBehaviorByName = function (name) {
  13740. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13741. var behavior = _a[_i];
  13742. if (behavior.name === name) {
  13743. return behavior;
  13744. }
  13745. }
  13746. return null;
  13747. };
  13748. Object.defineProperty(Control3D.prototype, "isVisible", {
  13749. /** Gets or sets a boolean indicating if the control is visible */
  13750. get: function () {
  13751. return this._isVisible;
  13752. },
  13753. set: function (value) {
  13754. if (this._isVisible === value) {
  13755. return;
  13756. }
  13757. this._isVisible = value;
  13758. var mesh = this.mesh;
  13759. if (mesh) {
  13760. mesh.setEnabled(value);
  13761. }
  13762. },
  13763. enumerable: true,
  13764. configurable: true
  13765. });
  13766. Object.defineProperty(Control3D.prototype, "typeName", {
  13767. /**
  13768. * Gets a string representing the class name
  13769. */
  13770. get: function () {
  13771. return this._getTypeName();
  13772. },
  13773. enumerable: true,
  13774. configurable: true
  13775. });
  13776. /**
  13777. * Get the current class name of the control.
  13778. * @returns current class name
  13779. */
  13780. Control3D.prototype.getClassName = function () {
  13781. return this._getTypeName();
  13782. };
  13783. Control3D.prototype._getTypeName = function () {
  13784. return "Control3D";
  13785. };
  13786. Object.defineProperty(Control3D.prototype, "node", {
  13787. /**
  13788. * Gets the transform node used by this control
  13789. */
  13790. get: function () {
  13791. return this._node;
  13792. },
  13793. enumerable: true,
  13794. configurable: true
  13795. });
  13796. Object.defineProperty(Control3D.prototype, "mesh", {
  13797. /**
  13798. * Gets the mesh used to render this control
  13799. */
  13800. get: function () {
  13801. if (this._node instanceof babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]) {
  13802. return this._node;
  13803. }
  13804. return null;
  13805. },
  13806. enumerable: true,
  13807. configurable: true
  13808. });
  13809. /**
  13810. * Link the control as child of the given node
  13811. * @param node defines the node to link to. Use null to unlink the control
  13812. * @returns the current control
  13813. */
  13814. Control3D.prototype.linkToTransformNode = function (node) {
  13815. if (this._node) {
  13816. this._node.parent = node;
  13817. }
  13818. return this;
  13819. };
  13820. /** @hidden **/
  13821. Control3D.prototype._prepareNode = function (scene) {
  13822. if (!this._node) {
  13823. this._node = this._createNode(scene);
  13824. if (!this.node) {
  13825. return;
  13826. }
  13827. this._node.metadata = this; // Store the control on the metadata field in order to get it when picking
  13828. this._node.position = this.position;
  13829. this._node.scaling = this.scaling;
  13830. var mesh = this.mesh;
  13831. if (mesh) {
  13832. mesh.isPickable = true;
  13833. this._affectMaterial(mesh);
  13834. }
  13835. }
  13836. };
  13837. /**
  13838. * Node creation.
  13839. * Can be overriden by children
  13840. * @param scene defines the scene where the node must be attached
  13841. * @returns the attached node or null if none. Must return a Mesh or AbstractMesh if there is an atttached visible object
  13842. */
  13843. Control3D.prototype._createNode = function (scene) {
  13844. // Do nothing by default
  13845. return null;
  13846. };
  13847. /**
  13848. * Affect a material to the given mesh
  13849. * @param mesh defines the mesh which will represent the control
  13850. */
  13851. Control3D.prototype._affectMaterial = function (mesh) {
  13852. mesh.material = null;
  13853. };
  13854. // Pointers
  13855. /** @hidden */
  13856. Control3D.prototype._onPointerMove = function (target, coordinates) {
  13857. this.onPointerMoveObservable.notifyObservers(coordinates, -1, target, this);
  13858. };
  13859. /** @hidden */
  13860. Control3D.prototype._onPointerEnter = function (target) {
  13861. if (this._enterCount > 0) {
  13862. return false;
  13863. }
  13864. if (this._enterCount === -1) { // -1 is for touch input, we are now sure we are with a mouse or pencil
  13865. this._enterCount = 0;
  13866. }
  13867. this._enterCount++;
  13868. this.onPointerEnterObservable.notifyObservers(this, -1, target, this);
  13869. if (this.pointerEnterAnimation) {
  13870. this.pointerEnterAnimation();
  13871. }
  13872. return true;
  13873. };
  13874. /** @hidden */
  13875. Control3D.prototype._onPointerOut = function (target) {
  13876. this._enterCount = 0;
  13877. this.onPointerOutObservable.notifyObservers(this, -1, target, this);
  13878. if (this.pointerOutAnimation) {
  13879. this.pointerOutAnimation();
  13880. }
  13881. };
  13882. /** @hidden */
  13883. Control3D.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex) {
  13884. if (this._downCount !== 0) {
  13885. this._downCount++;
  13886. return false;
  13887. }
  13888. this._downCount++;
  13889. this._downPointerIds[pointerId] = true;
  13890. this.onPointerDownObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13891. if (this.pointerDownAnimation) {
  13892. this.pointerDownAnimation();
  13893. }
  13894. return true;
  13895. };
  13896. /** @hidden */
  13897. Control3D.prototype._onPointerUp = function (target, coordinates, pointerId, buttonIndex, notifyClick) {
  13898. this._downCount--;
  13899. delete this._downPointerIds[pointerId];
  13900. if (this._downCount < 0) {
  13901. // Handle if forcePointerUp was called prior to this
  13902. this._downCount = 0;
  13903. return;
  13904. }
  13905. if (this._downCount == 0) {
  13906. if (notifyClick && (this._enterCount > 0 || this._enterCount === -1)) {
  13907. this.onPointerClickObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13908. }
  13909. this.onPointerUpObservable.notifyObservers(new _vector3WithInfo__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"](coordinates, buttonIndex), -1, target, this);
  13910. if (this.pointerUpAnimation) {
  13911. this.pointerUpAnimation();
  13912. }
  13913. }
  13914. };
  13915. /** @hidden */
  13916. Control3D.prototype.forcePointerUp = function (pointerId) {
  13917. if (pointerId === void 0) { pointerId = null; }
  13918. if (pointerId !== null) {
  13919. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), pointerId, 0, true);
  13920. }
  13921. else {
  13922. for (var key in this._downPointerIds) {
  13923. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), +key, 0, true);
  13924. }
  13925. if (this._downCount > 0) {
  13926. this._downCount = 1;
  13927. this._onPointerUp(this, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), 0, 0, true);
  13928. }
  13929. }
  13930. };
  13931. /** @hidden */
  13932. Control3D.prototype._processObservables = function (type, pickedPoint, pointerId, buttonIndex) {
  13933. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  13934. this._onPointerMove(this, pickedPoint);
  13935. var previousControlOver = this._host._lastControlOver[pointerId];
  13936. if (previousControlOver && previousControlOver !== this) {
  13937. previousControlOver._onPointerOut(this);
  13938. }
  13939. if (previousControlOver !== this) {
  13940. this._onPointerEnter(this);
  13941. }
  13942. this._host._lastControlOver[pointerId] = this;
  13943. return true;
  13944. }
  13945. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  13946. this._onPointerDown(this, pickedPoint, pointerId, buttonIndex);
  13947. this._host._lastControlDown[pointerId] = this;
  13948. this._host._lastPickedControl = this;
  13949. return true;
  13950. }
  13951. if (type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  13952. if (this._host._lastControlDown[pointerId]) {
  13953. this._host._lastControlDown[pointerId]._onPointerUp(this, pickedPoint, pointerId, buttonIndex, true);
  13954. }
  13955. delete this._host._lastControlDown[pointerId];
  13956. return true;
  13957. }
  13958. return false;
  13959. };
  13960. /** @hidden */
  13961. Control3D.prototype._disposeNode = function () {
  13962. if (this._node) {
  13963. this._node.dispose();
  13964. this._node = null;
  13965. }
  13966. };
  13967. /**
  13968. * Releases all associated resources
  13969. */
  13970. Control3D.prototype.dispose = function () {
  13971. this.onPointerDownObservable.clear();
  13972. this.onPointerEnterObservable.clear();
  13973. this.onPointerMoveObservable.clear();
  13974. this.onPointerOutObservable.clear();
  13975. this.onPointerUpObservable.clear();
  13976. this.onPointerClickObservable.clear();
  13977. this._disposeNode();
  13978. // Behaviors
  13979. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  13980. var behavior = _a[_i];
  13981. behavior.detach();
  13982. }
  13983. };
  13984. return Control3D;
  13985. }());
  13986. /***/ }),
  13987. /***/ "./3D/controls/cylinderPanel.ts":
  13988. /*!**************************************!*\
  13989. !*** ./3D/controls/cylinderPanel.ts ***!
  13990. \**************************************/
  13991. /*! exports provided: CylinderPanel */
  13992. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13993. "use strict";
  13994. __webpack_require__.r(__webpack_exports__);
  13995. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return CylinderPanel; });
  13996. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  13997. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  13998. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  13999. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14000. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14001. /**
  14002. * Class used to create a container panel deployed on the surface of a cylinder
  14003. */
  14004. var CylinderPanel = /** @class */ (function (_super) {
  14005. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CylinderPanel, _super);
  14006. function CylinderPanel() {
  14007. var _this = _super !== null && _super.apply(this, arguments) || this;
  14008. _this._radius = 5.0;
  14009. return _this;
  14010. }
  14011. Object.defineProperty(CylinderPanel.prototype, "radius", {
  14012. /**
  14013. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  14014. */
  14015. get: function () {
  14016. return this._radius;
  14017. },
  14018. set: function (value) {
  14019. var _this = this;
  14020. if (this._radius === value) {
  14021. return;
  14022. }
  14023. this._radius = value;
  14024. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14025. _this._arrangeChildren();
  14026. });
  14027. },
  14028. enumerable: true,
  14029. configurable: true
  14030. });
  14031. CylinderPanel.prototype._mapGridNode = function (control, nodePosition) {
  14032. var mesh = control.mesh;
  14033. if (!mesh) {
  14034. return;
  14035. }
  14036. var newPos = this._cylindricalMapping(nodePosition);
  14037. control.position = newPos;
  14038. switch (this.orientation) {
  14039. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14040. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, newPos.y, 2 * newPos.z));
  14041. break;
  14042. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14043. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, newPos.y, -newPos.z));
  14044. break;
  14045. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14046. break;
  14047. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14048. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14049. break;
  14050. }
  14051. };
  14052. CylinderPanel.prototype._cylindricalMapping = function (source) {
  14053. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, source.y, this._radius);
  14054. var yAngle = (source.x / this._radius);
  14055. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, 0, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14056. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14057. };
  14058. return CylinderPanel;
  14059. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14060. /***/ }),
  14061. /***/ "./3D/controls/holographicButton.ts":
  14062. /*!******************************************!*\
  14063. !*** ./3D/controls/holographicButton.ts ***!
  14064. \******************************************/
  14065. /*! exports provided: HolographicButton */
  14066. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14067. "use strict";
  14068. __webpack_require__.r(__webpack_exports__);
  14069. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return HolographicButton; });
  14070. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14071. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14072. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  14073. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__);
  14074. /* harmony import */ var _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../materials/fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  14075. /* harmony import */ var _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../2D/controls/stackPanel */ "./2D/controls/stackPanel.ts");
  14076. /* harmony import */ var _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../2D/controls/image */ "./2D/controls/image.ts");
  14077. /* harmony import */ var _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../2D/controls/textBlock */ "./2D/controls/textBlock.ts");
  14078. /* harmony import */ var _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../2D/advancedDynamicTexture */ "./2D/advancedDynamicTexture.ts");
  14079. /**
  14080. * Class used to create a holographic button in 3D
  14081. */
  14082. var HolographicButton = /** @class */ (function (_super) {
  14083. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HolographicButton, _super);
  14084. /**
  14085. * Creates a new button
  14086. * @param name defines the control name
  14087. */
  14088. function HolographicButton(name, shareMaterials) {
  14089. if (shareMaterials === void 0) { shareMaterials = true; }
  14090. var _this = _super.call(this, name) || this;
  14091. _this._shareMaterials = true;
  14092. _this._shareMaterials = shareMaterials;
  14093. // Default animations
  14094. _this.pointerEnterAnimation = function () {
  14095. if (!_this.mesh) {
  14096. return;
  14097. }
  14098. _this._frontPlate.setEnabled(true);
  14099. };
  14100. _this.pointerOutAnimation = function () {
  14101. if (!_this.mesh) {
  14102. return;
  14103. }
  14104. _this._frontPlate.setEnabled(false);
  14105. };
  14106. return _this;
  14107. }
  14108. HolographicButton.prototype._disposeTooltip = function () {
  14109. this._tooltipFade = null;
  14110. if (this._tooltipTextBlock) {
  14111. this._tooltipTextBlock.dispose();
  14112. }
  14113. if (this._tooltipTexture) {
  14114. this._tooltipTexture.dispose();
  14115. }
  14116. if (this._tooltipMesh) {
  14117. this._tooltipMesh.dispose();
  14118. }
  14119. this.onPointerEnterObservable.remove(this._tooltipHoverObserver);
  14120. this.onPointerOutObservable.remove(this._tooltipOutObserver);
  14121. };
  14122. Object.defineProperty(HolographicButton.prototype, "renderingGroupId", {
  14123. get: function () {
  14124. return this._backPlate.renderingGroupId;
  14125. },
  14126. /**
  14127. * Rendering ground id of all the mesh in the button
  14128. */
  14129. set: function (id) {
  14130. this._backPlate.renderingGroupId = id;
  14131. this._textPlate.renderingGroupId = id;
  14132. this._frontPlate.renderingGroupId = id;
  14133. if (this._tooltipMesh) {
  14134. this._tooltipMesh.renderingGroupId = id;
  14135. }
  14136. },
  14137. enumerable: true,
  14138. configurable: true
  14139. });
  14140. Object.defineProperty(HolographicButton.prototype, "tooltipText", {
  14141. get: function () {
  14142. if (this._tooltipTextBlock) {
  14143. return this._tooltipTextBlock.text;
  14144. }
  14145. return null;
  14146. },
  14147. /**
  14148. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  14149. */
  14150. set: function (text) {
  14151. var _this = this;
  14152. if (!text) {
  14153. this._disposeTooltip();
  14154. return;
  14155. }
  14156. if (!this._tooltipFade) {
  14157. // Create tooltip with mesh and text
  14158. this._tooltipMesh = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1 }, this._backPlate._scene);
  14159. var tooltipBackground = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["PlaneBuilder"].CreatePlane("", { size: 1, sideOrientation: babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Mesh"].DOUBLESIDE }, this._backPlate._scene);
  14160. var mat = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"]("", this._backPlate._scene);
  14161. mat.diffuseColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromHexString("#212121");
  14162. tooltipBackground.material = mat;
  14163. tooltipBackground.isPickable = false;
  14164. this._tooltipMesh.addChild(tooltipBackground);
  14165. tooltipBackground.position.z = 0.05;
  14166. this._tooltipMesh.scaling.y = 1 / 3;
  14167. this._tooltipMesh.position.y = 0.7;
  14168. this._tooltipMesh.position.z = -0.15;
  14169. this._tooltipMesh.isPickable = false;
  14170. this._tooltipMesh.parent = this._backPlate;
  14171. // Create text texture for the tooltip
  14172. this._tooltipTexture = _2D_advancedDynamicTexture__WEBPACK_IMPORTED_MODULE_7__["AdvancedDynamicTexture"].CreateForMesh(this._tooltipMesh);
  14173. this._tooltipTextBlock = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14174. this._tooltipTextBlock.scaleY = 3;
  14175. this._tooltipTextBlock.color = "white";
  14176. this._tooltipTextBlock.fontSize = 130;
  14177. this._tooltipTexture.addControl(this._tooltipTextBlock);
  14178. // Add hover action to tooltip
  14179. this._tooltipFade = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["FadeInOutBehavior"]();
  14180. this._tooltipFade.delay = 500;
  14181. this._tooltipMesh.addBehavior(this._tooltipFade);
  14182. this._tooltipHoverObserver = this.onPointerEnterObservable.add(function () {
  14183. if (_this._tooltipFade) {
  14184. _this._tooltipFade.fadeIn(true);
  14185. }
  14186. });
  14187. this._tooltipOutObserver = this.onPointerOutObservable.add(function () {
  14188. if (_this._tooltipFade) {
  14189. _this._tooltipFade.fadeIn(false);
  14190. }
  14191. });
  14192. }
  14193. if (this._tooltipTextBlock) {
  14194. this._tooltipTextBlock.text = text;
  14195. }
  14196. },
  14197. enumerable: true,
  14198. configurable: true
  14199. });
  14200. Object.defineProperty(HolographicButton.prototype, "text", {
  14201. /**
  14202. * Gets or sets text for the button
  14203. */
  14204. get: function () {
  14205. return this._text;
  14206. },
  14207. set: function (value) {
  14208. if (this._text === value) {
  14209. return;
  14210. }
  14211. this._text = value;
  14212. this._rebuildContent();
  14213. },
  14214. enumerable: true,
  14215. configurable: true
  14216. });
  14217. Object.defineProperty(HolographicButton.prototype, "imageUrl", {
  14218. /**
  14219. * Gets or sets the image url for the button
  14220. */
  14221. get: function () {
  14222. return this._imageUrl;
  14223. },
  14224. set: function (value) {
  14225. if (this._imageUrl === value) {
  14226. return;
  14227. }
  14228. this._imageUrl = value;
  14229. this._rebuildContent();
  14230. },
  14231. enumerable: true,
  14232. configurable: true
  14233. });
  14234. Object.defineProperty(HolographicButton.prototype, "backMaterial", {
  14235. /**
  14236. * Gets the back material used by this button
  14237. */
  14238. get: function () {
  14239. return this._backMaterial;
  14240. },
  14241. enumerable: true,
  14242. configurable: true
  14243. });
  14244. Object.defineProperty(HolographicButton.prototype, "frontMaterial", {
  14245. /**
  14246. * Gets the front material used by this button
  14247. */
  14248. get: function () {
  14249. return this._frontMaterial;
  14250. },
  14251. enumerable: true,
  14252. configurable: true
  14253. });
  14254. Object.defineProperty(HolographicButton.prototype, "plateMaterial", {
  14255. /**
  14256. * Gets the plate material used by this button
  14257. */
  14258. get: function () {
  14259. return this._plateMaterial;
  14260. },
  14261. enumerable: true,
  14262. configurable: true
  14263. });
  14264. Object.defineProperty(HolographicButton.prototype, "shareMaterials", {
  14265. /**
  14266. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  14267. */
  14268. get: function () {
  14269. return this._shareMaterials;
  14270. },
  14271. enumerable: true,
  14272. configurable: true
  14273. });
  14274. HolographicButton.prototype._getTypeName = function () {
  14275. return "HolographicButton";
  14276. };
  14277. HolographicButton.prototype._rebuildContent = function () {
  14278. this._disposeFacadeTexture();
  14279. var panel = new _2D_controls_stackPanel__WEBPACK_IMPORTED_MODULE_4__["StackPanel"]();
  14280. panel.isVertical = true;
  14281. if (this._imageUrl) {
  14282. var image = new _2D_controls_image__WEBPACK_IMPORTED_MODULE_5__["Image"]();
  14283. image.source = this._imageUrl;
  14284. image.paddingTop = "40px";
  14285. image.height = "180px";
  14286. image.width = "100px";
  14287. image.paddingBottom = "40px";
  14288. panel.addControl(image);
  14289. }
  14290. if (this._text) {
  14291. var text = new _2D_controls_textBlock__WEBPACK_IMPORTED_MODULE_6__["TextBlock"]();
  14292. text.text = this._text;
  14293. text.color = "white";
  14294. text.height = "30px";
  14295. text.fontSize = 24;
  14296. panel.addControl(text);
  14297. }
  14298. if (this._frontPlate) {
  14299. this.content = panel;
  14300. }
  14301. };
  14302. // Mesh association
  14303. HolographicButton.prototype._createNode = function (scene) {
  14304. this._backPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "BackMesh", {
  14305. width: 1.0,
  14306. height: 1.0,
  14307. depth: 0.08
  14308. }, scene);
  14309. this._frontPlate = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(this.name + "FrontMesh", {
  14310. width: 1.0,
  14311. height: 1.0,
  14312. depth: 0.08
  14313. }, scene);
  14314. this._frontPlate.parent = this._backPlate;
  14315. this._frontPlate.position.z = -0.08;
  14316. this._frontPlate.isPickable = false;
  14317. this._frontPlate.setEnabled(false);
  14318. this._textPlate = _super.prototype._createNode.call(this, scene);
  14319. this._textPlate.parent = this._backPlate;
  14320. this._textPlate.position.z = -0.08;
  14321. this._textPlate.isPickable = false;
  14322. return this._backPlate;
  14323. };
  14324. HolographicButton.prototype._applyFacade = function (facadeTexture) {
  14325. this._plateMaterial.emissiveTexture = facadeTexture;
  14326. this._plateMaterial.opacityTexture = facadeTexture;
  14327. };
  14328. HolographicButton.prototype._createBackMaterial = function (mesh) {
  14329. var _this = this;
  14330. this._backMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Back Material", mesh.getScene());
  14331. this._backMaterial.renderHoverLight = true;
  14332. this._pickedPointObserver = this._host.onPickedPointChangedObservable.add(function (pickedPoint) {
  14333. if (pickedPoint) {
  14334. _this._backMaterial.hoverPosition = pickedPoint;
  14335. _this._backMaterial.hoverColor.a = 1.0;
  14336. }
  14337. else {
  14338. _this._backMaterial.hoverColor.a = 0;
  14339. }
  14340. });
  14341. };
  14342. HolographicButton.prototype._createFrontMaterial = function (mesh) {
  14343. this._frontMaterial = new _materials_fluentMaterial__WEBPACK_IMPORTED_MODULE_3__["FluentMaterial"](this.name + "Front Material", mesh.getScene());
  14344. this._frontMaterial.innerGlowColorIntensity = 0; // No inner glow
  14345. this._frontMaterial.alpha = 0.5; // Additive
  14346. this._frontMaterial.renderBorders = true;
  14347. };
  14348. HolographicButton.prototype._createPlateMaterial = function (mesh) {
  14349. this._plateMaterial = new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["StandardMaterial"](this.name + "Plate Material", mesh.getScene());
  14350. this._plateMaterial.specularColor = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  14351. };
  14352. HolographicButton.prototype._affectMaterial = function (mesh) {
  14353. // Back
  14354. if (this._shareMaterials) {
  14355. if (!this._host._sharedMaterials["backFluentMaterial"]) {
  14356. this._createBackMaterial(mesh);
  14357. this._host._sharedMaterials["backFluentMaterial"] = this._backMaterial;
  14358. }
  14359. else {
  14360. this._backMaterial = this._host._sharedMaterials["backFluentMaterial"];
  14361. }
  14362. // Front
  14363. if (!this._host._sharedMaterials["frontFluentMaterial"]) {
  14364. this._createFrontMaterial(mesh);
  14365. this._host._sharedMaterials["frontFluentMaterial"] = this._frontMaterial;
  14366. }
  14367. else {
  14368. this._frontMaterial = this._host._sharedMaterials["frontFluentMaterial"];
  14369. }
  14370. }
  14371. else {
  14372. this._createBackMaterial(mesh);
  14373. this._createFrontMaterial(mesh);
  14374. }
  14375. this._createPlateMaterial(mesh);
  14376. this._backPlate.material = this._backMaterial;
  14377. this._frontPlate.material = this._frontMaterial;
  14378. this._textPlate.material = this._plateMaterial;
  14379. this._rebuildContent();
  14380. };
  14381. /**
  14382. * Releases all associated resources
  14383. */
  14384. HolographicButton.prototype.dispose = function () {
  14385. _super.prototype.dispose.call(this); // will dispose main mesh ie. back plate
  14386. this._disposeTooltip();
  14387. if (!this.shareMaterials) {
  14388. this._backMaterial.dispose();
  14389. this._frontMaterial.dispose();
  14390. this._plateMaterial.dispose();
  14391. if (this._pickedPointObserver) {
  14392. this._host.onPickedPointChangedObservable.remove(this._pickedPointObserver);
  14393. this._pickedPointObserver = null;
  14394. }
  14395. }
  14396. };
  14397. return HolographicButton;
  14398. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14399. /***/ }),
  14400. /***/ "./3D/controls/index.ts":
  14401. /*!******************************!*\
  14402. !*** ./3D/controls/index.ts ***!
  14403. \******************************/
  14404. /*! exports provided: AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel */
  14405. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14406. "use strict";
  14407. __webpack_require__.r(__webpack_exports__);
  14408. /* harmony import */ var _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractButton3D */ "./3D/controls/abstractButton3D.ts");
  14409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _abstractButton3D__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  14410. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  14412. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]; });
  14414. /* harmony import */ var _control3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./control3D */ "./3D/controls/control3D.ts");
  14415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _control3D__WEBPACK_IMPORTED_MODULE_3__["Control3D"]; });
  14416. /* harmony import */ var _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderPanel */ "./3D/controls/cylinderPanel.ts");
  14417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _cylinderPanel__WEBPACK_IMPORTED_MODULE_4__["CylinderPanel"]; });
  14418. /* harmony import */ var _holographicButton__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./holographicButton */ "./3D/controls/holographicButton.ts");
  14419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _holographicButton__WEBPACK_IMPORTED_MODULE_5__["HolographicButton"]; });
  14420. /* harmony import */ var _meshButton3D__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./meshButton3D */ "./3D/controls/meshButton3D.ts");
  14421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _meshButton3D__WEBPACK_IMPORTED_MODULE_6__["MeshButton3D"]; });
  14422. /* harmony import */ var _planePanel__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./planePanel */ "./3D/controls/planePanel.ts");
  14423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _planePanel__WEBPACK_IMPORTED_MODULE_7__["PlanePanel"]; });
  14424. /* harmony import */ var _scatterPanel__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scatterPanel */ "./3D/controls/scatterPanel.ts");
  14425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _scatterPanel__WEBPACK_IMPORTED_MODULE_8__["ScatterPanel"]; });
  14426. /* harmony import */ var _spherePanel__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./spherePanel */ "./3D/controls/spherePanel.ts");
  14427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _spherePanel__WEBPACK_IMPORTED_MODULE_9__["SpherePanel"]; });
  14428. /* harmony import */ var _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./stackPanel3D */ "./3D/controls/stackPanel3D.ts");
  14429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _stackPanel3D__WEBPACK_IMPORTED_MODULE_10__["StackPanel3D"]; });
  14430. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_11__["VolumeBasedPanel"]; });
  14432. /***/ }),
  14433. /***/ "./3D/controls/meshButton3D.ts":
  14434. /*!*************************************!*\
  14435. !*** ./3D/controls/meshButton3D.ts ***!
  14436. \*************************************/
  14437. /*! exports provided: MeshButton3D */
  14438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14439. "use strict";
  14440. __webpack_require__.r(__webpack_exports__);
  14441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return MeshButton3D; });
  14442. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14443. /* harmony import */ var _button3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./button3D */ "./3D/controls/button3D.ts");
  14444. /**
  14445. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  14446. */
  14447. var MeshButton3D = /** @class */ (function (_super) {
  14448. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(MeshButton3D, _super);
  14449. /**
  14450. * Creates a new 3D button based on a mesh
  14451. * @param mesh mesh to become a 3D button
  14452. * @param name defines the control name
  14453. */
  14454. function MeshButton3D(mesh, name) {
  14455. var _this = _super.call(this, name) || this;
  14456. _this._currentMesh = mesh;
  14457. /**
  14458. * Provides a default behavior on hover/out & up/down
  14459. * Override those function to create your own desired behavior specific to your mesh
  14460. */
  14461. _this.pointerEnterAnimation = function () {
  14462. if (!_this.mesh) {
  14463. return;
  14464. }
  14465. _this.mesh.scaling.scaleInPlace(1.1);
  14466. };
  14467. _this.pointerOutAnimation = function () {
  14468. if (!_this.mesh) {
  14469. return;
  14470. }
  14471. _this.mesh.scaling.scaleInPlace(1.0 / 1.1);
  14472. };
  14473. _this.pointerDownAnimation = function () {
  14474. if (!_this.mesh) {
  14475. return;
  14476. }
  14477. _this.mesh.scaling.scaleInPlace(0.95);
  14478. };
  14479. _this.pointerUpAnimation = function () {
  14480. if (!_this.mesh) {
  14481. return;
  14482. }
  14483. _this.mesh.scaling.scaleInPlace(1.0 / 0.95);
  14484. };
  14485. return _this;
  14486. }
  14487. MeshButton3D.prototype._getTypeName = function () {
  14488. return "MeshButton3D";
  14489. };
  14490. // Mesh association
  14491. MeshButton3D.prototype._createNode = function (scene) {
  14492. var _this = this;
  14493. this._currentMesh.getChildMeshes().forEach(function (mesh) {
  14494. mesh.metadata = _this;
  14495. });
  14496. return this._currentMesh;
  14497. };
  14498. MeshButton3D.prototype._affectMaterial = function (mesh) {
  14499. };
  14500. return MeshButton3D;
  14501. }(_button3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]));
  14502. /***/ }),
  14503. /***/ "./3D/controls/planePanel.ts":
  14504. /*!***********************************!*\
  14505. !*** ./3D/controls/planePanel.ts ***!
  14506. \***********************************/
  14507. /*! exports provided: PlanePanel */
  14508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14509. "use strict";
  14510. __webpack_require__.r(__webpack_exports__);
  14511. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return PlanePanel; });
  14512. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14513. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  14514. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  14515. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14516. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14517. /**
  14518. * Class used to create a container panel deployed on the surface of a plane
  14519. */
  14520. var PlanePanel = /** @class */ (function (_super) {
  14521. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(PlanePanel, _super);
  14522. function PlanePanel() {
  14523. return _super !== null && _super.apply(this, arguments) || this;
  14524. }
  14525. PlanePanel.prototype._mapGridNode = function (control, nodePosition) {
  14526. var mesh = control.mesh;
  14527. if (!mesh) {
  14528. return;
  14529. }
  14530. control.position = nodePosition.clone();
  14531. var target = babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14532. target.copyFrom(nodePosition);
  14533. switch (this.orientation) {
  14534. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION:
  14535. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARD_ORIENTATION:
  14536. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14537. mesh.lookAt(target);
  14538. break;
  14539. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14540. case _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14541. target.addInPlace(new babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14542. mesh.lookAt(target);
  14543. break;
  14544. }
  14545. };
  14546. return PlanePanel;
  14547. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_3__["VolumeBasedPanel"]));
  14548. /***/ }),
  14549. /***/ "./3D/controls/scatterPanel.ts":
  14550. /*!*************************************!*\
  14551. !*** ./3D/controls/scatterPanel.ts ***!
  14552. \*************************************/
  14553. /*! exports provided: ScatterPanel */
  14554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14555. "use strict";
  14556. __webpack_require__.r(__webpack_exports__);
  14557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return ScatterPanel; });
  14558. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14559. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14560. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14561. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14562. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14563. /**
  14564. * Class used to create a container panel where items get randomized planar mapping
  14565. */
  14566. var ScatterPanel = /** @class */ (function (_super) {
  14567. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ScatterPanel, _super);
  14568. function ScatterPanel() {
  14569. var _this = _super !== null && _super.apply(this, arguments) || this;
  14570. _this._iteration = 100.0;
  14571. return _this;
  14572. }
  14573. Object.defineProperty(ScatterPanel.prototype, "iteration", {
  14574. /**
  14575. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  14576. */
  14577. get: function () {
  14578. return this._iteration;
  14579. },
  14580. set: function (value) {
  14581. var _this = this;
  14582. if (this._iteration === value) {
  14583. return;
  14584. }
  14585. this._iteration = value;
  14586. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14587. _this._arrangeChildren();
  14588. });
  14589. },
  14590. enumerable: true,
  14591. configurable: true
  14592. });
  14593. ScatterPanel.prototype._mapGridNode = function (control, nodePosition) {
  14594. var mesh = control.mesh;
  14595. var newPos = this._scatterMapping(nodePosition);
  14596. if (!mesh) {
  14597. return;
  14598. }
  14599. switch (this.orientation) {
  14600. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14601. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14602. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1));
  14603. break;
  14604. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14605. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14606. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1));
  14607. break;
  14608. }
  14609. control.position = newPos;
  14610. };
  14611. ScatterPanel.prototype._scatterMapping = function (source) {
  14612. source.x = (1.0 - Math.random() * 2.0) * this._cellWidth;
  14613. source.y = (1.0 - Math.random() * 2.0) * this._cellHeight;
  14614. return source;
  14615. };
  14616. ScatterPanel.prototype._finalProcessing = function () {
  14617. var meshes = [];
  14618. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14619. var child = _a[_i];
  14620. if (!child.mesh) {
  14621. continue;
  14622. }
  14623. meshes.push(child.mesh);
  14624. }
  14625. for (var count = 0; count < this._iteration; count++) {
  14626. meshes.sort(function (a, b) {
  14627. var distance1 = a.position.lengthSquared();
  14628. var distance2 = b.position.lengthSquared();
  14629. if (distance1 < distance2) {
  14630. return 1;
  14631. }
  14632. else if (distance1 > distance2) {
  14633. return -1;
  14634. }
  14635. return 0;
  14636. });
  14637. var radiusPaddingSquared = Math.pow(this.margin, 2.0);
  14638. var cellSize = Math.max(this._cellWidth, this._cellHeight);
  14639. var difference2D = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector2[0];
  14640. var difference = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14641. for (var i = 0; i < meshes.length - 1; i++) {
  14642. for (var j = i + 1; j < meshes.length; j++) {
  14643. if (i != j) {
  14644. meshes[j].position.subtractToRef(meshes[i].position, difference);
  14645. // Ignore Z axis
  14646. difference2D.x = difference.x;
  14647. difference2D.y = difference.y;
  14648. var combinedRadius = cellSize;
  14649. var distance = difference2D.lengthSquared() - radiusPaddingSquared;
  14650. var minSeparation = Math.min(distance, radiusPaddingSquared);
  14651. distance -= minSeparation;
  14652. if (distance < (Math.pow(combinedRadius, 2.0))) {
  14653. difference2D.normalize();
  14654. difference.scaleInPlace((combinedRadius - Math.sqrt(distance)) * 0.5);
  14655. meshes[j].position.addInPlace(difference);
  14656. meshes[i].position.subtractInPlace(difference);
  14657. }
  14658. }
  14659. }
  14660. }
  14661. }
  14662. };
  14663. return ScatterPanel;
  14664. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14665. /***/ }),
  14666. /***/ "./3D/controls/spherePanel.ts":
  14667. /*!************************************!*\
  14668. !*** ./3D/controls/spherePanel.ts ***!
  14669. \************************************/
  14670. /*! exports provided: SpherePanel */
  14671. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14672. "use strict";
  14673. __webpack_require__.r(__webpack_exports__);
  14674. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return SpherePanel; });
  14675. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14676. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14677. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14678. /* harmony import */ var _volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./volumeBasedPanel */ "./3D/controls/volumeBasedPanel.ts");
  14679. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14680. /**
  14681. * Class used to create a container panel deployed on the surface of a sphere
  14682. */
  14683. var SpherePanel = /** @class */ (function (_super) {
  14684. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(SpherePanel, _super);
  14685. function SpherePanel() {
  14686. var _this = _super !== null && _super.apply(this, arguments) || this;
  14687. _this._radius = 5.0;
  14688. return _this;
  14689. }
  14690. Object.defineProperty(SpherePanel.prototype, "radius", {
  14691. /**
  14692. * Gets or sets the radius of the sphere where to project controls (5 by default)
  14693. */
  14694. get: function () {
  14695. return this._radius;
  14696. },
  14697. set: function (value) {
  14698. var _this = this;
  14699. if (this._radius === value) {
  14700. return;
  14701. }
  14702. this._radius = value;
  14703. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14704. _this._arrangeChildren();
  14705. });
  14706. },
  14707. enumerable: true,
  14708. configurable: true
  14709. });
  14710. SpherePanel.prototype._mapGridNode = function (control, nodePosition) {
  14711. var mesh = control.mesh;
  14712. if (!mesh) {
  14713. return;
  14714. }
  14715. var newPos = this._sphericalMapping(nodePosition);
  14716. control.position = newPos;
  14717. switch (this.orientation) {
  14718. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGIN_ORIENTATION:
  14719. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](2 * newPos.x, 2 * newPos.y, 2 * newPos.z));
  14720. break;
  14721. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEORIGINREVERSED_ORIENTATION:
  14722. mesh.lookAt(new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-newPos.x, -newPos.y, -newPos.z));
  14723. break;
  14724. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARD_ORIENTATION:
  14725. break;
  14726. case _container3D__WEBPACK_IMPORTED_MODULE_3__["Container3D"].FACEFORWARDREVERSED_ORIENTATION:
  14727. mesh.rotate(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y, Math.PI, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL);
  14728. break;
  14729. }
  14730. };
  14731. SpherePanel.prototype._sphericalMapping = function (source) {
  14732. var newPos = new babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, this._radius);
  14733. var xAngle = (source.y / this._radius);
  14734. var yAngle = -(source.x / this._radius);
  14735. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yAngle, xAngle, 0, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14736. return babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(newPos, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14737. };
  14738. return SpherePanel;
  14739. }(_volumeBasedPanel__WEBPACK_IMPORTED_MODULE_2__["VolumeBasedPanel"]));
  14740. /***/ }),
  14741. /***/ "./3D/controls/stackPanel3D.ts":
  14742. /*!*************************************!*\
  14743. !*** ./3D/controls/stackPanel3D.ts ***!
  14744. \*************************************/
  14745. /*! exports provided: StackPanel3D */
  14746. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14747. "use strict";
  14748. __webpack_require__.r(__webpack_exports__);
  14749. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return StackPanel3D; });
  14750. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14751. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14752. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14753. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14754. /**
  14755. * Class used to create a stack panel in 3D on XY plane
  14756. */
  14757. var StackPanel3D = /** @class */ (function (_super) {
  14758. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(StackPanel3D, _super);
  14759. /**
  14760. * Creates new StackPanel
  14761. * @param isVertical
  14762. */
  14763. function StackPanel3D(isVertical) {
  14764. if (isVertical === void 0) { isVertical = false; }
  14765. var _this = _super.call(this) || this;
  14766. _this._isVertical = false;
  14767. /**
  14768. * Gets or sets the distance between elements
  14769. */
  14770. _this.margin = 0.1;
  14771. _this._isVertical = isVertical;
  14772. return _this;
  14773. }
  14774. Object.defineProperty(StackPanel3D.prototype, "isVertical", {
  14775. /**
  14776. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  14777. */
  14778. get: function () {
  14779. return this._isVertical;
  14780. },
  14781. set: function (value) {
  14782. var _this = this;
  14783. if (this._isVertical === value) {
  14784. return;
  14785. }
  14786. this._isVertical = value;
  14787. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14788. _this._arrangeChildren();
  14789. });
  14790. },
  14791. enumerable: true,
  14792. configurable: true
  14793. });
  14794. StackPanel3D.prototype._arrangeChildren = function () {
  14795. var width = 0;
  14796. var height = 0;
  14797. var controlCount = 0;
  14798. var extendSizes = [];
  14799. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14800. // Measure
  14801. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14802. var child = _a[_i];
  14803. if (!child.mesh) {
  14804. continue;
  14805. }
  14806. controlCount++;
  14807. child.mesh.computeWorldMatrix(true);
  14808. child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14809. var boundingBox = child.mesh.getBoundingInfo().boundingBox;
  14810. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(boundingBox.extendSize, babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Matrix[0]);
  14811. extendSizes.push(extendSize);
  14812. if (this._isVertical) {
  14813. height += extendSize.y;
  14814. }
  14815. else {
  14816. width += extendSize.x;
  14817. }
  14818. }
  14819. if (this._isVertical) {
  14820. height += (controlCount - 1) * this.margin / 2;
  14821. }
  14822. else {
  14823. width += (controlCount - 1) * this.margin / 2;
  14824. }
  14825. // Arrange
  14826. var offset;
  14827. if (this._isVertical) {
  14828. offset = -height;
  14829. }
  14830. else {
  14831. offset = -width;
  14832. }
  14833. var index = 0;
  14834. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  14835. var child = _c[_b];
  14836. if (!child.mesh) {
  14837. continue;
  14838. }
  14839. controlCount--;
  14840. var extendSize = extendSizes[index++];
  14841. if (this._isVertical) {
  14842. child.position.y = offset + extendSize.y;
  14843. child.position.x = 0;
  14844. offset += extendSize.y * 2;
  14845. }
  14846. else {
  14847. child.position.x = offset + extendSize.x;
  14848. child.position.y = 0;
  14849. offset += extendSize.x * 2;
  14850. }
  14851. offset += (controlCount > 0 ? this.margin : 0);
  14852. }
  14853. };
  14854. return StackPanel3D;
  14855. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  14856. /***/ }),
  14857. /***/ "./3D/controls/volumeBasedPanel.ts":
  14858. /*!*****************************************!*\
  14859. !*** ./3D/controls/volumeBasedPanel.ts ***!
  14860. \*****************************************/
  14861. /*! exports provided: VolumeBasedPanel */
  14862. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14863. "use strict";
  14864. __webpack_require__.r(__webpack_exports__);
  14865. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return VolumeBasedPanel; });
  14866. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  14867. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math");
  14868. /* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__);
  14869. /* harmony import */ var _container3D__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./container3D */ "./3D/controls/container3D.ts");
  14870. /**
  14871. * Abstract class used to create a container panel deployed on the surface of a volume
  14872. */
  14873. var VolumeBasedPanel = /** @class */ (function (_super) {
  14874. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(VolumeBasedPanel, _super);
  14875. /**
  14876. * Creates new VolumeBasedPanel
  14877. */
  14878. function VolumeBasedPanel() {
  14879. var _this = _super.call(this) || this;
  14880. _this._columns = 10;
  14881. _this._rows = 0;
  14882. _this._rowThenColum = true;
  14883. _this._orientation = _container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"].FACEORIGIN_ORIENTATION;
  14884. /**
  14885. * Gets or sets the distance between elements
  14886. */
  14887. _this.margin = 0;
  14888. return _this;
  14889. }
  14890. Object.defineProperty(VolumeBasedPanel.prototype, "orientation", {
  14891. /**
  14892. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  14893. * | Value | Type | Description |
  14894. * | ----- | ----------------------------------- | ----------- |
  14895. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  14896. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  14897. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  14898. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  14899. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  14900. */
  14901. get: function () {
  14902. return this._orientation;
  14903. },
  14904. set: function (value) {
  14905. var _this = this;
  14906. if (this._orientation === value) {
  14907. return;
  14908. }
  14909. this._orientation = value;
  14910. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14911. _this._arrangeChildren();
  14912. });
  14913. },
  14914. enumerable: true,
  14915. configurable: true
  14916. });
  14917. Object.defineProperty(VolumeBasedPanel.prototype, "columns", {
  14918. /**
  14919. * Gets or sets the number of columns requested (10 by default).
  14920. * The panel will automatically compute the number of rows based on number of child controls.
  14921. */
  14922. get: function () {
  14923. return this._columns;
  14924. },
  14925. set: function (value) {
  14926. var _this = this;
  14927. if (this._columns === value) {
  14928. return;
  14929. }
  14930. this._columns = value;
  14931. this._rowThenColum = true;
  14932. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14933. _this._arrangeChildren();
  14934. });
  14935. },
  14936. enumerable: true,
  14937. configurable: true
  14938. });
  14939. Object.defineProperty(VolumeBasedPanel.prototype, "rows", {
  14940. /**
  14941. * Gets or sets a the number of rows requested.
  14942. * The panel will automatically compute the number of columns based on number of child controls.
  14943. */
  14944. get: function () {
  14945. return this._rows;
  14946. },
  14947. set: function (value) {
  14948. var _this = this;
  14949. if (this._rows === value) {
  14950. return;
  14951. }
  14952. this._rows = value;
  14953. this._rowThenColum = false;
  14954. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].SetImmediate(function () {
  14955. _this._arrangeChildren();
  14956. });
  14957. },
  14958. enumerable: true,
  14959. configurable: true
  14960. });
  14961. VolumeBasedPanel.prototype._arrangeChildren = function () {
  14962. this._cellWidth = 0;
  14963. this._cellHeight = 0;
  14964. var rows = 0;
  14965. var columns = 0;
  14966. var controlCount = 0;
  14967. var currentInverseWorld = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Invert(this.node.computeWorldMatrix(true));
  14968. // Measure
  14969. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  14970. var child = _a[_i];
  14971. if (!child.mesh) {
  14972. continue;
  14973. }
  14974. controlCount++;
  14975. child.mesh.computeWorldMatrix(true);
  14976. // child.mesh.getWorldMatrix().multiplyToRef(currentInverseWorld, Tmp.Matrix[0]);
  14977. var boundingBox = child.mesh.getHierarchyBoundingVectors();
  14978. var extendSize = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0];
  14979. var diff = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[1];
  14980. boundingBox.max.subtractToRef(boundingBox.min, diff);
  14981. diff.scaleInPlace(0.5);
  14982. babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(diff, currentInverseWorld, extendSize);
  14983. this._cellWidth = Math.max(this._cellWidth, extendSize.x * 2);
  14984. this._cellHeight = Math.max(this._cellHeight, extendSize.y * 2);
  14985. }
  14986. this._cellWidth += this.margin * 2;
  14987. this._cellHeight += this.margin * 2;
  14988. // Arrange
  14989. if (this._rowThenColum) {
  14990. columns = this._columns;
  14991. rows = Math.ceil(controlCount / this._columns);
  14992. }
  14993. else {
  14994. rows = this._rows;
  14995. columns = Math.ceil(controlCount / this._rows);
  14996. }
  14997. var startOffsetX = (columns * 0.5) * this._cellWidth;
  14998. var startOffsetY = (rows * 0.5) * this._cellHeight;
  14999. var nodeGrid = [];
  15000. var cellCounter = 0;
  15001. if (this._rowThenColum) {
  15002. for (var r = 0; r < rows; r++) {
  15003. for (var c = 0; c < columns; c++) {
  15004. 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));
  15005. cellCounter++;
  15006. if (cellCounter > controlCount) {
  15007. break;
  15008. }
  15009. }
  15010. }
  15011. }
  15012. else {
  15013. for (var c = 0; c < columns; c++) {
  15014. for (var r = 0; r < rows; r++) {
  15015. 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));
  15016. cellCounter++;
  15017. if (cellCounter > controlCount) {
  15018. break;
  15019. }
  15020. }
  15021. }
  15022. }
  15023. cellCounter = 0;
  15024. for (var _b = 0, _c = this._children; _b < _c.length; _b++) {
  15025. var child = _c[_b];
  15026. if (!child.mesh) {
  15027. continue;
  15028. }
  15029. this._mapGridNode(child, nodeGrid[cellCounter]);
  15030. cellCounter++;
  15031. }
  15032. this._finalProcessing();
  15033. };
  15034. /** Child classes can implement this function to provide additional processing */
  15035. VolumeBasedPanel.prototype._finalProcessing = function () {
  15036. };
  15037. return VolumeBasedPanel;
  15038. }(_container3D__WEBPACK_IMPORTED_MODULE_2__["Container3D"]));
  15039. /***/ }),
  15040. /***/ "./3D/gui3DManager.ts":
  15041. /*!****************************!*\
  15042. !*** ./3D/gui3DManager.ts ***!
  15043. \****************************/
  15044. /*! exports provided: GUI3DManager */
  15045. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15046. "use strict";
  15047. __webpack_require__.r(__webpack_exports__);
  15048. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return GUI3DManager; });
  15049. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/observable */ "babylonjs/Maths/math");
  15050. /* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__);
  15051. /* harmony import */ var _controls_container3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controls/container3D */ "./3D/controls/container3D.ts");
  15052. /**
  15053. * Class used to manage 3D user interface
  15054. * @see http://doc.babylonjs.com/how_to/gui3d
  15055. */
  15056. var GUI3DManager = /** @class */ (function () {
  15057. /**
  15058. * Creates a new GUI3DManager
  15059. * @param scene
  15060. */
  15061. function GUI3DManager(scene) {
  15062. var _this = this;
  15063. /** @hidden */
  15064. this._lastControlOver = {};
  15065. /** @hidden */
  15066. this._lastControlDown = {};
  15067. /**
  15068. * Observable raised when the point picked by the pointer events changed
  15069. */
  15070. this.onPickedPointChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  15071. // Shared resources
  15072. /** @hidden */
  15073. this._sharedMaterials = {};
  15074. this._scene = scene || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["EngineStore"].LastCreatedScene;
  15075. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  15076. _this._sceneDisposeObserver = null;
  15077. _this._utilityLayer = null;
  15078. _this.dispose();
  15079. });
  15080. this._utilityLayer = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"](this._scene);
  15081. this._utilityLayer.onlyCheckPointerDownEvents = false;
  15082. this._utilityLayer.pickUtilitySceneFirst = false;
  15083. this._utilityLayer.mainSceneTrackerPredicate = function (mesh) {
  15084. return mesh && mesh.metadata && mesh.metadata._node;
  15085. };
  15086. // Root
  15087. this._rootContainer = new _controls_container3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]("RootContainer");
  15088. this._rootContainer._host = this;
  15089. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  15090. // Events
  15091. this._pointerOutObserver = this._utilityLayer.onPointerOutObservable.add(function (pointerId) {
  15092. _this._handlePointerOut(pointerId, true);
  15093. });
  15094. this._pointerObserver = utilityLayerScene.onPointerObservable.add(function (pi, state) {
  15095. _this._doPicking(pi);
  15096. });
  15097. // Scene
  15098. this._utilityLayer.utilityLayerScene.autoClear = false;
  15099. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  15100. new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]("hemi", babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), this._utilityLayer.utilityLayerScene);
  15101. }
  15102. Object.defineProperty(GUI3DManager.prototype, "scene", {
  15103. /** Gets the hosting scene */
  15104. get: function () {
  15105. return this._scene;
  15106. },
  15107. enumerable: true,
  15108. configurable: true
  15109. });
  15110. Object.defineProperty(GUI3DManager.prototype, "utilityLayer", {
  15111. /** Gets associated utility layer */
  15112. get: function () {
  15113. return this._utilityLayer;
  15114. },
  15115. enumerable: true,
  15116. configurable: true
  15117. });
  15118. GUI3DManager.prototype._handlePointerOut = function (pointerId, isPointerUp) {
  15119. var previousControlOver = this._lastControlOver[pointerId];
  15120. if (previousControlOver) {
  15121. previousControlOver._onPointerOut(previousControlOver);
  15122. delete this._lastControlOver[pointerId];
  15123. }
  15124. if (isPointerUp) {
  15125. if (this._lastControlDown[pointerId]) {
  15126. this._lastControlDown[pointerId].forcePointerUp();
  15127. delete this._lastControlDown[pointerId];
  15128. }
  15129. }
  15130. this.onPickedPointChangedObservable.notifyObservers(null);
  15131. };
  15132. GUI3DManager.prototype._doPicking = function (pi) {
  15133. if (!this._utilityLayer || !this._utilityLayer.shouldRender || !this._utilityLayer.utilityLayerScene.activeCamera) {
  15134. return false;
  15135. }
  15136. var pointerEvent = (pi.event);
  15137. var pointerId = pointerEvent.pointerId || 0;
  15138. var buttonIndex = pointerEvent.button;
  15139. var pickingInfo = pi.pickInfo;
  15140. if (!pickingInfo || !pickingInfo.hit) {
  15141. this._handlePointerOut(pointerId, pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP);
  15142. return false;
  15143. }
  15144. var control = (pickingInfo.pickedMesh.metadata);
  15145. if (pickingInfo.pickedPoint) {
  15146. this.onPickedPointChangedObservable.notifyObservers(pickingInfo.pickedPoint);
  15147. }
  15148. if (!control._processObservables(pi.type, pickingInfo.pickedPoint, pointerId, buttonIndex)) {
  15149. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERMOVE) {
  15150. if (this._lastControlOver[pointerId]) {
  15151. this._lastControlOver[pointerId]._onPointerOut(this._lastControlOver[pointerId]);
  15152. }
  15153. delete this._lastControlOver[pointerId];
  15154. }
  15155. }
  15156. if (pi.type === babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  15157. if (this._lastControlDown[pointerEvent.pointerId]) {
  15158. this._lastControlDown[pointerEvent.pointerId].forcePointerUp();
  15159. delete this._lastControlDown[pointerEvent.pointerId];
  15160. }
  15161. if (pointerEvent.pointerType === "touch") {
  15162. this._handlePointerOut(pointerId, false);
  15163. }
  15164. }
  15165. return true;
  15166. };
  15167. Object.defineProperty(GUI3DManager.prototype, "rootContainer", {
  15168. /**
  15169. * Gets the root container
  15170. */
  15171. get: function () {
  15172. return this._rootContainer;
  15173. },
  15174. enumerable: true,
  15175. configurable: true
  15176. });
  15177. /**
  15178. * Gets a boolean indicating if the given control is in the root child list
  15179. * @param control defines the control to check
  15180. * @returns true if the control is in the root child list
  15181. */
  15182. GUI3DManager.prototype.containsControl = function (control) {
  15183. return this._rootContainer.containsControl(control);
  15184. };
  15185. /**
  15186. * Adds a control to the root child list
  15187. * @param control defines the control to add
  15188. * @returns the current manager
  15189. */
  15190. GUI3DManager.prototype.addControl = function (control) {
  15191. this._rootContainer.addControl(control);
  15192. return this;
  15193. };
  15194. /**
  15195. * Removes a control from the root child list
  15196. * @param control defines the control to remove
  15197. * @returns the current container
  15198. */
  15199. GUI3DManager.prototype.removeControl = function (control) {
  15200. this._rootContainer.removeControl(control);
  15201. return this;
  15202. };
  15203. /**
  15204. * Releases all associated resources
  15205. */
  15206. GUI3DManager.prototype.dispose = function () {
  15207. this._rootContainer.dispose();
  15208. for (var materialName in this._sharedMaterials) {
  15209. if (!this._sharedMaterials.hasOwnProperty(materialName)) {
  15210. continue;
  15211. }
  15212. this._sharedMaterials[materialName].dispose();
  15213. }
  15214. this._sharedMaterials = {};
  15215. if (this._pointerOutObserver && this._utilityLayer) {
  15216. this._utilityLayer.onPointerOutObservable.remove(this._pointerOutObserver);
  15217. this._pointerOutObserver = null;
  15218. }
  15219. this.onPickedPointChangedObservable.clear();
  15220. var utilityLayerScene = this._utilityLayer ? this._utilityLayer.utilityLayerScene : null;
  15221. if (utilityLayerScene) {
  15222. if (this._pointerObserver) {
  15223. utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  15224. this._pointerObserver = null;
  15225. }
  15226. }
  15227. if (this._scene) {
  15228. if (this._sceneDisposeObserver) {
  15229. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  15230. this._sceneDisposeObserver = null;
  15231. }
  15232. }
  15233. if (this._utilityLayer) {
  15234. this._utilityLayer.dispose();
  15235. }
  15236. };
  15237. return GUI3DManager;
  15238. }());
  15239. /***/ }),
  15240. /***/ "./3D/index.ts":
  15241. /*!*********************!*\
  15242. !*** ./3D/index.ts ***!
  15243. \*********************/
  15244. /*! exports provided: GUI3DManager, Vector3WithInfo, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15246. "use strict";
  15247. __webpack_require__.r(__webpack_exports__);
  15248. /* harmony import */ var _controls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./controls */ "./3D/controls/index.ts");
  15249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _controls__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15261. /* harmony import */ var _materials__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./materials */ "./3D/materials/index.ts");
  15262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _materials__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15264. /* harmony import */ var _gui3DManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gui3DManager */ "./3D/gui3DManager.ts");
  15265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _gui3DManager__WEBPACK_IMPORTED_MODULE_2__["GUI3DManager"]; });
  15266. /* harmony import */ var _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vector3WithInfo */ "./3D/vector3WithInfo.ts");
  15267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _vector3WithInfo__WEBPACK_IMPORTED_MODULE_3__["Vector3WithInfo"]; });
  15268. /***/ }),
  15269. /***/ "./3D/materials/fluentMaterial.ts":
  15270. /*!****************************************!*\
  15271. !*** ./3D/materials/fluentMaterial.ts ***!
  15272. \****************************************/
  15273. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15275. "use strict";
  15276. __webpack_require__.r(__webpack_exports__);
  15277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return FluentMaterialDefines; });
  15278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return FluentMaterial; });
  15279. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15280. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/decorators */ "babylonjs/Maths/math");
  15281. /* harmony import */ var babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__);
  15282. /* harmony import */ var _shaders_fluent_vertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./shaders/fluent.vertex */ "./3D/materials/shaders/fluent.vertex.ts");
  15283. /* harmony import */ var _shaders_fluent_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./shaders/fluent.fragment */ "./3D/materials/shaders/fluent.fragment.ts");
  15284. /** @hidden */
  15285. var FluentMaterialDefines = /** @class */ (function (_super) {
  15286. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterialDefines, _super);
  15287. function FluentMaterialDefines() {
  15288. var _this = _super.call(this) || this;
  15289. _this.INNERGLOW = false;
  15290. _this.BORDER = false;
  15291. _this.HOVERLIGHT = false;
  15292. _this.TEXTURE = false;
  15293. _this.rebuild();
  15294. return _this;
  15295. }
  15296. return FluentMaterialDefines;
  15297. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialDefines"]));
  15298. /**
  15299. * Class used to render controls with fluent desgin
  15300. */
  15301. var FluentMaterial = /** @class */ (function (_super) {
  15302. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(FluentMaterial, _super);
  15303. /**
  15304. * Creates a new Fluent material
  15305. * @param name defines the name of the material
  15306. * @param scene defines the hosting scene
  15307. */
  15308. function FluentMaterial(name, scene) {
  15309. var _this = _super.call(this, name, scene) || this;
  15310. /**
  15311. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  15312. */
  15313. _this.innerGlowColorIntensity = 0.5;
  15314. /**
  15315. * Gets or sets the inner glow color (white by default)
  15316. */
  15317. _this.innerGlowColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](1.0, 1.0, 1.0);
  15318. /**
  15319. * Gets or sets alpha value (default is 1.0)
  15320. */
  15321. _this.alpha = 1.0;
  15322. /**
  15323. * Gets or sets the albedo color (Default is Color3(0.3, 0.35, 0.4))
  15324. */
  15325. _this.albedoColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color3"](0.3, 0.35, 0.4);
  15326. /**
  15327. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  15328. */
  15329. _this.renderBorders = false;
  15330. /**
  15331. * Gets or sets border width (default is 0.5)
  15332. */
  15333. _this.borderWidth = 0.5;
  15334. /**
  15335. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  15336. */
  15337. _this.edgeSmoothingValue = 0.02;
  15338. /**
  15339. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  15340. */
  15341. _this.borderMinValue = 0.1;
  15342. /**
  15343. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  15344. */
  15345. _this.renderHoverLight = false;
  15346. /**
  15347. * Gets or sets the radius used to render the hover light (default is 1.0)
  15348. */
  15349. _this.hoverRadius = 1.0;
  15350. /**
  15351. * Gets or sets the color used to render the hover light (default is Color4(0.3, 0.3, 0.3, 1.0))
  15352. */
  15353. _this.hoverColor = new babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Color4"](0.3, 0.3, 0.3, 1.0);
  15354. /**
  15355. * Gets or sets the hover light position in world space (default is Vector3.Zero())
  15356. */
  15357. _this.hoverPosition = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  15358. return _this;
  15359. }
  15360. FluentMaterial.prototype.needAlphaBlending = function () {
  15361. return this.alpha !== 1.0;
  15362. };
  15363. FluentMaterial.prototype.needAlphaTesting = function () {
  15364. return false;
  15365. };
  15366. FluentMaterial.prototype.getAlphaTestTexture = function () {
  15367. return null;
  15368. };
  15369. FluentMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  15370. if (this.isFrozen) {
  15371. if (subMesh.effect && subMesh.effect._wasPreviouslyReady) {
  15372. return true;
  15373. }
  15374. }
  15375. if (!subMesh._materialDefines) {
  15376. subMesh._materialDefines = new FluentMaterialDefines();
  15377. }
  15378. var scene = this.getScene();
  15379. var defines = subMesh._materialDefines;
  15380. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  15381. if (defines._renderId === scene.getRenderId()) {
  15382. return true;
  15383. }
  15384. }
  15385. if (defines._areTexturesDirty) {
  15386. defines.INNERGLOW = this.innerGlowColorIntensity > 0;
  15387. defines.BORDER = this.renderBorders;
  15388. defines.HOVERLIGHT = this.renderHoverLight;
  15389. if (this._albedoTexture) {
  15390. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  15391. return false;
  15392. }
  15393. else {
  15394. defines.TEXTURE = true;
  15395. }
  15396. }
  15397. else {
  15398. defines.TEXTURE = false;
  15399. }
  15400. }
  15401. var engine = scene.getEngine();
  15402. // Get correct effect
  15403. if (defines.isDirty) {
  15404. defines.markAsProcessed();
  15405. scene.resetCachedMaterial();
  15406. //Attributes
  15407. var attribs = [babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  15408. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  15409. attribs.push(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  15410. var shaderName = "fluent";
  15411. var uniforms = ["world", "viewProjection", "innerGlowColor", "albedoColor", "borderWidth", "edgeSmoothingValue", "scaleFactor", "borderMinValue",
  15412. "hoverColor", "hoverPosition", "hoverRadius"
  15413. ];
  15414. var samplers = ["albedoSampler"];
  15415. var uniformBuffers = new Array();
  15416. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["MaterialHelper"].PrepareUniformsAndSamplersList({
  15417. uniformsNames: uniforms,
  15418. uniformBuffersNames: uniformBuffers,
  15419. samplers: samplers,
  15420. defines: defines,
  15421. maxSimultaneousLights: 4
  15422. });
  15423. var join = defines.toString();
  15424. subMesh.setEffect(scene.getEngine().createEffect(shaderName, {
  15425. attributes: attribs,
  15426. uniformsNames: uniforms,
  15427. uniformBuffersNames: uniformBuffers,
  15428. samplers: samplers,
  15429. defines: join,
  15430. fallbacks: null,
  15431. onCompiled: this.onCompiled,
  15432. onError: this.onError,
  15433. indexParameters: { maxSimultaneousLights: 4 }
  15434. }, engine));
  15435. }
  15436. if (!subMesh.effect || !subMesh.effect.isReady()) {
  15437. return false;
  15438. }
  15439. defines._renderId = scene.getRenderId();
  15440. subMesh.effect._wasPreviouslyReady = true;
  15441. return true;
  15442. };
  15443. FluentMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  15444. var scene = this.getScene();
  15445. var defines = subMesh._materialDefines;
  15446. if (!defines) {
  15447. return;
  15448. }
  15449. var effect = subMesh.effect;
  15450. if (!effect) {
  15451. return;
  15452. }
  15453. this._activeEffect = effect;
  15454. // Matrices
  15455. this.bindOnlyWorldMatrix(world);
  15456. this._activeEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  15457. if (this._mustRebind(scene, effect)) {
  15458. this._activeEffect.setColor4("albedoColor", this.albedoColor, this.alpha);
  15459. if (defines.INNERGLOW) {
  15460. this._activeEffect.setColor4("innerGlowColor", this.innerGlowColor, this.innerGlowColorIntensity);
  15461. }
  15462. if (defines.BORDER) {
  15463. this._activeEffect.setFloat("borderWidth", this.borderWidth);
  15464. this._activeEffect.setFloat("edgeSmoothingValue", this.edgeSmoothingValue);
  15465. this._activeEffect.setFloat("borderMinValue", this.borderMinValue);
  15466. mesh.getBoundingInfo().boundingBox.extendSize.multiplyToRef(mesh.scaling, babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15467. this._activeEffect.setVector3("scaleFactor", babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["TmpVectors"].Vector3[0]);
  15468. }
  15469. if (defines.HOVERLIGHT) {
  15470. this._activeEffect.setDirectColor4("hoverColor", this.hoverColor);
  15471. this._activeEffect.setFloat("hoverRadius", this.hoverRadius);
  15472. this._activeEffect.setVector3("hoverPosition", this.hoverPosition);
  15473. }
  15474. if (defines.TEXTURE) {
  15475. this._activeEffect.setTexture("albedoSampler", this._albedoTexture);
  15476. }
  15477. }
  15478. this._afterBind(mesh, this._activeEffect);
  15479. };
  15480. FluentMaterial.prototype.getActiveTextures = function () {
  15481. var activeTextures = _super.prototype.getActiveTextures.call(this);
  15482. return activeTextures;
  15483. };
  15484. FluentMaterial.prototype.hasTexture = function (texture) {
  15485. if (_super.prototype.hasTexture.call(this, texture)) {
  15486. return true;
  15487. }
  15488. return false;
  15489. };
  15490. FluentMaterial.prototype.dispose = function (forceDisposeEffect) {
  15491. _super.prototype.dispose.call(this, forceDisposeEffect);
  15492. };
  15493. FluentMaterial.prototype.clone = function (name) {
  15494. var _this = this;
  15495. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new FluentMaterial(name, _this.getScene()); }, this);
  15496. };
  15497. FluentMaterial.prototype.serialize = function () {
  15498. var serializationObject = babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  15499. serializationObject.customType = "BABYLON.GUI.FluentMaterial";
  15500. return serializationObject;
  15501. };
  15502. FluentMaterial.prototype.getClassName = function () {
  15503. return "FluentMaterial";
  15504. };
  15505. // Statics
  15506. FluentMaterial.Parse = function (source, scene, rootUrl) {
  15507. return babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new FluentMaterial(source.name, scene); }, source, scene, rootUrl);
  15508. };
  15509. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15510. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15511. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15512. ], FluentMaterial.prototype, "innerGlowColorIntensity", void 0);
  15513. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15514. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15515. ], FluentMaterial.prototype, "innerGlowColor", void 0);
  15516. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15517. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15518. ], FluentMaterial.prototype, "alpha", void 0);
  15519. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15520. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  15521. ], FluentMaterial.prototype, "albedoColor", void 0);
  15522. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15523. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15524. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15525. ], FluentMaterial.prototype, "renderBorders", void 0);
  15526. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15527. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15528. ], FluentMaterial.prototype, "borderWidth", void 0);
  15529. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15530. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15531. ], FluentMaterial.prototype, "edgeSmoothingValue", void 0);
  15532. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15533. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15534. ], FluentMaterial.prototype, "borderMinValue", void 0);
  15535. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15536. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  15537. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  15538. ], FluentMaterial.prototype, "renderHoverLight", void 0);
  15539. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15540. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  15541. ], FluentMaterial.prototype, "hoverRadius", void 0);
  15542. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15543. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  15544. ], FluentMaterial.prototype, "hoverColor", void 0);
  15545. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15546. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  15547. ], FluentMaterial.prototype, "hoverPosition", void 0);
  15548. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15549. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("albedoTexture")
  15550. ], FluentMaterial.prototype, "_albedoTexture", void 0);
  15551. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"])([
  15552. Object(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  15553. ], FluentMaterial.prototype, "albedoTexture", void 0);
  15554. return FluentMaterial;
  15555. }(babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["PushMaterial"]));
  15556. babylonjs_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["_TypeStore"].RegisteredTypes["BABYLON.GUI.FluentMaterial"] = FluentMaterial;
  15557. /***/ }),
  15558. /***/ "./3D/materials/index.ts":
  15559. /*!*******************************!*\
  15560. !*** ./3D/materials/index.ts ***!
  15561. \*******************************/
  15562. /*! exports provided: FluentMaterialDefines, FluentMaterial */
  15563. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15564. "use strict";
  15565. __webpack_require__.r(__webpack_exports__);
  15566. /* harmony import */ var _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fluentMaterial */ "./3D/materials/fluentMaterial.ts");
  15567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _fluentMaterial__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15569. /***/ }),
  15570. /***/ "./3D/materials/shaders/fluent.fragment.ts":
  15571. /*!*************************************************!*\
  15572. !*** ./3D/materials/shaders/fluent.fragment.ts ***!
  15573. \*************************************************/
  15574. /*! exports provided: fluentPixelShader */
  15575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15576. "use strict";
  15577. __webpack_require__.r(__webpack_exports__);
  15578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentPixelShader", function() { return fluentPixelShader; });
  15579. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  15580. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15581. var name = 'fluentPixelShader';
  15582. 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}";
  15583. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15584. /** @hidden */
  15585. var fluentPixelShader = { name: name, shader: shader };
  15586. /***/ }),
  15587. /***/ "./3D/materials/shaders/fluent.vertex.ts":
  15588. /*!***********************************************!*\
  15589. !*** ./3D/materials/shaders/fluent.vertex.ts ***!
  15590. \***********************************************/
  15591. /*! exports provided: fluentVertexShader */
  15592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15593. "use strict";
  15594. __webpack_require__.r(__webpack_exports__);
  15595. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fluentVertexShader", function() { return fluentVertexShader; });
  15596. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/effect */ "babylonjs/Maths/math");
  15597. /* harmony import */ var babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__);
  15598. var name = 'fluentVertexShader';
  15599. 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";
  15600. babylonjs_Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  15601. /** @hidden */
  15602. var fluentVertexShader = { name: name, shader: shader };
  15603. /***/ }),
  15604. /***/ "./3D/vector3WithInfo.ts":
  15605. /*!*******************************!*\
  15606. !*** ./3D/vector3WithInfo.ts ***!
  15607. \*******************************/
  15608. /*! exports provided: Vector3WithInfo */
  15609. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15610. "use strict";
  15611. __webpack_require__.r(__webpack_exports__);
  15612. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return Vector3WithInfo; });
  15613. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../../node_modules/tslib/tslib.es6.js");
  15614. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math */ "babylonjs/Maths/math");
  15615. /* harmony import */ var babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__);
  15616. /**
  15617. * Class used to transport Vector3 information for pointer events
  15618. */
  15619. var Vector3WithInfo = /** @class */ (function (_super) {
  15620. Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Vector3WithInfo, _super);
  15621. /**
  15622. * Creates a new Vector3WithInfo
  15623. * @param source defines the vector3 data to transport
  15624. * @param buttonIndex defines the current mouse button index
  15625. */
  15626. function Vector3WithInfo(source,
  15627. /** defines the current mouse button index */
  15628. buttonIndex) {
  15629. if (buttonIndex === void 0) { buttonIndex = 0; }
  15630. var _this = _super.call(this, source.x, source.y, source.z) || this;
  15631. _this.buttonIndex = buttonIndex;
  15632. return _this;
  15633. }
  15634. return Vector3WithInfo;
  15635. }(babylonjs_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]));
  15636. /***/ }),
  15637. /***/ "./index.ts":
  15638. /*!******************!*\
  15639. !*** ./index.ts ***!
  15640. \******************/
  15641. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, 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, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15642. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15643. "use strict";
  15644. __webpack_require__.r(__webpack_exports__);
  15645. /* harmony import */ var _2D__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./2D */ "./2D/index.ts");
  15646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  15686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _2D__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15687. /* harmony import */ var _3D__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./3D */ "./3D/index.ts");
  15688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["GUI3DManager"]; });
  15689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Vector3WithInfo"]; });
  15690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["AbstractButton3D"]; });
  15691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Button3D"]; });
  15692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Container3D"]; });
  15693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["Control3D"]; });
  15694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["CylinderPanel"]; });
  15695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["HolographicButton"]; });
  15696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["MeshButton3D"]; });
  15697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["PlanePanel"]; });
  15698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["ScatterPanel"]; });
  15699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["SpherePanel"]; });
  15700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["StackPanel3D"]; });
  15701. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["VolumeBasedPanel"]; });
  15702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterialDefines"]; });
  15703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _3D__WEBPACK_IMPORTED_MODULE_1__["FluentMaterial"]; });
  15704. /***/ }),
  15705. /***/ "./legacy/legacy.ts":
  15706. /*!**************************!*\
  15707. !*** ./legacy/legacy.ts ***!
  15708. \**************************/
  15709. /*! exports provided: AdvancedDynamicTexture, AdvancedDynamicTextureInstrumentation, Vector2WithInfo, Matrix2D, Measure, MultiLinePoint, Style, ValueAndUnit, XmlLoader, GUI3DManager, Vector3WithInfo, 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, AbstractButton3D, Button3D, Container3D, Control3D, CylinderPanel, HolographicButton, MeshButton3D, PlanePanel, ScatterPanel, SpherePanel, StackPanel3D, VolumeBasedPanel, FluentMaterialDefines, FluentMaterial */
  15710. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15711. "use strict";
  15712. __webpack_require__.r(__webpack_exports__);
  15713. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  15714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTexture"]; });
  15715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AdvancedDynamicTextureInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AdvancedDynamicTextureInstrumentation"]; });
  15716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2WithInfo"]; });
  15717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix2D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix2D"]; });
  15718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Measure", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Measure"]; });
  15719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLinePoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLinePoint"]; });
  15720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Style", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Style"]; });
  15721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueAndUnit", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueAndUnit"]; });
  15722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XmlLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["XmlLoader"]; });
  15723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GUI3DManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GUI3DManager"]; });
  15724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3WithInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3WithInfo"]; });
  15725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button"]; });
  15726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Checkbox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Checkbox"]; });
  15727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPicker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorPicker"]; });
  15728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container"]; });
  15729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control"]; });
  15730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ellipse", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ellipse"]; });
  15731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Grid"]; });
  15732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Image"]; });
  15733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputText", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputText"]; });
  15734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InputPassword", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InputPassword"]; });
  15735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Line"]; });
  15736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiLine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiLine"]; });
  15737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioButton"]; });
  15738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel"]; });
  15739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectorGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectorGroup"]; });
  15740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CheckboxGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CheckboxGroup"]; });
  15741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RadioGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RadioGroup"]; });
  15742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SliderGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SliderGroup"]; });
  15743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SelectionPanel"]; });
  15744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollViewer"]; });
  15745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextWrapping", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextWrapping"]; });
  15746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextBlock"]; });
  15747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyPropertySet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyPropertySet"]; });
  15748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualKeyboard", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualKeyboard"]; });
  15749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Rectangle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Rectangle"]; });
  15750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayGrid", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayGrid"]; });
  15751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSlider"]; });
  15752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Slider"]; });
  15753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBasedSlider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageBasedSlider"]; });
  15754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScrollBar"]; });
  15755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageScrollBar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageScrollBar"]; });
  15756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "name", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["name"]; });
  15757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractButton3D"]; });
  15758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Button3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Button3D"]; });
  15759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Container3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Container3D"]; });
  15760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Control3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Control3D"]; });
  15761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderPanel"]; });
  15762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HolographicButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HolographicButton"]; });
  15763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshButton3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshButton3D"]; });
  15764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlanePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlanePanel"]; });
  15765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScatterPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScatterPanel"]; });
  15766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpherePanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpherePanel"]; });
  15767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StackPanel3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StackPanel3D"]; });
  15768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumeBasedPanel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumeBasedPanel"]; });
  15769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterialDefines"]; });
  15770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FluentMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FluentMaterial"]; });
  15771. /**
  15772. * Legacy support, defining window.BABYLON.GUI (global variable).
  15773. *
  15774. * This is the entry point for the UMD module.
  15775. * The entry point for a future ESM package should be index.ts
  15776. */
  15777. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  15778. if (typeof globalObject !== "undefined") {
  15779. globalObject.BABYLON = globalObject.BABYLON || {};
  15780. globalObject.BABYLON.GUI = _index__WEBPACK_IMPORTED_MODULE_0__;
  15781. }
  15782. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../node_modules/webpack/buildin/global.js */ "../../node_modules/webpack/buildin/global.js")))
  15783. /***/ }),
  15784. /***/ "babylonjs/Maths/math":
  15785. /*!****************************************************************************************************!*\
  15786. !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***!
  15787. \****************************************************************************************************/
  15788. /*! no static exports found */
  15789. /***/ (function(module, exports) {
  15790. module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math__;
  15791. /***/ })
  15792. /******/ });
  15793. });
  15794. //# sourceMappingURL=babylon.gui.js.map